Module AM37

Class BuildAgainSameCell

java.lang.Object
it.polimi.ingsw.model.rules.RuleSetBase
it.polimi.ingsw.model.godCardsEffects.buildingEffects.BuildingStrategy
it.polimi.ingsw.model.godCardsEffects.buildingEffects.BuildAgainSameCell
All Implemented Interfaces:
RuleSetStrategy

public class BuildAgainSameCell
extends BuildingStrategy
Move, build, build again (optional)

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

  • Constructor Details

  • Method Details

    • initialize

      public void initialize()
      Sets the parameters for a new turn

      Using 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 class RuleSetBase
    • doEffect

      public void doEffect()
      Applies end turn effects

      Using this ruleSet, the end turn effects simply resets the attributes changed during the turn

      Specified by:
      doEffect in interface RuleSetStrategy
      Overrides:
      doEffect in class RuleSetBase
    • getPossibleActions

      public java.util.List<PossibleActions> getPossibleActions​(Worker worker)
      Provides a list of possible actions for a player to perform, based on the chosen worker

      g 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 interface RuleSetStrategy
      Overrides:
      getPossibleActions in class RuleSetBase
      Parameters:
      worker - the worker to perform an action with
      Returns:
      a list of possible performable actions
    • isBuildActionValid

      public boolean isBuildActionValid​(BuildAction action)
      Determines if a buildAction is legal and applies it

      g 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 interface RuleSetStrategy
      Overrides:
      isBuildActionValid in class RuleSetBase
      Parameters:
      action - the build action to validate
      Returns:
      true if the action has been applied, false otherwise
    • getBuildableCells

      public java.util.List<Cell> getBuildableCells​(Worker worker)
      Provides a list of cells on which the worker can build on

      Using 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 interface RuleSetStrategy
      Overrides:
      getBuildableCells in class RuleSetBase
      Parameters:
      worker - the worker to build with
      Returns:
      a list of buildable cells
    • canEndTurn

      public boolean canEndTurn()
      Determines whether a player can end its turn

      Using this ruleSet, a player can end its turn after it performs the first build action correctly

      Specified by:
      canEndTurn in interface RuleSetStrategy
      Overrides:
      canEndTurn in class RuleSetBase
      Returns:
      true if the player can end its turn, false otherwise
    • cloneStrategy

      public RuleSetStrategy cloneStrategy​(Game game)
      Creates a clone of this object
      Specified by:
      cloneStrategy in interface RuleSetStrategy
      Overrides:
      cloneStrategy in class RuleSetBase
      Parameters:
      game - the current game
      Returns:
      a clone of this object