|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dip.world.Position
Stores all the mutable (state) information for a given TurnState. Immutable data is retained in the Power/Province/etc. objects; only mutable data is stored here.
This object can be cloned, and should be cloned, when creating a new Position based upon previous Position data. Several clone methods are available, each optimized for speed and cloning requirements.
WARNING: this code is not MT (Multithread) safe!
This class is heavily optimized, as adjudicator performance is highly dependent upon the performance of this class.
The clone() methods are not strictly implemented; they call a constructor to assist in cloning rather than call super.clone(). This is done for performance reasons.
Field Summary | |
protected Map |
map
|
protected java.util.Map |
powerMap
|
protected dip.world.Position.ProvinceData[] |
provArray
|
Constructor Summary | |
Position(Map map)
|
Method Summary | |
java.lang.Object |
clone()
Deep clone of the contents of this Position. |
Position |
cloneExceptDislodged()
Deep clone of everything except dislodged units. |
Position |
cloneExceptUnits()
Deep clone of everything *except* dislodged & non-dislodged units; (e.g., SC ownership, Power Info, etc.) |
Unit |
getDislodgedUnit(Province province)
Get the dislodged unit in this Province. |
int |
getDislodgedUnitCount()
Returns the number of provinces with dislodged units |
Province[] |
getDislodgedUnitProvinces()
Returns an array of provinces with dislodged units |
Province[] |
getDislodgedUnitProvinces(Power power)
Gets all the Provinces with dislodged Units for a particular power. |
Province[] |
getHomeSupplyCenters()
Returns an array of provinces with home supply centers |
Province[] |
getHomeSupplyCenters(Power power)
Returns an Array of the Home Supply Centers for a given power (whether or not they are owned by that power) |
Power |
getLastOccupier(Province province)
Returns the Power that last occupied a given space. |
Province[] |
getOwnedSupplyCenters()
Returns an array of provinces with owned supply centers |
Province[] |
getOwnedSupplyCenters(Power power)
Returns an Array of the owned Supply Centers for a given Power (whether or not they are home supply centers) |
Province[] |
getProvinces()
Convenience method: Returns an array of Provinces |
Power |
getSupplyCenterHomePower(Province province)
Get the home power of the supply center; null if no supply center or home power |
Power |
getSupplyCenterOwner(Province province)
Get the owner of the supply center; null if no owner or no supply center. |
Unit |
getUnit(Province province)
Get the unit contained in this Province. |
int |
getUnitCount()
Returns the number of provinces with non-dislodged units |
Province[] |
getUnitProvinces()
Returns an array of provinces with non-dislodged units |
Province[] |
getUnitProvinces(Power power)
Gets all the Provinces with non-dislodged Units for a particular power. |
boolean |
hasAnOwnedHomeSC(Power power)
Determines if a Power has at least one owned Home Supply Center. |
boolean |
hasDislodgedUnit(Province province)
Determines if there is a dislodged unit present in this province. |
boolean |
hasDislodgedUnit(Province province,
Unit.Type unitType)
Test if the given type of unit is contained in this Province. |
boolean |
hasSupplyCenterOwner(Province province)
Determine if this Province contains a supply center |
boolean |
hasUnit(Province province)
Determines if there is a unit present in this province. |
boolean |
hasUnit(Province province,
Unit.Type unitType)
Test if the given type of unit is contained in this Province. |
boolean |
isEliminated(Power power)
Returns true if this Power has been eliminated. |
boolean |
isSupplyCenterAHome(Province province)
Determine if this Province contains a Home supply center |
void |
setDislodgedUnit(Province province,
Unit unit)
Set the dislodged unit contained in this province; null to eliminate an existing unit. |
void |
setEliminated(Power power,
boolean value)
Set whether this Power has been eliminated. |
void |
setEliminationStatus(Power[] powers)
Scans the Position; sets/unsets elimination depending upon if a given Power has any units (including dislodged units) or supply centers on the map |
void |
setLastOccupier(Province province,
Power power)
Sets the Power that last occupied a given space. |
void |
setSupplyCenterHomePower(Province province,
Power power)
Set the owner of a home supply center. |
void |
setSupplyCenterOwner(Province province,
Power power)
Set the owner of the supply center. |
void |
setUnit(Province province,
Unit unit)
Set the unit contained in this province; null to eliminate an existing unit. |
int |
size()
The Number of Provinces in this Position |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final java.util.Map powerMap
protected final dip.world.Position.ProvinceData[] provArray
protected final Map map
Constructor Detail |
public Position(Map map)
Method Detail |
public final int size()
public final Province[] getProvinces()
public boolean isEliminated(Power power)
public void setEliminated(Power power, boolean value)
public void setEliminationStatus(Power[] powers)
public void setSupplyCenterOwner(Province province, Power power)
public void setSupplyCenterHomePower(Province province, Power power)
public boolean hasSupplyCenterOwner(Province province)
public boolean isSupplyCenterAHome(Province province)
public Power getSupplyCenterHomePower(Province province)
public Power getSupplyCenterOwner(Province province)
public void setUnit(Province province, Unit unit)
public boolean hasUnit(Province province)
public Unit getUnit(Province province)
public boolean hasUnit(Province province, Unit.Type unitType)
public boolean hasDislodgedUnit(Province province, Unit.Type unitType)
public void setDislodgedUnit(Province province, Unit unit)
public Unit getDislodgedUnit(Province province)
public void setLastOccupier(Province province, Power power)
public Power getLastOccupier(Province province)
public boolean hasDislodgedUnit(Province province)
public Province[] getUnitProvinces()
public Province[] getDislodgedUnitProvinces()
public int getUnitCount()
public int getDislodgedUnitCount()
public Province[] getHomeSupplyCenters()
public Province[] getHomeSupplyCenters(Power power)
public boolean hasAnOwnedHomeSC(Power power)
An owned home supply center need not have a unit present.
public Province[] getOwnedSupplyCenters(Power power)
public Province[] getOwnedSupplyCenters()
public java.lang.Object clone()
public Position cloneExceptUnits()
public Position cloneExceptDislodged()
public Province[] getUnitProvinces(Power power)
public Province[] getDislodgedUnitProvinces(Power power)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |