Class MoveMotherNature

java.lang.Object
it.polimi.ingsw.Controller.Actions.PlayerAction
it.polimi.ingsw.Controller.Actions.MoveMotherNature
All Implemented Interfaces:
Serializable

public class MoveMotherNature extends PlayerAction
This PlayerAction allows the caller to move the mother nature entity forward by a specified amount. This action is linked to the Action Phase.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • distanceToMove

      private final int distanceToMove
  • Constructor Details

    • MoveMotherNature

      public MoveMotherNature(int playerBoardId, int distanceToMove)
      Create a new instance of this class with the following inputs:
      Parameters:
      playerBoardId - the ID of the current PlayerBoard
      distanceToMove - the amount of distance Mother Nature is going to be moved
  • Method Details

    • customValidation

      protected OptionalValue<InputValidationException> customValidation(List<PlayerAction> history, Model ctx)
      This function is used by PlayerAction.validate(List, Model) to check whether or not the declared PlayerAction is possible.
      This function will check for the following requirements:
      Specified by:
      customValidation in class PlayerAction
      Parameters:
      history - the controller stores a List of previous PlayerActions related to the player taking the current turn (at every new turn, the history is cleared). Some actions may use this List to check for duplicates.
      ctx - a reference to Model. Some actions may use this reference to check for consistency between what the actions declares and what the Model offers.
      Returns:
      An empty OptionalValue in case of a successful validation. Otherwise the returned OptionalValue contains the related InputValidationException
    • unsafeExecute

      public void unsafeExecute(Model ctx)
      Description copied from class: PlayerAction
      Every class extending PlayerAction must implement the following method, which takes a Model reference and applies the concrete effect of the action.
      Warning: this function, as implied by the name, is unsafe. it should never be called by called outside the scope of the class Controller, which takes adequate precautions in order to guarantee a coherent execution of the method.
      Specified by:
      unsafeExecute in class PlayerAction
      Parameters:
      ctx - the Model reference, once the method finishes running the game state will be altered.