Fix build function call
This commit is contained in:
parent
87d4b6ca39
commit
aea8ac654d
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -4,7 +4,6 @@ import fr.lnl.game.server.games.grid.Grid;
|
||||
|
||||
public interface BuildStrategy {
|
||||
|
||||
void build();
|
||||
void initPlacePlayers();
|
||||
Grid getGrid();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user