diff --git a/server/src/main/java/fr/lnl/game/server/games/Game.java b/server/src/main/java/fr/lnl/game/server/games/Game.java index b6c0ea6..7fa5aa6 100644 --- a/server/src/main/java/fr/lnl/game/server/games/Game.java +++ b/server/src/main/java/fr/lnl/game/server/games/Game.java @@ -6,6 +6,7 @@ import fr.lnl.game.server.games.grid.build.GridFactoryBuilder; import fr.lnl.game.server.games.grid.elements.CountdownBox; import fr.lnl.game.server.games.player.ComputerPlayer; import fr.lnl.game.server.games.player.Player; +import fr.lnl.game.server.utils.Point; import java.util.ArrayList; import java.util.Arrays; diff --git a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java index eaa6e65..43cdad1 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java @@ -27,6 +27,11 @@ public abstract class AbstractPlayer implements Player { this.position = position; } + /** + * + * @return a list of {@link ReunionSameAction} which groups the same types of actions together. + * It is used by the player action choice strategy + */ @Override public List generateAvailableActions() { List actions = new ArrayList<>(); diff --git a/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java index 40eb8e9..8c525bf 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java @@ -30,5 +30,10 @@ public abstract class ComputerPlayer extends AbstractPlayer { return action; } + /** + * + * Method belonging to classes which extend this class to define the specific strategy of the player + * @return the chosen action between all available + */ public abstract Action strategy(Game game); } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/Player.java b/server/src/main/java/fr/lnl/game/server/games/player/Player.java index b772c52..c53b44a 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/Player.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/Player.java @@ -13,6 +13,10 @@ public interface Player { Point getPosition(); + /** + * + * @return true if this player is Alive, false otherwise + */ boolean isAlive(); int getId(); @@ -21,6 +25,10 @@ public interface Player { Weapon getWeapon(); + /** + * + * @return true if this player has his shield activated, false otherwise + */ boolean isShieldDeploy(); void setEnergy(int energy); @@ -37,8 +45,18 @@ public interface Player { void setPosition(Point position); + /** + * + * Call by the implementing classes {@link fr.lnl.game.server.games.action.Action} to withdraw + * a certain number of energy from a player + */ void decrementEnergy(int energy); + /** + * + * Call by the implementing classes {@link fr.lnl.game.server.games.action.Action} to add + * a certain number of energy from a player + */ void incrementEnergy(int energy); } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/StrategyComputerPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/StrategyComputerPlayer.java index 0b63de2..a681bd9 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/StrategyComputerPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/StrategyComputerPlayer.java @@ -19,6 +19,10 @@ public class StrategyComputerPlayer extends ComputerPlayer { super(id,point, classPlayer); } + /** + * Choose an action following the strategy + * @return an action between all available + */ @Override public Action strategy(Game game) { Action deployShield = choseDeployShield(game); @@ -38,6 +42,7 @@ public class StrategyComputerPlayer extends ComputerPlayer { return choseExplosive(actions); } + private Action choseExplosive(List actions){ Random random = new Random(); if(isInReunion(actions, DropBomb.class) || isInReunion(actions, DropMine.class)){