2021-03-27 11:12:20 +01:00
|
|
|
package battleship.model;
|
|
|
|
|
|
|
|
import battleship.model.player.Player;
|
|
|
|
|
|
|
|
public class Game {
|
|
|
|
|
|
|
|
public Player[] players;
|
2021-03-27 13:12:33 +01:00
|
|
|
public Player currentPlayer;
|
|
|
|
public int size;
|
2021-03-27 11:12:20 +01:00
|
|
|
|
2021-03-27 13:12:33 +01:00
|
|
|
public Game(Player[] players,int size) {
|
2021-03-27 11:12:20 +01:00
|
|
|
this.players = players;
|
2021-03-27 13:12:33 +01:00
|
|
|
this.size = size;
|
2021-03-27 11:12:20 +01:00
|
|
|
}
|
2021-03-27 13:12:33 +01:00
|
|
|
|
|
|
|
public Player getCurrentPlayer(){
|
|
|
|
return this.currentPlayer;
|
|
|
|
}
|
|
|
|
public void changeCurrentPlayer(){
|
|
|
|
currentPlayer = (currentPlayer == players[1])? players[0] : players[1];
|
|
|
|
}
|
|
|
|
public void checkDrownedShips(){
|
|
|
|
changeCurrentPlayer();
|
|
|
|
Player otherPlayer = currentPlayer;
|
|
|
|
changeCurrentPlayer();
|
|
|
|
for(Ship ship : currentPlayer.getShips()){
|
|
|
|
if(!ship.hasDrown())
|
|
|
|
otherPlayer.isItDrown(ship);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-27 11:12:20 +01:00
|
|
|
}
|