Finalisation des classes DeployShield, DropBomb et DropMine

This commit is contained in:
Valentin Valentin 2021-10-22 08:17:50 +02:00
parent ce39edaead
commit d6f2217554
3 changed files with 19 additions and 6 deletions

View File

@ -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

View File

@ -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<Point> 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

View File

@ -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<Point> 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