Merge remote-tracking branch 'origin/master'

This commit is contained in:
Quentin Legot 2021-10-21 17:14:31 +02:00
commit f5ba25843c
6 changed files with 81 additions and 6 deletions

View File

@ -9,7 +9,8 @@ public class DeployShield extends AbstractAction {
@Override @Override
public void doAction(){ public void doAction(){
getGame().getCurrent_player().setShieldDeploy(true);
//TO-DO retirer les point du player
} }
@Override @Override

View File

@ -1,6 +1,9 @@
package fr.lnl.game.server.games.action; package fr.lnl.game.server.games.action;
import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.utils.Point;
import java.util.List;
public class DropBomb extends DropObject { public class DropBomb extends DropObject {
@ -15,6 +18,13 @@ public class DropBomb extends DropObject {
@Override @Override
public boolean isPossible() { public boolean isPossible() {
return false; return super.isPossible();
} }
@Override
public List<Point> getValidPoint() {
return super.getValidPoint();
} }
}

View File

@ -1,6 +1,11 @@
package fr.lnl.game.server.games.action; package fr.lnl.game.server.games.action;
import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.grid.Mine;
import fr.lnl.game.server.utils.Point;
import java.util.List;
import java.util.Random;
public class DropMine extends DropObject { public class DropMine extends DropObject {
public DropMine(Game game){ public DropMine(Game game){
@ -8,11 +13,22 @@ public class DropMine extends DropObject {
} }
@Override @Override
public void doAction() { public void doAction() {
super.doAction(); 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
} }
@Override @Override
public boolean isPossible() { public boolean isPossible() {
return false; return super.isPossible();
} }
@Override
public List<Point> getValidPoint() {
return super.getValidPoint();
}
} }

View File

@ -1,6 +1,17 @@
package fr.lnl.game.server.games.action; package fr.lnl.game.server.games.action;
import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.grid.Box;
import fr.lnl.game.server.games.grid.Grid;
import fr.lnl.game.server.games.grid.Wall;
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.LinkedList;
import java.util.List;
import java.util.Random;
public abstract class DropObject extends AbstractAction { public abstract class DropObject extends AbstractAction {
@ -10,6 +21,30 @@ public abstract class DropObject extends AbstractAction {
@Override @Override
public void doAction() { public void doAction() {
}
@Override
public boolean isPossible() {
return getValidPoint().isEmpty();
}
public List<Point> getValidPoint() {
List<Point> listMoves = new LinkedList<>();
HashMap<Point, Pair<Player, Box>> board = getGame().getGrid().getBoard();
Point position = getGame().getCurrent_player().getPoint();
for (int row = -1; row <= 1; row++) {
for (int column = -1; column <= 1; column++) {
if(Grid.caseisValid(position.getA(),row,position.getB(),column)){
Point neighbour = new Point(position.getA() + row, position.getB() + column);
Pair<Player, Box> state = board.get(neighbour);
if(state.getA() == null || state.getB() instanceof Wall){
listMoves.add(neighbour);
}
}
}
}
return listMoves;
}
} }
}

View File

@ -1,7 +1,20 @@
package fr.lnl.game.server.games.player; package fr.lnl.game.server.games.player;
import fr.lnl.game.server.games.action.Action;
import fr.lnl.game.server.games.weapon.Weapon;
import fr.lnl.game.server.utils.Point; import fr.lnl.game.server.utils.Point;
public interface Player { public interface Player {
Point getPoint(); Point getPoint();
boolean isAlive();
int getId();
int getEnergy();
Weapon getWeapon();
boolean isShieldDeploy();
void setEnergy(int energy);
void setShieldDeploy(boolean shieldDeploy);
void setWeapon(Weapon weapon);
Action[] getActions();
ClassPlayer getClassPlayer();
void setPoint(Point point);
} }