rails.game
Class TrainType

java.lang.Object
  extended by rails.game.TrainType
All Implemented Interfaces:
java.lang.Cloneable, ConfigurableComponentI, TrainTypeI

public class TrainType
extends java.lang.Object
implements TrainTypeI


Field Summary
protected  BooleanState available
           
protected  boolean canBeExchanged
           
protected  int cityScoreFactor
           
protected  int cost
           
protected  boolean countHexes
           
protected  int exchangeCost
           
protected  int index
          Index: used for sorting trains lists in configured order.
protected  boolean infiniteAmount
           
protected  java.lang.String initialPortfolio
          In some cases, trains start their life in the Pool
protected  int lastIndex
           
protected static org.apache.log4j.Logger log
           
protected  int majorStops
           
protected  int minorStops
           
protected  java.lang.String name
           
static int NO_TOWN_COUNT
           
protected  IntegerState numberBoughtFromIPO
           
protected  boolean obsoleting
           
protected  boolean permanent
           
protected  int quantity
           
protected  java.util.List<TrainTypeI> releasedTrainTypes
           
protected  BooleanState rusted
           
protected  TrainTypeI rustedTrainType
           
protected  java.lang.String startedPhaseName
           
static int TOWN_COUNT_MAJOR
           
static int TOWN_COUNT_MINOR
           
protected  int townCountIndicator
           
protected  int townScoreFactor
           
protected  java.lang.Class<? extends Train> trainClass
           
protected  java.lang.String trainClassName
           
protected  TrainManager trainManager
           
protected  java.util.ArrayList<TrainI> trains
           
 
Constructor Summary
TrainType(boolean real)
           
 
Method Summary
 void addToBoughtFromIPO()
           
 java.lang.Object clone()
           
 TrainI cloneTrain()
          Create train without throwing exceptions.
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 boolean countsHexes()
           
protected  TrainI createTrain()
           
 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.
 int getCityScoreFactor()
           
 int getCost()
           
 int getExchangeCost()
           
 int getIndex()
           
 java.lang.String getInfo()
           
 int getMajorStops()
           
 int getMinorStops()
           
 java.lang.String getName()
           
 int getNumberBoughtFromIPO()
           
 java.lang.String getReleasedTrainTypeNames()
           
 java.util.List<TrainTypeI> getReleasedTrainTypes()
           
 TrainTypeI getRustedTrainType()
           
 java.lang.String getRustedTrainTypeName()
           
 java.lang.String getStartedPhaseName()
           
 int getTownCountIndicator()
           
 int getTownScoreFactor()
           
 TrainManager getTrainManager()
           
 boolean hasInfiniteAmount()
           
 boolean hasRusted()
           
 boolean isAvailable()
           
 boolean isObsoleting()
           
 boolean isPermanent()
           
 boolean nextCanBeExchanged()
           
 void setAvailable(Bank bank)
          Make a train type available for buying by public companies.
 void setPermanent(boolean permanent)
           
 void setReleasedTrainTypes(java.util.List<TrainTypeI> releasedTrainTypes)
           
 void setRusted(Portfolio lastBuyingCompany)
           
 void setRustedTrainType(TrainTypeI rustedTrainType)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOWN_COUNT_MAJOR

public static final int TOWN_COUNT_MAJOR
See Also:
Constant Field Values

TOWN_COUNT_MINOR

public static final int TOWN_COUNT_MINOR
See Also:
Constant Field Values

NO_TOWN_COUNT

public static final int NO_TOWN_COUNT
See Also:
Constant Field Values

trainClassName

protected java.lang.String trainClassName

trainClass

protected java.lang.Class<? extends Train> trainClass

name

protected java.lang.String name

quantity

protected int quantity

infiniteAmount

protected boolean infiniteAmount

index

protected int index
Index: used for sorting trains lists in configured order.


countHexes

protected boolean countHexes

townCountIndicator

protected int townCountIndicator

townScoreFactor

protected int townScoreFactor

cityScoreFactor

protected int cityScoreFactor

canBeExchanged

protected boolean canBeExchanged

numberBoughtFromIPO

protected IntegerState numberBoughtFromIPO

obsoleting

protected boolean obsoleting

permanent

protected boolean permanent

cost

protected int cost

majorStops

protected int majorStops

minorStops

protected int minorStops

exchangeCost

protected int exchangeCost

startedPhaseName

protected java.lang.String startedPhaseName

rustedTrainType

protected TrainTypeI rustedTrainType

releasedTrainTypes

protected java.util.List<TrainTypeI> releasedTrainTypes

trains

protected java.util.ArrayList<TrainI> trains

lastIndex

protected int lastIndex

available

protected BooleanState available

rusted

protected BooleanState rusted

trainManager

protected TrainManager trainManager

initialPortfolio

protected java.lang.String initialPortfolio
In some cases, trains start their life in the Pool


log

protected static org.apache.log4j.Logger log
Constructor Detail

TrainType

public TrainType(boolean real)
Parameters:
real - False for the default type, else real. The default type does not have top-level attributes.
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Description copied from interface: ConfigurableComponentI
Instructs the component to configure itself from the provided XML element.

