rails.game
Class Tile

java.lang.Object
  extended by java.util.Observable
      extended by rails.game.model.ModelObject
          extended by rails.game.Tile
All Implemented Interfaces:
java.lang.Comparable<TileI>, StationHolder, TileI

public class Tile
extends ModelObject
implements TileI, StationHolder, java.lang.Comparable<TileI>

Represents a certain tile type, identified by its id (tile number).

For each tile number, only one tile object is created. The list tilesLaid records in which hexes a certain tile number has been laid.

Author:
Erik

Nested Class Summary
protected  class Tile.Upgrade
           
 
Field Summary
static java.lang.String BROWN_COLOUR_NAME
           
static int BROWN_COLOUR_NUMBER
           
static java.lang.String FIXED_COLOUR_NAME
          Non-upgradeable preprinted tiles (colour grey or dark brown)
static int FIXED_COLOUR_NUMBER
           
static java.lang.String GREEN_COLOUR_NAME
           
static int GREEN_COLOUR_NUMBER
           
static java.lang.String GREY_COLOUR_NAME
           
static int GREY_COLOUR_NUMBER
           
static java.lang.String RED_COLOUR_NAME
          Off-board preprinted tiles
static int RED_COLOUR_NUMBER
           
(package private)  boolean relayBaseTokensOnUpgrade
          Flag indicating that player must reposition any basetokens during the upgrade.
protected  java.util.List<RevenueBonusTemplate> revenueBonuses
          Storage of revenueBonus that are bound to the tile
protected static int TILE_NUMBER_OFFSET
          The offset to convert tile numbers to tilename index.
static int UNLIMITED_TILES
           
protected static java.util.List<java.lang.String> VALID_COLOUR_NAMES
           
static java.lang.String WHITE_COLOUR_NAME
          Preprinted pre-yellow tiles
static int WHITE_COLOUR_NUMBER
           
static java.lang.String YELLOW_COLOUR_NAME
           
static int YELLOW_COLOUR_NUMBER
           
 
Fields inherited from class rails.game.model.ModelObject
dependents, log, option
 
Constructor Summary
Tile(java.lang.Integer id)
           
 
Method Summary
 boolean add(MapHex hex)
          Register a tile of this type being laid on the map.
 boolean allowsMultipleBasesOfOneCompany()
           
 int compareTo(TileI anotherTile)
          ordering of tiles based first on colour, then on external id
 void configureFromXML(Tag setTag, Tag defTag)
           
 int countFreeTiles()
          Return the number of free tiles
 void finishConfiguration(TileManager tileManager)
           
 java.util.List<TileI> getAllUpgrades(MapHex hex)
          Get all possible upgrades for a specific tile on a certain hex
 java.lang.String getColourName()
           
 int getColourNumber()
           
 java.lang.String getExternalId()
           
 int getFixedOrientation()
           
 int getId()
           
 java.lang.String getName()
           
 int getNumStations()
           
 int getPictureId()
           
 int getQuantity()
           
 java.util.List<RevenueBonusTemplate> getRevenueBonuses()
           
 java.util.List<Station> getStations()
           
 java.lang.String getText()
          Return a caption for the Remaining Tiles window
 java.util.List<Track> getTracks()
           
 java.util.List<Track> getTracksPerSide(int sideNumber)
           
 java.util.List<Track> getTracksPerStation(int stationNumber)
           
 java.util.Map<java.lang.Integer,java.util.List<Track>> getTracksPerStationMap()
           
 java.util.List<TileI> getUpgrades(MapHex hex, PhaseI phase)
          Get the valid upgrades if this tile on a certain hex (restrictions per hex have not yet been implemented).
 java.lang.String getUpgradesString(MapHex hex)
          Get a delimited list of all possible upgrades, regardless current phase
 java.util.List<TileI> getValidUpgrades(MapHex hex, PhaseI phase)
           
 boolean hasStations()
           
 boolean hasTracks(int sideNumber)
           
 boolean isUpgradeable()
          Is a tile upgradeable at any time (regardles the phase)?
 boolean relayBaseTokensOnUpgrade()
           
 boolean remove(MapHex hex)
          Register a tile of this type being removed from the map.
 java.lang.String toString()
           
 
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

UNLIMITED_TILES

public static final int UNLIMITED_TILES
See Also:
Constant Field Values

relayBaseTokensOnUpgrade

boolean relayBaseTokensOnUpgrade
Flag indicating that player must reposition any basetokens during the upgrade.


RED_COLOUR_NAME

public static final java.lang.String RED_COLOUR_NAME
Off-board preprinted tiles

See Also:
Constant Field Values

RED_COLOUR_NUMBER

public static final int RED_COLOUR_NUMBER
See Also:
Constant Field Values

FIXED_COLOUR_NAME

public static final java.lang.String FIXED_COLOUR_NAME
Non-upgradeable preprinted tiles (colour grey or dark brown)

See Also:
Constant Field Values

FIXED_COLOUR_NUMBER

public static final int FIXED_COLOUR_NUMBER
See Also:
Constant Field Values

WHITE_COLOUR_NAME

public static final java.lang.String WHITE_COLOUR_NAME
Preprinted pre-yellow tiles

See Also:
Constant Field Values

WHITE_COLOUR_NUMBER

public static final int WHITE_COLOUR_NUMBER
See Also:
Constant Field Values

YELLOW_COLOUR_NAME

public static final java.lang.String YELLOW_COLOUR_NAME
See Also:
Constant Field Values

YELLOW_COLOUR_NUMBER

public static final int YELLOW_COLOUR_NUMBER
See Also:
Constant Field Values

GREEN_COLOUR_NAME

public static final java.lang.String GREEN_COLOUR_NAME
See Also:
Constant Field Values

