rails.game
Class GameManager

java.lang.Object
  extended by rails.game.GameManager
All Implemented Interfaces:
ConfigurableComponentI, GameManagerI, MoveableHolder
Direct Known Subclasses:
GameManager_1835, GameManager_1856, GameManager_18EU

public class GameManager
extends java.lang.Object
implements ConfigurableComponentI, GameManagerI

This class manages the playing rounds by supervising all implementations of Round. Currently everything is hardcoded à la 1830.


Field Summary
protected  IntegerState absoluteORNumber
           
protected  java.util.List<GameOption> availableGameOptions
          A List of available game options
protected  Bank bank
           
protected  java.util.List<SpecialPropertyI> commonSpecialProperties
          Special properties that can be used by other players or companies than just the owner (such as buyable bonus tokens as in 1856).
protected  CompanyManagerI companyManager
           
protected  java.util.Map<CorrectionType,CorrectionManagerI> correctionManagers
           
protected  int currentNumberOfOperatingRounds
           
protected  State currentPlayer
           
protected  State currentRound
          Current round should not be set here but from within the Round classes.
protected  DisplayBuffer displayBuffer
          The DisplayBuffer instance collects messages to be displayed in the UI.
protected  boolean dynamicOperatingOrder
           
protected  BooleanState endedByBankruptcy
           
protected  java.util.List<PossibleAction> executedActions
           
protected  boolean forcedSellingCompanyDump
           
protected  boolean gameEndsAfterSetOfORs
           
protected  int gameEndsWhenBankHasLessOrEqual
           
protected  boolean gameEndsWithBankruptcy
           
protected static java.util.Map<java.lang.String,GameManagerI> gameManagerMap
          Map of GameManager instances.
protected  java.lang.String gameName
           
protected  java.util.Map<java.lang.String,java.lang.String> gameOptions
           
protected  BooleanState gameOver
          GameOver is executed, no more moves
protected  BooleanState gameOverPending
          GameOver pending, a last OR or set of ORs must still be completed
protected  java.lang.Boolean gameOverReportedUI
           
protected  java.util.EnumMap<GameDef.Parm,java.lang.Object> gameParameters
           
protected  java.lang.String gameStatusClassName
           
protected  java.lang.String gameUIManagerClassName
           
static java.lang.String GM_KEY
          The temporary fixed key to the currently single GameManager instance in the GameManager map.
static java.lang.String GM_NAME
           
protected  java.lang.String gmKey
           
protected  java.lang.String gmName
           
protected  GuiHints guiHints
          UI display hints
protected  java.util.EnumMap<GuiDef.Parm,java.lang.Boolean> guiParameters
          Flags to be passed to the UI, aiding the layout definition
protected  RoundI interruptedRound
           
protected static org.apache.log4j.Logger log
           
protected  MapManager mapManager
           
protected  MoveStack moveStack
          The MoveSet stack is maintained to enable Undo and Redo throughout the game.
protected  java.util.List<java.lang.String> nextPlayerMessages
          nextPlayerMessages collects all messages to be displayed to the next player
protected  int numberOfPlayers
           
protected  IntegerState numOfORs
           
protected  java.lang.Class<? extends OperatingRound> operatingRoundClass
           
protected  java.lang.String orUIManagerClassName
           
protected  java.lang.String orWindowClassName
           
protected  PhaseManager phaseManager
           
protected  IntegerState playerCertificateLimit
           
protected  PlayerManager playerManager
           
protected  java.util.List<java.lang.String> playerNames
           
protected  java.util.List<Player> players
           
protected  java.util.Map<java.lang.String,Portfolio> portfolioMap
          Map relating portfolio names and objects, to enable deserialization.
protected  java.util.Map<java.lang.String,Portfolio> portfolioUniqueNameMap
          Map relating portfolio unique names and objects, to enable deserialization
protected  PossibleActions possibleActions
           
protected  State priorityPlayer
           
protected  boolean recoverySaveWarning
          indicates that the recoverySave already issued a warning, avoids displaying several warnings
