Package it.polimi.ingsw.Model
Class CharacterCard
java.lang.Object
it.polimi.ingsw.Model.CharacterCard
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
StatefulEffect,StatelessEffect
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddUse()checkInput(CharacterCardInput input) This function checks whether the correct input has been provided.final intgetCost()final intgetId()final intprotected abstract OptionalValue<InputValidationException>This function checks whether the correct input has been provided.protected abstract voidThis method must be called aftercheckInput(CharacterCardInput)Execute CharacterCard's effect (NOTE: keep in mind this funcion DOES ALTERATE the gamestate)final voidunsafeUseCard(CharacterCardInput input) This method must be called after checking user's input Play
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
id
protected final int id -
cost
protected final int cost -
context
-
timeUsed
protected int timeUsed
-
-
Constructor Details
-
CharacterCard
-
-
Method Details
-
getId
public final int getId() -
getCost
public final int getCost() -
getTimeUsed
public final int getTimeUsed() -
checkInput
This function checks whether the correct input has been provided. It should always be called BEFORE calling an unsafeApplyEffect. Keep in mind this function does not alterate the gamestate.- Parameters:
input- user's input object- Returns:
- a non empty
OptionalValuecontaining a validation error. Or an empty one when the input is correct
-
overridableCheckInput
protected abstract OptionalValue<InputValidationException> overridableCheckInput(CharacterCardInput input) This function checks whether the correct input has been provided. It is part of the checkInput function. Keep in mind this function does not alterate the gamestate. NOTE: checkInput(input) by default checks whether the correct player has called the card, then relays all other checks to this function. So don't check the correct user in this function as it is pointless.- Parameters:
input- user's input object- Returns:
- a non empty
OptionalValuecontaining a validation error. Or an empty one when the input is correct
-
unsafeUseCard
This method must be called after checking user's input Play- Parameters:
input- aCharacterCardInputobject, the same used during validation
-
unsafeApplyEffect
This method must be called aftercheckInput(CharacterCardInput)Execute CharacterCard's effect (NOTE: keep in mind this funcion DOES ALTERATE the gamestate)- Parameters:
input- verified user's input- Throws:
Exception- not related to user's input and not recoverable
-
addUse
private void addUse()
-