GREEN_COLOUR_NUMBER

public static final int GREEN_COLOUR_NUMBER
See Also:
Constant Field Values

BROWN_COLOUR_NAME

public static final java.lang.String BROWN_COLOUR_NAME
See Also:
Constant Field Values

BROWN_COLOUR_NUMBER

public static final int BROWN_COLOUR_NUMBER
See Also:
Constant Field Values

GREY_COLOUR_NAME

public static final java.lang.String GREY_COLOUR_NAME
See Also:
Constant Field Values

GREY_COLOUR_NUMBER

public static final int GREY_COLOUR_NUMBER
See Also:
Constant Field Values

VALID_COLOUR_NAMES

protected static final java.util.List<java.lang.String> VALID_COLOUR_NAMES

TILE_NUMBER_OFFSET

protected static final int TILE_NUMBER_OFFSET
The offset to convert tile numbers to tilename index. Colour number 0 and higher are upgradeable.

See Also:
Constant Field Values

revenueBonuses

protected java.util.List<RevenueBonusTemplate> revenueBonuses
Storage of revenueBonus that are bound to the tile

Constructor Detail

Tile

public Tile(java.lang.Integer id)
Method Detail

configureFromXML

public void configureFromXML(Tag setTag,
                             Tag defTag)
                      throws ConfigurationException
Specified by:
configureFromXML in interface TileI
Parameters:
se - <Tile> element from TileSet.xml
te - <Tile> element from Tiles.xml
Throws:
ConfigurationException

finishConfiguration

public void finishConfiguration(TileManager tileManager)
                         throws ConfigurationException
Specified by:
finishConfiguration in interface TileI
Throws:
ConfigurationException

getColourName

public java.lang.String getColourName()
Specified by:
getColourName in interface TileI
Returns:
Returns the colour.

getColourNumber

public int getColourNumber()
Specified by:
getColourNumber in interface TileI

getId

public int getId()
Specified by:
getId in interface TileI
Returns:
Returns the id.

getExternalId

public java.lang.String getExternalId()
Specified by:
getExternalId in interface TileI

getPictureId

public int getPictureId()
Specified by:
getPictureId in interface TileI

getName

public java.lang.String getName()
Specified by:
getName in interface StationHolder
Specified by:
getName in interface TileI
Returns:
Returns the name.

hasTracks

public boolean hasTracks(int sideNumber)
Specified by:
hasTracks in interface TileI

getTracksPerSide

public java.util.List<Track> getTracksPerSide(int sideNumber)
Specified by:
getTracksPerSide in interface TileI

isUpgradeable

public boolean isUpgradeable()
Is a tile upgradeable at any time (regardles the phase)?

Specified by:
isUpgradeable in interface TileI

allowsMultipleBasesOfOneCompany

public boolean allowsMultipleBasesOfOneCompany()
Specified by:
allowsMultipleBasesOfOneCompany in interface TileI

getUpgrades

public java.util.List<TileI> getUpgrades(MapHex hex,
                                         PhaseI phase)
Get the valid upgrades if this tile on a certain hex (restrictions per hex have not yet been implemented).

Specified by:
getUpgrades in interface TileI
Parameters:
hex - The MapHex to be upgraded.
Returns:
A List of valid upgrade TileI objects.

getAllUpgrades

public java.util.List<TileI> getAllUpgrades(MapHex hex)
Get all possible upgrades for a specific tile on a certain hex

Specified by:
getAllUpgrades in interface TileI
Returns:
A List of valid upgrade TileI objects.

getUpgradesString

public java.lang.String getUpgradesString(MapHex hex)
Get a delimited list of all possible upgrades, regardless current phase

Specified by:
getUpgradesString in interface TileI

getValidUpgrades

public java.util.List<TileI> getValidUpgrades(MapHex hex,
                                              PhaseI phase)
Specified by:
getValidUpgrades in interface TileI

hasStations

public boolean hasStations()
Specified by:
hasStations in interface TileI

getStations

public java.util.List<Station> getStations()
Specified by:
getStations in interface TileI

getTracks

public java.util.List<Track> getTracks()
Specified by:
getTracks in interface TileI

getTracksPerStationMap

public java.util.Map<java.lang.Integer,java.util.List<Track>> getTracksPerStationMap()
Specified by:
getTracksPerStationMap in interface TileI

getTracksPerStation

public java.util.List<Track> getTracksPerStation(int stationNumber)
Specified by:
getTracksPerStation in interface TileI

getNumStations

public int getNumStations()
Specified by:
getNumStations in interface TileI

relayBaseTokensOnUpgrade

public boolean relayBaseTokensOnUpgrade()
Specified by:
relayBaseTokensOnUpgrade in interface TileI

add

public boolean add(MapHex hex)
Register a tile of this type being laid on the map. This method may only be called via the TileMove execute() and undo() methods.

Specified by:
add in interface TileI

remove

public boolean remove(MapHex hex)
Register a tile of this type being removed from the map. This method may only be called via the TileMove execute() and undo() methods.

Specified by:
remove in interface TileI

countFreeTiles

public int countFreeTiles()
Return the number of free tiles

Specified by:
countFreeTiles in interface TileI

getText

public java.lang.String getText()
Return a caption for the Remaining Tiles window

Specified by:
getText in class ModelObject
Returns:

getQuantity

public int getQuantity()
Specified by:
getQuantity in interface TileI

getFixedOrientation

public int getFixedOrientation()
Specified by:
getFixedOrientation in interface TileI

getRevenueBonuses

public java.util.List<RevenueBonusTemplate> getRevenueBonuses()
Specified by:
getRevenueBonuses in interface TileI

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(TileI anotherTile)
ordering of tiles based first on colour, then on external id

Specified by:
compareTo in interface java.lang.Comparable<TileI>