From f4477ac1e0d5827dfa4d95c7c2bb2ba0fff5a894 Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Sat, 4 Dec 2021 15:17:41 +0100 Subject: [PATCH] Add buildGrid Strategy Pattern --- .../java/fr/lnl/game/client/view/Cell.java | 7 +- .../java/fr/lnl/game/client/view/GUI.java | 1 + .../java/fr/lnl/game/server/games/Game.java | 20 ++- .../game/server/games/action/DropBomb.java | 2 +- .../game/server/games/action/DropMine.java | 2 +- .../game/server/games/action/DropObject.java | 2 +- .../fr/lnl/game/server/games/action/Move.java | 6 +- .../fr/lnl/game/server/games/action/Shot.java | 2 +- .../fr/lnl/game/server/games/grid/Grid.java | 119 ++---------------- .../grid/{ => elements}/AbstractBox.java | 2 +- .../games/grid/{ => elements}/Bomb.java | 3 +- .../server/games/grid/{ => elements}/Box.java | 2 +- .../games/grid/{ => elements}/EnergyBall.java | 3 +- .../games/grid/{ => elements}/Explosive.java | 3 +- .../grid/{ => elements}/InteractiveBox.java | 3 +- .../games/grid/{ => elements}/Mine.java | 3 +- .../games/grid/{ => elements}/Wall.java | 4 +- server/src/main/java/module-info.java | 1 + .../fr/lnl/game/server/ActionPlayerTest.java | 2 +- .../java/fr/lnl/game/server/GridTest.java | 8 +- .../test/java/fr/lnl/game/server/Mock.java | 14 ++- 21 files changed, 61 insertions(+), 148 deletions(-) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/AbstractBox.java (85%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/Bomb.java (78%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/Box.java (62%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/EnergyBall.java (85%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/Explosive.java (77%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/InteractiveBox.java (67%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/Mine.java (78%) rename server/src/main/java/fr/lnl/game/server/games/grid/{ => elements}/Wall.java (88%) diff --git a/client/src/main/java/fr/lnl/game/client/view/Cell.java b/client/src/main/java/fr/lnl/game/client/view/Cell.java index 65fbcd6..fe1f011 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Cell.java +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -1,9 +1,8 @@ package fr.lnl.game.client.view; -import fr.lnl.game.server.games.grid.Bomb; -import fr.lnl.game.server.games.grid.EnergyBall; -import fr.lnl.game.server.games.grid.Mine; -import fr.lnl.game.server.games.grid.Wall; +import fr.lnl.game.server.games.grid.elements.Bomb; +import fr.lnl.game.server.games.grid.elements.EnergyBall; +import fr.lnl.game.server.games.grid.elements.Mine; import fr.lnl.game.server.games.player.Player; import javafx.scene.image.Image; import javafx.scene.image.ImageView; diff --git a/client/src/main/java/fr/lnl/game/client/view/GUI.java b/client/src/main/java/fr/lnl/game/client/view/GUI.java index 917913c..24b70cd 100644 --- a/client/src/main/java/fr/lnl/game/client/view/GUI.java +++ b/client/src/main/java/fr/lnl/game/client/view/GUI.java @@ -2,6 +2,7 @@ package fr.lnl.game.client.view; import fr.lnl.game.server.games.grid.*; +import fr.lnl.game.server.games.grid.elements.*; import fr.lnl.game.server.games.player.ClassPlayer; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.games.player.RandomComputerPlayer; 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 1406c89..22b389c 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 @@ -2,6 +2,7 @@ package fr.lnl.game.server.games; import fr.lnl.game.server.games.action.*; import fr.lnl.game.server.games.grid.Grid; +import fr.lnl.game.server.games.grid.build.BuildStrategy; import fr.lnl.game.server.games.player.ComputerPlayer; import fr.lnl.game.server.games.player.HumanPlayer; import fr.lnl.game.server.games.player.Player; @@ -16,23 +17,30 @@ import java.util.stream.Stream; public class Game { + private final BuildStrategy buildStrategy; private final Grid grid; private final List players; private final ModelListener gameFinishEvent; private Player currentPlayer; private Action selectedAction = null; - public Game(Grid grid, List players, ModelListener gameFinishEvent) throws IllegalArgumentException { + public Game(BuildStrategy buildStrategy, List players, ModelListener gameFinishEvent) throws IllegalArgumentException { + this.grid = buildStrategy.getGrid(); + this.buildStrategy = buildStrategy; + this.players = players; + this.currentPlayer = players.get(0); + this.gameFinishEvent = gameFinishEvent; + initGame(); + } + + 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"); } - this.players = players; - this.currentPlayer = players.get(0); - this.grid = grid; - this.gameFinishEvent = gameFinishEvent; - this.grid.initPlacePlayers(); + buildStrategy.initPlacePlayers(); currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer)); } diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DropBomb.java b/server/src/main/java/fr/lnl/game/server/games/action/DropBomb.java index 8c6c4df..c346a77 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DropBomb.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DropBomb.java @@ -1,7 +1,7 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Bomb; +import fr.lnl.game.server.games.grid.elements.Bomb; import fr.lnl.game.server.games.player.Player; public class DropBomb extends DropObject { diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DropMine.java b/server/src/main/java/fr/lnl/game/server/games/action/DropMine.java index 6aecc67..7d85f02 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DropMine.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DropMine.java @@ -1,7 +1,7 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Mine; +import fr.lnl.game.server.games.grid.elements.Mine; import fr.lnl.game.server.games.player.Player; public class DropMine extends DropObject { diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java b/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java index 6960be8..b4123fe 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java @@ -1,7 +1,7 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Box; +import fr.lnl.game.server.games.grid.elements.Box; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Pair; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/action/Move.java b/server/src/main/java/fr/lnl/game/server/games/action/Move.java index 596f6d1..c1516fe 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/Move.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/Move.java @@ -1,9 +1,9 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Box; -import fr.lnl.game.server.games.grid.InteractiveBox; -import fr.lnl.game.server.games.grid.Wall; +import fr.lnl.game.server.games.grid.elements.Box; +import fr.lnl.game.server.games.grid.elements.InteractiveBox; +import fr.lnl.game.server.games.grid.elements.Wall; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Pair; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/action/Shot.java b/server/src/main/java/fr/lnl/game/server/games/action/Shot.java index 8f12403..bf0b38e 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/Shot.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/Shot.java @@ -1,7 +1,7 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Wall; +import fr.lnl.game.server.games.grid.elements.Wall; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.games.weapon.Weapon; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java b/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java index dae6c70..0f39221 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java @@ -1,12 +1,11 @@ package fr.lnl.game.server.games.grid; - +import fr.lnl.game.server.games.grid.elements.*; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Pair; import fr.lnl.game.server.utils.Point; import java.util.HashMap; import java.util.List; -import java.util.Random; public class Grid { @@ -15,96 +14,11 @@ public class Grid { private final int column; private final List players; - public Grid(int row, int column, List players, float wallProbability, float energyProbability) { + public Grid(int row, int column, List players) { this.row = row; this.column = column; this.players = players; board = new HashMap<>(); - initBoard(wallProbability, energyProbability); - } - - public void initBoard(float wallProbability, float energyProbability){ - initGrid(); - initPlaceInternWall(wallProbability); - initPlaceEnergyBall(energyProbability); - } - - public void initGrid(){ - for (int i = 0; i < row; i++) { - for (int j = 0; j < column; j++) { - Box box; - if (i == 0 && j == 0) { - box = new Wall(i, j); - } else if (i == 0 && j == column-1) { - box = new Wall(i, j); - } else if (i == row-1 && j == 0) { - box = new Wall(i, j); - } else if (i == row-1 && j == column-1) { - box = new Wall(i, j); - } else if (i == 0) { - box = new Wall(i, j); - } else if (i == row-1) { - box = new Wall(i, j); - } else if (j == 0) { - box = new Wall(i, j); - } else if (j == column-1) { - box = new Wall(i, j); - } else { - box = null; - } - board.put(new Point(i,j), new Pair<>(null,box)); - } - } - } - - public void initPlacePlayers(){ - Random random = new Random(); - Box boxTargeted; - Player playerTargeted; - Point point; - for (Player player: players) { - do{ - int i = random.nextInt(1,getRow() - 1); - int j = random.nextInt(1,getColumn() - 1); - point = new Point(i,j); - Pair pairTargeted = getBoard().get(point); - boxTargeted = pairTargeted.getB(); - playerTargeted = pairTargeted.getA(); - }while(playerTargeted != null || !isNeutralBox(boxTargeted)); - getBoard().get(point).setA(player); - player.setPosition(point); - } - } - - - public void initPlaceEnergyBall(float probability){ - for (int i = 1; i < row - 1; i++) { - for (int j = 1; j < column - 1; j++) { - if(Math.random() >= probability){ - Point point = new Point(i,j); - if(!(getBoard().get(point).getB() instanceof Wall)){ - getBoard().get(point).setB(new EnergyBall()); - } - } - } - } - } - - public void initPlaceInternWall(float probability){ - for (int i = 1; i < row - 1; i++) { - for (int j = 1; j < column - 1; j++) { - if(Math.random() >= probability){ - Point point = new Point(i,j); - if(getIllusionNumberWallNeighbour(point) <= 3){ - getBoard().get(point).setB(new Wall(i,j)); - } - else{ - getBoard().get(point).setB(new AbstractBox()); - getBoard().get(point).getB().setLock(true); - } - } - } - } } public boolean boardPositionIsValid(int row, int deltaRow, int column, int deltaColumn){ @@ -119,29 +33,11 @@ public class Grid { return boardPositionIsValid(point.getA(), point.getB()); } - public int getIllusionNumberWallNeighbour(Point point){ - int countWall = 0; - for (int deltaRow = -1; deltaRow <= 1; deltaRow++){ - for (int deltaColomn = -1; deltaColomn <= 1; deltaColomn++) { - Point neighbour = new Point(point.getA() + deltaRow, point.getB() + deltaColomn); - if (boardPositionIsValid(neighbour)) { - Box box = getBoard().get(neighbour).getB(); - if (box != null) { - if (box instanceof Wall || box.isLock()) { - countWall++; - } - } - } - } - } - return countWall; - } - public int getNumberNeutralBox(){ int countBox = 0; for (int i = 1; i < row - 1; i++) { for (int j = 1; j < column - 1; j++) { - Box box = getBoard().get(new Point(i,j)).getB(); + Box box = board.get(new Point(i,j)).getB(); if(isNeutralBox(box)){ countBox++; } @@ -154,10 +50,6 @@ public class Grid { return !(box instanceof Wall) && !(box instanceof EnergyBall); } - public HashMap> getBoard() { - return board; - } - @Override public String toString() { StringBuilder str = new StringBuilder(); @@ -188,6 +80,10 @@ public class Grid { return str.toString(); } + public HashMap> getBoard() { + return board; + } + public List getPlayers() { return players; } @@ -199,4 +95,5 @@ public class Grid { public int getColumn() { return column; } + } diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/AbstractBox.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/AbstractBox.java similarity index 85% rename from server/src/main/java/fr/lnl/game/server/games/grid/AbstractBox.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/AbstractBox.java index ebf58ee..f48a2b1 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/AbstractBox.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/AbstractBox.java @@ -1,4 +1,4 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; public class AbstractBox implements Box{ diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Bomb.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java similarity index 78% rename from server/src/main/java/fr/lnl/game/server/games/grid/Bomb.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java index ff7e1a7..f528ebe 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Bomb.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java @@ -1,5 +1,6 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Box.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Box.java similarity index 62% rename from server/src/main/java/fr/lnl/game/server/games/grid/Box.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/Box.java index 1a7186f..2db46e6 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Box.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Box.java @@ -1,4 +1,4 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; public interface Box { diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/EnergyBall.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/EnergyBall.java similarity index 85% rename from server/src/main/java/fr/lnl/game/server/games/grid/EnergyBall.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/EnergyBall.java index 88e9ce3..f6377a6 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/EnergyBall.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/EnergyBall.java @@ -1,5 +1,6 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Explosive.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java similarity index 77% rename from server/src/main/java/fr/lnl/game/server/games/grid/Explosive.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java index e4c6321..2287608 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Explosive.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java @@ -1,5 +1,6 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/InteractiveBox.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/InteractiveBox.java similarity index 67% rename from server/src/main/java/fr/lnl/game/server/games/grid/InteractiveBox.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/InteractiveBox.java index e604b8b..e6d0640 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/InteractiveBox.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/InteractiveBox.java @@ -1,5 +1,6 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Mine.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Mine.java similarity index 78% rename from server/src/main/java/fr/lnl/game/server/games/grid/Mine.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/Mine.java index 7f3030f..c0f8c3e 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Mine.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Mine.java @@ -1,5 +1,6 @@ -package fr.lnl.game.server.games.grid; +package fr.lnl.game.server.games.grid.elements; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Wall.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Wall.java similarity index 88% rename from server/src/main/java/fr/lnl/game/server/games/grid/Wall.java rename to server/src/main/java/fr/lnl/game/server/games/grid/elements/Wall.java index 70097d9..745aab0 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Wall.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Wall.java @@ -1,6 +1,4 @@ -package fr.lnl.game.server.games.grid; - -import java.util.Objects; +package fr.lnl.game.server.games.grid.elements; public class Wall extends AbstractBox { diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index f52db89..c856548 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -7,4 +7,5 @@ module server { exports fr.lnl.game.server.games.action; exports fr.lnl.game.server.utils; exports fr.lnl.game.server.listener; + exports fr.lnl.game.server.games.grid.elements; } \ No newline at end of file diff --git a/server/src/test/java/fr/lnl/game/server/ActionPlayerTest.java b/server/src/test/java/fr/lnl/game/server/ActionPlayerTest.java index ff50b3f..0a2cb38 100644 --- a/server/src/test/java/fr/lnl/game/server/ActionPlayerTest.java +++ b/server/src/test/java/fr/lnl/game/server/ActionPlayerTest.java @@ -2,7 +2,7 @@ package fr.lnl.game.server; import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.action.*; -import fr.lnl.game.server.games.grid.Bomb; +import fr.lnl.game.server.games.grid.elements.Bomb; import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; diff --git a/server/src/test/java/fr/lnl/game/server/GridTest.java b/server/src/test/java/fr/lnl/game/server/GridTest.java index dad117d..65ddd63 100644 --- a/server/src/test/java/fr/lnl/game/server/GridTest.java +++ b/server/src/test/java/fr/lnl/game/server/GridTest.java @@ -1,10 +1,10 @@ package fr.lnl.game.server; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.Box; -import fr.lnl.game.server.games.grid.EnergyBall; +import fr.lnl.game.server.games.grid.elements.Box; +import fr.lnl.game.server.games.grid.elements.EnergyBall; import fr.lnl.game.server.games.grid.Grid; -import fr.lnl.game.server.games.grid.Wall; +import fr.lnl.game.server.games.grid.elements.Wall; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Pair; import fr.lnl.game.server.utils.Point; @@ -55,7 +55,7 @@ public class GridTest { str.append(" \033[0;35mL\033[0m"); } if(value.getB() instanceof Wall){ - str.append(" \033[0;32mW\033[0m"); + str.append(" \033[0;32m□\033[0m"); } if(value.getB() instanceof EnergyBall){ str.append(" \033[0;31mE\033[0m"); 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 a2dbb8d..96b445c 100644 --- a/server/src/test/java/fr/lnl/game/server/Mock.java +++ b/server/src/test/java/fr/lnl/game/server/Mock.java @@ -1,9 +1,11 @@ package fr.lnl.game.server; import fr.lnl.game.server.games.Game; -import fr.lnl.game.server.games.grid.EnergyBall; +import fr.lnl.game.server.games.grid.build.BuildStrategy; +import fr.lnl.game.server.games.grid.build.LockStrategy; +import fr.lnl.game.server.games.grid.elements.EnergyBall; import fr.lnl.game.server.games.grid.Grid; -import fr.lnl.game.server.games.grid.Wall; +import fr.lnl.game.server.games.grid.elements.Wall; import fr.lnl.game.server.games.player.ClassPlayer; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.games.player.RandomComputerPlayer; @@ -15,14 +17,16 @@ import java.util.List; public class Mock { - public Grid grid; + public BuildStrategy buildStrategy; public Game game; + public Grid grid; public 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); - game = new Game(grid, players, new GameFinishEvent()); + this.buildStrategy = new LockStrategy(new Grid(16,16, players),0.80F, 0.95F); + game = new Game(buildStrategy, players, new GameFinishEvent()); + this.grid = buildStrategy.getGrid(); } public void placePlayersBRUT(){