java.lang.Object
it.polimi.ingsw.model.rules.RuleSetContext
public class RuleSetContext
extends java.lang.Object
Context class for the implementation of the Strategy pattern
on the various gods effects
-
Constructor Summary
Constructors Constructor Description RuleSetContext() -
Method Summary
Modifier and Type Method Description booleancanEndTurn()Determines whether a player can end its turnbooleancanEndTurnAutomatically()Determines whether a player can end its turnbooleancheckLoseCondition()Checks if the turn can begin, checking for both players to be freebooleancheckLoseCondition(BuildAction action)Determines if the lose conditions are satisfied upon a movement actionbooleancheckLoseCondition(MoveAction action)Determines if the lose conditions are satisfied upon a movement actionbooleancheckWinCondition(MoveAction action)Determines if the win conditions are satisfied upon a movement actionvoiddoEffect()Applies end turn effectsjava.util.List<Cell>getBuildableCells(Worker worker)Provides a list of cells on which the worker can build onRuleSetStrategygetStrategy()strategy getterjava.util.List<Cell>getWalkableCells(Worker worker)Provides a list of cells on which the worker can walk onvoidsetGame(Game game)game settervoidsetStrategy(RuleSetStrategy strategy)strategy setterbooleanvalidateBuildAction(BuildAction action)Determines if a buildAction is legal and applies itbooleanvalidateMoveAction(MoveAction action)Determines if a moveAction is legal and applies it
-
Constructor Details
-
RuleSetContext
public RuleSetContext()
-
-
Method Details
-
setGame
game setter- Parameters:
game- the game in which the effect is used
-
validateMoveAction
Determines if a moveAction is legal and applies it- Parameters:
action- the movement action to validate- Returns:
- true if the action has been applied, false otherwise
-
validateBuildAction
Determines if a buildAction is legal and applies it- Parameters:
action- the build action to validate- Returns:
- true if the action has been applied, false otherwise
-
getStrategy
strategy getter- Returns:
- the current strategy
-
setStrategy
strategy setter- Parameters:
strategy- the strategy to set
-
canEndTurn
public boolean canEndTurn()Determines whether a player can end its turn- Returns:
- true if the player can end its turn, false otherwise
-
canEndTurnAutomatically
public boolean canEndTurnAutomatically()Determines whether a player can end its turn- Returns:
- true if the player can end its turn, false otherwise
-
doEffect
public void doEffect()Applies end turn effects -
checkWinCondition
Determines if the win conditions are satisfied upon a movement action- Parameters:
action- the action to analyze- Returns:
- true if the action led to victory, false otherwise
-
checkLoseCondition
Determines if the lose conditions are satisfied upon a movement action- Parameters:
action- the action to analyze- Returns:
- true if the action led to a loss, false otherwise
-
checkLoseCondition
Determines if the lose conditions are satisfied upon a movement action- Parameters:
action- the action to analyze- Returns:
- true if the action led to a loss, false otherwise
-
checkLoseCondition
public boolean checkLoseCondition()Checks if the turn can begin, checking for both players to be free- Returns:
- true if there is at least one action to perform, false otherwise
-
getWalkableCells
Provides a list of cells on which the worker can walk on- Parameters:
worker- the worker to be moved- Returns:
- a list of walkable cells
-
getBuildableCells
Provides a list of cells on which the worker can build on- Parameters:
worker- the worker to build with- Returns:
- a list of buildable cells
-