protected  IntegerState relativeORNumber
           
protected  boolean reloading
          Will only be set during game reload
protected  ReportBuffer reportBuffer
          The ReportBuffer collects messages to be shown in the Game Report.
protected  RevenueManager revenueManager
           
static long saveFileVersionID
          Overall save file version ID, taking into account the version ID of the action package.
protected  java.lang.Class<? extends ShareSellingRound> shareSellingRoundClass
           
protected  boolean showCompositeORNumber
           
protected  boolean skipFirstStockRound
           
protected  boolean skipNextDone
          Flag to skip a subsequent Done action (if present) during reloading.
protected  GameDef.OrStep skippedStep
          Step that must be in effect to do an actual Done skip during reloading.
protected  IntegerState srNumber
           
protected  StartPacket startPacket
           
protected  java.lang.String statusWindowClassName
           
protected  StockMarketI stockMarket
           
protected  java.lang.Class<? extends StockRound> stockRoundClass
           
protected  TileManager tileManager
           
protected  TrainManager trainManager
           
 
Constructor Summary
GameManager()
           
 
Method Summary
 boolean addObject(Moveable object, int[] position)
          Add an object.
 void addPortfolio(Portfolio portfolio)
           
 boolean addSpecialProperty(SpecialPropertyI property, int position)
           
 void addToNextPlayerMessages(java.lang.String s, boolean undoable)
           
 boolean canAnyCompanyHoldShares()
           
protected  void canClassBeInstantiated(java.lang.String className)
          Check if a classname can be instantiated.
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
protected
<T extends RoundI>
T
createRound(java.lang.Class<T> roundClass)
           
protected
<T extends RoundI,U extends RoundI>
T
createRound(java.lang.Class<T> roundClass, U parentRound)
           
protected  boolean export(GameAction exportAction)
           
 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.
 void finishLoading()
           
 void finishShareSellingRound()
           
 void finishTreasuryShareRound()
           
 int getAbsoluteORNumber()
           
 java.util.List<PrivateCompanyI> getAllPrivateCompanies()
           
 java.util.List<PublicCompanyI> getAllPublicCompanies()
           
 Bank getBank()
           
 java.lang.String getClassName(GuiDef.ClassName key)
           
 java.util.List<SpecialPropertyI> getCommonSpecialProperties()
           
 java.util.List<PublicCompanyI> getCompaniesInRunningOrder()
          Return a list of companies in operation order.
 CompanyManagerI getCompanyManager()
           
 java.lang.String getCompositeORNumber()
           
 CorrectionManagerI getCorrectionManager(CorrectionType ct)
           
 PhaseI getCurrentPhase()
           
 Player getCurrentPlayer()
           
 int getCurrentPlayerIndex()
           
 RoundI getCurrentRound()
          Should be called whenever a Phase changes.
 DisplayBuffer getDisplayBuffer()
           
 java.lang.String getGameName()
           
 java.lang.String getGameOption(java.lang.String key)
           
 boolean getGameOverReportedUI()
           
 java.lang.Object getGameParameter(GameDef.Parm key)
           
 java.util.List<java.lang.String> getGameReport()
          Create a HTML-formatted rails.game status report.
 java.lang.String getGMKey()
           
 java.lang.Object getGuiParameter(GuiDef.Parm key)
           
 java.lang.String getHelp()
           
static GameManagerI getInstance()
           
 RoundI getInterruptedRound()
           
 int[] getListIndex(Moveable object)
           
 MapManager getMapManager()
           
 MoveStack getMoveStack()
           
 java.lang.String getName()
          Get name of the GM instance.
 int getNumberOfPlayers()
           
 java.lang.String getNumOfORs()
           
 java.lang.String getORId()
           
 PhaseManager getPhaseManager()
           
 Player getPlayerByIndex(int index)
          Return a player by its index in the list, modulo the number of players.
 int getPlayerCertificateLimit(Player player)
           
 IntegerState getPlayerCertificateLimitModel()
           
 PlayerManager getPlayerManager()
           
 java.util.List<java.lang.String> getPlayerNames()
           
 java.util.List<Player> getPlayers()
           
 Portfolio getPortfolioByName(java.lang.String name)
           
 Portfolio getPortfolioByUniqueName(java.lang.String name)
           
 Player getPriorityPlayer()
           
 int getRelativeORNumber()
           
 ReportBuffer getReportBuffer()
           
 RevenueManager getRevenueManager()
          The RevenueManager is optional, thus a null reference might be returned
