diff --git a/server/src/main/java/fr/lnl/game/server/games/Game.java b/server/src/main/java/fr/lnl/game/server/games/Game.java index 58b918f..1406c89 100644 --- a/server/src/main/java/fr/lnl/game/server/games/Game.java +++ b/server/src/main/java/fr/lnl/game/server/games/Game.java @@ -23,12 +23,16 @@ public class Game { private Action selectedAction = null; public Game(Grid grid, List 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)); } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java index 7f85b36..41dcfdd 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java @@ -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; } diff --git a/server/src/test/java/fr/lnl/game/server/Mock.java b/server/src/test/java/fr/lnl/game/server/Mock.java index a7f5526..98644cb 100644 --- a/server/src/test/java/fr/lnl/game/server/Mock.java +++ b/server/src/test/java/fr/lnl/game/server/Mock.java @@ -23,9 +23,6 @@ public class Mock { List 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()); }