public class Country
extends java.lang.Object
Each Country stores a country-code, continent-code, owner-code, number of armies, and number of fortifyable armies. As well, each Country stores an array containing references to all adjoining Country's.
When first initialized by the game world, each Country will be given a permanent country-code, continent-code and adjoining-list. The owner-code and number of armies are set to -1.
The country-code is a unique number used to identify countries. The array returned by the Board.getCountries() will always be ordered by country-code.
Constructor and Description |
---|
Country(int newCountryCode,
int newContCode,
java.lang.Object passkey)
Create a new country.
|
Modifier and Type | Method and Description |
---|---|
void |
addArmy(java.lang.Object passkey)
Adds one to the army count of the the Country, as long as the passkey object is the same as supplied in the constructor.
|
void |
addToAdjoiningList(Country destinationCountry,
java.lang.Object passkey)
Add a connection from this Country object to the destinationCountry object.
|
void |
addToAdjoiningListBoth(Country otherCountry,
java.lang.Object passkey)
Add a 2-way connection between this Country object and the otherCountry object.
|
boolean |
canGoto(Country country)
An adjacency test.
|
boolean |
canGoto(int countryCode)
An adjacency test.
|
void |
clearAdjoiningList(java.lang.Object passkey) |
int[] |
getAdjoiningCodeList()
Return an int array containing the country codes of all adjoining countries.
|
Country[] |
getAdjoiningList()
Returns an array containing all of the Country's that are touching this Country.
|
int |
getArmies()
Returns the number of armies in this Country.
|
int |
getCode()
Returns the country-code of this Country.
|
int |
getContinent()
Returns the continent-code of this Country.
|
int[] |
getFriendlyAdjoiningCodeList()
Return an int array containing the country codes of all the neigbors of this country that are owned by the same player.
|
int[] |
getHostileAdjoiningCodeList()
Return an int array containing the country codes of all the countries that this country can attack.
|
int |
getMoveableArmies()
Returns the number of armies in this Country that may be fortified somewhere else.
|
java.lang.String |
getName()
Return the name of the country.
|
int |
getNumberEnemyNeighbors()
Returns the number of neighbor countries owned by players that don't own this Country.
|
int |
getNumberNeighbors()
Returns the number of adjacent countries.
|
int |
getNumberNotPlayerNeighbors(int player)
Returns the number of adjacent countries not owned by player.
|
int |
getNumberPlayerNeighbors(int player)
Returns the number of adjacent countries owned by player.
|
int |
getNumberPlayerNotNamedNeighbors(java.lang.String agentName,
Board board)
Returns the number of adjacent countries not owned by an agent named agentName.
|
int |
getOwner()
Returns the current owner-code of this Country.
|
Country |
getStrongestNeighborOwnedBy(int player)
Returns a reference to the neighbor that is owned by 'player' with the most number of armies on it.
|
Country |
getWeakestEnemyNeighbor()
Returns a reference to the weakest neighbor that is owned by another player, or null if there are no enemy neighbors.
|
Country |
getWeakestEnemyNeighborInContinent(int cont)
Operates like getWeakestEnemyNeighbor but limits its search to the given continent.
|
boolean |
isNextTo(Country country)
Depreciated: use canGoto() instead.
|
boolean |
isNextTo(int countryCode)
Depreciated: use canGoto() instead.
|
void |
setArmies(int newArmies,
java.lang.Object passkey)
Sets the number of armies on the Country, as long as the passkey object is the same as supplied in the constructor.
|
void |
setContinentCode(int newContinentCode,
java.lang.Object passkey)
Sets the continent code of the Country, as long as the passkey object is the same as supplied in the constructor.
|
void |
setName(java.lang.String name,
java.lang.Object passkey)
Set the name of the Country.
|
void |
setOwner(int newOwner,
java.lang.Object passkey)
Sets the owner code of the Country, as long as the passkey object is the same as supplied in the constructor.
|
java.lang.String |
toString()
Returns a String representation of the country.
|
public Country(int newCountryCode, int newContCode, java.lang.Object passkey)
public void addArmy(java.lang.Object passkey)
public void addToAdjoiningList(Country destinationCountry, java.lang.Object passkey)
public void addToAdjoiningListBoth(Country otherCountry, java.lang.Object passkey)
public boolean canGoto(Country country)
public boolean canGoto(int countryCode)
public void clearAdjoiningList(java.lang.Object passkey)
public int[] getAdjoiningCodeList()
public Country[] getAdjoiningList()
public int getArmies()
public int getCode()
public int getContinent()
public int[] getFriendlyAdjoiningCodeList()
public int[] getHostileAdjoiningCodeList()
public int getMoveableArmies()
public java.lang.String getName()
public int getNumberEnemyNeighbors()
public int getNumberNeighbors()
public int getNumberNotPlayerNeighbors(int player)
public int getNumberPlayerNeighbors(int player)
public int getNumberPlayerNotNamedNeighbors(java.lang.String agentName, Board board)
public int getOwner()
public Country getStrongestNeighborOwnedBy(int player)
public Country getWeakestEnemyNeighbor()
public Country getWeakestEnemyNeighborInContinent(int cont)
public boolean isNextTo(Country country)
public boolean isNextTo(int countryCode)
public void setArmies(int newArmies, java.lang.Object passkey)
public void setContinentCode(int newContinentCode, java.lang.Object passkey)
public void setName(java.lang.String name, java.lang.Object passkey)
public void setOwner(int newOwner, java.lang.Object passkey)
public java.lang.String toString()
toString
in class java.lang.Object