Skip to content
GitLab
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
93e67aee
Commit
93e67aee
authored
Dec 16, 2017
by
Quentin DRUAULT-AUBIN
Committed by
Paul Jeannot
Dec 17, 2017
Browse files
[Data] Check if the 2 players are ready
parent
bc526707
Changes
1
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/data/module/GameMediator.java
View file @
93e67aee
...
...
@@ -179,8 +179,8 @@ public class GameMediator {
//last ship
if
(
this
.
currentGame
.
getTemplateShips
().
size
()
==
player
.
getShips
().
size
())
{
if
(
this
.
dataFacade
.
getComfacade
()
!=
null
)
{
this
.
dataFacade
.
getComfacade
().
sendShipsToEnnemy
(
player
.
getShips
(),
this
.
currentGame
.
getRecipients
());
checkPlayersReady
();
}
}
...
...
@@ -545,21 +545,28 @@ public class GameMediator {
// Set the ships
p
.
setShips
(
ships
);
// If the 2 players are ready, notify IHM Table.
boolean
ready
=
true
;
for
(
Player
player
:
currentGame
.
getPlayers
())
{
// If their ships are placed.
if
(
this
.
currentGame
.
getTemplateShips
().
size
()
!=
player
.
getShips
().
size
())
{
ready
=
false
;
break
;
}
}
if
(
ready
)
{
this
.
dataFacade
.
getIhmTablefacade
().
notifyGameReady
();
}
checkPlayersReady
();
}
}
}
/**
* Check if the two players are ready.
*/
private
void
checkPlayersReady
()
{
// If the 2 players are ready, notify IHM Table.
boolean
ready
=
true
;
for
(
Player
player
:
currentGame
.
getPlayers
())
{
// If their ships are placed.
if
(
this
.
currentGame
.
getTemplateShips
().
size
()
!=
player
.
getShips
().
size
())
{
ready
=
false
;
break
;
}
}
if
(
ready
)
{
this
.
dataFacade
.
getIhmTablefacade
().
notifyGameReady
();
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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