Fix build function call

This commit is contained in:
Katchan 2021-12-04 15:36:47 +01:00
parent 87d4b6ca39
commit aea8ac654d
3 changed files with 6 additions and 9 deletions

View File

@ -26,6 +26,11 @@ public class Game {
public Game(BuildStrategy buildStrategy, List<Player> players, ModelListener gameFinishEvent) throws IllegalArgumentException {
this.grid = buildStrategy.getGrid();
if(players.size() < 2)
throw new IllegalArgumentException("The game need 2 or more player to start");
if(players.size() > grid.getNumberNeutralBox()){
throw new IllegalArgumentException("There are too many players for the number of box available");
}
this.buildStrategy = buildStrategy;
this.players = players;
this.currentPlayer = players.get(0);
@ -34,12 +39,6 @@ public class Game {
}
public void initGame(){
buildStrategy.build();
if(players.size() < 2)
throw new IllegalArgumentException("The game need 2 or more player to start");
if(players.size() > grid.getNumberNeutralBox()){
throw new IllegalArgumentException("There are too many players for the number of box available");
}
buildStrategy.initPlacePlayers();
currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer));
}

View File

@ -11,10 +11,9 @@ public abstract class AbstractBuildStrategy implements BuildStrategy{
this.GRID = grid;
this.WALL_PROBABILITY = wallProbability;
this.ENERGY_PROBABILITY = energyProbability;
build();
}
@Override
public void build() {
initGrid();
initPlaceInternWall(WALL_PROBABILITY);

View File

@ -4,7 +4,6 @@ import fr.lnl.game.server.games.grid.Grid;
public interface BuildStrategy {
void build();
void initPlacePlayers();
Grid getGrid();