<T extends SpecialPropertyI>
java.util.List<T>
getSpecialProperties(java.lang.Class<T> clazz, boolean includeExercised)
           
 int getSRNumber()
           
 StartPacket getStartPacket()
           
 StockMarketI getStockMarket()
           
 TileManager getTileManager()
           
 TrainManager getTrainManager()
           
 GuiHints getUIHints()
           
 void init(java.lang.String gameName, PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, TileManager tileManager, RevenueManager revenueManager, Bank bank)
           
 void initialiseNewPhase(PhaseI phase)
           
 boolean isDynamicOperatingOrder()
           
 boolean isGameOver()
          To be called by the UI to check if the rails.game is over.
 boolean isReloading()
           
 void newPhaseChecks(RoundI round)
          Stub, can be overridden in subclasses with actual actions
 void nextRound(RoundI round)
          Should be called by each Round when it finishes.
 boolean process(PossibleAction action)
          The central server-side method that takes a client-side initiated action and processes it.
protected  void processBankruptcy()
           
 boolean processOnReload(PossibleAction action)
           
protected  void recoverySave()
          recoverySave method Uses filePath defined in save.recovery.filepath
 void registerBankruptcy()
           
 void registerBrokenBank()
           
 void registerMaxedSharePrice(PublicCompanyI company, StockSpaceI space)
           
protected  boolean reload(GameAction reloadAction)
           
 boolean removeObject(Moveable object)
          Remove an object.
 boolean removeSpecialProperty(SpecialPropertyI property)
          Remove a special property.
 Player reorderPlayersByCash(boolean ascending)
           
protected  boolean save(java.io.File file, boolean displayErrorMessage, java.lang.String errorMessageKey)
           
protected  boolean save(GameAction saveAction)
           
 void setCurrentPlayer(Player player)
           
 void setCurrentPlayerIndex(int currentPlayerIndex)
           
 void setGameOverReportedUI(boolean b)
           
 void setGameParameter(GameDef.Parm key, java.lang.Object value)
           
 void setNextPlayer()
           
 void setPlayerCertificateLimit(int newLimit)
           
 void setPriorityPlayer()
          Set priority deal to the player after the current player.
 void setPriorityPlayer(Player player)
           
 void setReloading(boolean reloading)
           
protected  void setRound(RoundI round)
           
 void setSkipDone(GameDef.OrStep step)
           
 void startGame(java.util.Map<java.lang.String,java.lang.String> gameOptions)
           
protected  void startOperatingRound(boolean operate)
           
 void startShareSellingRound(Player player, int cashToRaise, PublicCompanyI cashNeedingCompany, boolean problemDumpOtherCompanies)
           
protected  void startStartRound()
           
protected  void startStockRound()
           
 void startTreasuryShareTradingRound()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saveFileVersionID

public static final long saveFileVersionID
Overall save file version ID, taking into account the version ID of the action package.

See Also:
Constant Field Values

stockRoundClass

protected java.lang.Class<? extends StockRound> stockRoundClass

operatingRoundClass

protected java.lang.Class<? extends OperatingRound> operatingRoundClass

shareSellingRoundClass

protected java.lang.Class<? extends ShareSellingRound> shareSellingRoundClass

gameUIManagerClassName

protected java.lang.String gameUIManagerClassName

orUIManagerClassName

protected java.lang.String orUIManagerClassName

gameStatusClassName

protected java.lang.String gameStatusClassName

statusWindowClassName

protected java.lang.String statusWindowClassName

orWindowClassName

protected java.lang.String orWindowClassName

playerManager

