rails.game
Class PrivateCompany

java.lang.Object
  extended by rails.game.Company
      extended by rails.game.PrivateCompany
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<Company>, Certificate, Closeable, CompanyI, ConfigurableComponentI, Moveable, MoveableHolder, PrivateCompanyI

public class PrivateCompany
extends Company
implements PrivateCompanyI


Field Summary
protected  java.lang.String auctionType
           
protected  int basePrice
           
protected  java.util.List<MapHex> blockedHexes
           
protected  java.lang.String blockedHexesString
           
protected  boolean closeAtEndOfTurn
           
protected  java.lang.String closeAtPhaseName
           
protected  boolean closeIfAllExercised
           
protected  boolean closeIfAnyExercised
           
protected  boolean closeManually
           
protected  int closingPhase
           
protected  int lowerPlayerPrice
           
protected  float lowerPlayerPriceFactor
           
protected  int lowerPrice
           
protected  float lowerPriceFactor
           
protected static int numberOfPrivateCompanies
           
protected  java.util.List<java.lang.String> preventClosingConditions
           
protected  int privateNumber
           
protected  int[] revenue
           
protected  boolean tradeableToCompany
           
protected  boolean tradeableToPlayer
           
protected  int upperPlayerPrice
           
protected  float upperPlayerPriceFactor
           
protected  int upperPrice
           
protected  float upperPriceFactor
           
 
Fields inherited from class rails.game.Company
alias, certLimitCount, closedObject, companyNumber, infoText, log, longName, name, parentInfoText, portfolio, specialProperties, type, value
 
Fields inherited from interface rails.game.PrivateCompanyI
NO_PRICE_LIMIT, REVENUE, TYPE_TAG
 
Fields inherited from interface rails.game.CompanyI
COMPANY_ELEMENT_ID, COMPANY_NAME_TAG, COMPANY_TYPE_TAG
 
Fields inherited from interface rails.game.move.Moveable
AT_END
 
Constructor Summary
PrivateCompany()
           
 
Method Summary
 boolean addObject(Moveable object, int[] position)
          Stub to satisfy MoveableHolderI.
 void checkClosingIfExercised(boolean endOfTurn)
           
 java.lang.Object clone()
           
 void close()
           
 boolean closesAtEndOfTurn()
           
 boolean closesIfAllExercised()
           
 boolean closesIfAnyExercised()
           
 boolean closesManually()
           
 void configureFromXML(Tag tag)
          Only to be called from subclasses
 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 getBasePrice()
           
 java.util.List<MapHex> getBlockedHexes()
           
 java.lang.String getClosingInfo()
           
 int getClosingPhase()
           
 int[] getListIndex(Moveable object)
           
 int getLowerPrice()
           
 int getLowerPrice(boolean saleToPlayer)
           
 Portfolio getPortfolio()
          Get the Portfolio of this company, containing all privates and certificates owned..
 java.util.List<java.lang.String> getPreventClosingConditions()
           
 int getPrivateNumber()
           
 int[] getRevenue()
           
 int getRevenueByPhase(PhaseI phase)
           
 int getUpperPrice()
           
 int getUpperPrice(boolean saleToPlayer)
           
 void init(java.lang.String name, CompanyTypeI type)
          Initialisation, to be called directly after instantiation (cloning)
 boolean isCloseable()
           
 void moveTo(MoveableHolder newHolder)
           
 boolean removeObject(Moveable object)
          Remove a special property.
 void setClosed()
          Close this company.
 void setClosingPhase(int i)
           
 void setHolder(Portfolio portfolio)
           
 java.lang.String toString()
           
 boolean tradeableToCompany()
           
 boolean tradeableToPlayer()
           
protected  void unblockHexes()
           
 
Methods inherited from class rails.game.Company
addToken, compareTo, equals, getAlias, getCertLimitCount, getCompanyNumber, getHolder, getInfoText, getLongName, getName, getNumber, getSpecialProperties, getType, getTypeName, getValue, hasSpecialProperties, isClosed, joinNamesWithDelimiter, setCertLimitCount, setValue
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rails.game.CompanyI
equals, getAlias, getCertLimitCount, getCompanyNumber, getInfoText, getLongName, getName, getSpecialProperties, getType, getTypeName, getValue, hasSpecialProperties, isClosed, setCertLimitCount, setValue
 
Methods inherited from interface rails.game.Certificate
getName
 
Methods inherited from interface rails.game.move.Moveable
getHolder
 

Field Detail

numberOfPrivateCompanies

protected static int numberOfPrivateCompanies

privateNumber

protected int privateNumber

basePrice

protected int basePrice

revenue

protected int[] revenue

auctionType

protected java.lang.String auctionType

closingPhase

protected int closingPhase

closeIfAllExercised

protected boolean closeIfAllExercised

closeIfAnyExercised

protected boolean closeIfAnyExercised

closeAtEndOfTurn

protected boolean closeAtEndOfTurn

preventClosingConditions

protected java.util.List<java.lang.String> preventClosingConditions

closeAtPhaseName

protected java.lang.String closeAtPhaseName

closeManually

protected boolean closeManually

blockedHexesString

protected java.lang.String blockedHexesString

blockedHexes

protected java.util.List<MapHex> blockedHexes

upperPrice

protected int upperPrice

lowerPrice

protected int lowerPrice

lowerPriceFactor

protected float lowerPriceFactor

upperPriceFactor

protected float upperPriceFactor

upperPlayerPrice

protected int upperPlayerPrice

lowerPlayerPrice

