rails.game
Class Phase

java.lang.Object
  extended by rails.game.Phase
All Implemented Interfaces:
ConfigurableComponentI, PhaseI

public class Phase
extends java.lang.Object
implements PhaseI


Field Summary
protected  java.util.List<Closeable> closedObjects
          Items to close if a phase gets activated
protected  java.lang.String colourList
           
protected  Phase defaults
          Previous phase, defining the current one's defaults
protected  java.lang.String extraInfo
           
protected  int index
           
protected  boolean loanTakingAllowed
          Is loan taking allowed
protected static org.apache.log4j.Logger log
           
protected  java.lang.String name
           
protected  int numberOfOperatingRounds
           
protected  int offBoardRevenueStep
           
protected  boolean oneTrainPerTurn
          May company buy more than one Train from the Bank per turn?
protected  boolean oneTrainPerTypePerTurn
          May company buy more than one Train of each type from the Bank per turn?
protected  java.util.Map<java.lang.String,java.lang.String> parameters
          A HashMap to contain phase-dependent parameters by name and value.
protected  boolean privatesClose
           
protected  boolean privateSellingAllowed
           
protected  int privatesRevenueStep
           
protected  java.util.HashMap<java.lang.String,java.lang.Integer> tileColours
           
protected  boolean trainTradingAllowed
           
 
Constructor Summary
Phase(int index, java.lang.String name, Phase previousPhase)
           
 
Method Summary
 void activate()
          Called when a phase gets activated
 void addObjectToClose(Closeable object)
           
 boolean canBuyMoreTrainsPerTurn()
           
 boolean canBuyMoreTrainsPerTypePerTurn()
           
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 boolean doPrivatesClose()
           
 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<Closeable> getClosedObjects()
           
 int getIndex()
           
 java.lang.String getInfo()
           
 java.lang.String getName()
           
 int getNumberOfOperatingRounds()
           
 int getOffBoardRevenueStep()
           
 int getParameterAsInteger(java.lang.String key)
           
 java.lang.String getParameterAsString(java.lang.String key)
           
 int getPrivatesRevenueStep()
           
 java.util.Map<java.lang.String,java.lang.Integer> getTileColours()
           
 java.lang.String getTileColoursString()
           
 boolean isLoanTakingAllowed()
           
 boolean isPrivateSellingAllowed()
           
 boolean isTileColourAllowed(java.lang.String tileColour)
           
 boolean isTrainTradingAllowed()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected int index

name

protected java.lang.String name

colourList

protected java.lang.String colourList

tileColours

protected java.util.HashMap<java.lang.String,java.lang.Integer> tileColours

privateSellingAllowed

protected boolean privateSellingAllowed

privatesClose

protected boolean privatesClose

numberOfOperatingRounds

protected int numberOfOperatingRounds

offBoardRevenueStep

protected int offBoardRevenueStep

privatesRevenueStep

protected int privatesRevenueStep

trainTradingAllowed

protected boolean trainTradingAllowed

oneTrainPerTurn

protected boolean oneTrainPerTurn
May company buy more than one Train from the Bank per turn?


oneTrainPerTypePerTurn

protected boolean oneTrainPerTypePerTurn
May company buy more than one Train of each type from the Bank per turn?


loanTakingAllowed

protected boolean loanTakingAllowed
Is loan taking allowed


defaults

protected Phase defaults
Previous phase, defining the current one's defaults


closedObjects

protected java.util.List<Closeable> closedObjects
Items to close if a phase gets activated


extraInfo

protected java.lang.String extraInfo

parameters

protected java.util.Map<java.lang.String,java.lang.String> parameters
A HashMap to contain phase-dependent parameters by name and value.


log

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

Phase

public Phase(int index,
             java.lang.String name,
             Phase previousPhase)
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

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.

activate

public void activate()
Called when a phase gets activated

Specified by:
activate in interface PhaseI

getInfo

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

isTileColourAllowed

public boolean isTileColourAllowed(java.lang.String tileColour)
Specified by:
isTileColourAllowed in interface PhaseI

getTileColours

public java.util.Map<java.lang.String,java.lang.Integer> getTileColours()
Specified by:
getTileColours in interface PhaseI

getTileColoursString

public java.lang.String getTileColoursString()

getIndex

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

getName

public java.lang.String getName()
Specified by:
getName in interface PhaseI

doPrivatesClose

public boolean doPrivatesClose()
Specified by:
doPrivatesClose in interface PhaseI
Returns:
Returns the privatesClose.

isPrivateSellingAllowed

public boolean isPrivateSellingAllowed()
Specified by:
isPrivateSellingAllowed in interface PhaseI
Returns:
Returns the privateSellingAllowed.

getPrivatesRevenueStep

public int getPrivatesRevenueStep()
Specified by:
getPrivatesRevenueStep in interface PhaseI

isTrainTradingAllowed

public boolean isTrainTradingAllowed()
Specified by:
isTrainTradingAllowed in interface PhaseI

canBuyMoreTrainsPerTurn

public boolean canBuyMoreTrainsPerTurn()
Specified by:
canBuyMoreTrainsPerTurn in interface PhaseI

canBuyMoreTrainsPerTypePerTurn

public boolean canBuyMoreTrainsPerTypePerTurn()
Specified by:
canBuyMoreTrainsPerTypePerTurn in interface PhaseI

isLoanTakingAllowed

public boolean isLoanTakingAllowed()
Specified by:
isLoanTakingAllowed in interface PhaseI

getNumberOfOperatingRounds

public int getNumberOfOperatingRounds()
Specified by:
getNumberOfOperatingRounds in interface PhaseI

getOffBoardRevenueStep

public int getOffBoardRevenueStep()
Specified by:
getOffBoardRevenueStep in interface PhaseI
Returns:
Returns the offBoardRevenueStep.

addObjectToClose

public void addObjectToClose(Closeable object)
Specified by:
addObjectToClose in interface PhaseI

getParameterAsString

public java.lang.String getParameterAsString(java.lang.String key)
Specified by:
getParameterAsString in interface PhaseI

getParameterAsInteger

public int getParameterAsInteger(java.lang.String key)
Specified by:
getParameterAsInteger in interface PhaseI

getClosedObjects

public java.util.List<Closeable> getClosedObjects()

toString

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