protected PlayerManager playerManager

companyManager

protected CompanyManagerI companyManager

phaseManager

protected PhaseManager phaseManager

trainManager

protected TrainManager trainManager

stockMarket

protected StockMarketI stockMarket

mapManager

protected MapManager mapManager

tileManager

protected TileManager tileManager

revenueManager

protected RevenueManager revenueManager

bank

protected Bank bank

correctionManagers

protected java.util.Map<CorrectionType,CorrectionManagerI> correctionManagers

gameName

protected java.lang.String gameName

gameOptions

protected java.util.Map<java.lang.String,java.lang.String> gameOptions

players

protected java.util.List<Player> players

playerNames

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

numberOfPlayers

protected int numberOfPlayers

currentPlayer

protected State currentPlayer

priorityPlayer

protected State priorityPlayer

portfolioMap

protected java.util.Map<java.lang.String,Portfolio> portfolioMap
Map relating portfolio names and objects, to enable deserialization. OBSOLETE since Rails 1.3.1, but still required to enable reading old saved files


portfolioUniqueNameMap

protected java.util.Map<java.lang.String,Portfolio> portfolioUniqueNameMap
Map relating portfolio unique names and objects, to enable deserialization


playerCertificateLimit

protected IntegerState playerCertificateLimit

currentNumberOfOperatingRounds

protected int currentNumberOfOperatingRounds

skipFirstStockRound

protected boolean skipFirstStockRound

showCompositeORNumber

protected boolean showCompositeORNumber

forcedSellingCompanyDump

protected boolean forcedSellingCompanyDump

gameEndsWithBankruptcy

protected boolean gameEndsWithBankruptcy

gameEndsWhenBankHasLessOrEqual

protected int gameEndsWhenBankHasLessOrEqual

gameEndsAfterSetOfORs

protected boolean gameEndsAfterSetOfORs

dynamicOperatingOrder

protected boolean dynamicOperatingOrder

reloading

protected boolean reloading
Will only be set during game reload


gameParameters

protected java.util.EnumMap<GameDef.Parm,java.lang.Object> gameParameters

currentRound

protected State currentRound
Current round should not be set here but from within the Round classes. This is because in some cases the round has already changed to another one when the constructor terminates. Example: if the privates have not been sold, it finishes by starting an Operating Round, which handles the privates payout and then immediately starts a new Start Round.


interruptedRound

protected RoundI interruptedRound

srNumber

protected IntegerState srNumber

absoluteORNumber

protected IntegerState absoluteORNumber

relativeORNumber

protected IntegerState relativeORNumber

numOfORs

protected IntegerState numOfORs

gameOverPending

protected BooleanState gameOverPending
GameOver pending, a last OR or set of ORs must still be completed


gameOver

protected BooleanState gameOver
GameOver is executed, no more moves


gameOverReportedUI

protected java.lang.Boolean gameOverReportedUI

endedByBankruptcy

protected BooleanState endedByBankruptcy

guiHints

protected GuiHints guiHints
UI display hints


guiParameters

protected java.util.EnumMap<GuiDef.Parm,java.lang.Boolean> guiParameters
Flags to be passed to the UI, aiding the layout definition


gameManagerMap

protected static java.util.Map<java.lang.String,GameManagerI> gameManagerMap
Map of GameManager instances. Currently there can be only one instance, but in a possible future multi-game server there may be several instances running in parallel.

The reason for creating this map is the need to access GameManager instances (or other common instances via the GM) from many different classes, some of which (like those in the move package) are many method calls away from the actual GM.

To prevent the need to pass GameManager instances or the keys to this map around throughout the code, NDC is (mis-)used as the mechanism to pass around a string key to each GM instance. This is possible,because the server processes all player actions in one thread. The key will be set in process(), which is where server processing currently starts (in the future it will probably be moved to the communication interface that will be added by then). The key can be retrieved (via NDC.peek()) anywhere.

For now, the key is a fixed string, but that may change in the future.


GM_KEY

