# Class Card

java.lang.Object
it.polimi.ingsw.is25am31.model.cards.Card

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `AbandonedShipCard`, `AbandonedStationCard`, `CombatZoneCard`, `EpidemicCard`, `MeteorSwarmCard`, `OpenSpaceCard`, `PiratesCard`, `PlanetsCard`, `SlaversCard`, `SmugglersCard`, `StardustCard`

public abstract class Card extends Object implements Serializable
Represents a generic card used in the game. This class is abstract and defines the common properties and methods that all specific card types must implement or inherit. Instances of this class are deserialized from JSON using Jackson.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final int`
  `id`
  `protected final int`
  `level`
  `protected final String`
  `name`
  `protected final boolean`
  `testFlight`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Card(int id, int level, String name, boolean testFlight)`
  the constructor is called by the Jackson library, and the values are read from the JSON file

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract boolean`
  `applyEffect(Player player, Context context)`
  Applies the specific card effect relative to the current game state and the passed parameters.
  `abstract String[]`
  `getAsciiArt()`
  Generates an ASCII art representation of the card containing details such as the card name, level, optional status, and its effects.
  `int`
  `getCrewMembers()`
  Retrieves the number of crew members associated with the card.
  `int`
  `getId()`
  `int`
  `getIterations()`
  `abstract EffectType`
  `getType()`
  `boolean`
  `isTestFlight()`
  Determines if the card is available in test flight mode.
  `void`
  `setCardContext(Player player, Context context)`
  Method used to do things that the player may/must do before applying the effect.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### id

    protected final int id

  - ### level

    protected final int level

  - ### name

    protected final String name

  - ### testFlight

    protected final boolean testFlight

- ## Constructor Details

  - ### Card

    public Card(int id, int level, String name, boolean testFlight)
    the constructor is called by the Jackson library, and the values are read from the JSON file
    Parameters:
      `id` - card's id
      `level` - card's level
      `name` - card's name
      `testFlight` - `true` if the card is available in test flight mode, `false` otherwise

- ## Method Details

  - ### getCrewMembers

    public int getCrewMembers()
    Retrieves the number of crew members associated with the card.
    Returns:
      the number of crew members for the card
    Throws:
      `UnsupportedOperationException` - if the card does not have crew members

  - ### isTestFlight

    public boolean isTestFlight()
    Determines if the card is available in test flight mode.
    Returns:
      `true` if the card is a test flight card, `false` otherwise

  - ### getType

    public abstract EffectType getType()
    Returns:
      card type

  - ### getIterations

    public int getIterations()
    Returns:
      Number of times the applyEffect method needs to be called in order to fully resolve the effect of the specific Card subclass.

  - ### setCardContext

    public void setCardContext(Player player, Context context)
    Method used to do things that the player may/must do before applying the effect.
    Parameters:
      `player` - Player setting their context.
      `context` - map of parameters passed by the player, useful to set the context of the card

  - ### applyEffect

    public abstract boolean applyEffect(Player player, Context context)
    Applies the specific card effect relative to the current game state and the passed parameters.
    Parameters:
      `player` - Player on whom the effect is applied.
      `context` - Map of parameters passed by the player, used to apply the effect.
    Returns:
      `true` if effect has been completely resolved for passed player, `false` otherwise

  - ### getAsciiArt

    public abstract String[] getAsciiArt()
    Generates an ASCII art representation of the card containing details such as the card name, level, optional status, and its effects. This representation serves as a textual description of the card, formatted line by line for display.
    Returns:
      an array of strings containing the ASCII art representation of the card

  - ### getId

    public int getId()