Fix critical bug
This commit is contained in:
parent
7afd79b929
commit
3066ecf211
@ -23,12 +23,16 @@ public class Game {
|
||||
private Action selectedAction = null;
|
||||
|
||||
public Game(Grid grid, List<Player> players, ModelListener gameFinishEvent) throws IllegalArgumentException {
|
||||
if(players.size() < 2 || players.size() > grid.getNumberNeutralBox())
|
||||
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.players = players;
|
||||
this.currentPlayer = players.get(0);
|
||||
this.grid = grid;
|
||||
this.gameFinishEvent = gameFinishEvent;
|
||||
this.grid.initPlacePlayers();
|
||||
currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer));
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,9 @@ public abstract class AbstractPlayer implements Player {
|
||||
|
||||
@Override
|
||||
public void setPosition(Point position){
|
||||
if(position == null){
|
||||
throw new IllegalArgumentException("Position is null");
|
||||
}
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,6 @@ public class Mock {
|
||||
List<Player> players = Arrays.asList(new RandomComputerPlayer(1,null, ClassPlayer.DEFAULT),
|
||||
new RandomComputerPlayer(2,null, ClassPlayer.DEFAULT));
|
||||
this.grid = new Grid(16,16, players,0.80F, 0.95F);
|
||||
placePlayersBRUT();
|
||||
placeEnergyBallBRUT();
|
||||
placeInternWallBRUT();
|
||||
game = new Game(grid, players, new GameFinishEvent());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user