Class Player

java.lang.Object
it.polimi.ingsw.gc14.Model.Player
All Implemented Interfaces:
Serializable

public class Player extends Object implements Serializable
Default Player class; contains all identifiers and methods needed.
See Also:
  • Field Details

    • MAX_USERNAME_LENGTH

      private static final int MAX_USERNAME_LENGTH
      The maximum length allowed for the username string.
      See Also:
    • totem

      private Totems totem
      Identifier for the Player when displaying the game through the GUI.
      See Also:
    • userName

      private final String userName
      Unique string identifier for players; must not be null and must not exceed MAX_USERNAME_LENGTH otherwise an IllegalArgumentException will be thrown when the constructor is called.
    • buildingCards

      private final ArrayList<BuildingCard> buildingCards
      The current Building Cards in the player's deck.
    • artists

      private final ArrayList<Artist> artists
      The current Artist cards in the player's deck.
    • builders

      private final ArrayList<Builder> builders
      The current Builder cards in the player's deck.
    • inventors

      private final ArrayList<Inventor> inventors
      The current Inventor cards in the player's deck.
    • gatherers

      private final ArrayList<Gatherer> gatherers
      The current Gatherer cards in the player's deck.
    • shamans

      private final ArrayList<Shaman> shamans
      The current Shaman cards in the player's deck.
    • hunters

      private final ArrayList<Hunter> hunters
      The current Hunter cards in the player's deck.
    • foodValue

      private int foodValue
      The current amount of Food the Player possesses. Cannot be negative.
    • prestigeValue

      private int prestigeValue
      The current amount of Prestige the Player possesses.
  • Constructor Details

  • Method Details

    • getUserName

      public String getUserName()
      Getter for the private attribute userName.
      Returns:
      String - The UserName
    • getTotem

      public Totems getTotem()
      Returns the totem assigned to this player.
      Returns:
      this player's totem.
    • getTotCharacters

      public int getTotCharacters()
      Counts the total Character Cards the player currently possesses.
      Returns:
      int - Total Character Cards.
    • getNType

      public int getNType(CharacterType type)
      Counts the total number of cards of the specified Character Type. Character Type must not be null
      Parameters:
      type - the Character Type to be Counted.
      Returns:
      int - Total number of cards of given type.
    • getBuildingCards

      public ArrayList<BuildingCard> getBuildingCards()
      Returns:
      this player's building cards.
    • getArtists

      public ArrayList<Artist> getArtists()
      Returns:
      this player's Artist character cards.
    • getBuilders

      public ArrayList<Builder> getBuilders()
      Returns:
      this player's Builder character cards.
    • getInventors

      public ArrayList<Inventor> getInventors()
      Returns:
      this player's Inventor character cards.
    • getGatherers

      public ArrayList<Gatherer> getGatherers()
      Returns:
      this player's Gatherer character cards.
    • getShamans

      public ArrayList<Shaman> getShamans()
      Returns:
      this player's Shaman character cards.
    • getHunters

      public ArrayList<Hunter> getHunters()
      Returns:
      this player's Hunter character cards.
    • getFoodValue

      public int getFoodValue()
      Getter for the private attribute foodValue.
      Returns:
      int - The amount of Food the player possesses.
    • getPrestigeValue

      public int getPrestigeValue()
      Getter for the private attribute prestigeValue.
      Returns:
      int - The amount of Prestige the Player possesses.
    • addFood

      public void addFood(int value)
      Adds value amount of Food to the Player.
      Parameters:
      value - The amount of Food to be added. Should be non-negative.
      See Also:
    • setTotem

      public void setTotem(Totems totem)
      Sets the totem for this player.
      Parameters:
      totem - the totem to assign.
    • removeFood

      public boolean removeFood(int value)
      Removes value amount of Food from the Player. foodValue cannot go negative: returns false if value exceeds the current food and leaves the value unchanged.
      Parameters:
      value - The amount of Food to be removed. Should be non-negative.
      Returns:
      true if the Food is successfully removed, false otherwise.
      See Also:
    • addPrestige

      public void addPrestige(int value)
      Adds value amount of Prestige to the Player.
      Parameters:
      value - The amount of Prestige to be added. Should be non-negative.
      See Also:
    • removePrestige

      public void removePrestige(int value)
      Removes value amount of Prestige from the Player.
      Parameters:
      value - The amount of Prestige to be removed. Should be non-negative.
      See Also:
    • equals

      public boolean equals(Object obj)
      Checks equality between this Player and another object. Two players are equal if and only if they share the same userName.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with.
      Returns:
      true if obj is a Player with the same username; false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Prints the Player's attributes for the Board's representation. Uses the UNICODE border style. Includes:
      Overrides:
      toString in class Object
      Returns:
      String - A string representation of the Player's attributes.
      See Also: