- All Implemented Interfaces:
RuleSetStrategy
public class MoveAgain extends MovementStrategy
This effect alters the player's movement actions; the player must perform a movement action, then it can choose to perform another movement action (it cannot move on the same cell its worker started the turn on); after that, it must perform a build action to end its turn
-
Field Summary
Fields inherited from class it.polimi.ingsw.model.rules.RuleSetBase
buildsAvailable, game, hasMovedUp, movedWorker, movesAvailable, movesUpAvailable, startingCell
-
Constructor Summary
Constructors Constructor Description MoveAgain()
Default constructor -
Method Summary
Modifier and Type Method Description boolean
checkLoseCondition(MoveAction moveAction)
Determines if the lose conditions are satisfied upon a movement actionRuleSetStrategy
cloneStrategy(Game game)
Creates a clone of this objectvoid
doEffect()
Applies end turn effectsjava.util.List<PossibleActions>
getPossibleActions(Worker worker)
Provides a list of possible actions for a player to perform, based on the chosen workerjava.util.List<Cell>
getWalkableCells(Worker worker)
Provides a list of cells on which the worker can walk onvoid
initialize()
Sets the parameters for a new turnboolean
isMoveActionValid(MoveAction action)
Determines if a moveAction is legal and applies itMethods inherited from class it.polimi.ingsw.model.godCardsEffects.movementEffects.MovementStrategy
canGo, isNotSameOwner
Methods inherited from class it.polimi.ingsw.model.rules.RuleSetBase
addBuildableCells, addWalkableCells, canBuild, canEndTurn, canEndTurnAutomatically, checkLoseCondition, checkLoseCondition, checkWinCondition, getBlocks, getBuildableCells, getBuildsAvailable, getMovedWorker, getMovesAvailable, getMovesUpAvailable, hasMovedUp, isBuildActionValid, isCorrectBlock, isCorrectDistance, isInsideBuildableCells, isInsideWalkableCells, setGame, setMovesUpAvailable
-
Constructor Details
-
MoveAgain
public MoveAgain()Default constructor- See Also:
initialize()
-
-
Method Details
-
initialize
public void initialize()Sets the parameters for a new turnUsing this ruleSet, a player is granted two movement and one building action, to be performed by the same worker following the rules mentioned in the class documentation.
- Overrides:
initialize
in classRuleSetBase
-
doEffect
public void doEffect()Applies end turn effectsUsing this ruleSet, the end turn effects simply resets the attributes changed during the turn
- Specified by:
doEffect
in interfaceRuleSetStrategy
- Overrides:
doEffect
in classRuleSetBase
-
getPossibleActions
Provides a list of possible actions for a player to perform, based on the chosen workerg this ruleSet, the possible actions for a worker are:
- Change Worker/Move, if the worker has not been moved yet
- Move, Build, if the worker has been moved once
- Build, if the worker has been moved once
- None, in any other case
- Specified by:
getPossibleActions
in interfaceRuleSetStrategy
- Overrides:
getPossibleActions
in classRuleSetBase
- Parameters:
worker
- the worker to perform an action with- Returns:
- a list of possible performable actions
-
isMoveActionValid
Determines if a moveAction is legal and applies itg this ruleSet, a movement action is considered valid if the following conditions are all true:
- no worker has been moved yet during the turn OR the worker to be moved has already been moved once during the turn
- the target cell is a walkable cell (see getWalkableCells(Worker)) for the worker to be moved
- in case of the second movement, the target cell must not be the same as the cell from which the worker started its turn
- Specified by:
isMoveActionValid
in interfaceRuleSetStrategy
- Overrides:
isMoveActionValid
in classRuleSetBase
- Parameters:
action
- the movement action to validate- Returns:
- true if the action has been applied, false otherwise
-
getWalkableCells
Provides a list of cells on which the worker can walk onUsing this ruleSet, a worker can walk on the cells adjacent to its starting cell which height difference is at most one compared to the starting cell; in case the player decides to move a second time, the worker can move into a cell adjacent to its current position, except for the cell it started its turnn from
- Specified by:
getWalkableCells
in interfaceRuleSetStrategy
- Overrides:
getWalkableCells
in classRuleSetBase
- Parameters:
worker
- the worker to be moved- Returns:
- a list of walkable cells
-
checkLoseCondition
Determines if the lose conditions are satisfied upon a movement actionUsing this ruleSet, a player can lose upon a movement action if the worker which has been moved cannot build any block around it and it already used all of its movement actions
- Specified by:
checkLoseCondition
in interfaceRuleSetStrategy
- Overrides:
checkLoseCondition
in classRuleSetBase
- Parameters:
moveAction
- the action to analyze- Returns:
- true if the action led to a loss, false otherwise
-
cloneStrategy
Creates a clone of this object- Specified by:
cloneStrategy
in interfaceRuleSetStrategy
- Overrides:
cloneStrategy
in classRuleSetBase
- Parameters:
game
- the current game- Returns:
- a clone of this object
-