Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Quentin DRUAULT-AUBIN
lo23-project
Commits
f9634016
Commit
f9634016
authored
Dec 19, 2017
by
JING LI
Browse files
Javadoc
parent
3279dff7
Changes
16
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/data/facade/DataFacade.java
View file @
f9634016
...
...
@@ -78,7 +78,7 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
/**
* Set the test mode
*
* @param
boolean the value to set to
test
M
ode
parameter
* @param
testMode if
test
m
ode
or not
*/
public
void
setTestMode
(
boolean
testMode
)
{
this
.
testMode
=
testMode
;
...
...
@@ -391,6 +391,7 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
*
* @return my owner profile
*/
@Override
public
Owner
getMyOwnerProfile
()
{
return
this
.
userMediator
.
getMyOwnerProfile
();
...
...
@@ -418,6 +419,7 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* @param user the new user who has joined
* @param id id of the stat game
* @param role role of the new user
* @throws com.utclo23.data.module.DataException
*/
@Override
public
void
updateGameList
(
LightPublicUser
user
,
String
id
,
String
role
)
throws
DataException
{
...
...
@@ -429,6 +431,7 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* Get ships to place
*
* @return the list of ships to place
* @throws com.utclo23.data.module.DataException
*
*/
@Override
...
...
@@ -446,8 +449,10 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* Set a given ship
*
* @param ship the ship to set
* @throws com.utclo23.data.module.DataException
*
*/
@Override
public
void
setShip
(
Ship
ship
)
throws
DataException
{
Logger
.
getLogger
(
DataFacade
.
class
.
getName
()).
log
(
Level
.
INFO
,
null
,
"data | set ship"
);
...
...
@@ -459,8 +464,7 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* Attack a given location
*
* @param coords the location to attack
* @param isTrueAttack true = this is a true attack ; false = this is just a
* test
* @param isAttack
* @return Pair<Integer, Ship>
* Integer = 0 if the mine is not in a right place ; Integer = 1 if the mine
* is in the place of a ship. Ship = null if the ship isn't destroyed ; ship
...
...
@@ -573,7 +577,6 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* Get a user profile
*
* @param id the id of the user to get his profile
* @return the public user
*
*/
@Override
...
...
@@ -596,9 +599,12 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
* Create a game
*
* @param name the name of the game created
* @param computerMode mode of game is computer
* @param spectator are spectators allowed or not
* @param spectatorChat are spectators allowed to chat or not
* @param type type of the game created
* @return
* @throws com.utclo23.data.module.DataException
*/
@Override
public
Game
createGame
(
String
name
,
boolean
computerMode
,
boolean
spectator
,
boolean
spectatorChat
,
GameType
type
)
throws
DataException
{
...
...
@@ -666,6 +672,11 @@ public class DataFacade implements IDataCom, IDataIHMTable, IDataIHMMain {
this
.
userMediator
.
setIPDiscovery
(
discoveryNodes
);
}
/**
*
* @param profile
*/
@Override
public
void
receivePublicUserProfile
(
PublicUser
profile
)
{
try
{
this
.
ihmMainFacade
.
recievePublicUserProfile
(
profile
);
...
...
Battleship/src/main/java/com/utclo23/data/facade/IDataCom.java
View file @
f9634016
...
...
@@ -7,8 +7,6 @@ package com.utclo23.data.facade;
import
com.utclo23.data.module.DataException
;
import
com.utclo23.data.structure.*
;
import
java.net.NetworkInterface
;
import
java.rmi.server.UID
;
import
java.util.List
;
/**
...
...
Battleship/src/main/java/com/utclo23/data/facade/IDataIHMMain.java
View file @
f9634016
...
...
@@ -8,7 +8,6 @@ package com.utclo23.data.facade;
import
com.utclo23.data.module.DataException
;
import
com.utclo23.data.structure.*
;
import
java.net.InterfaceAddress
;
import
java.rmi.server.UID
;
import
java.util.List
;
import
java.util.Date
;
...
...
Battleship/src/main/java/com/utclo23/data/facade/IDataIHMTable.java
View file @
f9634016
...
...
@@ -7,11 +7,9 @@ package com.utclo23.data.facade;
import
com.utclo23.data.module.DataException
;
import
com.utclo23.data.structure.*
;
import
java.rmi.server.UID
;
import
java.util.List
;
import
javafx.util.Pair
;
import
java.io.IOException
;
/**
*
...
...
Battleship/src/main/java/com/utclo23/data/module/Caretaker.java
View file @
f9634016
...
...
@@ -25,8 +25,7 @@ public class Caretaker extends SerializableEntity{
private
int
current
;
/**
* constructor
* @param mementoList
* constructor
*/
public
Caretaker
()
{
this
.
mementoList
=
new
ArrayList
<>();
...
...
Battleship/src/main/java/com/utclo23/data/module/GameMediator.java
View file @
f9634016
package
com.utclo23.data.module
;
import
com.utclo23.com.ComFacade
;
import
com.utclo23.data.configuration.Configuration
;
import
com.utclo23.data.facade.DataFacade
;
import
com.utclo23.data.structure.ComputerPlayer
;
import
com.utclo23.data.structure.Coordinate
;
import
com.utclo23.data.structure.Event
;
import
com.utclo23.data.structure.Game
;
...
...
@@ -44,6 +42,7 @@ public class GameMediator {
/**
* Constructor
* @param dataFacade
*/
public
GameMediator
(
DataFacade
dataFacade
)
{
...
...
@@ -68,9 +67,12 @@ public class GameMediator {
* Create a game
*
* @param name
* @param computerMode if the game is played with computer
* @param spectator
* @param spectatorChat
* @param type
* @return
* @throws com.utclo23.data.module.DataException
*/
public
Game
createGame
(
String
name
,
boolean
computerMode
,
boolean
spectator
,
boolean
spectatorChat
,
GameType
type
)
throws
DataException
{
//empty game name
...
...
@@ -106,7 +108,7 @@ public class GameMediator {
/**
* add a new game
*
* @param game
* @param
statgame state of new
game
*/
public
void
addNewGame
(
StatGame
statgame
)
{
if
(!
this
.
gamesMap
.
containsKey
(
statgame
.
getId
()))
{
...
...
@@ -264,6 +266,8 @@ public class GameMediator {
* @param isTrueAttack
* @return
* @throws DataException
* @throws java.io.IOException
* @throws java.lang.ClassNotFoundException
*/
public
Pair
<
Integer
,
Ship
>
attack
(
Coordinate
coordinate
,
boolean
isTrueAttack
)
throws
DataException
,
IOException
,
ClassNotFoundException
{
...
...
@@ -371,6 +375,7 @@ public class GameMediator {
* @param user the new user who has joined
* @param id id of the stat game
* @param role role of the new user
* @throws com.utclo23.data.module.DataException
*/
public
void
updateGameList
(
LightPublicUser
user
,
String
id
,
String
role
)
throws
DataException
{
System
.
out
.
println
(
"id "
+
id
);
...
...
@@ -557,6 +562,7 @@ public class GameMediator {
/**
* Win if the game has no winner yet.
* @throws com.utclo23.data.module.DataException
*/
public
void
defWin
()
throws
DataException
{
if
(
this
.
currentGame
==
null
)
{
...
...
Battleship/src/main/java/com/utclo23/data/module/UserMediator.java
View file @
f9634016
...
...
@@ -11,14 +11,10 @@ import java.awt.Graphics2D;
import
java.awt.RenderingHints
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.DataBufferByte
;
import
java.awt.image.WritableRaster
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.rmi.server.UID
;
import
java.util.ArrayList
;
...
...
@@ -107,6 +103,7 @@ public class UserMediator {
/**
* set facade
* @param dataFacade
*/
public
void
setDataFacade
(
DataFacade
dataFacade
)
{
this
.
dataFacade
=
dataFacade
;
...
...
@@ -313,7 +310,7 @@ public class UserMediator {
*
* @param username
* @param password
* @throws Exception
* @throws
com.utclo23.data.module.Data
Exception
*/
public
void
signIn
(
String
username
,
String
password
)
throws
DataException
{
...
...
@@ -376,6 +373,7 @@ public class UserMediator {
/**
* disconnection
* @throws com.utclo23.data.module.DataException
*/
public
void
signOut
()
throws
DataException
{
if
(
this
.
owner
!=
null
)
{
...
...
@@ -536,7 +534,7 @@ public class UserMediator {
save
();
// Create the Inet4Address list
List
<
Inet4Address
>
ips
=
new
ArrayList
<
Inet4Address
>();
List
<
Inet4Address
>
ips
=
new
ArrayList
<>();
for
(
String
stringIp
:
discoveryNodes
)
{
Inet4Address
inetIp
=
(
Inet4Address
)
InetAddress
.
getByName
(
stringIp
);
...
...
Battleship/src/main/java/com/utclo23/data/structure/BelgianGame.java
View file @
f9634016
...
...
@@ -27,8 +27,9 @@ public class BelgianGame extends Game {
* get templates of ships for belgian game
* @return
*/
@Override
public
List
<
Ship
>
getTemplateShips
()
{
List
<
Ship
>
ships
=
new
ArrayList
<
Ship
>();
List
<
Ship
>
ships
=
new
ArrayList
<>();
ships
.
add
(
new
Ship
(
ShipType
.
BATTLESHIP
,
4
));
...
...
Battleship/src/main/java/com/utclo23/data/structure/ClassicGame.java
View file @
f9634016
...
...
@@ -28,9 +28,10 @@ public class ClassicGame extends Game{
* @return
*/
@Override
public
List
<
Ship
>
getTemplateShips
()
{
List
<
Ship
>
ships
=
new
ArrayList
<
Ship
>();
List
<
Ship
>
ships
=
new
ArrayList
<>();
ships
.
add
(
new
Ship
(
ShipType
.
CARRIER
,
5
));
ships
.
add
(
new
Ship
(
ShipType
.
BATTLESHIP
,
4
));
ships
.
add
(
new
Ship
(
ShipType
.
CRUISER
,
3
));
...
...
Battleship/src/main/java/com/utclo23/data/structure/ComputerPlayer.java
View file @
f9634016
...
...
@@ -6,10 +6,8 @@
package
com.utclo23.data.structure
;
import
com.utclo23.data.configuration.Configuration
;
import
java.rmi.server.UID
;
import
java.util.List
;
import
java.util.Random
;
import
javafx.util.Pair
;
/**
*
...
...
Battleship/src/main/java/com/utclo23/data/structure/Coordinate.java
View file @
f9634016
...
...
@@ -4,7 +4,6 @@
* and open the template in the editor.
*/
package
com.utclo23.data.structure
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
Battleship/src/main/java/com/utclo23/data/structure/Event.java
View file @
f9634016
...
...
@@ -5,7 +5,6 @@
*/
package
com.utclo23.data.structure
;
import
java.util.Comparator
;
import
java.util.Date
;
/**
...
...
Battleship/src/main/java/com/utclo23/data/structure/Game.java
View file @
f9634016
...
...
@@ -14,8 +14,6 @@ import java.io.IOException;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
javafx.util.Pair
;
...
...
@@ -315,7 +313,7 @@ public abstract class Game extends SerializableEntity {
//reset
this
.
messages
.
clear
();
for
(
Player
p
:
players
)
{
p
.
getMines
().
clear
();
;
p
.
getMines
().
clear
();
}
List
<
Event
>
events
=
memento
.
getState
();
...
...
Battleship/src/main/java/com/utclo23/data/structure/Player.java
View file @
f9634016
...
...
@@ -5,7 +5,6 @@
*/
package
com.utclo23.data.structure
;
import
java.rmi.server.UID
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
Battleship/src/main/java/com/utclo23/data/structure/PublicUser.java
View file @
f9634016
...
...
@@ -6,7 +6,6 @@
package
com.utclo23.data.structure
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.rmi.server.UID
;
import
java.util.Date
;
/**
...
...
Battleship/src/main/java/com/utclo23/data/structure/StatGame.java
View file @
f9634016
...
...
@@ -133,7 +133,7 @@ public class StatGame extends SerializableEntity{
this
.
name
=
name
;
this
.
spectator
=
spectator
;
this
.
spectatorChat
=
spectatorChat
;
this
.
players
=
new
ArrayList
<>();
;
this
.
players
=
new
ArrayList
<>();
this
.
winner
=
null
;
this
.
creator
=
creator
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment