Class ChooseCloudTile
java.lang.Object
it.polimi.ingsw.Controller.Actions.PlayerAction
it.polimi.ingsw.Controller.Actions.ChooseCloudTile
- All Implemented Interfaces:
Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate static final long -
Constructor Summary
ConstructorsConstructorDescriptionChooseCloudTile(int playerBoardId, int selectedTile) Create a new instance of this class with the following inputs: -
Method Summary
Modifier and TypeMethodDescriptionprotected OptionalValue<InputValidationException>customValidation(List<PlayerAction> history, Model ctx) This function is used byPlayerAction.validate(List, Model)to check whether or not the declaredPlayerActionis possible.
This function will check for the following requirements:voidunsafeExecute(Model ctx) Every class extendingPlayerActionmust implement the following method, which takes aModelreference and applies the concrete effect of the action.Methods inherited from class it.polimi.ingsw.Controller.Actions.PlayerAction
getPlayerBoardID, validate
-
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 currentPlayerBoardselectedTile- the ID of theCloudthe player has chosen
-
-
Method Details
-
customValidation
protected OptionalValue<InputValidationException> customValidation(List<PlayerAction> history, Model ctx) This function is used byPlayerAction.validate(List, Model)to check whether or not the declaredPlayerActionis possible.
This function will check for the following requirements:- This action can be called only after having called one and only one
MoveMotherNatureaction - The previous
PlayerActions must be eitherMoveMotherNatureorPlayCharacterCard - 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:
customValidationin classPlayerAction- Parameters:
history- the controller stores aListof previousPlayerActions related to the player taking the current turn (at every new turn, the history is cleared). Some actions may use thisListto check for duplicates.ctx- a reference toModel. Some actions may use this reference to check for consistency between what the actions declares and what the Model offers.- Returns:
- An empty
OptionalValuein case of a successful validation. Otherwise the returnedOptionalValuecontains the relatedInputValidationException
- This action can be called only after having called one and only one
-
unsafeExecute
Description copied from class:PlayerActionEvery class extendingPlayerActionmust implement the following method, which takes aModelreference 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 classController, which takes adequate precautions in order to guarantee a coherent execution of the method.- Specified by:
unsafeExecutein classPlayerAction- Parameters:
ctx- theModelreference, once the method finishes running the game state will be altered.
-