rails.game
Class TrainManager

java.lang.Object
  extended by rails.game.TrainManager
All Implemented Interfaces:
ConfigurableComponentI

public class TrainManager
extends java.lang.Object
implements ConfigurableComponentI


Field Summary
protected  BooleanState anyTrainBought
          Required for the sell-train-to-foreigners feature of some games
protected  Bank bank
           
protected  java.util.List<PublicCompanyI> companiesWithExcessTrains
           
protected  GameManagerI gameManager
           
protected  Portfolio ipo
           
protected  java.util.List<TrainTypeI> lTrainTypes
           
protected  java.util.Map<java.lang.String,TrainTypeI> mTrainTypes
           
protected  IntegerState newTypeIndex
           
protected  boolean phaseHasChanged
           
protected  boolean trainAvailabilityChanged
           
protected  java.util.Map<java.lang.String,TrainI> trainMap
           
(package private)  boolean trainPriceAtFaceValueIfDifferentPresidents
           
protected  boolean trainsHaveRusted
           
protected  Portfolio unavailable
           
 
Constructor Summary
TrainManager()
          No-args constructor.
 
Method Summary
 void addTrain(java.lang.String uniqueID, TrainI train)
           
 void checkTrainAvailability(TrainI train, Portfolio from)
          This method handles any consequences of new train buying (from the IPO), such as rusting and phase changes.
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 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<TrainI> getAvailableNewTrains()
           
 TrainI getTrainByUniqueId(java.lang.String id)
           
 java.lang.String getTrainCostOverview()
           
 java.util.List<TrainTypeI> getTrainTypes()
           
 TrainTypeI getTypeByName(java.lang.String name)
           
 boolean hasAvailabilityChanged()
           
 boolean hasPhaseChanged()
           
 boolean isAnyTrainBought()
           
 void resetAvailabilityChanged()
           
 void setAnyTrainBought(boolean newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lTrainTypes

protected java.util.List<TrainTypeI> lTrainTypes

mTrainTypes

protected java.util.Map<java.lang.String,TrainTypeI> mTrainTypes

trainMap

protected java.util.Map<java.lang.String,TrainI> trainMap

unavailable

protected Portfolio unavailable

newTypeIndex

protected IntegerState newTypeIndex

trainsHaveRusted

protected boolean trainsHaveRusted

phaseHasChanged

protected boolean phaseHasChanged

trainAvailabilityChanged

protected boolean trainAvailabilityChanged

companiesWithExcessTrains

protected java.util.List<PublicCompanyI> companiesWithExcessTrains

gameManager

protected GameManagerI gameManager

bank

protected Bank bank

anyTrainBought

protected BooleanState anyTrainBought
Required for the sell-train-to-foreigners feature of some games


ipo

protected Portfolio ipo

trainPriceAtFaceValueIfDifferentPresidents

boolean trainPriceAtFaceValueIfDifferentPresidents
Constructor Detail

TrainManager

public TrainManager()
No-args constructor.

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)
                         throws ConfigurationException
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.
Throws:
ConfigurationException

addTrain

public void addTrain(java.lang.String uniqueID,
                     TrainI train)

getTrainByUniqueId

public TrainI getTrainByUniqueId(java.lang.String id)

checkTrainAvailability

public void checkTrainAvailability(TrainI train,
                                   Portfolio from)
This method handles any consequences of new train buying (from the IPO), such as rusting and phase changes. It must be called after the train has been transferred.


getAvailableNewTrains

public java.util.List<TrainI> getAvailableNewTrains()

getTrainCostOverview

public java.lang.String getTrainCostOverview()

getTypeByName

public TrainTypeI getTypeByName(java.lang.String name)

getTrainTypes

public java.util.List<TrainTypeI> getTrainTypes()

hasAvailabilityChanged

public boolean hasAvailabilityChanged()

resetAvailabilityChanged

public void resetAvailabilityChanged()

hasPhaseChanged

public boolean hasPhaseChanged()

isAnyTrainBought

public boolean isAnyTrainBought()

setAnyTrainBought

public void setAnyTrainBought(boolean newValue)