From 5201e7377280dc6b1e80d29c1c20df011c2e97cf Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:01:49 +0100 Subject: [PATCH] Add AbstractBox and lock case notion (to see if it is viable to keep it) --- .../java/fr/lnl/game/client/view/GUI.java | 4 +--- .../game/server/games/grid/AbstractBox.java | 21 +++++++++++++++++++ .../fr/lnl/game/server/games/grid/Box.java | 3 +++ .../game/server/games/grid/EnergyBall.java | 2 +- .../lnl/game/server/games/grid/Explosive.java | 2 +- .../fr/lnl/game/server/games/grid/Wall.java | 2 +- 6 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 server/src/main/java/fr/lnl/game/server/games/grid/AbstractBox.java 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 175918f..09b4b51 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 @@ -101,9 +101,7 @@ public class GUI { List players = Arrays.asList(new RandomComputerPlayer(1, null, ClassPlayer.DEFAULT), new RandomComputerPlayer(2, null, ClassPlayer.DEFAULT)); Grid grid = new Grid(16, 16, players); - grid.placePlayersBRUT(); - grid.placeEnergyBallBRUT(); - grid.placeInternWallBRUT(); + //grid.placePlayersBRUT(); return grid; } 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/AbstractBox.java new file mode 100644 index 0000000..ebf58ee --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/games/grid/AbstractBox.java @@ -0,0 +1,21 @@ +package fr.lnl.game.server.games.grid; + +public class AbstractBox implements Box{ + + boolean lock; + + public AbstractBox(){ + lock = false; + } + + @Override + public void setLock(boolean lock) { + this.lock = lock; + } + + @Override + public boolean isLock() { + return lock; + } +} + 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/Box.java index 593512e..1a7186f 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/Box.java @@ -1,4 +1,7 @@ package fr.lnl.game.server.games.grid; public interface Box { + + boolean isLock(); + void setLock(boolean lock); } 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/EnergyBall.java index 1fd9193..88e9ce3 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/EnergyBall.java @@ -3,7 +3,7 @@ package fr.lnl.game.server.games.grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; -public class EnergyBall implements Box, InteractiveBox { +public class EnergyBall extends AbstractBox implements InteractiveBox{ @Override public boolean equals(Object o) { 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/Explosive.java index 8861a4b..e4c6321 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/Explosive.java @@ -3,7 +3,7 @@ package fr.lnl.game.server.games.grid; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; -public abstract class Explosive implements Box, InteractiveBox { +public abstract class Explosive extends AbstractBox implements InteractiveBox { @Override public void interact(Grid grid, Player player, Point position) { 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/Wall.java index 06d8853..dd52cec 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/Wall.java @@ -4,7 +4,7 @@ import fr.lnl.game.server.utils.Cardinal; import java.util.Objects; -public class Wall implements Box { +public class Wall extends AbstractBox { private final Cardinal cardinal; private final int x;