Class ChooseCloudTile

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

public class ChooseCloudTile extends PlayerAction
PlayerAction allowing a user to choose one of many cloud tiles present on the gameboard. This action is linked to the Action Phase
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • selectedTile

      private final int selectedTile
  • Constructor Details

    • ChooseCloudTile

      public ChooseCloudTile(int playerBoardId, int selectedTile)
      Create a new instance of this class with the following inputs:
      Parameters:
      playerBoardId - the ID of the current PlayerBoard
      selectedTile - the ID of the Cloud the player has chosen
  • 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:
      • This action can be called only after having called one and only one MoveMotherNature action
      • The previous PlayerActions must be either MoveMotherNature or PlayCharacterCard
      • The distance declared to move must be within acceptable ranges
      • The Player who calls the action must have enough space in its "entrance" field to allow for all pawns on the tile to be transferred
      • The selected cloud tile must not be empty (unless no other non-empty cloud tiles are present)
      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.