|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
rails.game.model.ModelObject
rails.game.MapHex
public class MapHex
Represents a Hex on the Map from the Model side.
Tile orientations. Tiles can be oriented NS or EW; the directions refer to the "flat" hex sides.
The term "rotation" is used to indicate the amount of rotation (in 60 degree units) from the standard orientation of the tile (sometimes the term orientation is also used to refer to rotation).
Rotation is always relative to the standard orientation, which has the printed tile number on the S edge for NS oriented tiles, or on the SW edge for EW oriented tiles. The rotation numbers are indicated in the below picture for an NS-oriented tile:
____3____
/ \
2 4
/ NS \
\ /
1 5
\____0____/
For EW-oriented tiles the above picture should be rotated 30 degrees clockwise.
Nested Class Summary | |
---|---|
static class |
MapHex.Run
|
Field Summary | |
---|---|
protected java.util.List<City> |
cities
|
protected java.lang.String |
cityName
|
protected int |
column
|
protected TileI |
currentTile
|
protected int |
currentTileRotation
|
protected java.util.List<PublicCompanyI> |
destinations
|
static int |
EW
|
protected java.util.Map<PublicCompanyI,City> |
homes
|
protected java.lang.String |
impassable
|
protected java.util.List<java.lang.Integer> |
impassableSides
|
protected java.lang.String |
infoText
|
protected int |
letter
|
protected static org.apache.log4j.Logger |
log
|
protected MapManager |
mapManager
|
protected java.util.Map<java.lang.Integer,City> |
mCities
|
protected java.lang.String |
name
|
protected MapHex[] |
neighbours
Neighbouring hexes to which track may be laid. |
static int |
NS
|
protected int |
number
|
protected int[] |
offBoardValues
Values if this is an off-board hex |
protected java.util.List<TokenI> |
offStationTokens
Tokens that are not bound to a Station (City), such as Bonus tokens |
protected boolean[] |
openHexSides
Any open sides against which track may be laid even at board edges (1825) |
protected int |
preprintedTileId
|
protected int |
preprintedTileRotation
|
protected java.lang.String |
reservedForCompany
|
protected java.util.List<RevenueBonusTemplate> |
revenueBonuses
Storage of revenueBonus that are bound to the hex |
protected int |
row
|
protected MapHex.Run |
runThroughAllowed
Run-through status of any "city"-type stations on the hex (whether visible or not). |
protected MapHex.Run |
runToAllowed
Run-to status of any "city"-type stations on the hex (whether visible or not). |
protected int[] |
tileCost
|
protected java.lang.String |
tileFileName
|
protected int |
x
|
protected int |
y
|
Fields inherited from class rails.game.model.ModelObject |
---|
dependents, option |
Constructor Summary | |
---|---|
MapHex(MapManager mapManager)
|
Method Summary | |
---|---|
void |
addDestination(PublicCompanyI company)
|
void |
addHome(PublicCompanyI company,
int cityNumber)
|
void |
addImpassableSide(int orientation)
|
boolean |
addObject(Moveable object,
int[] position)
Add an object to its list at a certain position. |
boolean |
addToken(TokenI token,
int position)
|
void |
addX(int offset)
Add an X offset. |
void |
addY(int offset)
Add an Y offset. |
void |
configureFromXML(Tag tag)
Instructs the component to configure itself from the provided XML element. |
boolean |
equals(MapHex hex)
|
void |
finishConfiguration(GameManagerI gameManager)
This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first. |
java.util.List<BaseToken> |
getBaseTokens()
|
java.util.List<City> |
getCities()
|
City |
getCity(int cityNumber)
|
java.lang.String |
getCityName()
|
int |
getCityOfBaseToken(PublicCompanyI company)
Return the city number (1,...) where a company has a base token. |
int |
getColumn()
|
java.lang.String |
getConnectionString(int cityNumber)
|
java.lang.String |
getConnectionString(TileI tile,
int rotation,
int stationNumber)
Get a String describing one stations's connection directions of a laid tile, taking into account the current tile rotation. |
int |
getCurrentOffBoardValue(PhaseI phase)
|
TileI |
getCurrentTile()
|
int |
getCurrentTileRotation()
|
java.util.List<PublicCompanyI> |
getDestinations()
|
java.util.Map<PublicCompanyI,City> |
getHomes()
|
java.util.List<java.lang.Integer> |
getImpassableSides()
|
java.lang.String |
getInfo()
|
int[] |
getListIndex(Moveable object)
|
MapManager |
getMapManager()
|
java.lang.String |
getName()
Each station must have a name, which includes the tile Id (if on a tile) or the hex name (if on a MapHex). |
MapHex |
getNeighbor(int orientation)
|
MapHex[] |
getNeighbors()
|
int[] |
getOffBoardValues()
|
java.lang.String |
getOrientationName(int orientation)
|
int |
getPreprintedTileId()
|
int |
getPreprintedTileRotation()
|
City |
getRelatedCity(Station station)
|
java.lang.String |
getReservedForCompany()
|
java.util.List<RevenueBonusTemplate> |
getRevenueBonuses()
|
int |
getRow()
|
java.lang.String |
getText()
The string sent to the GUIHex as it is notified. |
int |
getTileCost()
|
int |
getTileCost(int index)
|
int[] |
getTileCostAsArray()
|
java.lang.String |
getTileFileName()
|
int |
getTileOrientation()
|
java.util.List<TokenI> |
getTokens()
|
java.util.List<TokenI> |
getTokens(int cityNumber)
|
int[] |
getTrackEndPoints(TileI tile,
int rotation,
Station station)
|
int |
getX()
|
int |
getY()
|
boolean |
hasNeighbour(int orientation)
|
boolean |
hasOffBoardValues()
|
boolean |
hasTokenOfCompany(PublicCompanyI company)
Check if the tile already has a token of a company in any station |
boolean |
hasTokens()
Do we have any tokens? |
boolean |
hasTokenSlotsLeft()
|
boolean |
hasTokenSlotsLeft(int station)
|
boolean |
isBlockedForTileLays()
|
boolean |
isBlockedForTokenLays(PublicCompanyI company,
int cityNumber)
|
boolean |
isDestination(PublicCompanyI company)
|
boolean |
isHomeFor(PublicCompanyI company)
|
boolean |
isImpassable(MapHex neighbour)
|
boolean |
isNeighbour(MapHex neighbour,
int direction)
|
boolean |
isOpenSide(int side)
|
boolean |
isReservedForCompany()
|
MapHex.Run |
isRunThroughAllowed()
|
MapHex.Run |
isRunToAllowed()
|
boolean |
isUpgradeableNow()
|
boolean |
isUpgradeableNow(PhaseI currentPhase)
|
boolean |
layBaseToken(PublicCompanyI company,
int station)
|
boolean |
layBonusToken(BonusToken token,
PhaseManager phaseManager)
Lay a bonus token. |
boolean |
letterAHasEvenNumbers()
|
boolean |
lettersGoHorizontal()
|
boolean |
removeObject(Moveable object)
|
boolean |
removeToken(TokenI token)
Remove a token. |
void |
replaceTile(TileI oldTile,
TileI newTile,
int newTileOrientation,
java.util.List<City> newCities)
Execute a tile replacement. |
void |
setBlockedForTileLays(boolean isBlocked)
|
void |
setBlockedForTokenLays(boolean isBlocked)
|
void |
setNeighbor(int orientation,
MapHex neighbour)
|
java.lang.String |
toString()
|
void |
upgrade(LayTile action)
new wrapper function for the LayTile action that calls the actual upgrade mehod |
void |
upgrade(TileI newTile,
int newRotation,
java.util.Map<java.lang.String,java.lang.Integer> relaidTokens)
Prepare a tile upgrade. |
Methods inherited from class rails.game.model.ModelObject |
---|
addDependent, addObserver, getUpdate, removeDependent, resetOption, setOption, update |
Methods inherited from class java.util.Observable |
---|
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int EW
public static final int NS
protected int x
protected int y
protected java.lang.String name
protected int row
protected int column
protected int letter
protected int number
protected java.lang.String tileFileName
protected int preprintedTileId
protected TileI currentTile
protected int currentTileRotation
protected int preprintedTileRotation
protected int[] tileCost
protected java.lang.String cityName
protected java.lang.String infoText
protected java.lang.String reservedForCompany
protected MapHex[] neighbours
protected int[] offBoardValues
protected java.lang.String impassable
protected java.util.List<java.lang.Integer> impassableSides
protected java.util.List<City> cities
protected java.util.Map<java.lang.Integer,City> mCities
protected java.util.Map<PublicCompanyI,City> homes
protected java.util.List<PublicCompanyI> destinations
protected java.util.List<TokenI> offStationTokens
protected java.util.List<RevenueBonusTemplate> revenueBonuses
protected boolean[] openHexSides
protected MapHex.Run runThroughAllowed
Values (see Run below for definitions):
- "yes" (default for all except off-map hexes) means that trains of all companies
may run through this station, unless it is completely filled with foreign base tokens.
- "tokenOnly" means that trains may only run through the station if it contains a base token of the operating company.
- "no" (default for off-map hexes) means that no train may run through this hex.
protected MapHex.Run runToAllowed
Values (see Run below for definitions):
- "yes" (default) means that trains of all companies may run to/from this station.
- "tokenOnly" means that trains may only access the station if it contains a base token of the operating company.
- "no" would mean that the hex is inaccessible (like 18AL Birmingham in the early game),
but this option is not yet useful as there is no provision yet to change this setting
in an undoable way (no state variable).
protected MapManager mapManager
protected static org.apache.log4j.Logger log
Constructor Detail |
---|
public MapHex(MapManager mapManager)
Method Detail |
---|
public void configureFromXML(Tag tag) throws ConfigurationException
ConfigurableComponentI
configureFromXML
in interface ConfigurableComponentI
ConfigurationException
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)
public void finishConfiguration(GameManagerI gameManager)
ConfigurableComponentI
This method should be called where necessary after all XML file parsing has completed, so that all objects that need to be related to do exist.
finishConfiguration
in interface ConfigurableComponentI
gameManager
- The 'parent' configurable component is passed to allow
the 'child' to access any other object without the need to resort to
static calls where possible.public void addImpassableSide(int orientation)
public java.util.List<java.lang.Integer> getImpassableSides()
public boolean isImpassable(MapHex neighbour)
public boolean isNeighbour(MapHex neighbour, int direction)
public boolean isOpenSide(int side)
public int getTileOrientation()
public boolean letterAHasEvenNumbers()
public boolean lettersGoHorizontal()
public java.lang.String getOrientationName(int orientation)
public int getColumn()
public int getRow()
public java.lang.String getName()
TokenHolder
getName
in interface MoveableHolder
getName
in interface StationHolder
getName
in interface TokenHolder
public int getX()
public int getY()
public void addX(int offset)
public void addY(int offset)
public int getPreprintedTileId()
public int getPreprintedTileRotation()
public java.lang.String getTileFileName()
public void setNeighbor(int orientation, MapHex neighbour)
public MapHex getNeighbor(int orientation)
public MapHex[] getNeighbors()
public boolean hasNeighbour(int orientation)
public TileI getCurrentTile()
public int getCurrentTileRotation()
public int getTileCost()
public int getTileCost(int index)
public int[] getTileCostAsArray()
public void upgrade(LayTile action)
action
- executed LayTile actionpublic void upgrade(TileI newTile, int newRotation, java.util.Map<java.lang.String,java.lang.Integer> relaidTokens)
public void replaceTile(TileI oldTile, TileI newTile, int newTileOrientation, java.util.List<City> newCities)
oldTile
- The tile to be replaced (only used for validation).newTile
- The new tile to be laid on this hex.newTileOrientation
- The orientation of the new tile (0-5).public boolean layBaseToken(PublicCompanyI company, int station)
public boolean layBonusToken(BonusToken token, PhaseManager phaseManager)
token
- The bonus token object to placephaseManager
- The PhaseManager is also passed in case the
token must register itself for removal when a certain phase starts.
public boolean addToken(TokenI token, int position)
addToken
in interface TokenHolder
public java.util.List<BaseToken> getBaseTokens()
public java.util.List<TokenI> getTokens()
getTokens
in interface TokenHolder
public boolean hasTokens()
TokenHolder
hasTokens
in interface TokenHolder
public boolean removeToken(TokenI token)
TokenHolder
removeToken
in interface TokenHolder
token
- The token object to remove.
public boolean addObject(Moveable object, int[] position)
MoveableHolder
addObject
in interface MoveableHolder
object
- The Moveable object to be added.position
- Position to insert object at. O: at front, -1, at end, >0: at that position.
public boolean removeObject(Moveable object)
removeObject
in interface MoveableHolder
public int[] getListIndex(Moveable object)
getListIndex
in interface MoveableHolder
public boolean hasTokenSlotsLeft(int station)
public boolean hasTokenSlotsLeft()
public boolean hasTokenOfCompany(PublicCompanyI company)
public java.util.List<TokenI> getTokens(int cityNumber)
public int getCityOfBaseToken(PublicCompanyI company)
company
-
public java.util.List<City> getCities()
public City getCity(int cityNumber)
public City getRelatedCity(Station station)
public void addHome(PublicCompanyI company, int cityNumber) throws ConfigurationException
ConfigurationException
public java.util.Map<PublicCompanyI,City> getHomes()
public boolean isHomeFor(PublicCompanyI company)
public void addDestination(PublicCompanyI company)
public java.util.List<PublicCompanyI> getDestinations()
public boolean isDestination(PublicCompanyI company)
public boolean isBlockedForTileLays()
public void setBlockedForTileLays(boolean isBlocked)
isBlocked
- The isBlocked to set (state variable)public boolean isUpgradeableNow()
public boolean isUpgradeableNow(PhaseI currentPhase)
public boolean isBlockedForTokenLays(PublicCompanyI company, int cityNumber)
public void setBlockedForTokenLays(boolean isBlocked)
isBlocked
- The isBlocked to set (state variable)public boolean hasOffBoardValues()
public int[] getOffBoardValues()
public int getCurrentOffBoardValue(PhaseI phase)
public java.lang.String getCityName()
public java.lang.String getInfo()
public java.lang.String getReservedForCompany()
public boolean isReservedForCompany()
public java.util.List<RevenueBonusTemplate> getRevenueBonuses()
public boolean equals(MapHex hex)
public MapManager getMapManager()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getText()
getText
in class ModelObject
public java.lang.String getConnectionString(TileI tile, int rotation, int stationNumber)
public java.lang.String getConnectionString(int cityNumber)
public int[] getTrackEndPoints(TileI tile, int rotation, Station station)
public MapHex.Run isRunThroughAllowed()
public MapHex.Run isRunToAllowed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |