rails.game
Class Round

java.lang.Object
  extended by rails.game.Round
All Implemented Interfaces:
RoundI
Direct Known Subclasses:
EndOfGameRound, OperatingRound, StartRound, StockRound, SwitchableUIRound

public abstract class Round
extends java.lang.Object
implements RoundI

Author:
Erik Vos

Field Summary
protected  java.util.List<Player> autopasses
          Autopasses
protected  Bank bank
           
protected  java.util.List<Player> canRequestTurn
           
protected  CompanyManagerI companyManager
           
protected  GameManagerI gameManager
           
protected  GuiHints guiHints
           
protected  java.util.List<Player> hasRequestedTurn
           
protected  Portfolio ipo
           
protected static org.apache.log4j.Logger log
           
protected  MapManager mapManager
           
protected  MoveStack moveStack
           
protected  PlayerManager playerManager
           
protected  Portfolio pool
           
protected  PossibleActions possibleActions
           
protected  Portfolio scrapHeap
           
protected  StockMarketI stockMarket
           
protected  Portfolio unavailable
           
protected  BooleanState wasInterrupted
           
 
Constructor Summary
Round(GameManagerI aGameManager)
          Constructor with the GameManager, will call setGameManager with the parameter to initialize
 
Method Summary
protected  boolean canCompanyOperateThisRound(PublicCompanyI company)
          Can a public company operate? (Default version)
 boolean canRequestTurn(Player player)
           
protected  boolean certCountsAsSold(PublicCertificateI cert)
          Can be subclassed for games with special rules
protected  void checkFlotation(PublicCompanyI company)
          Check if a company must be floated, and if so, do it.
protected  boolean exchangeTokens(ExchangeTokens action, boolean linkedMoveSet)
           
protected  void finishRound()
           
protected  void floatCompany(PublicCompanyI company)
          Float a company, including a default implementation of moving cash and shares as a result of flotation.
 java.util.List<Player> getAutopasses()
           
 PhaseI getCurrentPhase()
           
 Player getCurrentPlayer()
          Get the player that has the next turn.
 int getCurrentPlayerIndex()
           
 GameManagerI getGameManager()
           
 java.lang.String getGameOption(java.lang.String name)
           
protected  java.lang.Object getGameParameter(GameDef.Parm key)
           
 boolean getGameParameterAsBoolean(GameDef.Parm key)
           
 int getGameParameterAsInt(GameDef.Parm key)
           
 java.lang.String getHelp()
           
protected  int getNumberOfActivePlayers()
           
protected  int getNumberOfPlayers()
           
protected  java.util.List<Player> getPlayers()
           
 java.lang.String getRoundName()
           
 java.lang.Class<? extends RoundI> getRoundTypeForUI()
          Allows round instances to tell the UI what type of window to raise.
protected  int getSoldPercentage(PublicCompanyI company)
          Determine sold percentage for floating purposes
 java.util.List<SpecialPropertyI> getSpecialProperties()
           
 boolean hasAutopassed(Player player)
           
protected  void pay(CashHolder from, CashHolder to, int amount)
           
protected  void pay(Portfolio from, Portfolio to, int amount)
           
 boolean process(PossibleAction action)
           
 boolean requestTurn(Player player)
           
 void resume()
          Generic stub to resume an interrupted round.
 void setAutopass(Player player, boolean value)
           
 void setCanRequestTurn(Player player, boolean value)
           
 void setCurrentPlayer(Player player)
           
 void setCurrentPlayerIndex(int newIndex)
           
 java.util.List<PublicCompanyI> setOperatingCompanies()
          Set the operating companies in their current acting order
 java.util.List<PublicCompanyI> setOperatingCompanies(java.util.List<PublicCompanyI> oldOperatingCompanies, PublicCompanyI lastOperatingCompany)
           
 boolean setPossibleActions()
          Default version, does nothing.
 java.lang.String toString()
           
protected  void transferCertificate(Certificate cert, Portfolio newHolder)
           
protected  void transferCertificates(java.util.List<? extends Certificate> certs, Portfolio newHolder)
           
 boolean wasInterrupted()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

possibleActions

protected PossibleActions possibleActions

guiHints

protected GuiHints guiHints

log

protected static org.apache.log4j.Logger log

gameManager

protected GameManagerI gameManager

companyManager

protected CompanyManagerI companyManager

playerManager

protected PlayerManager playerManager

bank

protected Bank bank

ipo

protected Portfolio ipo

pool

protected Portfolio pool

unavailable

protected Portfolio unavailable

scrapHeap

protected Portfolio scrapHeap

stockMarket

protected StockMarketI stockMarket

mapManager

protected MapManager mapManager

wasInterrupted

protected BooleanState wasInterrupted

moveStack

protected MoveStack moveStack

autopasses

protected java.util.List<Player> autopasses
Autopasses


canRequestTurn

