- All Implemented Interfaces:
RuleSetStrategy
public class BuildAgainSameCell extends BuildingStrategy
This effect alters the player's build action; the player can play the turn as usual, but after it builds, it can choose if it wants to build again on top of the previously built cell (no dome can be built on the second build action) or pass the 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 BuildAgainSameCell()
Default constructor -
Method Summary
Modifier and Type Method Description boolean
canEndTurn()
Determines whether a player can end its turnRuleSetStrategy
cloneStrategy(Game game)
Creates a clone of this objectvoid
doEffect()
Applies end turn effectsjava.util.List<Cell>
getBuildableCells(Worker worker)
Provides a list of cells on which the worker can build onjava.util.List<PossibleActions>
getPossibleActions(Worker worker)
Provides a list of possible actions for a player to perform, based on the chosen workervoid
initialize()
Sets the parameters for a new turnboolean
isBuildActionValid(BuildAction action)
Determines if a buildAction is legal and applies itMethods inherited from class it.polimi.ingsw.model.rules.RuleSetBase
addBuildableCells, addWalkableCells, canBuild, canEndTurnAutomatically, checkLoseCondition, checkLoseCondition, checkLoseCondition, checkWinCondition, getBlocks, getBuildsAvailable, getMovedWorker, getMovesAvailable, getMovesUpAvailable, getWalkableCells, hasMovedUp, isCorrectBlock, isCorrectDistance, isInsideBuildableCells, isInsideWalkableCells, isMoveActionValid, setGame, setMovesUpAvailable
-
Constructor Details
-
BuildAgainSameCell
public BuildAgainSameCell()Default constructor- See Also:
initialize()
-
-
Method Details
-
initialize
public void initialize()Sets the parameters for a new turnUsing this ruleSet, a player is granted one movement and two 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
- Build, if the worker has been moved
- Build, Pass turn, if the worker has built 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
-
isBuildActionValid
Determines if a buildAction is legal and applies itg this ruleSet, a build action is considered valid if the following conditions are all true:
- the worker to perform the action has already been moved
- the worker to perform the action has already built once, the target cell is the same the worker already built on and the block to be built is not a dome
- Specified by:
isBuildActionValid
in interfaceRuleSetStrategy
- Overrides:
isBuildActionValid
in classRuleSetBase
- Parameters:
action
- the build action to validate- Returns:
- true if the action has been applied, false otherwise
-
getBuildableCells
Provides a list of cells on which the worker can build onUsing this ruleSet, a worker can build on any cell adjacent to its cell for the first action, and on any cell adjacent to its cell minus the cell it already built on if it already built once during the turn.
- Specified by:
getBuildableCells
in interfaceRuleSetStrategy
- Overrides:
getBuildableCells
in classRuleSetBase
- Parameters:
worker
- the worker to build with- Returns:
- a list of buildable cells
-
canEndTurn
public boolean canEndTurn()Determines whether a player can end its turnUsing this ruleSet, a player can end its turn after it performs the first build action correctly
- Specified by:
canEndTurn
in interfaceRuleSetStrategy
- Overrides:
canEndTurn
in classRuleSetBase
- Returns:
- true if the player can end its turn, 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
-