public static final java.lang.String GM_KEY
The temporary fixed key to the currently single GameManager instance in the GameManager map. It will only be used inside the GM objects. All other objects will access it via NDC.

See Also:
Constant Field Values

GM_NAME

public static final java.lang.String GM_NAME
See Also:
Constant Field Values

moveStack

protected MoveStack moveStack
The MoveSet stack is maintained to enable Undo and Redo throughout the game.


displayBuffer

protected DisplayBuffer displayBuffer
The DisplayBuffer instance collects messages to be displayed in the UI.


nextPlayerMessages

protected java.util.List<java.lang.String> nextPlayerMessages
nextPlayerMessages collects all messages to be displayed to the next player


reportBuffer

protected ReportBuffer reportBuffer
The ReportBuffer collects messages to be shown in the Game Report.


gmName

protected java.lang.String gmName

gmKey

protected java.lang.String gmKey

startPacket

protected StartPacket startPacket

possibleActions

protected PossibleActions possibleActions

executedActions

protected java.util.List<PossibleAction> executedActions

commonSpecialProperties

protected java.util.List<SpecialPropertyI> commonSpecialProperties
Special properties that can be used by other players or companies than just the owner (such as buyable bonus tokens as in 1856).


availableGameOptions

protected java.util.List<GameOption> availableGameOptions
A List of available game options


recoverySaveWarning

protected boolean recoverySaveWarning
indicates that the recoverySave already issued a warning, avoids displaying several warnings


skipNextDone

protected boolean skipNextDone
Flag to skip a subsequent Done action (if present) during reloading.
This is a fix to maintain backwards compatibility when redundant actions are skipped in new code versions (such as the bypassing of a treasury trading step if it cannot be executed).
This flag must be reset after processing any action (not just Done).


skippedStep

protected GameDef.OrStep skippedStep
Step that must be in effect to do an actual Done skip during reloading.
This is to ensure that Done actions in different OR steps are considered separately.


log

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

GameManager

public GameManager()
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.

canClassBeInstantiated

protected void canClassBeInstantiated(java.lang.String className)
                               throws ConfigurationException
Check if a classname can be instantiated. Throws a ConfiguratioNException if not.

Parameters:
className -
Throws:
ConfigurationException

init

public void init(java.lang.String gameName,
                 PlayerManager playerManager,
                 CompanyManagerI companyManager,
                 PhaseManager phaseManager,
                 TrainManager trainManager,
                 StockMarketI stockMarket,
                 MapManager mapManager,
                 TileManager tileManager,
                 RevenueManager revenueManager,
                 Bank bank)
Specified by:
init in interface GameManagerI
See Also:
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)

startGame

public void startGame(java.util.Map<java.lang.String,java.lang.String> gameOptions)
Specified by:
startGame in interface GameManagerI

getInstance

public static GameManagerI getInstance()
Returns:
instance of GameManager

getCompanyManager

public CompanyManagerI getCompanyManager()
Specified by:
getCompanyManager in interface GameManagerI

setRound

protected void setRound(RoundI round)

nextRound

public void nextRound(RoundI round)
Description copied from interface: GameManagerI
Should be called by each Round when it finishes.

Specified by:
nextRound in interface GameManagerI
Parameters:
round - The object that represents the finishing round.

startStartRound

protected void startStartRound()

startStockRound

protected void startStockRound()

startOperatingRound

protected void startOperatingRound(boolean operate)

createRound

protected <T extends RoundI> T createRound(java.lang.Class<T> roundClass)

createRound

protected <T extends RoundI,U extends RoundI> T createRound(java.lang.Class<T> roundClass,
                                                            U parentRound)

newPhaseChecks

public void newPhaseChecks(RoundI round)
Stub, can be overridden in subclasses with actual actions


getORId

public java.lang.String getORId()
Specified by:
getORId in interface GameManagerI

getAbsoluteORNumber

public int getAbsoluteORNumber()
Specified by:
getAbsoluteORNumber in interface GameManagerI

getCompositeORNumber

public java.lang.String getCompositeORNumber()
Specified by:
getCompositeORNumber in interface GameManagerI