protected java.util.List<Player> canRequestTurn

hasRequestedTurn

protected java.util.List<Player> hasRequestedTurn
Constructor Detail

Round

public Round(GameManagerI aGameManager)
Constructor with the GameManager, will call setGameManager with the parameter to initialize

Parameters:
aGameManager - The GameManager Object needed to initialize the Round Class
Method Detail

getCurrentPlayer

public Player getCurrentPlayer()
Description copied from interface: RoundI
Get the player that has the next turn.

Specified by:
getCurrentPlayer in interface RoundI
Returns:
Player object.

getCurrentPlayerIndex

public int getCurrentPlayerIndex()
Returns:
Returns the currentPlayerIndex.

setCurrentPlayerIndex

public void setCurrentPlayerIndex(int newIndex)

setCurrentPlayer

public void setCurrentPlayer(Player player)

getPlayers

protected java.util.List<Player> getPlayers()

getNumberOfPlayers

protected int getNumberOfPlayers()

getNumberOfActivePlayers

protected int getNumberOfActivePlayers()

getCurrentPhase

public PhaseI getCurrentPhase()

getRoundTypeForUI

public java.lang.Class<? extends RoundI> getRoundTypeForUI()
Allows round instances to tell the UI what type of window to raise. Normally the type corresponds to the round type (e.g. OperatingRound needs ORWindow), but sometimes deviations occur (such as the CGRFormationRound, which isn't a StockRound type but needs StatusWindow).

Specified by:
getRoundTypeForUI in interface RoundI
Returns:

getGameOption

public java.lang.String getGameOption(java.lang.String name)

getHelp

public java.lang.String getHelp()
Specified by:
getHelp in interface RoundI

getSpecialProperties

public java.util.List<SpecialPropertyI> getSpecialProperties()

process

public boolean process(PossibleAction action)
Specified by:
process in interface RoundI

exchangeTokens

protected boolean exchangeTokens(ExchangeTokens action,
                                 boolean linkedMoveSet)

setPossibleActions

public boolean setPossibleActions()
Default version, does nothing. Subclasses should override this method with a real version.

Specified by:
setPossibleActions in interface RoundI
Returns:

setOperatingCompanies

public java.util.List<PublicCompanyI> setOperatingCompanies()
Set the operating companies in their current acting order


setOperatingCompanies

public java.util.List<PublicCompanyI> setOperatingCompanies(java.util.List<PublicCompanyI> oldOperatingCompanies,
                                                            PublicCompanyI lastOperatingCompany)

canCompanyOperateThisRound

protected boolean canCompanyOperateThisRound(PublicCompanyI company)
Can a public company operate? (Default version)


checkFlotation

protected void checkFlotation(PublicCompanyI company)
Check if a company must be floated, and if so, do it.

This method is included here because it is used in various types of Round.

Parameters:
company -

getSoldPercentage

protected int getSoldPercentage(PublicCompanyI company)
Determine sold percentage for floating purposes


certCountsAsSold

protected boolean certCountsAsSold(PublicCertificateI cert)
Can be subclassed for games with special rules


floatCompany

protected void floatCompany(PublicCompanyI company)
Float a company, including a default implementation of moving cash and shares as a result of flotation.

Full capitalisation is implemented as in 1830. Partial capitalisation is implemented as in 1851. Other ways to process the consequences of company flotation must be handled in game-specific subclasses.


finishRound

protected void finishRound()

resume

public void resume()
Generic stub to resume an interrupted round. Only valid if implemented in a subclass.

Specified by:
resume in interface RoundI

wasInterrupted

public boolean wasInterrupted()
Specified by:
wasInterrupted in interface RoundI

toString

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

transferCertificate

protected void transferCertificate(Certificate cert,
                                   Portfolio newHolder)

transferCertificates

protected void transferCertificates(java.util.List<? extends Certificate> certs,
                                    Portfolio newHolder)

pay

protected void pay(CashHolder from,
                   CashHolder to,
                   int amount)

pay

protected void pay(Portfolio from,
                   Portfolio to,
                   int amount)

getGameManager

public GameManagerI getGameManager()

getGameParameter

protected java.lang.Object getGameParameter(GameDef.Parm key)

getGameParameterAsInt

public int getGameParameterAsInt(GameDef.Parm key)

getGameParameterAsBoolean

public boolean getGameParameterAsBoolean(GameDef.Parm key)

getRoundName

public java.lang.String getRoundName()
Specified by:
getRoundName in interface RoundI

requestTurn

public boolean requestTurn(Player player)

canRequestTurn

public boolean canRequestTurn(Player player)

setCanRequestTurn

public void setCanRequestTurn(Player player,
                              boolean value)

setAutopass

public void setAutopass(Player player,
                        boolean value)

hasAutopassed

public boolean hasAutopassed(Player player)

getAutopasses

public java.util.List<Player> getAutopasses()