Class BuildAgainDifferentCell
- All Implemented Interfaces:
RuleSetStrategy
public class BuildAgainDifferentCell 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 (not on top of the previously built cell) 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 BuildAgainDifferentCell()Default constructor -
Method Summary
Modifier and Type Method Description booleancanEndTurn()Determines whether a player can end its turnbooleancanEndTurnAutomatically()Determines whether a player can end its turnRuleSetStrategycloneStrategy(Game game)Creates a clone of this objectvoiddoEffect()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 workervoidinitialize()Sets the parameters for a new turnbooleanisBuildActionValid(BuildAction action)Determines if a buildAction is legal and applies itMethods inherited from class it.polimi.ingsw.model.rules.RuleSetBase
addBuildableCells, addWalkableCells, canBuild, checkLoseCondition, checkLoseCondition, checkLoseCondition, checkWinCondition, getBlocks, getBuildsAvailable, getMovedWorker, getMovesAvailable, getMovesUpAvailable, getWalkableCells, hasMovedUp, isCorrectBlock, isCorrectDistance, isInsideBuildableCells, isInsideWalkableCells, isMoveActionValid, setGame, setMovesUpAvailable
-
Constructor Details
-
BuildAgainDifferentCell
public BuildAgainDifferentCell()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:
initializein 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:
doEffectin interfaceRuleSetStrategy- Overrides:
doEffectin 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:
getPossibleActionsin interfaceRuleSetStrategy- Overrides:
getPossibleActionsin 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
- Specified by:
isBuildActionValidin interfaceRuleSetStrategy- Overrides:
isBuildActionValidin 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:
getBuildableCellsin interfaceRuleSetStrategy- Overrides:
getBuildableCellsin 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:
canEndTurnin interfaceRuleSetStrategy- Overrides:
canEndTurnin classRuleSetBase- Returns:
- true if the player can end its turn, false otherwise
-
canEndTurnAutomatically
public boolean canEndTurnAutomatically()Description copied from class:RuleSetBaseDetermines whether a player can end its turnUsing this ruleSet, a player turn is ended automatically right after it performs its build action
This method should never be invoked directly from the player- Specified by:
canEndTurnAutomaticallyin interfaceRuleSetStrategy- Overrides:
canEndTurnAutomaticallyin classRuleSetBase- Returns:
- true if the player can end its turn, false otherwise
-
cloneStrategy
Creates a clone of this object- Specified by:
cloneStrategyin interfaceRuleSetStrategy- Overrides:
cloneStrategyin classRuleSetBase- Parameters:
game- the current game- Returns:
- a clone of this object
-