Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6460/rails/game Modified Files: StartRound.java StockRound.java StockMarket.java GameManagerI.java Game.java ComponentManager.java GameManager.java Log Message: More rationalising of static method usage Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** StartRound.java 7 Oct 2009 21:03:36 -0000 1.28 --- StartRound.java 29 Oct 2009 19:41:28 -0000 1.29 *************** *** 55,59 **** public void start() { ! this.variant = Game.getGameOption(GameManager.VARIANT_KEY); if (variant == null) variant = ""; numPlayers = gameManager.getNumberOfPlayers(); --- 55,59 ---- public void start() { ! this.variant = gameManager.getGameOption(GameManager.VARIANT_KEY); if (variant == null) variant = ""; numPlayers = gameManager.getNumberOfPlayers(); Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** GameManager.java 9 Oct 2009 22:29:01 -0000 1.62 --- GameManager.java 29 Oct 2009 19:41:29 -0000 1.63 *************** *** 52,55 **** --- 52,57 ---- protected Bank bank; + protected Map<String, String> gameOptions; + protected List<Player> players; protected List<String> playerNames; *************** *** 400,405 **** } ! public void startGame() { setGameParameters(); --- 402,408 ---- } ! public void startGame(Map<String,String> gameOptions) { + this.gameOptions = gameOptions; setGameParameters(); *************** *** 1032,1035 **** --- 1035,1042 ---- } + public String getGameOption (String key) { + return gameOptions.get(key); + } + // TODO Should be removed public void initialiseNewPhase(PhaseI phase) { Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Game.java 9 Oct 2009 22:29:01 -0000 1.32 --- Game.java 29 Oct 2009 19:41:29 -0000 1.33 *************** *** 69,73 **** public void start() { ! gameManager.startGame(); } --- 69,73 ---- public void start() { ! gameManager.startGame(gameOptions); } *************** *** 89,93 **** } ! ComponentManager.configureInstance(name, componentManagerTag); componentManager = ComponentManager.getInstance(); --- 89,93 ---- } ! ComponentManager.configureInstance(name, componentManagerTag, gameOptions); componentManager = ComponentManager.getInstance(); *************** *** 170,174 **** playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); --- 170,174 ---- playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); *************** *** 255,265 **** * @return The company manager */ - public static CompanyManagerI getCompanyManager() { - return instance.companyManager; - } - - /** - * @return The company manager - */ public static StockMarketI getStockMarket() { return instance.stockMarket; --- 255,258 ---- Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** StockMarket.java 9 Oct 2009 20:20:34 -0000 1.19 --- StockMarket.java 29 Oct 2009 19:41:28 -0000 1.20 *************** *** 146,150 **** public void finishConfiguration (GameManager gameManager) { ! for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { if (!comp.hasStarted() && comp.getStartSpace() != null) { comp.getStartSpace().addFixedStartPrice(comp); --- 146,150 ---- public void finishConfiguration (GameManager gameManager) { ! for (PublicCompanyI comp : GameManager.getInstance().getCompanyManager().getAllPublicCompanies()) { if (!comp.hasStarted() && comp.getStartSpace() != null) { comp.getStartSpace().addFixedStartPrice(comp); Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** StockRound.java 7 Oct 2009 19:00:38 -0000 1.46 --- StockRound.java 29 Oct 2009 19:41:28 -0000 1.47 *************** *** 1247,1251 **** // Over the hold limit of any company? ! for (PublicCompanyI company : Game.getCompanyManager().getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() && !mayPlayerBuyCompanyShare(player, company, 0)) return true; --- 1247,1251 ---- // Over the hold limit of any company? ! for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() && !mayPlayerBuyCompanyShare(player, company, 0)) return true; Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ComponentManager.java 15 Jan 2009 20:53:28 -0000 1.12 --- ComponentManager.java 29 Oct 2009 19:41:29 -0000 1.13 *************** *** 35,38 **** --- 35,40 ---- private List<Tag> componentTags; + private Map<String, String> gameOptions; + protected static Logger log = Logger.getLogger(ComponentManager.class.getPackage().getName()); *************** *** 47,51 **** } ! public static synchronized void configureInstance(String gameName, Tag tag) throws ConfigurationException { if (instance != null) { --- 49,54 ---- } ! public static synchronized void configureInstance(String gameName, Tag tag, ! Map<String, String> gameOptions) throws ConfigurationException { if (instance != null) { *************** *** 53,62 **** LocalText.getText("ComponentManagerNotReconfigured")); } ! new ComponentManager(gameName, tag); } ! private ComponentManager(String gameName, Tag tag) throws ConfigurationException { instance = this; ComponentManager.gameName = gameName; --- 56,67 ---- LocalText.getText("ComponentManagerNotReconfigured")); } ! new ComponentManager(gameName, tag, gameOptions); } ! private ComponentManager(String gameName, Tag tag, Map<String, String> gameOptions) throws ConfigurationException { + instance = this; + this.gameOptions = gameOptions; ComponentManager.gameName = gameName; *************** *** 82,86 **** } ! private static void configureComponent(Tag componentTag) throws ConfigurationException { --- 87,91 ---- } ! private void configureComponent(Tag componentTag) throws ConfigurationException { Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GameManagerI.java 9 Oct 2009 22:29:01 -0000 1.18 --- GameManagerI.java 29 Oct 2009 19:41:28 -0000 1.19 *************** *** 2,5 **** --- 2,6 ---- import java.util.List; + import java.util.Map; import rails.common.Defs; *************** *** 19,23 **** TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, TileManager tileManager, Bank bank); ! public abstract void startGame(); public abstract CompanyManagerI getCompanyManager(); --- 20,24 ---- TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, TileManager tileManager, Bank bank); ! public abstract void startGame(Map<String, String> gameOptions); public abstract CompanyManagerI getCompanyManager(); *************** *** 152,155 **** --- 153,158 ---- public Bank getBank (); + public String getGameOption (String key); + public int getPlayerCertificateLimit(); public void setPlayerCertificateLimit(int newLimit); |