protected int lowerPlayerPrice

lowerPlayerPriceFactor

protected float lowerPlayerPriceFactor

upperPlayerPriceFactor

protected float upperPlayerPriceFactor

tradeableToCompany

protected boolean tradeableToCompany

tradeableToPlayer

protected boolean tradeableToPlayer
Constructor Detail

PrivateCompany

public PrivateCompany()
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Description copied from class: Company
Only to be called from subclasses

Specified by:
configureFromXML in interface ConfigurableComponentI
Overrides:
configureFromXML in class Company
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

init

public void init(java.lang.String name,
                 CompanyTypeI type)
Initialisation, to be called directly after instantiation (cloning)

Specified by:
init in interface CompanyI
Overrides:
init in class Company

moveTo

public void moveTo(MoveableHolder newHolder)
Specified by:
moveTo in interface Moveable

getPrivateNumber

public int getPrivateNumber()
Specified by:
getPrivateNumber in interface PrivateCompanyI
Returns:
Private Company Number

getBasePrice

public int getBasePrice()
Specified by:
getBasePrice in interface PrivateCompanyI
Returns:
Base Price

getRevenue

public int[] getRevenue()
Specified by:
getRevenue in interface PrivateCompanyI
Returns:
Revenue

getRevenueByPhase

public int getRevenueByPhase(PhaseI phase)
Specified by:
getRevenueByPhase in interface PrivateCompanyI

getClosingPhase

public int getClosingPhase()
Returns:
Phase this Private closes

getPortfolio

public Portfolio getPortfolio()
Description copied from class: Company
Get the Portfolio of this company, containing all privates and certificates owned..

Specified by:
getPortfolio in interface Certificate
Specified by:
getPortfolio in interface CompanyI
Overrides:
getPortfolio in class Company
Returns:
Portfolio (holder) of this Private

setClosed

public void setClosed()
Description copied from class: Company
Close this company.

Specified by:
setClosed in interface CompanyI
Overrides:
setClosed in class Company
Parameters:
b -

isCloseable

public boolean isCloseable()
Specified by:
isCloseable in interface PrivateCompanyI

getPreventClosingConditions

public java.util.List<java.lang.String> getPreventClosingConditions()
Specified by:
getPreventClosingConditions in interface PrivateCompanyI

setClosingPhase

public void setClosingPhase(int i)
Parameters:
i -

setHolder

public void setHolder(Portfolio portfolio)
Specified by:
setHolder in interface PrivateCompanyI
Parameters:
portfolio -

unblockHexes

protected void unblockHexes()

toString

public java.lang.String toString()
Specified by:
toString in interface CompanyI
Overrides:
toString in class Company

clone

public java.lang.Object clone()
Specified by:
clone in interface CompanyI
Overrides:
clone in class Company

addObject

public boolean addObject(Moveable object,
                         int[] position)
Stub to satisfy MoveableHolderI. Special properties are never added after completing the initial setup.

Specified by:
addObject in interface MoveableHolder
Parameters:
object - The Moveable object to be added.
position - Position to insert object at. O: at front, -1, at end, >0: at that position.
Returns:
True if successful.

removeObject

public boolean removeObject(Moveable object)
Remove a special property. Only used to transfer a persistent special property to a Portfolio, where it becomes independent of the private.

Specified by:
removeObject in interface MoveableHolder
Parameters:
token - The special property object to remove.
Returns:
True if successful.

getListIndex

public int[] getListIndex(Moveable object)
Specified by:
getListIndex in interface MoveableHolder

getBlockedHexes

public java.util.List<MapHex> getBlockedHexes()
Specified by:
getBlockedHexes in interface PrivateCompanyI

closesIfAllExercised

public boolean closesIfAllExercised()
Specified by:
closesIfAllExercised in interface PrivateCompanyI

closesIfAnyExercised

public boolean closesIfAnyExercised()
Specified by:
closesIfAnyExercised in interface PrivateCompanyI

closesAtEndOfTurn

public boolean closesAtEndOfTurn()
Specified by:
closesAtEndOfTurn in interface PrivateCompanyI

closesManually

public boolean closesManually()
Specified by:
closesManually in interface PrivateCompanyI

checkClosingIfExercised

public void checkClosingIfExercised(boolean endOfTurn)
Specified by:
checkClosingIfExercised in interface PrivateCompanyI

getClosingInfo

public java.lang.String getClosingInfo()
Specified by:
getClosingInfo in interface Closeable

close

public void close()
Specified by:
close in interface Closeable

getUpperPrice

public int getUpperPrice()
Specified by:
getUpperPrice in interface PrivateCompanyI
Returns:
Returns the upperPrice that the company can be sold in for.

getUpperPrice

public int getUpperPrice(boolean saleToPlayer)
Specified by:
getUpperPrice in interface PrivateCompanyI

getLowerPrice

public int getLowerPrice()
Specified by:
getLowerPrice in interface PrivateCompanyI
Returns:
Returns the lowerPrice that the company can be sold in for.

getLowerPrice

public int getLowerPrice(boolean saleToPlayer)
Specified by:
getLowerPrice in interface PrivateCompanyI

tradeableToCompany

public boolean tradeableToCompany()
Specified by:
tradeableToCompany in interface PrivateCompanyI
Returns:
Returns whether or not the company can be bought by a company

tradeableToPlayer

public boolean tradeableToPlayer()
Specified by:
tradeableToPlayer in interface PrivateCompanyI
Returns:
Returns whether or not the company can be bought by a player (from another player)