Modifications et ajouts de méthodes aux classes et interface (DeployShield,DropBomb,DropMine,DropObject,Nothing,Player)
This commit is contained in:
parent
f2e42c68bf
commit
dcf09f6b3f
@ -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
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class Nothing extends AbstractAction {
|
|||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user