# Class Player

java.lang.Object
it.polimi.ingsw.is25am31.model.player.Player

All Implemented Interfaces:
  `Serializable`

public class Player extends Object implements Serializable
Represents a player in a game, identified by a unique ID and nickname, with associated game-specific objects like a rocket and a ship.
This class contains methods for manipulating and accessing the state of the player, including score-related properties, game objects, and player status.
Implements the Serializable interface to allow player data to be serialized.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Player(int id, String nickname, Gameboard gameboard)`
  Constructs a new player

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCargoCredits(int amount)`
  Adds credits from cargo sales to the total
  `void`
  `addCosmicCredits(int cosmicCredits)`
  Adds cosmic credits to the current total
  `int`
  `getCargoCredits()`
  Returns the credits obtained from cargo sales
  `int`
  `getCosmicCredits()`
  Returns the current cosmic credits
  `int`
  `getCrew()`
  Returns the number of crew members
  `int`
  `getId()`
  Returns the player's identifier
  `int`
  `getLostComponents()`
  Returns the number of lost components
  `String`
  `getNickname()`
  Returns the player's nickname
  `Rocket`
  `getRocket()`
  Returns the player's rocket
  `Ship`
  `getShip()`
  Returns the player's current ship
  `boolean`
  `hasAbandoned()`
  Indicates whether the player has abandoned the game
  `void`
  `incrementLostComponents()`
  Increments the lost components
  `void`
  `setAbandoned(boolean hasAbandoned)`
  Sets the player's abandonment status
  `void`
  `setCrew(int crew)`
  Sets the number of crew members at the player level
  `void`
  `setRocket(Rocket rocket)`
  Sets the player's rocket
  `void`
  `setShip(Ship ship)`
  Sets a new ship for the player

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

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

- ## Constructor Details

  - ### Player

    public Player(int id, String nickname, Gameboard gameboard)
    Constructs a new player
    Parameters:
      `id` - unique player identifier
      `nickname` - chosen nickname
      `gameboard` - reference to the game board

- ## Method Details

  - ### getId

    public int getId()
    Returns the player's identifier
    Returns:
      unique player ID

  - ### getNickname

    public String getNickname()
    Returns the player's nickname
    Returns:
      nickname string

  - ### getCosmicCredits

    public int getCosmicCredits()
    Returns the current cosmic credits
    Returns:
      amount of cosmic credits

  - ### addCosmicCredits

    public void addCosmicCredits(int cosmicCredits)
    Adds cosmic credits to the current total
    Parameters:
      `cosmicCredits` - number of credits to add

  - ### getShip

    public Ship getShip()
    Returns the player's current ship
    Returns:
      Ship instance

  - ### setShip

    public void setShip(Ship ship)
    Sets a new ship for the player
    Parameters:
      `ship` - new Ship instance

  - ### getRocket

    public Rocket getRocket()
    Returns the player's rocket
    Returns:
      Rocket instance

  - ### setRocket

    public void setRocket(Rocket rocket)
    Sets the player's rocket
    Parameters:
      `rocket` - new Rocket instance

  - ### getLostComponents

    public int getLostComponents()
    Returns the number of lost components
    Returns:
      penalty count for lost components

  - ### incrementLostComponents

    public void incrementLostComponents()
    Increments the lost components

  - ### getCargoCredits

    public int getCargoCredits()
    Returns the credits obtained from cargo sales
    Returns:
      cargo sale credits

  - ### addCargoCredits

    public void addCargoCredits(int amount)
    Adds credits from cargo sales to the total
    Parameters:
      `amount` - credits amount to add

  - ### setCrew

    public void setCrew(int crew)
    Sets the number of crew members at the player level
    Parameters:
      `crew` - number of crew members

  - ### getCrew

    public int getCrew()
    Returns the number of crew members
    Returns:
      number of crew members

  - ### hasAbandoned

    public boolean hasAbandoned()
    Indicates whether the player has abandoned the game
    Returns:
      true if abandoned, false otherwise

  - ### setAbandoned

    public void setAbandoned(boolean hasAbandoned)
    Sets the player's abandonment status
    Parameters:
      `hasAbandoned` - true if the player abandons, false otherwise