diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java b/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java index 4fec118..7424b83 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java @@ -1,6 +1,7 @@ package fr.lnl.game.server.games.action; import fr.lnl.game.server.games.Game; +import fr.lnl.game.server.games.player.Player; public class DeployShield extends AbstractAction { public DeployShield(Game game){ @@ -9,8 +10,9 @@ public class DeployShield extends AbstractAction { @Override public void doAction(){ - getGame().getCurrentPlayer().setShieldDeploy(true); - //TO-DO retirer les point du player + Player player = getGame().getCurrentPlayer(); + player.setShieldDeploy(true); + player.decrementEnergy(player.getClassPlayer().getShieldCost()); } @Override 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 8bd298d..7126873 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,9 +1,13 @@ 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.Mine; +import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Point; import java.util.List; +import java.util.Random; public class DropBomb extends DropObject { @@ -11,9 +15,15 @@ public class DropBomb extends DropObject { super(game); } + //voir pour la redondance de code au niveau de DropBomb,DropObject,DropMine @Override public void doAction() { - + List points = getValidPoint(); + Random random = new Random(); + Point point = points.get(random.nextInt(0,points.size()-1)); + getGame().getGrid().getBoard().get(point).setB(new Bomb()); + Player player = getGame().getCurrentPlayer(); + player.decrementEnergy(player.getClassPlayer().getBombCost()); } @Override 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 7d020ba..e35113a 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 @@ -2,6 +2,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.player.Player; import fr.lnl.game.server.utils.Point; import java.util.List; @@ -16,9 +17,9 @@ public class DropMine extends DropObject { List points = getValidPoint(); Random random = new Random(); Point point = points.get(random.nextInt(0,points.size()-1)); - Mine mine = new Mine(); - getGame().getGrid().getBoard().get(point).setB(mine); - //TO-DO : retirer les points au player + getGame().getGrid().getBoard().get(point).setB(new Mine()); + Player player = getGame().getCurrentPlayer(); + player.decrementEnergy(player.getClassPlayer().getMineCost()); } @Override