Package model

Class Player

java.lang.Object
model.Player
All Implemented Interfaces:
Serializable

public class Player extends Object implements Serializable
Implementation of the Player class for Double Trouble Kingdom Game, contains the Player's name, entities and gold. Implements the methods of manipulating entities.
See Also:
  • Constructor Details

    • Player

      public Player(String name)
      Constructs the Player with starter gold, entities and name.
      Parameters:
      name - the name of the Player
  • Method Details

    • getSide

      public Sides getSide()
      Returns the player's side.
      Returns:
      the player's side
    • isUnitRestricted

      public boolean isUnitRestricted()
      Returns if the player has unlocked all unit types.
      Returns:
      if the player has unlocked all unit types
    • setUnitRestricted

      public void setUnitRestricted(boolean isUnitRestricted)
      Sets the unit restriction to the given value.
      Parameters:
      isUnitRestricted - the value to set the unit restriction to
    • getPlayerNumber

      public int getPlayerNumber()
      Returns the player's number.
      Returns:
      the player's number
    • getName

      public String getName()
      Returns the player's name.
      Returns:
      the player's name
    • getGold

      public int getGold()
      Returns the player's gold amount.
      Returns:
      the player's gold amount
    • addGold

      public void addGold(int amount)
      Adds gold to the player's gold amount.
      Parameters:
      amount - the amount of gold to add
    • getEntities

      public ArrayList<Entity> getEntities()
      Returns an ArrayList with the player's entities.
      Returns:
      an ArrayList with the player's entities
    • setEntities

      public void setEntities(ArrayList<Entity> entities)
      Sets the player's entities.
      Parameters:
      entities - the player's entities
    • addEntity

      public void addEntity(Entity entity)
      Adds an entity to the player's entity ArrayList.
      Parameters:
      entity - the entity to add
    • getSoldierCount

      public int getSoldierCount()
      Returns the number of soldiers the player has.
      Returns:
      the number of soldiers the player has
    • setSoldierCount

      public void setSoldierCount(int soldierCount)
      Sets the number of soldiers the player has.
      Parameters:
      soldierCount - the number of soldiers the player has
    • removeSoldier

      public void removeSoldier(Soldier soldier)
      Remove a soldier from the player's entity ArrayList.
      Parameters:
      soldier - the soldier to remove
    • addSavedEntity

      public void addSavedEntity(Entity entity)
      Adds an entity to the player's entity ArrayList from a save.
      Parameters:
      entity - the entity to add
    • upgradeBuilding

      public void upgradeBuilding(Building building)
      Upgrades the selected Building, removes the upgrade cost from the player's gold.
      Parameters:
      building - the Building to upgrade
    • transformTower

      public Tower transformTower(Tower tower, Types type)
      Transforms the selected Tower to the given type, refunds a part of the building cost.
      Parameters:
      tower - the tower to transform
      type - the type we want
      Returns:
      new Tower Entity
    • removeEntity

      public void removeEntity(Entity entity)
      Removes the given entity from the player's entities ArrayList.
      Parameters:
      entity - the entity to remove
    • getCastle

      public Building getCastle()
      Returns the player's castle
      Returns:
      the player's castle
    • getSoldiers

      public ArrayList<Soldier> getSoldiers()
      Returns the player's soldiers
      Returns:
      the player's soldiers
    • getTowers

      public ArrayList<Tower> getTowers()
      Returns the player's towers
      Returns:
      the player's towers
    • calculateGoldAtRound

      public void calculateGoldAtRound()
      Calculates the player's gold at round start.