getRelativeORNumber

public int getRelativeORNumber()
Specified by:
getRelativeORNumber in interface GameManagerI

getNumOfORs

public java.lang.String getNumOfORs()

getSRNumber

public int getSRNumber()
Specified by:
getSRNumber in interface GameManagerI

startShareSellingRound

public void startShareSellingRound(Player player,
                                   int cashToRaise,
                                   PublicCompanyI cashNeedingCompany,
                                   boolean problemDumpOtherCompanies)
Specified by:
startShareSellingRound in interface GameManagerI

startTreasuryShareTradingRound

public void startTreasuryShareTradingRound()
Specified by:
startTreasuryShareTradingRound in interface GameManagerI

process

public boolean process(PossibleAction action)
Description copied from interface: GameManagerI
The central server-side method that takes a client-side initiated action and processes it.

Specified by:
process in interface GameManagerI
Parameters:
action - A PossibleAction subclass object sent by the client.
Returns:
TRUE is the action was valid.

processOnReload

public boolean processOnReload(PossibleAction action)
                        throws java.lang.Exception
Specified by:
processOnReload in interface GameManagerI
Throws:
java.lang.Exception

finishLoading

public void finishLoading()
Specified by:
finishLoading in interface GameManagerI

recoverySave

protected void recoverySave()
recoverySave method Uses filePath defined in save.recovery.filepath


save

protected boolean save(GameAction saveAction)

save

protected boolean save(java.io.File file,
                       boolean displayErrorMessage,
                       java.lang.String errorMessageKey)

reload

protected boolean reload(GameAction reloadAction)

export

protected boolean export(GameAction exportAction)

finishShareSellingRound

public void finishShareSellingRound()
Specified by:
finishShareSellingRound in interface GameManagerI

finishTreasuryShareRound

public void finishTreasuryShareRound()
Specified by:
finishTreasuryShareRound in interface GameManagerI

registerBankruptcy

public void registerBankruptcy()
Specified by:
registerBankruptcy in interface GameManagerI

processBankruptcy

protected void processBankruptcy()

registerBrokenBank

public void registerBrokenBank()
Specified by:
registerBrokenBank in interface GameManagerI

registerMaxedSharePrice

public void registerMaxedSharePrice(PublicCompanyI company,
                                    StockSpaceI space)
Specified by:
registerMaxedSharePrice in interface GameManagerI

isDynamicOperatingOrder

public boolean isDynamicOperatingOrder()
Specified by:
isDynamicOperatingOrder in interface GameManagerI

isGameOver

public boolean isGameOver()
Description copied from interface: GameManagerI
To be called by the UI to check if the rails.game is over.

Specified by:
isGameOver in interface GameManagerI
Returns:

setGameOverReportedUI

public void setGameOverReportedUI(boolean b)
Specified by:
setGameOverReportedUI in interface GameManagerI

getGameOverReportedUI

public boolean getGameOverReportedUI()
Specified by:
getGameOverReportedUI in interface GameManagerI

getGameReport

public java.util.List<java.lang.String> getGameReport()
Description copied from interface: GameManagerI
Create a HTML-formatted rails.game status report.

Specified by:
getGameReport in interface GameManagerI
Returns:

getCurrentRound

public RoundI getCurrentRound()
Description copied from interface: GameManagerI
Should be called whenever a Phase changes. The effect on the number of ORs is delayed until a StockRound finishes.

Specified by:
getCurrentRound in interface GameManagerI

getCurrentPlayerIndex

public int getCurrentPlayerIndex()
Specified by:
getCurrentPlayerIndex in interface GameManagerI
Returns:
Returns the currentPlayerIndex.

setCurrentPlayerIndex

public void setCurrentPlayerIndex(int currentPlayerIndex)
Specified by:
setCurrentPlayerIndex in interface GameManagerI
Parameters:
currentPlayerIndex - The currentPlayerIndex to set.

setCurrentPlayer

public void setCurrentPlayer(Player player)
Specified by:
setCurrentPlayer in interface GameManagerI

