Package org.bitsquad.warzone.player
Class BasePlayer
java.lang.Object
org.bitsquad.warzone.player.BasePlayer
- All Implemented Interfaces:
PlayerStrategy
- Direct Known Subclasses:
AggressivePlayer,BenevolentPlayer,CheaterPlayer,Player,RandomPlayer
Represents a player in the game
The class defines a player with the aid of an ID, player name, number of army units available for the user in the following turn, list of orders which it places and the list of countries it owns.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCountryOwned(Country p_country) Adds a country to the countries ownedvoidClears the state of the player for executing the next turn of the gameintGetter method for player available army unitsGetter method for player countries ownedgetCountryByID(int p_countryID) Used to fetch a player owned country using Country IDGetter for the cards which a player holdsGetter method for player current orderintgetId()Getter method for player idgetName()Getter method for player nameGetter method for player order listbooleanChecks if a player has a cardbooleanhasCountryWithID(int p_countryID) Used to check if player has a particular countrybooleanTells if a player has a new territoryHelper method to check if the next order to be executed is a Deploy orderGet the next order in the order listvoidremoveCountryOwned(Country p_country) Removes a country from countries ownedvoidsetAvailableArmyUnits(int p_availableArmyUnits) Setter method for player available army unitsvoidsetCountriesOwned(ArrayList<Country> p_countriesOwned) Setter method for player countries ownedvoidsetCurrentOrder(Order p_currentOrder) Setter method for player current ordervoidsetHasNewTerritory(boolean p_hasNewTerritory) Sets if the player has gained a new territoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bitsquad.warzone.player.PlayerStrategy
issueOrder
-
Field Details
-
d_availableArmyUnits
protected int d_availableArmyUnits -
d_countriesOwned
-
d_orderList
-
d_currentOrder
-
-
Constructor Details
-
BasePlayer
Constructor- Parameters:
p_name- player name
-
-
Method Details
-
getId
public int getId()Getter method for player id- Returns:
- the player id
-
getName
Getter method for player name- Returns:
- the player name
-
getAvailableArmyUnits
public int getAvailableArmyUnits()Getter method for player available army units- Returns:
- the player available army units
-
setAvailableArmyUnits
public void setAvailableArmyUnits(int p_availableArmyUnits) Setter method for player available army units- Parameters:
p_availableArmyUnits- army units
-
getCountriesOwned
Getter method for player countries owned- Returns:
- the player countries owned
-
getCountryByID
Used to fetch a player owned country using Country ID- Parameters:
p_countryID-- Returns:
- Country
-
hasCountryWithID
public boolean hasCountryWithID(int p_countryID) Used to check if player has a particular country- Parameters:
p_countryID-- Returns:
- boolean
-
setCountriesOwned
Setter method for player countries owned- Parameters:
p_countriesOwned- countries owned
-
getOrderList
Getter method for player order list- Returns:
- the order list
-
getCurrentOrder
Getter method for player current order- Returns:
- player current order
-
setCurrentOrder
Setter method for player current order- Parameters:
p_currentOrder- current order
-
getCurrentCards
Getter for the cards which a player holds- Returns:
- HashMap
-
hasCard
Checks if a player has a card- Parameters:
p_card-- Returns:
- boolean
-
hasNewTerritory
public boolean hasNewTerritory()Tells if a player has a new territory- Returns:
- boolean
-
setHasNewTerritory
public void setHasNewTerritory(boolean p_hasNewTerritory) Sets if the player has gained a new territory- Parameters:
p_hasNewTerritory-
-
nextOrder
Get the next order in the order list- Returns:
- the next order
-
addCountryOwned
Adds a country to the countries owned- Parameters:
p_country- Country object
-
removeCountryOwned
Removes a country from countries owned- Parameters:
p_country- Country object
-
isNextDeploy
Helper method to check if the next order to be executed is a Deploy order- Returns:
-
clearState
public void clearState()Clears the state of the player for executing the next turn of the game
-