Class EndTurnOfActionPhase
java.lang.Object
it.polimi.ingsw.Controller.Actions.PlayerAction
it.polimi.ingsw.Controller.Actions.EndTurnOfActionPhase
- All Implemented Interfaces:
Serializable
The Action phase is a lengthy one and its length cannot be determined. This
PlayerAction
enables the caller to
end an Action phase on its own accord.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEndTurnOfActionPhase
(int playerBoardId) 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 declaredPlayerAction
is possible.
This function will check for the following requirements:void
unsafeExecute
(Model ctx) Every class extendingPlayerAction
must implement the following method, which takes aModel
reference 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:
-
-
Constructor Details
-
EndTurnOfActionPhase
public EndTurnOfActionPhase(int playerBoardId) Create a new instance of this class with the following inputs:- Parameters:
playerBoardId
- the ID of the currentPlayerBoard
-
-
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 declaredPlayerAction
is possible.
This function will check for the following requirements:- This action can be called only after having called one and only one
ChooseCloudTile
action - The previous
PlayerAction
s must be eitherChooseCloudTile
orPlayCharacterCard
- Specified by:
customValidation
in classPlayerAction
- Parameters:
history
- the controller stores aList
of previousPlayerAction
s related to the player taking the current turn (at every new turn, the history is cleared). Some actions may use thisList
to 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
OptionalValue
in case of a successful validation. Otherwise the returnedOptionalValue
contains the relatedInputValidationException
- This action can be called only after having called one and only one
-
unsafeExecute
Description copied from class:PlayerAction
Every class extendingPlayerAction
must implement the following method, which takes aModel
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 classController
, which takes adequate precautions in order to guarantee a coherent execution of the method.- Specified by:
unsafeExecute
in classPlayerAction
- Parameters:
ctx
- theModel
reference, once the method finishes running the game state will be altered.- Throws:
Exception
- Should an error occur during the execution of the method, such error will be reported through the thrownException
. Note that anyPlayerAction
inheritor should guarantee the absence of Exceptions for any positive return value yielded byPlayerAction.validate(List, Model)
-