add javadoc to actions, delete gradle.properties
This commit is contained in:
parent
938eefe387
commit
03be6c2a78
@ -5,7 +5,4 @@ subprojects {
|
|||||||
javadoc {
|
javadoc {
|
||||||
options.memberLevel = JavadocMemberLevel.PRIVATE
|
options.memberLevel = JavadocMemberLevel.PRIVATE
|
||||||
}
|
}
|
||||||
compileJava {
|
|
||||||
// options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
# org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
|
||||||
systemProp.file.encoding=UTF-8
|
|
@ -17,19 +17,4 @@ public abstract class AbstractAction implements Action {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point choseRandomPoint(List<Point> getValidPoint) {
|
|
||||||
Point point = null;
|
|
||||||
switch (getValidPoint.size()) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
point = getValidPoint.get(0);
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
Random random = new Random();
|
|
||||||
point = getValidPoint.get(random.nextInt(0, getValidPoint.size()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,22 @@ import fr.lnl.game.server.utils.Point;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Action {
|
public interface Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call by {@link fr.lnl.game.server.games.Game} when player do this action
|
||||||
|
*/
|
||||||
void doAction();
|
void doAction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if this action is possible, false otherwise
|
||||||
|
*/
|
||||||
boolean isPossible();
|
boolean isPossible();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by {@link Move}, {@link Shot} and {@link DropObject} to list all direction when the action is possible
|
||||||
|
* @return a list a point where the action is possible (not block by a wall per example)
|
||||||
|
*/
|
||||||
List<Point> getValidPoint();
|
List<Point> getValidPoint();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,28 @@ import fr.lnl.game.server.utils.Point;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when a player want to protect himself from taking damage (shield state is reset to false at next player turn)
|
||||||
|
*/
|
||||||
public class DeployShield extends AbstractAction {
|
public class DeployShield extends AbstractAction {
|
||||||
|
|
||||||
public DeployShield(Player player){
|
public DeployShield(Player player){
|
||||||
super(null, player);
|
super(null, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deploy player shield and decrement its energy
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction(){
|
public void doAction(){
|
||||||
player.setShieldDeploy(true);
|
|
||||||
player.decrementEnergy(player.getClassPlayer().getShieldCost());
|
player.decrementEnergy(player.getClassPlayer().getShieldCost());
|
||||||
|
player.setShieldDeploy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This action is always possible
|
||||||
|
* @return always true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPossible() {
|
public boolean isPossible() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum used to chose where to move, shot, etc.
|
||||||
|
*/
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
|
|
||||||
UP(-1, 0, true),
|
UP(-1, 0, true),
|
||||||
@ -25,6 +28,11 @@ public enum Direction {
|
|||||||
return deltaY;
|
return deltaY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by {@link Shot} to know if the direction is in vertical direction cause shot action can have a different
|
||||||
|
* distance depending of the direction
|
||||||
|
* @return true if the direction is vertical
|
||||||
|
*/
|
||||||
public boolean isVertical() {
|
public boolean isVertical() {
|
||||||
return isVertical;
|
return isVertical;
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,18 @@ import fr.lnl.game.server.games.Game;
|
|||||||
import fr.lnl.game.server.games.grid.elements.Bomb;
|
import fr.lnl.game.server.games.grid.elements.Bomb;
|
||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when player want to drop a {@link Bomb}, bomb explode when someone walks on it and after 3 turns
|
||||||
|
*/
|
||||||
public class DropBomb extends DropObject {
|
public class DropBomb extends DropObject {
|
||||||
|
|
||||||
public DropBomb(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
public DropBomb(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
||||||
super(game, player, direction);
|
super(game, player, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop a bomb in player's selected direction and decrement its energy
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
game.getGrid().getBoard().get(point).setB(new Bomb(point, game));
|
game.getGrid().getBoard().get(point).setB(new Bomb(point, game));
|
||||||
|
@ -4,6 +4,9 @@ import fr.lnl.game.server.games.Game;
|
|||||||
import fr.lnl.game.server.games.grid.elements.Mine;
|
import fr.lnl.game.server.games.grid.elements.Mine;
|
||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when player want to drop a {@link Mine}, Mine only explode when someone walks on it
|
||||||
|
*/
|
||||||
public class DropMine extends DropObject {
|
public class DropMine extends DropObject {
|
||||||
|
|
||||||
public DropMine(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
public DropMine(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
||||||
@ -11,6 +14,9 @@ public class DropMine extends DropObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop a mine in player's selected direction and decrement its energy
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
game.getGrid().getBoard().get(point).setB(new Mine(player));
|
game.getGrid().getBoard().get(point).setB(new Mine(player));
|
||||||
|
@ -10,11 +10,19 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Super class used by {@link DropMine} and {@link DropBomb}
|
||||||
|
*/
|
||||||
public abstract class DropObject extends AbstractAction {
|
public abstract class DropObject extends AbstractAction {
|
||||||
|
|
||||||
protected final Point point;
|
protected final Point point;
|
||||||
private final Direction direction;
|
private final Direction direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param player basically current player
|
||||||
|
* @param direction chosen direction
|
||||||
|
* @throws NotValidDirectionException throw when the chosen direction is invalid
|
||||||
|
*/
|
||||||
public DropObject(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
public DropObject(Game game, Player player, Direction direction) throws NotValidDirectionException {
|
||||||
super(game, player);
|
super(game, player);
|
||||||
List<Point> points = getValidPoint();
|
List<Point> points = getValidPoint();
|
||||||
@ -27,11 +35,20 @@ public abstract class DropObject extends AbstractAction {
|
|||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if player can play this action in current context, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPossible() {
|
public boolean isPossible() {
|
||||||
return !getValidPoint().isEmpty();
|
return !getValidPoint().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of point where it's possible to place a bomb of a mine.
|
||||||
|
* We add a point where there is nothing on the board.
|
||||||
|
* @see Action#getValidPoint()
|
||||||
|
*/
|
||||||
public List<Point> getValidPoint() {
|
public List<Point> getValidPoint() {
|
||||||
List<Point> listMoves = new ArrayList<>();
|
List<Point> listMoves = new ArrayList<>();
|
||||||
HashMap<Point, Pair<Player, Box>> board = game.getGrid().getBoard();
|
HashMap<Point, Pair<Player, Box>> board = game.getGrid().getBoard();
|
||||||
|
@ -12,6 +12,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when the player want to move in a direction, it can move in a direction when there is another player or a wall
|
||||||
|
*/
|
||||||
public class Move extends AbstractAction {
|
public class Move extends AbstractAction {
|
||||||
|
|
||||||
private final Point point;
|
private final Point point;
|
||||||
@ -29,6 +32,9 @@ public class Move extends AbstractAction {
|
|||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move player to its new position and decrement its point
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
game.getGrid().getBoard().get(player.getPosition()).setA(null);
|
game.getGrid().getBoard().get(player.getPosition()).setA(null);
|
||||||
@ -41,11 +47,19 @@ public class Move extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if player can play this action in current context, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPossible() {
|
public boolean isPossible() {
|
||||||
return !getValidPoint().isEmpty();
|
return !getValidPoint().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of point where it's possible to move.
|
||||||
|
* We add a point to the list where there is nothing on the board.
|
||||||
|
* @see Action#getValidPoint()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Point> getValidPoint() {
|
public List<Point> getValidPoint() {
|
||||||
List<Point> listMoves = new ArrayList<>();
|
List<Point> listMoves = new ArrayList<>();
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exception is throw when player has no remaining bullet
|
||||||
|
*/
|
||||||
public class NoMoreBulletInWeaponException extends Exception {
|
public class NoMoreBulletInWeaponException extends Exception {
|
||||||
|
|
||||||
public NoMoreBulletInWeaponException() {
|
public NoMoreBulletInWeaponException() {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* throw when action instantiated and the chosen direction in constructor isn't valid
|
||||||
|
*/
|
||||||
public class NotValidDirectionException extends Exception {
|
public class NotValidDirectionException extends Exception {
|
||||||
|
|
||||||
public NotValidDirectionException(String message) {
|
public NotValidDirectionException(String message) {
|
||||||
|
@ -4,16 +4,26 @@ import fr.lnl.game.server.utils.Point;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This action is used when player doesn't want to move and/or loose energy
|
||||||
|
*/
|
||||||
public class Nothing extends AbstractAction {
|
public class Nothing extends AbstractAction {
|
||||||
|
|
||||||
public Nothing() {
|
public Nothing() {
|
||||||
super(null, null);
|
super(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doAction in this context don't execute any operation
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction(){
|
public void doAction(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This action is always possible
|
||||||
|
* @return always true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPossible() {
|
public boolean isPossible() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When we generate action, we generate one per available direction (like in {@link Move}) but to improve human
|
||||||
|
* readability, we list every same Action here
|
||||||
|
*/
|
||||||
public class ReunionSameAction {
|
public class ReunionSameAction {
|
||||||
|
|
||||||
private final String actionName;
|
private final String actionName;
|
||||||
|
@ -29,6 +29,10 @@ public class Shot extends AbstractAction {
|
|||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We decrement player's energy and shot on every of its opponents on the chosen direction by decrementing its
|
||||||
|
* energy too
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
player.decrementEnergy(player.getClassPlayer().getShootCost());
|
player.decrementEnergy(player.getClassPlayer().getShootCost());
|
||||||
@ -36,22 +40,30 @@ public class Shot extends AbstractAction {
|
|||||||
for(int i=0; i < range; i++) {
|
for(int i=0; i < range; i++) {
|
||||||
Point point = new Point(this.point.getA() + (i * direction.getDeltaX()),
|
Point point = new Point(this.point.getA() + (i * direction.getDeltaX()),
|
||||||
this.point.getB() + (i * direction.getDeltaY()));
|
this.point.getB() + (i * direction.getDeltaY()));
|
||||||
// TODO: 07/12/2021 WARNING -> probleme de nullpointerexeption sur getA car on verif pas la sortie de terrain
|
if(game.getGrid().boardPositionIsValid(point)) {
|
||||||
Player player = game.getGrid().getBoard().get(point).getA();
|
Player player = game.getGrid().getBoard().get(point).getA();
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
player.decrementEnergy(player.getClassPlayer().getPenaltyShoot());
|
player.decrementEnergy(player.getClassPlayer().getPenaltyShoot());
|
||||||
System.out.println("Not null: " + point);
|
|
||||||
} else {
|
|
||||||
System.out.println("null:" + point);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if player can play this action in current context, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPossible() {
|
public boolean isPossible() {
|
||||||
return !getValidPoint().isEmpty();
|
return !getValidPoint().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of point where it's possible to shot.
|
||||||
|
* We add a point to the list where there is a player depending on the direction and the distance the weapon can
|
||||||
|
* shoot.
|
||||||
|
* @see Action#getValidPoint()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Point> getValidPoint() {
|
public List<Point> getValidPoint() {
|
||||||
List<Point> listMoves = new ArrayList<>();
|
List<Point> listMoves = new ArrayList<>();
|
||||||
@ -66,7 +78,14 @@ public class Shot extends AbstractAction {
|
|||||||
return listMoves;
|
return listMoves;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param point player current position
|
||||||
|
* @param deltaX given by {@link Direction}
|
||||||
|
* @param deltaY given by {@link Direction}
|
||||||
|
* @param range given by {@link Weapon#getHorizontalDistance()} or {@link Weapon#getVerticalDistance()}
|
||||||
|
* @return true if there is a player in the chosen direction, false otherwise
|
||||||
|
*/
|
||||||
public Point seeNeighbour(Point point, int deltaX, int deltaY, int range) {
|
public Point seeNeighbour(Point point, int deltaX, int deltaY, int range) {
|
||||||
if(range == 0)
|
if(range == 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Package storing all actions a player can do
|
||||||
|
*/
|
||||||
|
package fr.lnl.game.server.games.action;
|
Loading…
Reference in New Issue
Block a user