setPriorityPlayer

public void setPriorityPlayer()
Description copied from interface: GameManagerI
Set priority deal to the player after the current player.

Specified by:
setPriorityPlayer in interface GameManagerI

setPriorityPlayer

public void setPriorityPlayer(Player player)
Specified by:
setPriorityPlayer in interface GameManagerI

getPriorityPlayer

public Player getPriorityPlayer()
Specified by:
getPriorityPlayer in interface GameManagerI
Returns:
Returns the priorityPlayer.

getCurrentPlayer

public Player getCurrentPlayer()
Specified by:
getCurrentPlayer in interface GameManagerI
Returns:
Returns the currentPlayer.

getPlayers

public java.util.List<Player> getPlayers()
Specified by:
getPlayers in interface GameManagerI
Returns:
Returns the players.

getNumberOfPlayers

public int getNumberOfPlayers()
Specified by:
getNumberOfPlayers in interface GameManagerI

getPlayerNames

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

getPlayerCertificateLimit

public int getPlayerCertificateLimit(Player player)
Specified by:
getPlayerCertificateLimit in interface GameManagerI

setPlayerCertificateLimit

public void setPlayerCertificateLimit(int newLimit)
Specified by:
setPlayerCertificateLimit in interface GameManagerI

getPlayerCertificateLimitModel

public IntegerState getPlayerCertificateLimitModel()
Specified by:
getPlayerCertificateLimitModel in interface GameManagerI

getAllPublicCompanies

public java.util.List<PublicCompanyI> getAllPublicCompanies()
Specified by:
getAllPublicCompanies in interface GameManagerI

getAllPrivateCompanies

public java.util.List<PrivateCompanyI> getAllPrivateCompanies()
Specified by:
getAllPrivateCompanies in interface GameManagerI

getPlayerByIndex

public Player getPlayerByIndex(int index)
Description copied from interface: GameManagerI
Return a player by its index in the list, modulo the number of players.

Specified by:
getPlayerByIndex in interface GameManagerI
Parameters:
index - The player index.
Returns:
A player object.

setNextPlayer

public void setNextPlayer()
Specified by:
setNextPlayer in interface GameManagerI

addPortfolio

public void addPortfolio(Portfolio portfolio)
Specified by:
addPortfolio in interface GameManagerI

getPortfolioByName

public Portfolio getPortfolioByName(java.lang.String name)
Specified by:
getPortfolioByName in interface GameManagerI

getPortfolioByUniqueName

public Portfolio getPortfolioByUniqueName(java.lang.String name)
Specified by:
getPortfolioByUniqueName in interface GameManagerI

getStartPacket

public StartPacket getStartPacket()
Specified by:
getStartPacket in interface GameManagerI
Returns:
the StartPacket

getCurrentPhase

public PhaseI getCurrentPhase()
Specified by:
getCurrentPhase in interface GameManagerI
Returns:
Current phase

getPhaseManager

public PhaseManager getPhaseManager()
Specified by:
getPhaseManager in interface GameManagerI

getGameName

public java.lang.String getGameName()
Specified by:
getGameName in interface GameManagerI

getPlayerManager

public PlayerManager getPlayerManager()
Specified by:
getPlayerManager in interface GameManagerI

getTrainManager

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

getStockMarket

public StockMarketI getStockMarket()
Specified by:
getStockMarket in interface GameManagerI

getMapManager

public MapManager getMapManager()
Specified by:
getMapManager in interface GameManagerI

getTileManager

public TileManager getTileManager()
Specified by:
getTileManager in interface GameManagerI

getRevenueManager

public RevenueManager getRevenueManager()
The RevenueManager is optional, thus a null reference might be returned

Specified by:
getRevenueManager in interface GameManagerI

getBank

public Bank getBank()
Specified by:
getBank in interface GameManagerI

getGameOption

public java.lang.String getGameOption(java.lang.String key)
Specified by:
getGameOption in interface GameManagerI

initialiseNewPhase

