Module AM37

Class RuleSetContext

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 Details

  • Method Details

    • setGame

      public void setGame​(Game game)
      game setter
      Parameters:
      game - the game in which the effect is used
    • validateMoveAction

      public boolean validateMoveAction​(MoveAction action)
      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

      public boolean validateBuildAction​(BuildAction action)
      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

      public RuleSetStrategy getStrategy()
      strategy getter
      Returns:
      the current strategy
    • setStrategy

      public void setStrategy​(RuleSetStrategy strategy)
      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

      public boolean checkWinCondition​(MoveAction action)
      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

      public boolean checkLoseCondition​(MoveAction action)
      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​(BuildAction action)
      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

      public java.util.List<Cell> getWalkableCells​(Worker worker)
      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

      public java.util.List<Cell> getBuildableCells​(Worker worker)
      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