Commit 93e67aee authored by Quentin DRUAULT-AUBIN's avatar Quentin DRUAULT-AUBIN Committed by Paul Jeannot
Browse files

[Data] Check if the 2 players are ready

parent bc526707
......@@ -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();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment