Add FactoryPattern Javadoc
This commit is contained in:
parent
af5cbf80c1
commit
51a0498886
@ -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.grid.elements.CountdownBox;
|
||||||
import fr.lnl.game.server.games.player.ComputerPlayer;
|
import fr.lnl.game.server.games.player.ComputerPlayer;
|
||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
|
import fr.lnl.game.server.utils.Point;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -27,6 +27,11 @@ public abstract class AbstractPlayer implements Player {
|
|||||||
this.position = position;
|
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
|
@Override
|
||||||
public List<ReunionSameAction> generateAvailableActions() {
|
public List<ReunionSameAction> generateAvailableActions() {
|
||||||
List<ReunionSameAction> actions = new ArrayList<>();
|
List<ReunionSameAction> actions = new ArrayList<>();
|
||||||
|
@ -30,5 +30,10 @@ public abstract class ComputerPlayer extends AbstractPlayer {
|
|||||||
return action;
|
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);
|
public abstract Action strategy(Game game);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ public interface Player {
|
|||||||
|
|
||||||
Point getPosition();
|
Point getPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if this player is Alive, false otherwise
|
||||||
|
*/
|
||||||
boolean isAlive();
|
boolean isAlive();
|
||||||
|
|
||||||
int getId();
|
int getId();
|
||||||
@ -21,6 +25,10 @@ public interface Player {
|
|||||||
|
|
||||||
Weapon getWeapon();
|
Weapon getWeapon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if this player has his shield activated, false otherwise
|
||||||
|
*/
|
||||||
boolean isShieldDeploy();
|
boolean isShieldDeploy();
|
||||||
|
|
||||||
void setEnergy(int energy);
|
void setEnergy(int energy);
|
||||||
@ -37,8 +45,18 @@ public interface Player {
|
|||||||
|
|
||||||
void setPosition(Point position);
|
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);
|
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);
|
void incrementEnergy(int energy);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@ public class StrategyComputerPlayer extends ComputerPlayer {
|
|||||||
super(id,point, classPlayer);
|
super(id,point, classPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Choose an action following the strategy
|
||||||
|
* @return an action between all available
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Action strategy(Game game) {
|
public Action strategy(Game game) {
|
||||||
Action deployShield = choseDeployShield(game);
|
Action deployShield = choseDeployShield(game);
|
||||||
@ -38,6 +42,7 @@ public class StrategyComputerPlayer extends ComputerPlayer {
|
|||||||
return choseExplosive(actions);
|
return choseExplosive(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Action choseExplosive(List<ReunionSameAction> actions){
|
private Action choseExplosive(List<ReunionSameAction> actions){
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
if(isInReunion(actions, DropBomb.class) || isInReunion(actions, DropMine.class)){
|
if(isInReunion(actions, DropBomb.class) || isInReunion(actions, DropMine.class)){
|
||||||
|
Loading…
Reference in New Issue
Block a user