Specified by:
configureFromXML in interface ConfigurableComponentI
Throws:
ConfigurationException
See Also:
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)

finishConfiguration

public void finishConfiguration(GameManagerI gameManager)
Description copied from interface: ConfigurableComponentI
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. This includes creating any required relationships to other configured components and objects.

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.

Specified by:
finishConfiguration in interface ConfigurableComponentI
Parameters:
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.

createTrain

protected TrainI createTrain()
                      throws ConfigurationException
Throws:
ConfigurationException

cloneTrain

public TrainI cloneTrain()
Create train without throwing exceptions. To be used after completing initialization, i.e. in cloning infinitely available trains.

Specified by:
cloneTrain in interface TrainTypeI

getCityScoreFactor

public int getCityScoreFactor()
Specified by:
getCityScoreFactor in interface TrainTypeI
Returns:
Returns the cityScoreFactor.

getCost

public int getCost()
Specified by:
getCost in interface TrainTypeI
Returns:
Returns the cost.

countsHexes

public boolean countsHexes()
Specified by:
countsHexes in interface TrainTypeI
Returns:
Returns the countHexes.

nextCanBeExchanged

public boolean nextCanBeExchanged()
Specified by:
nextCanBeExchanged in interface TrainTypeI
Returns:
Returns the firstExchange.

addToBoughtFromIPO

public void addToBoughtFromIPO()
Specified by:
addToBoughtFromIPO in interface TrainTypeI

getNumberBoughtFromIPO

public int getNumberBoughtFromIPO()
Specified by:
getNumberBoughtFromIPO in interface TrainTypeI

getExchangeCost

public int getExchangeCost()
Specified by:
getExchangeCost in interface TrainTypeI
Returns:
Returns the firstExchangeCost.

getMajorStops

public int getMajorStops()
Specified by:
getMajorStops in interface TrainTypeI
Returns:
Returns the majorStops.

getMinorStops

public int getMinorStops()
Specified by:
getMinorStops in interface TrainTypeI
Returns:
Returns the minorStops.

getName

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

getReleasedTrainTypes

public java.util.List<TrainTypeI> getReleasedTrainTypes()
Specified by:
getReleasedTrainTypes in interface TrainTypeI
Returns:
Returns the releasedTrainTypes.

getRustedTrainType

public TrainTypeI getRustedTrainType()
Specified by:
getRustedTrainType in interface TrainTypeI
Returns:
Returns the rustedTrainType.

getStartedPhaseName

public java.lang.String getStartedPhaseName()
Specified by:
getStartedPhaseName in interface TrainTypeI
Returns:
Returns the startedPhaseName.

getTownCountIndicator

public int getTownCountIndicator()
Specified by:
getTownCountIndicator in interface TrainTypeI
Returns:
Returns the townCountIndicator.

getTownScoreFactor

public int getTownScoreFactor()
Specified by:
getTownScoreFactor in interface TrainTypeI
Returns:
Returns the townScoreFactor.

getReleasedTrainTypeNames

public java.lang.String getReleasedTrainTypeNames()
Specified by:
getReleasedTrainTypeNames in interface TrainTypeI
Returns:
Returns the releasedTrainTypeName.

getRustedTrainTypeName

public java.lang.String getRustedTrainTypeName()
Specified by:
getRustedTrainTypeName in interface TrainTypeI
Returns:
Returns the rustedTrainTypeName.

isObsoleting

public boolean isObsoleting()
Specified by:
isObsoleting in interface TrainTypeI

setReleasedTrainTypes

public void setReleasedTrainTypes(java.util.List<TrainTypeI> releasedTrainTypes)
Specified by:
setReleasedTrainTypes in interface TrainTypeI
Parameters:
releasedTrainType - The releasedTrainType to set.

setRustedTrainType

public void setRustedTrainType(TrainTypeI rustedTrainType)
Specified by:
setRustedTrainType in interface TrainTypeI
Parameters:
rustedTrainType - The rustedTrainType to set.

isPermanent

public boolean isPermanent()
Specified by:
isPermanent in interface TrainTypeI

setPermanent

public void setPermanent(boolean permanent)
Specified by:
setPermanent in interface TrainTypeI

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface TrainTypeI
Returns:
Returns the available.

setAvailable

public void setAvailable(Bank bank)
Make a train type available for buying by public companies.

Specified by:
setAvailable in interface TrainTypeI

hasInfiniteAmount

public boolean hasInfiniteAmount()
Specified by:
hasInfiniteAmount in interface TrainTypeI

setRusted

public void setRusted(Portfolio lastBuyingCompany)
Specified by:
setRusted in interface TrainTypeI

hasRusted

public boolean hasRusted()
Specified by:
hasRusted in interface TrainTypeI

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getIndex

public int getIndex()
Specified by:
getIndex in interface TrainTypeI

getTrainManager

public TrainManager getTrainManager()
Specified by:
getTrainManager in interface TrainTypeI

getInfo

public java.lang.String getInfo()
Specified by:
getInfo in interface TrainTypeI

toString

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