|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdip.world.Province
A Province represents a region on the map.
Provinces may be sea, coastal, or landlocked. Their connectivity and type (sea, coastal, or landlocked) is determined by the Adjacency data.
The types of provinces are:
The adjacency information is similar to that used by the Ken Lowe Judge software.
It is illegal to have a Province without any Coasts, to combine single-coast and multi-coast, or to have only multiple coasts without a land coast.
L S N S W E (land / single / north / south / west / east) =========== x - - - - - landlocked - x - - - - seaspace ("sealocked") x x - - - - coastal land space (only 1 coast) - - ? ? ? ? INVALID - x ? ? ? ? INVALID x x ? ? ? ? INVALID x - ? ? ? ? see below other valid: land + (!single) + (any combination of north/south/west/east)
If Supply Centers become more complex in the future, they may be handled as a separate object within the Province.
Nested Class Summary | |
protected static class |
Province.Adjacency
Adjacency maintains the connectivity graph between provinces. |
Constructor Summary | |
Province(java.lang.String fullName,
java.lang.String[] shortNames,
int index,
boolean isConvoyableCoast)
Creates a new Province object. |
Method Summary | |
boolean |
canTransit(Location fromLoc,
Unit.Type unit,
Phase phase,
java.lang.Class orderClass)
Checks if unit can transit from a Location to this Province. |
boolean |
canTransit(Phase phase,
Order order)
Convenient version of canTransit() |
int |
compareTo(java.lang.Object obj)
Compares this province to another, by the full name, ignoring case |
protected Province.Adjacency |
getAdjacency()
Gets the Adjacency data for this Province |
Location[] |
getAdjacentLocations(Coast coast)
Gets the Locations adjacent to this province, given the specified coast. |
Location[] |
getAllAdjacent()
Get all the Locations that are adjacent to this province. |
int |
getBaseMoveModifier(Location fromLoc)
Looks through borders to determine if there is a baseMoveModifier. |
java.lang.String |
getFullName()
Gets the full name (long name) of the Province |
int |
getIndex()
Returns the Province index; this is an int between 0 (inclusive) and the total number of provinces (exclusive). |
java.lang.String |
getShortName()
Gets the short name of the Province This returns the first short name if there are more than one. |
java.lang.String[] |
getShortNames()
Gets all short names of the Province |
Border |
getTransit(Location fromLoc,
Unit.Type unit,
Phase phase,
java.lang.Class orderClass)
Checks if unit can transit from a Location to this Province. |
Border |
getTransit(Phase phase,
Order order)
Convenient version of getTransit() |
Coast[] |
getValidDirectionalCoasts()
Return the coasts supported by this province. |
int |
hashCode()
Implementation of Object.hashCode() |
boolean |
hasSupplyCenter()
Determine if this Province contains a supply center |
boolean |
isAdjacent(Coast sourceCoast,
Location dest)
Checks connectivity between this and another province This method only determines if the current Province with the specified coast is connected to the destination Province and Coast. |
boolean |
isAdjacent(Coast sourceCoast,
Province dest)
Checks connectivity between this and another province This method only determines if the current Province with the specified coast is connected to the destination Province. |
boolean |
isCoastal()
Determines if this Province is coastal (including multi-coastal). |
boolean |
isCoastValid(Coast coast)
Determines if specified coast is allowed for this Province |
boolean |
isConvoyable()
Indicates if this province is convoyable, either because it is a Sea province or a convoyable coast. |
boolean |
isConvoyableCoast()
If this province is a convoyable coastal Province, this will return true . |
boolean |
isLand()
Determines if this Province is a Land province (landlocked OR coastal) |
boolean |
isLandLocked()
Determines if this Province is landlocked. |
boolean |
isMultiCoastal()
Determines if this Province has multiple coasts (e.g., Spain). |
boolean |
isSea()
Determines if this Province is a Sea province (no land, not coastal). |
boolean |
isTouching(Province province)
Determines if two provinces are in any way adjacent (connected). |
protected void |
setBorders(Border[] value)
Sets the Border data for this province. |
protected void |
setSupplyCenter(boolean value)
Sets if this province has a supply center. |
java.lang.String |
toString()
Returns the full name of the province |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Province(java.lang.String fullName, java.lang.String[] shortNames, int index, boolean isConvoyableCoast)
These are created by a WorldFactory, or through de-serialization. Null names are not allowed. At least one shortName is required.
Method Detail |
protected void setBorders(Border[] value)
protected void setSupplyCenter(boolean value)
public final int getIndex()
protected final Province.Adjacency getAdjacency()
public Location[] getAllAdjacent()
public Location[] getAdjacentLocations(Coast coast)
public final java.lang.String getFullName()
public final java.lang.String getShortName()
This returns the first short name if there are more than one.
public final java.lang.String[] getShortNames()
public boolean hasSupplyCenter()
public boolean isTouching(Province province)
If two provinces are adjacent, by any coast, this will return true. This implies connectivity in the broadest sense. No coast information is required or needed in this or the Province that is compared. because Coasts are ignored, this method should generally not be used to determine adjacency for the movement of units.
This now uses the "Wing" ("Touching") Coast which is equivalent.
public boolean isAdjacent(Coast sourceCoast, Province dest)
This method only determines if the current Province with the specified coast is connected to the destination Province.
public boolean isAdjacent(Coast sourceCoast, Location dest)
This method only determines if the current Province with the specified coast is connected to the destination Province and Coast.
This is a stricter version of isAdjacent(Coast, Province)
public boolean isLandLocked()
public boolean isCoastal()
public boolean isLand()
public boolean isSea()
public boolean isMultiCoastal()
public Coast[] getValidDirectionalCoasts()
public boolean isCoastValid(Coast coast)
public int hashCode()
public boolean canTransit(Location fromLoc, Unit.Type unit, Phase phase, java.lang.Class orderClass)
public boolean canTransit(Phase phase, Order order)
public Border getTransit(Location fromLoc, Unit.Type unit, Phase phase, java.lang.Class orderClass)
public Border getTransit(Phase phase, Order order)
public int getBaseMoveModifier(Location fromLoc)
public boolean isConvoyableCoast()
true
.
public boolean isConvoyable()
No transit checking is performed.
public java.lang.String toString()
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |