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 boolean
canEndTurn()
Determines whether a player can end its turnboolean
canEndTurnAutomatically()
Determines whether a player can end its turnboolean
checkLoseCondition()
Checks if the turn can begin, checking for both players to be freeboolean
checkLoseCondition(BuildAction action)
Determines if the lose conditions are satisfied upon a movement actionboolean
checkLoseCondition(MoveAction action)
Determines if the lose conditions are satisfied upon a movement actionboolean
checkWinCondition(MoveAction action)
Determines if the win conditions are satisfied upon a movement actionvoid
doEffect()
Applies end turn effectsjava.util.List<Cell>
getBuildableCells(Worker worker)
Provides a list of cells on which the worker can build onRuleSetStrategy
getStrategy()
strategy getterjava.util.List<Cell>
getWalkableCells(Worker worker)
Provides a list of cells on which the worker can walk onvoid
setGame(Game game)
game settervoid
setStrategy(RuleSetStrategy strategy)
strategy setterboolean
validateBuildAction(BuildAction action)
Determines if a buildAction is legal and applies itboolean
validateMoveAction(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
-