Class CharacterCard

java.lang.Object
it.polimi.ingsw.Model.CharacterCard
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StatefulEffect, StatelessEffect

public abstract class CharacterCard extends Object implements Serializable
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • id

      protected final int id
    • cost

      protected final int cost
    • context

      protected final Model context
    • timeUsed

      protected int timeUsed
  • Constructor Details

    • CharacterCard

      public CharacterCard(int id, int cost, Model context)
  • Method Details

    • getId

      public final int getId()
    • getCost

      public final int getCost()
    • getTimeUsed

      public final int getTimeUsed()
    • checkInput

      public final OptionalValue<InputValidationException> checkInput(CharacterCardInput input)
      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 OptionalValue containing 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 OptionalValue containing a validation error. Or an empty one when the input is correct
    • unsafeUseCard

      public final void unsafeUseCard(CharacterCardInput input)
      This method must be called after checking user's input Play
      Parameters:
      input - a CharacterCardInput object, the same used during validation
    • unsafeApplyEffect

      protected abstract void unsafeApplyEffect(CharacterCardInput input) throws Exception
      This method must be called after checkInput(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()