Package model
Class Player
java.lang.Object
model.Player
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an entity to the player's entity ArrayList.void
addGold
(int amount) Adds gold to the player's gold amount.void
addSavedEntity
(Entity entity) Adds an entity to the player's entity ArrayList from a save.void
Calculates the player's gold at round start.Returns the player's castleReturns an ArrayList with the player's entities.int
getGold()
Returns the player's gold amount.getName()
Returns the player's name.int
Returns the player's number.getSide()
Returns the player's side.int
Returns the number of soldiers the player has.Returns the player's soldiersReturns the player's towersboolean
Returns if the player has unlocked all unit types.void
removeEntity
(Entity entity) Removes the given entity from the player's entities ArrayList.void
removeSoldier
(Soldier soldier) Remove a soldier from the player's entity ArrayList.void
setEntities
(ArrayList<Entity> entities) Sets the player's entities.void
setSoldierCount
(int soldierCount) Sets the number of soldiers the player has.void
setUnitRestricted
(boolean isUnitRestricted) Sets the unit restriction to the given value.transformTower
(Tower tower, Types type) Transforms the selected Tower to the given type, refunds a part of the building cost.void
upgradeBuilding
(Building building) Upgrades the selected Building, removes the upgrade cost from the player's gold.
-
Constructor Details
-
Player
Constructs the Player with starter gold, entities and name.- Parameters:
name
- the name of the Player
-
-
Method Details
-
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
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
Returns an ArrayList with the player's entities.- Returns:
- an ArrayList with the player's entities
-
setEntities
Sets the player's entities.- Parameters:
entities
- the player's entities
-
addEntity
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
Remove a soldier from the player's entity ArrayList.- Parameters:
soldier
- the soldier to remove
-
addSavedEntity
Adds an entity to the player's entity ArrayList from a save.- Parameters:
entity
- the entity to add
-
upgradeBuilding
Upgrades the selected Building, removes the upgrade cost from the player's gold.- Parameters:
building
- the Building to upgrade
-
transformTower
Transforms the selected Tower to the given type, refunds a part of the building cost.- Parameters:
tower
- the tower to transformtype
- the type we want- Returns:
- new Tower Entity
-
removeEntity
Removes the given entity from the player's entities ArrayList.- Parameters:
entity
- the entity to remove
-
getCastle
Returns the player's castle- Returns:
- the player's castle
-
getSoldiers
Returns the player's soldiers- Returns:
- the player's soldiers
-
getTowers
Returns the player's towers- Returns:
- the player's towers
-
calculateGoldAtRound
public void calculateGoldAtRound()Calculates the player's gold at round start.
-