public void initialiseNewPhase(PhaseI phase)
Specified by:
initialiseNewPhase in interface GameManagerI

getHelp

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

canAnyCompanyHoldShares

public boolean canAnyCompanyHoldShares()
Specified by:
canAnyCompanyHoldShares in interface GameManagerI

getClassName

public java.lang.String getClassName(GuiDef.ClassName key)
Specified by:
getClassName in interface GameManagerI

getGuiParameter

public java.lang.Object getGuiParameter(GuiDef.Parm key)
Specified by:
getGuiParameter in interface GameManagerI

setGameParameter

public void setGameParameter(GameDef.Parm key,
                             java.lang.Object value)
Specified by:
setGameParameter in interface GameManagerI

getGameParameter

public java.lang.Object getGameParameter(GameDef.Parm key)
Specified by:
getGameParameter in interface GameManagerI

getInterruptedRound

public RoundI getInterruptedRound()
Specified by:
getInterruptedRound in interface GameManagerI

addObject

public boolean addObject(Moveable object,
                         int[] position)
Add an object.

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

getListIndex

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

removeObject

public boolean removeObject(Moveable object)
Remove an object.

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

addSpecialProperty

public boolean addSpecialProperty(SpecialPropertyI property,
                                  int position)

removeSpecialProperty

public boolean removeSpecialProperty(SpecialPropertyI property)
Remove a special property.

Parameters:
property - The special property object to remove.
Returns:
True if successful.

getCommonSpecialProperties

public java.util.List<SpecialPropertyI> getCommonSpecialProperties()
Specified by:
getCommonSpecialProperties in interface GameManagerI

getSpecialProperties

public <T extends SpecialPropertyI> java.util.List<T> getSpecialProperties(java.lang.Class<T> clazz,
                                                                           boolean includeExercised)
Specified by:
getSpecialProperties in interface GameManagerI

getName

public java.lang.String getName()
Get name of the GM instance. Currently, the name is fixed, but that will change whenever a multi-game server will be implemented.

Specified by:
getName in interface MoveableHolder

getGMKey

public java.lang.String getGMKey()
Specified by:
getGMKey in interface GameManagerI

getMoveStack

public MoveStack getMoveStack()
Specified by:
getMoveStack in interface GameManagerI

getDisplayBuffer

public DisplayBuffer getDisplayBuffer()
Specified by:
getDisplayBuffer in interface GameManagerI

addToNextPlayerMessages

public void addToNextPlayerMessages(java.lang.String s,
                                    boolean undoable)
Specified by:
addToNextPlayerMessages in interface GameManagerI

getReportBuffer

public ReportBuffer getReportBuffer()
Specified by:
getReportBuffer in interface GameManagerI

getUIHints

public GuiHints getUIHints()
Specified by:
getUIHints in interface GameManagerI

getCorrectionManager

public CorrectionManagerI getCorrectionManager(CorrectionType ct)
Specified by:
getCorrectionManager in interface GameManagerI

getCompaniesInRunningOrder

public java.util.List<PublicCompanyI> getCompaniesInRunningOrder()
Return a list of companies in operation order.

Note that, unlike Round.setOperatingCompanies(), this method does not check if the companies are actualy allowed to operate. One purpose is to check for upping the share price at the end of an SR un sucn a way, that the token order gets preserved.

Specified by:
getCompaniesInRunningOrder in interface GameManagerI
Returns:

isReloading

public boolean isReloading()
Specified by:
isReloading in interface GameManagerI

setReloading

public void setReloading(boolean reloading)
Specified by:
setReloading in interface GameManagerI

setSkipDone

public void setSkipDone(GameDef.OrStep step)
Specified by:
setSkipDone in interface GameManagerI

reorderPlayersByCash

public Player reorderPlayersByCash(boolean ascending)
Specified by:
reorderPlayersByCash in interface GameManagerI
Parameters:
ascending - Boolean to determine if the playerlist will be sorted in ascending or descending order based on their cash
Returns:
Returns the player at index position 0 that is either the player with the most or least cash depending on sort order.