You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: Erik V. <ev...@us...> - 2009-10-07 19:00:56
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/specific/_18EU Modified Files: FinalMinorExchangeRound.java StartRound_18EU.java StockRound_18EU.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: StockRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StockRound_18EU.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** StockRound_18EU.java 25 Sep 2009 19:13:01 -0000 1.24 --- StockRound_18EU.java 7 Oct 2009 19:00:39 -0000 1.25 *************** *** 5,9 **** import rails.game.*; import rails.game.action.*; ! import rails.game.move.*; import rails.game.state.BooleanState; import rails.game.state.IntegerState; --- 5,10 ---- import rails.game.*; import rails.game.action.*; ! import rails.game.move.AddToList; ! import rails.game.move.CashMove; import rails.game.state.BooleanState; import rails.game.state.IntegerState; *************** *** 376,380 **** } ! MoveSet.start(true); // All is OK, now start the company --- 377,381 ---- } ! moveStack.start(true); // All is OK, now start the company *************** *** 493,497 **** // TODO Validation to be added? ! MoveSet.start(true); if (major != null) { --- 494,498 ---- // TODO Validation to be added? ! moveStack.start(true); if (major != null) { *************** *** 636,642 **** /* End of validation, start of execution */ ! MoveSet.start(false); // ! if (action.isForced()) MoveSet.setLinkedToPrevious(); pool.buyTrain(train, 0); --- 637,643 ---- /* End of validation, start of execution */ ! moveStack.start(false); // ! if (action.isForced()) moveStack.setLinkedToPrevious(); pool.buyTrain(train, 0); Index: StartRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartRound_18EU.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StartRound_18EU.java 15 Jan 2009 20:53:28 -0000 1.7 --- StartRound_18EU.java 7 Oct 2009 19:00:39 -0000 1.8 *************** *** 4,8 **** import rails.game.*; import rails.game.action.*; - import rails.game.move.MoveSet; import rails.game.state.IntegerState; import rails.game.state.State; --- 4,7 ---- *************** *** 145,149 **** } ! MoveSet.start(false); assignItem(player, item, price, 0); --- 144,148 ---- } ! moveStack.start(false); assignItem(player, item, price, 0); *************** *** 229,233 **** } ! MoveSet.start(false); if (getStep() == SELECT_STEP) { --- 228,232 ---- } ! moveStack.start(false); if (getStep() == SELECT_STEP) { *************** *** 294,298 **** ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! MoveSet.start(false); StartItem auctionedItem = (StartItem) currentAuctionItem.getObject(); --- 293,297 ---- ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! moveStack.start(false); StartItem auctionedItem = (StartItem) currentAuctionItem.getObject(); Index: FinalMinorExchangeRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/FinalMinorExchangeRound.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FinalMinorExchangeRound.java 15 Jan 2009 20:53:28 -0000 1.7 --- FinalMinorExchangeRound.java 7 Oct 2009 19:00:38 -0000 1.8 *************** *** 7,11 **** import rails.game.action.MergeCompanies; import rails.game.action.NullAction; - import rails.game.move.MoveSet; import rails.util.LocalText; --- 7,10 ---- *************** *** 95,99 **** public boolean done(String playerName) { ! MoveSet.start(false); for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { --- 94,98 ---- public boolean done(String playerName) { ! moveStack.start(false); for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:52
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game Modified Files: StartRound.java StartRound_1835.java StockRound.java ShareSellingRound.java OperatingRound.java PhaseManager.java GameManagerI.java StartRound_1830.java Round.java PublicCompany.java TreasuryShareRound.java GameManager.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TreasuryShareRound.java 25 Sep 2009 19:13:01 -0000 1.13 --- TreasuryShareRound.java 7 Oct 2009 19:00:38 -0000 1.14 *************** *** 9,13 **** import rails.game.action.*; - import rails.game.move.MoveSet; import rails.game.state.BooleanState; import rails.util.LocalText; --- 9,12 ---- *************** *** 352,356 **** } ! MoveSet.start(true); PublicCertificateI cert2; for (int i = 0; i < number; i++) { --- 351,355 ---- } ! moveStack.start(true); PublicCertificateI cert2; for (int i = 0; i < number; i++) { *************** *** 473,477 **** } ! MoveSet.start(true); ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", --- 472,476 ---- } ! moveStack.start(true); ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", *************** *** 511,515 **** } ! MoveSet.start(false); // Inform GameManager --- 510,514 ---- } ! moveStack.start(false); // Inform GameManager Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** PublicCompany.java 6 Oct 2009 18:34:04 -0000 1.64 --- PublicCompany.java 7 Oct 2009 19:00:38 -0000 1.65 *************** *** 1400,1407 **** Player player; int share; for (int i = presIndex + 1; i < presIndex ! + GameManager.getInstance().getNumberOfPlayers(); i++) { ! player = GameManager.getInstance().getPlayerByIndex(i); share = player.getPortfolio().getShare(this); if (share > presShare) { --- 1400,1408 ---- Player player; int share; + GameManagerI gmgr = GameManager.getInstance(); for (int i = presIndex + 1; i < presIndex ! + gmgr.getNumberOfPlayers(); i++) { ! player = gmgr.getPlayerByIndex(i); share = player.getPortfolio().getShare(this); if (share > presShare) { Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** StartRound.java 25 Sep 2009 19:29:56 -0000 1.26 --- StartRound.java 7 Oct 2009 19:00:38 -0000 1.27 *************** *** 6,10 **** import rails.game.action.*; import rails.game.model.ModelObject; - import rails.game.move.MoveSet; import rails.game.state.IntegerState; import rails.game.state.State; --- 6,9 ---- *************** *** 227,231 **** } ! MoveSet.start(false); assignItem(player, item, price, sharePrice); --- 226,230 ---- } ! moveStack.start(false); assignItem(player, item, price, sharePrice); Index: PhaseManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PhaseManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PhaseManager.java 11 Sep 2009 19:27:23 -0000 1.15 --- PhaseManager.java 7 Oct 2009 19:00:38 -0000 1.16 *************** *** 4,7 **** --- 4,9 ---- import java.util.*; + import org.apache.log4j.Logger; + import rails.game.state.State; import rails.util.Tag; *************** *** 18,21 **** --- 20,26 ---- protected GameManagerI gameManager; + protected static Logger log = + Logger.getLogger(PhaseManager.class.getPackage().getName()); + public PhaseManager() {} Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** GameManager.java 6 Oct 2009 18:34:04 -0000 1.56 --- GameManager.java 7 Oct 2009 19:00:38 -0000 1.57 *************** *** 7,10 **** --- 7,11 ---- import org.apache.log4j.Logger; + import org.apache.log4j.NDC; import rails.common.Defs; *************** *** 99,103 **** protected int stockRoundSequenceRule = StockRound.SELL_BUY_SELL; ! protected static GameManager instance; protected String name; --- 100,140 ---- protected int stockRoundSequenceRule = StockRound.SELL_BUY_SELL; ! //protected static GameManager instance; ! /** ! * 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. ! * ! * <p>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. ! * <p>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 furtire it will probably be moved ! * to the then needed communication interface). The key ! * can be retrieved (via NDC.peek()) anywhere. ! * <p>For now, the key is a fixed string, but that may change in the future. ! */ ! protected static Map<String, GameManagerI> gameManagerMap ! = new HashMap<String, GameManagerI>(); ! ! /** ! * 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. ! */ ! protected static final String GM_KEY = "GM-1"; ! ! /** ! * The MoveSet stack is maintained to enable Undo and Redo throughout the game. ! */ ! protected MoveStack moveStack = new MoveStack(); protected String name; *************** *** 132,136 **** */ public GameManager() { ! instance = this; } --- 169,174 ---- */ public GameManager() { ! //instance = this; ! gameManagerMap.put(GM_KEY, this); } *************** *** 351,354 **** --- 389,395 ---- public void startGame() { + NDC.clear(); + NDC.push (GM_KEY); + setGameParameters(); *************** *** 365,369 **** // Initialisation is complete. Undoability starts here. ! MoveSet.enable(); } --- 406,410 ---- // Initialisation is complete. Undoability starts here. ! moveStack.enable(); } *************** *** 397,402 **** * @return instance of GameManager */ ! public static GameManagerI getInstance() { ! return instance; } --- 438,443 ---- * @return instance of GameManager */ ! public static GameManagerI getInstance () { ! return gameManagerMap.get(NDC.peek()); } *************** *** 438,442 **** } else if (round instanceof StockRound) { PhaseI currentPhase = getCurrentPhase(); ! numOfORs = getCurrentPhase().getNumberOfOperatingRounds(); log.info("Phase=" + currentPhase.getName() + " ORs=" + numOfORs); --- 479,484 ---- } else if (round instanceof StockRound) { PhaseI currentPhase = getCurrentPhase(); ! if (currentPhase == null) log.error ("Current Phase is null??", new Exception ("")); ! numOfORs = currentPhase.getNumberOfOperatingRounds(); log.info("Phase=" + currentPhase.getName() + " ORs=" + numOfORs); *************** *** 572,575 **** --- 614,620 ---- public boolean process(PossibleAction action) { + NDC.clear(); + NDC.push (GM_KEY); + boolean result = true; *************** *** 607,619 **** break; case GameAction.UNDO: ! MoveSet.undo(false); result = true; break; case GameAction.FORCED_UNDO: ! MoveSet.undo(true); result = true; break; case GameAction.REDO: ! MoveSet.redo(); result = true; break; --- 652,664 ---- break; case GameAction.UNDO: ! moveStack.undoMoveSet(false); result = true; break; case GameAction.FORCED_UNDO: ! moveStack.undoMoveSet(true); result = true; break; case GameAction.REDO: ! moveStack.redoMoveSet(); result = true; break; *************** *** 638,648 **** getCurrentRound().setPossibleActions(); ! // MoveSet closing is done here to allow state changes to occur // when setting possible actions if (action != null) { if (result && !(action instanceof GameAction)) { ! if (MoveSet.isOpen()) MoveSet.finish(); } else { ! if (MoveSet.isOpen()) MoveSet.cancel(); } } --- 683,693 ---- getCurrentRound().setPossibleActions(); ! // moveStack closing is done here to allow state changes to occur // when setting possible actions if (action != null) { if (result && !(action instanceof GameAction)) { ! if (moveStack.isOpen()) moveStack.finish(); } else { ! if (moveStack.isOpen()) moveStack.cancel(); } } *************** *** 654,664 **** // Add the Undo/Redo possibleActions here. ! if (MoveSet.isUndoableByPlayer()) { possibleActions.add(new GameAction(GameAction.UNDO)); } ! if (MoveSet.isUndoableByManager()) { possibleActions.add(new GameAction(GameAction.FORCED_UNDO)); } ! if (MoveSet.isRedoable()) { possibleActions.add(new GameAction(GameAction.REDO)); } --- 699,709 ---- // Add the Undo/Redo possibleActions here. ! if (moveStack.isUndoableByPlayer()) { possibleActions.add(new GameAction(GameAction.UNDO)); } ! if (moveStack.isUndoableByManager()) { possibleActions.add(new GameAction(GameAction.FORCED_UNDO)); } ! if (moveStack.isRedoable()) { possibleActions.add(new GameAction(GameAction.REDO)); } *************** *** 674,677 **** --- 719,725 ---- public void processOnReload(List<PossibleAction> actions) throws Exception { + NDC.clear(); + NDC.push (GM_KEY); + for (PossibleAction action : actions) { *************** *** 696,700 **** new AddToList<PossibleAction>(executedActions, action, "ExecutedActions"); ! if (MoveSet.isOpen()) MoveSet.finish(); } } --- 744,748 ---- new AddToList<PossibleAction>(executedActions, action, "ExecutedActions"); ! if (moveStack.isOpen()) moveStack.finish(); } } *************** *** 986,990 **** // TODO The below should be merged into activate() if (phase.doPrivatesClose()) { ! instance.companyManager.closeAllPrivates(); } } --- 1034,1038 ---- // TODO The below should be merged into activate() if (phase.doPrivatesClose()) { ! companyManager.closeAllPrivates(); } } *************** *** 1136,1138 **** --- 1184,1190 ---- } + public MoveStack getMoveStack () { + return moveStack; + } + } Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Round.java 6 Oct 2009 18:34:04 -0000 1.26 --- Round.java 7 Oct 2009 19:00:38 -0000 1.27 *************** *** 12,16 **** import rails.game.action.*; import rails.game.move.CashMove; ! import rails.game.move.MoveSet; import rails.game.special.SpecialPropertyI; import rails.game.state.BooleanState; --- 12,16 ---- import rails.game.action.*; import rails.game.move.CashMove; ! import rails.game.move.MoveStack; import rails.game.special.SpecialPropertyI; import rails.game.state.BooleanState; *************** *** 41,44 **** --- 41,46 ---- protected BooleanState wasInterrupted = new BooleanState ("RoundInterrupted", false); + protected MoveStack moveStack = null; + /** * Constructor with the GameManager, will call setGameManager with the parameter to initialize *************** *** 63,66 **** --- 65,70 ---- stockMarket = aGameManager.getStockMarket(); mapManager = aGameManager.getMapManager(); + + moveStack = aGameManager.getMoveStack(); } *************** *** 167,171 **** } ! MoveSet.start(true); if (exchanged > 0) { --- 171,175 ---- } ! moveStack.start(true); if (exchanged > 0) { *************** *** 264,268 **** int unsoldPercentage = company.getUnsoldPercentage(); - if (unsoldPercentage <= 100 - company.getFloatPercentage()) { // Company floats --- 268,271 ---- Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ShareSellingRound.java 6 Oct 2009 18:34:04 -0000 1.23 --- ShareSellingRound.java 7 Oct 2009 19:00:38 -0000 1.24 *************** *** 10,14 **** import rails.game.action.PossibleAction; import rails.game.action.SellShares; - import rails.game.move.MoveSet; import rails.game.state.IntegerState; import rails.util.LocalText; --- 10,13 ---- *************** *** 41,45 **** } ! public void start(Player sellingPlayer, int cashToRaise, PublicCompanyI unsellableCompany) { log.info("Share selling round started, player=" --- 40,44 ---- } ! public void start(Player sellingPlayer, int cashToRaise, PublicCompanyI unsellableCompany) { log.info("Share selling round started, player=" *************** *** 323,327 **** } ! MoveSet.start(true); ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", --- 322,326 ---- } ! moveStack.start(true); ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", *************** *** 353,357 **** } } ! company.adjustSharePrice (SOLD, numberToSell, gameManager.getStockMarket()); // Check if we still have the presidency --- 352,356 ---- } } ! company.adjustSharePrice (SOLD, numberToSell, gameManager.getStockMarket()); // Check if we still have the presidency Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** OperatingRound.java 6 Oct 2009 18:34:04 -0000 1.70 --- OperatingRound.java 7 Oct 2009 19:00:38 -0000 1.71 *************** *** 5,9 **** import rails.game.action.*; ! import rails.game.move.*; import rails.game.special.*; import rails.game.state.IntegerState; --- 5,10 ---- import rails.game.action.*; ! import rails.game.move.CashMove; ! import rails.game.move.MapChange; import rails.game.special.*; import rails.game.state.IntegerState; *************** *** 155,165 **** if (operate) { - - StringBuffer msg = new StringBuffer(); for (PublicCompanyI company : operatingCompanyArray) { msg.append(",").append(company.getName()); } ! msg.deleteCharAt(0); log.info("Initial operating sequence is "+msg.toString()); --- 156,164 ---- if (operate) { StringBuffer msg = new StringBuffer(); for (PublicCompanyI company : operatingCompanyArray) { msg.append(",").append(company.getName()); } ! if (msg.length() > 0) msg.deleteCharAt(0); log.info("Initial operating sequence is "+msg.toString()); *************** *** 404,408 **** /* End of validation, start of execution */ ! MoveSet.start(true); if (tile != null) { --- 403,407 ---- /* End of validation, start of execution */ ! moveStack.start(true); if (tile != null) { *************** *** 572,576 **** /* End of validation, start of execution */ ! MoveSet.start(true); if (hex.layBaseToken(operatingCompany, station)) { --- 571,575 ---- /* End of validation, start of execution */ ! moveStack.start(true); if (hex.layBaseToken(operatingCompany, station)) { *************** *** 669,673 **** /* End of validation, start of execution */ ! MoveSet.start(true); if (hex.layBonusToken(token, gameManager.getPhaseManager())) { --- 668,672 ---- /* End of validation, start of execution */ ! moveStack.start(true); if (hex.layBonusToken(token, gameManager.getPhaseManager())) { *************** *** 734,738 **** /* End of validation, start of execution */ ! MoveSet.start(true); new CashMove (operatingCompany, seller, cost); --- 733,737 ---- /* End of validation, start of execution */ ! moveStack.start(true); new CashMove (operatingCompany, seller, cost); *************** *** 766,770 **** } ! MoveSet.start(true); int remainingAmount = checkForDeductions (action); --- 765,769 ---- } ! moveStack.start(true); int remainingAmount = checkForDeductions (action); *************** *** 1176,1180 **** public void skip() { log.debug("Skip step " + stepObject.intValue()); ! MoveSet.start(true); nextStep(); } --- 1175,1179 ---- public void skip() { log.debug("Skip step " + stepObject.intValue()); ! moveStack.start(true); nextStep(); } *************** *** 1201,1205 **** } ! MoveSet.start(false); nextStep(); --- 1200,1204 ---- } ! moveStack.start(false); nextStep(); *************** *** 1379,1383 **** /* End of validation, start of execution */ ! MoveSet.start(true); PhaseI previousPhase = getCurrentPhase(); --- 1378,1382 ---- /* End of validation, start of execution */ ! moveStack.start(true); PhaseI previousPhase = getCurrentPhase(); *************** *** 1528,1534 **** /* End of validation, start of execution */ ! MoveSet.start(true); // ! if (action.isForced()) MoveSet.setLinkedToPrevious(); pool.buyTrain(train, 0); --- 1527,1533 ---- /* End of validation, start of execution */ ! moveStack.start(true); // ! if (action.isForced()) moveStack.setLinkedToPrevious(); pool.buyTrain(train, 0); *************** *** 1645,1649 **** } ! MoveSet.start(true); operatingCompany.buyPrivate(privateCompany, player.getPortfolio(), --- 1644,1648 ---- } ! moveStack.start(true); operatingCompany.buyPrivate(privateCompany, player.getPortfolio(), *************** *** 1662,1666 **** if (company.hasDestination() && !company.hasReachedDestination()) { ! if (!MoveSet.isOpen()) MoveSet.start(true); company.setReachedDestination(true); ReportBuffer.add(LocalText.getText("DestinationReached", --- 1661,1665 ---- if (company.hasDestination() && !company.hasReachedDestination()) { ! if (!moveStack.isOpen()) moveStack.start(true); company.setReachedDestination(true); ReportBuffer.add(LocalText.getText("DestinationReached", *************** *** 1691,1695 **** } ! MoveSet.start(true); executeTakeLoans (action); --- 1690,1694 ---- } ! moveStack.start(true); executeTakeLoans (action); *************** *** 1810,1814 **** log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! MoveSet.start(true); gameManager.startShareSellingRound(operatingCompany.getPresident(), cashToBeRaisedByPresident, operatingCompany); --- 1809,1813 ---- log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! moveStack.start(true); gameManager.startShareSellingRound(operatingCompany.getPresident(), cashToBeRaisedByPresident, operatingCompany); *************** *** 1817,1821 **** } ! MoveSet.start(true); if (repayment > 0) executeRepayLoans (action); --- 1816,1820 ---- } ! moveStack.start(true); if (repayment > 0) executeRepayLoans (action); Index: StartRound_1830.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1830.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** StartRound_1830.java 11 Sep 2009 19:27:23 -0000 1.20 --- StartRound_1830.java 7 Oct 2009 19:00:38 -0000 1.21 *************** *** 3,7 **** import rails.game.action.*; - import rails.game.move.MoveSet; import rails.util.LocalText; --- 3,6 ---- *************** *** 154,158 **** } ! /*----- MoveSet methods -----*/ /** * The current player bids on a given start item. --- 153,157 ---- } ! /*----- moveStack methods -----*/ /** * The current player bids on a given start item. *************** *** 234,238 **** } ! MoveSet.start(false); item.setBid(bidAmount, player); --- 233,237 ---- } ! moveStack.start(false); item.setBid(bidAmount, player); *************** *** 288,292 **** ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! MoveSet.start(false); numPasses.add(1); --- 287,291 ---- ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! moveStack.start(false); numPasses.add(1); Index: StartRound_1835.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1835.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** StartRound_1835.java 19 Jul 2009 19:24:21 -0000 1.20 --- StartRound_1835.java 7 Oct 2009 19:00:38 -0000 1.21 *************** *** 6,10 **** import rails.game.action.*; - import rails.game.move.MoveSet; import rails.game.state.IntegerState; import rails.util.LocalText; --- 6,9 ---- *************** *** 147,151 **** } ! /*----- MoveSet methods -----*/ @Override --- 146,150 ---- } ! /*----- moveStack methods -----*/ @Override *************** *** 242,246 **** ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! MoveSet.start(false); numPasses.add(1); --- 241,245 ---- ReportBuffer.add(LocalText.getText("PASSES", playerName)); ! moveStack.start(false); numPasses.add(1); Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** StockRound.java 6 Oct 2009 18:34:04 -0000 1.45 --- StockRound.java 7 Oct 2009 19:00:38 -0000 1.46 *************** *** 4,8 **** import rails.game.action.*; ! import rails.game.move.*; import rails.game.special.*; import rails.game.state.*; --- 4,9 ---- import rails.game.action.*; ! import rails.game.move.CashMove; ! import rails.game.move.DoubleMapChange; import rails.game.special.*; import rails.game.state.*; *************** *** 524,528 **** } ! MoveSet.start(true); // All is OK, now start the company --- 525,529 ---- } ! moveStack.start(true); // All is OK, now start the company *************** *** 702,706 **** // All seems OK, now buy the shares. ! MoveSet.start(true); CashHolder priceRecipient = getSharePriceRecipient (cert, cash); --- 703,707 ---- // All seems OK, now buy the shares. ! moveStack.start(true); CashHolder priceRecipient = getSharePriceRecipient (cert, cash); *************** *** 953,957 **** } ! MoveSet.start(true); if (numberToSell == 1) { --- 954,958 ---- } ! moveStack.start(true); if (numberToSell == 1) { *************** *** 1030,1034 **** if (sp instanceof ExchangeForShare) { ! boolean result = ((ExchangeForShare) sp).execute(this); if (result) hasActed.set(true); return result; --- 1031,1035 ---- if (sp instanceof ExchangeForShare) { ! boolean result = executeExchangeForShare((ExchangeForShare) sp); if (result) hasActed.set(true); return result; *************** *** 1039,1042 **** --- 1040,1113 ---- } + public boolean executeExchangeForShare (ExchangeForShare sp) { + + PublicCompanyI publicCompany = + companyManager.getPublicCompany(sp.getPublicCompanyName()); + PrivateCompanyI privateCompany = sp.getCompany(); + Portfolio portfolio = privateCompany.getPortfolio(); + Player player = null; + String errMsg = null; + boolean ipoHasShare = ipo.getShare(publicCompany) >= sp.getShare(); + boolean poolHasShare = pool.getShare(publicCompany) >= sp.getShare(); + + while (true) { + + /* Check if the private is owned by a player */ + if (!(portfolio.getOwner() instanceof Player)) { + errMsg = + LocalText.getText("PrivateIsNotOwnedByAPlayer", + privateCompany.getName()); + break; + } + + player = (Player) portfolio.getOwner(); + + /* Check if a share is available */ + if (!ipoHasShare && !poolHasShare) { + errMsg = + LocalText.getText("NoSharesAvailable", + publicCompany.getName()); + break; + } + /* Check if the player has room for a share of this company */ + if (!mayPlayerBuyCompanyShare(player, publicCompany, 1)) { + // TODO: Not nice to use '1' here, should be percentage. + errMsg = + LocalText.getText("WouldExceedHoldLimit", + String.valueOf(gameManager.getPlayerShareLimit())); + break; + } + break; + } + if (errMsg != null) { + DisplayBuffer.add(LocalText.getText( + "CannotSwapPrivateForCertificate", + player.getName(), + privateCompany.getName(), + sp.getShare(), + publicCompany.getName(), + errMsg )); + return false; + } + + moveStack.start(true); + + Certificate cert = + ipoHasShare ? ipo.findCertificate(publicCompany, + false) : pool.findCertificate(publicCompany, + false); + //player.buy(cert, 0); + cert.moveTo(player.getPortfolio()); + ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", + player.getName(), + privateCompany.getName(), + sp.getShare(), + publicCompany.getName())); + sp.setExercised(); + privateCompany.setClosed(); + + return true; + } + /** * The current Player passes or is done. *************** *** 1054,1058 **** } ! MoveSet.start(false); if (hasActed.booleanValue()) { --- 1125,1129 ---- } ! moveStack.start(false); if (hasActed.booleanValue()) { Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GameManagerI.java 6 Oct 2009 18:34:04 -0000 1.13 --- GameManagerI.java 7 Oct 2009 19:00:38 -0000 1.14 *************** *** 6,9 **** --- 6,10 ---- import rails.game.action.PossibleAction; import rails.game.model.ModelObject; + import rails.game.move.MoveStack; import rails.game.move.MoveableHolderI; import rails.game.special.SpecialPropertyI; *************** *** 178,180 **** --- 179,184 ---- public <T extends SpecialPropertyI> List<T> getSpecialProperties( Class<T> clazz, boolean includeExercised); + + public MoveStack getMoveStack (); + } \ No newline at end of file |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:51
|
Update of /cvsroot/rails/18xx/rails/game/state In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/state Modified Files: State.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: State.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/state/State.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** State.java 25 Sep 2009 19:13:01 -0000 1.11 --- State.java 7 Oct 2009 19:00:37 -0000 1.12 *************** *** 67,71 **** public void setState(Object object) { this.object = object; ! // log.debug (getClassName() + " "+name+" set to "+object); update(); } --- 67,71 ---- public void setState(Object object) { this.object = object; ! //log.debug (getClassName() + " "+name+" set to "+object); update(); } |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:49
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/special Modified Files: ExchangeForShare.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ExchangeForShare.java 3 Oct 2009 13:59:33 -0000 1.14 --- ExchangeForShare.java 7 Oct 2009 19:00:38 -0000 1.15 *************** *** 3,7 **** import rails.game.*; - import rails.game.move.MoveSet; import rails.util.*; --- 3,6 ---- *************** *** 36,110 **** } - public boolean execute(StockRound round) { - - publicCompany = - Game.getCompanyManager().getPublicCompany(publicCompanyName); - - Portfolio portfolio = privateCompany.getPortfolio(); - Player player = null; - String errMsg = null; - Bank bank = Bank.getInstance(); - boolean ipoHasShare = bank.getIpo().getShare(publicCompany) >= share; - boolean poolHasShare = bank.getPool().getShare(publicCompany) >= share; - - while (true) { - - /* Check if the private is owned by a player */ - if (!(portfolio.getOwner() instanceof Player)) { - errMsg = - LocalText.getText("PrivateIsNotOwnedByAPlayer", - privateCompany.getName()); - break; - } - - player = (Player) portfolio.getOwner(); - - /* Check if a share is available */ - if (!ipoHasShare && !poolHasShare) { - errMsg = - LocalText.getText("NoSharesAvailable", - publicCompanyName); - break; - } - /* Check if the player has room for a share of this company */ - if (!round.mayPlayerBuyCompanyShare(player, publicCompany, 1)) { - // TODO: Not nice to use '1' here, should be percentage. - errMsg = - LocalText.getText("WouldExceedHoldLimit", - String.valueOf(round.getGameManager().getPlayerShareLimit())); - break; - } - break; - } - if (errMsg != null) { - DisplayBuffer.add(LocalText.getText( - "CannotSwapPrivateForCertificate", - player.getName(), - privateCompany.getName(), - share, - publicCompanyName, - errMsg )); - return false; - } - - MoveSet.start(true); - - Certificate cert = - ipoHasShare ? bank.getIpo().findCertificate(publicCompany, - false) : bank.getPool().findCertificate(publicCompany, - false); - //player.buy(cert, 0); - cert.moveTo(player.getPortfolio()); - ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", - player.getName(), - privateCompany.getName(), - share, - publicCompanyName )); - setExercised(); - privateCompany.setClosed(); - - return true; - } - /** * @return Returns the privateCompany. --- 35,38 ---- |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:49
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/specific/_1856 Modified Files: CGRFormationRound.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CGRFormationRound.java 6 Oct 2009 18:34:03 -0000 1.19 --- CGRFormationRound.java 7 Oct 2009 19:00:38 -0000 1.20 *************** *** 6,10 **** import rails.game.action.*; import rails.game.move.CashMove; - import rails.game.move.MoveSet; import rails.game.state.IntegerState; import rails.util.LocalText; --- 6,9 ---- *************** *** 225,229 **** // TODO Validation skipped for now... ! MoveSet.start(true); PublicCompanyI company = action.getCompany(); --- 224,228 ---- // TODO Validation skipped for now... ! moveStack.start(true); PublicCompanyI company = action.getCompany(); *************** *** 771,779 **** /* End of validation, start of execution */ ! MoveSet.start(true); if (train != null) { ! if (action.isForced()) MoveSet.setLinkedToPrevious(); train.moveTo(pool); --- 770,778 ---- /* End of validation, start of execution */ ! moveStack.start(true); if (train != null) { ! if (action.isForced()) moveStack.setLinkedToPrevious(); train.moveTo(pool); |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:46
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/specific/_18AL Modified Files: OperatingRound_18AL.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: OperatingRound_18AL.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/OperatingRound_18AL.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OperatingRound_18AL.java 25 Sep 2009 19:13:01 -0000 1.6 --- OperatingRound_18AL.java 7 Oct 2009 19:00:38 -0000 1.7 *************** *** 8,12 **** import rails.game.action.PossibleAction; import rails.game.move.CashMove; - import rails.game.move.MoveSet; import rails.util.LocalText; --- 8,11 ---- *************** *** 57,61 **** } ! MoveSet.start(true); for (int i = 0; i < trains.size(); i++) { --- 56,60 ---- } ! moveStack.start(true); for (int i = 0; i < trains.size(); i++) { |
From: Erik V. <ev...@us...> - 2009-10-07 19:00:46
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9081/rails/game/move Modified Files: ObjectMove.java MoveSet.java PriceTokenMove.java Added Files: MoveStack.java Log Message: Created basic mechanism to allow more games running in parallel at the server side (which itself will not be implemented anytime soon). NDC is used to assign a key to each GameManager. GameManager.getInstance() uses this to find the correct instance. Using this static method to find the GM from anywhere is now 'blessed'. MoveStack added. MoveSet uses the above to have a separate stack per game. Index: MoveSet.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/MoveSet.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MoveSet.java 4 Jun 2008 19:00:33 -0000 1.11 --- MoveSet.java 7 Oct 2009 19:00:38 -0000 1.12 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: *************** *** 6,16 **** package rails.game.move; ! import java.util.ArrayList; ! import java.util.List; import org.apache.log4j.Logger; ! import rails.game.ReportBuffer; ! import rails.util.LocalText; /** --- 6,15 ---- package rails.game.move; ! import java.util.*; import org.apache.log4j.Logger; ! import rails.game.GameManager; ! import rails.game.GameManagerI; /** *************** *** 19,198 **** public class MoveSet { - private static boolean enabled = false; private List<Move> moves = new ArrayList<Move>(); private boolean undoableByPlayer; /** If TRUE, undoing this move will also undo the previous one. */ private boolean linkedToPrevious = false; - private static MoveSet currentAction = null; - private static List<MoveSet> actionStack = new ArrayList<MoveSet>(); - private static int lastIndex = -1; - protected static Logger log = Logger.getLogger(MoveSet.class.getPackage().getName()); ! private MoveSet(boolean undoableByPlayer) { this.undoableByPlayer = undoableByPlayer; } ! /** ! * Start making moves undoable. Will be called once, after all ! * initialisations are complete. ! */ ! public static void enable() { ! enabled = true; ! } ! ! public static boolean start(boolean undoableByPlayer) { ! log.debug(">>> Start MoveSet (index=" + (lastIndex + 1) + ")"); ! if (currentAction == null) { ! currentAction = new MoveSet(undoableByPlayer); ! while (lastIndex < actionStack.size() - 1) { ! actionStack.remove(actionStack.size() - 1); ! } ! return true; ! } else { ! log.warn("MoveSet is already open"); ! return false; ! } ! } ! ! public static boolean finish() { ! log.debug("<<< Finish MoveSet (index=" + (lastIndex + 1) + ")"); ! if (currentAction == null) { ! log.warn("No action open for finish"); ! return false; ! } else if (currentAction.isEmpty()) { ! log.warn("Action to finish is empty and will be discarded"); ! currentAction = null; ! return true; ! } else { ! actionStack.add(currentAction); ! lastIndex++; ! currentAction = null; ! return true; ! } ! } ! ! public static boolean cancel() { ! if (currentAction != null) { ! currentAction.unexecute(); ! currentAction = null; ! return true; ! } else { ! log.warn("No action open for cancel"); ! return false; ! } } ! public static boolean add(Move move) { ! ! move.execute(); ! if (!enabled) return true; ! ! if (currentAction != null) { ! currentAction.moves.add(0, move); // Prepare for undo in reverse ! // order! ! log.debug("Done: " + move); ! return true; ! } else { ! // Uncomment one of the next statements to detect un-undoable ! // actions ! log.warn("No MoveSet open for " + move); ! return false; ! } ! } ! public static void setLinkedToPrevious() { ! if (currentAction != null) { ! currentAction.linkedToPrevious = true; ! } else { ! log.warn("No MoveSet open"); } } ! public static boolean undo(boolean forced) { ! if ((forced || isUndoableByPlayer()) && currentAction == null ! && lastIndex >= 0 && lastIndex < actionStack.size()) { ! MoveSet undoAction; ! do { ! ReportBuffer.add(LocalText.getText("UNDO")); ! // log.debug ("MoveSet undo index is "+lastIndex); ! undoAction = (MoveSet) actionStack.get(lastIndex--); ! undoAction.unexecute(); ! } while (undoAction.linkedToPrevious); ! return true; ! } else { ! log.error("Invalid undo: index=" + lastIndex + " size=" ! + actionStack.size() + " currentAction=" + currentAction ! + " forced=" + forced + " byPlayer=" ! + isUndoableByPlayer()); ! return false; ! } ! } ! public static boolean redo() { ! if (currentAction == null && lastIndex < actionStack.size() - 1) { ! ReportBuffer.add(LocalText.getText("REDO")); ! ((MoveSet) actionStack.get(++lastIndex)).execute(); ! // log.debug ("MoveSet redo index is "+lastIndex); ! return true; ! } else { ! log.error("Invalid redo: index=" + lastIndex + " size=" ! + actionStack.size()); ! return false; } } ! public static boolean isUndoableByPlayer() { ! return lastIndex >= 0 && actionStack.get(lastIndex).undoableByPlayer; } ! public static boolean isRedoable() { ! return lastIndex < actionStack.size() - 1; } ! public static boolean isUndoableByManager() { ! return lastIndex >= 0; } ! public static boolean isOpen() { ! return currentAction != null; } ! /** ! * Clear the whole stack. To be used if a state change occurs that cannot ! * (yet) be undone. ! * ! * @return ! */ ! public static boolean clear() { ! if (currentAction != null) currentAction.execute(); ! actionStack.clear(); ! currentAction = null; ! lastIndex = -1; ! return true; ! ! } ! private void execute() { ! for (Move move : moves) { ! move.execute(); ! log.debug("Redone: " + move); ! } } ! private void unexecute() { ! ! // TODO Should not the move order be reversed? ! for (Move move : moves) { ! move.undo(); ! log.debug("Undone: " + move); ! } } - private boolean isEmpty() { - return moves.isEmpty(); - } } --- 18,94 ---- public class MoveSet { private List<Move> moves = new ArrayList<Move>(); + private List<Move> reversedMoves = null; private boolean undoableByPlayer; /** If TRUE, undoing this move will also undo the previous one. */ private boolean linkedToPrevious = false; protected static Logger log = Logger.getLogger(MoveSet.class.getPackage().getName()); ! protected MoveSet(boolean undoableByPlayer) { this.undoableByPlayer = undoableByPlayer; } ! protected void addMove (Move move) { ! moves.add(move); ! log.debug("Done: " + move); } ! protected void reexecute() { ! for (Move move : moves) { ! move.execute(); ! log.debug("Redone: " + move); } } ! protected void unexecute() { ! // Create a reversed move list, if not yet done ! if (reversedMoves == null) { ! reversedMoves = new ArrayList<Move>(moves); ! Collections.reverse(reversedMoves); ! } ! for (Move move : reversedMoves) { ! move.undo(); ! log.debug("Undone: " + move); } } ! protected boolean isEmpty() { ! return moves.isEmpty(); } ! public void setLinkedToPrevious() { ! linkedToPrevious = true; } ! protected boolean isLinkedToPrevious() { ! return linkedToPrevious; } ! protected boolean isUndoableByPlayer () { ! return undoableByPlayer; } ! /* Static methods to enable access from anywhere */ ! protected static void add (Move move) { ! move.execute(); ! MoveStack moveStack = getMoveStack(); ! if (moveStack != null) moveStack.addMove(move); } ! private static MoveStack getMoveStack () { ! GameManagerI gameManager = GameManager.getInstance(); ! if (gameManager != null) { ! return gameManager.getMoveStack(); ! } else { ! // No GM during game setup; no problem, as MoveSets are not yet enabled then. ! return null; ! } } } Index: PriceTokenMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/PriceTokenMove.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PriceTokenMove.java 25 Sep 2009 19:29:56 -0000 1.4 --- PriceTokenMove.java 7 Oct 2009 19:00:38 -0000 1.5 *************** *** 1,4 **** /* $Header$ ! * * Created on 22-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 22-Jul-2006 * Change Log: *************** *** 6,13 **** package rails.game.move; ! import rails.game.PublicCompanyI; ! import rails.game.StockMarket; ! import rails.game.StockMarketI; ! import rails.game.StockSpaceI; /** --- 6,10 ---- package rails.game.move; ! import rails.game.*; /** *************** *** 30,44 **** } ! public boolean execute() { stockMarket.processMove(company, from, to); return true; } ! public boolean undo() { stockMarket.processMove(company, to, from); return true; } ! public String toString() { return "PriceTokenMove: " + company.getName() + " from " + from + " to " + to; --- 27,44 ---- } ! @Override ! public boolean execute() { stockMarket.processMove(company, from, to); return true; } ! @Override ! public boolean undo() { stockMarket.processMove(company, to, from); return true; } ! @Override ! public String toString() { return "PriceTokenMove: " + company.getName() + " from " + from + " to " + to; --- NEW FILE: MoveStack.java --- /* $Header: /cvsroot/rails/18xx/rails/game/move/MoveStack.java,v 1.1 2009/10/07 19:00:38 evos Exp $ * * Created on 17-Jul-2006 * Change Log: */ package rails.game.move; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import rails.game.ReportBuffer; import rails.util.LocalText; /** * This class represent one game's complete "move stack", which is a list * of MoveSets. Each MoveSet contains the (low-level) changes caused by * one particular player action. * <p>The only purpose of the move stack is to enable Undo and Redo. * @author Erik Vos */ public class MoveStack { private MoveSet currentMoveSet = null; private List<MoveSet> moveStack = new ArrayList<MoveSet>(); private int lastIndex = -1; private boolean enabled = false; protected static Logger log = Logger.getLogger(MoveStack.class.getPackage().getName()); public MoveStack () { } /** * Start making moves undoable. Will be called once, after all * initialisations are complete. */ public void enable() { enabled = true; } public boolean start(boolean undoableByPlayer) { log.debug(">>> Start MoveSet(index=" + (lastIndex + 1) + ")"); if (currentMoveSet == null) { currentMoveSet = new MoveSet(undoableByPlayer); while (lastIndex < moveStack.size() - 1) { moveStack.remove(moveStack.size() - 1); } return true; } else { log.warn("MoveStack is already open"); return false; } } public boolean finish() { log.debug("<<< Finish MoveSet (index=" + (lastIndex + 1) + ")"); if (currentMoveSet == null) { log.warn("No action open for finish"); return false; } else if (currentMoveSet.isEmpty()) { log.warn("Action to finish is empty and will be discarded"); currentMoveSet = null; return true; } else { moveStack.add(currentMoveSet); lastIndex++; currentMoveSet = null; return true; } } public boolean cancel() { if (currentMoveSet != null) { currentMoveSet.unexecute(); currentMoveSet = null; return true; } else { log.warn("No action open for cancel"); return false; } } public boolean addMove (Move move) { if (!enabled) return true; if (currentMoveSet != null) { currentMoveSet.addMove(move); return true; } else { log.warn("No MoveSet open for " + move); return false; } } public void setLinkedToPrevious() { if (currentMoveSet != null) { currentMoveSet.setLinkedToPrevious(); } else { log.warn("No MoveSet open"); } } public boolean undoMoveSet (boolean forced) { if (lastIndex >= 0 && lastIndex < moveStack.size() && (forced || moveStack.get(lastIndex).isUndoableByPlayer()) && currentMoveSet == null) { MoveSet undoAction; do { ReportBuffer.add(LocalText.getText("UNDO")); // log.debug ("MoveStack undo index is "+lastIndex); undoAction = moveStack.get(lastIndex--); undoAction.unexecute(); } while (undoAction.isLinkedToPrevious()); return true; } else { log.error("Invalid undo: index=" + lastIndex + " size=" + moveStack.size() + " currentAction=" + currentMoveSet + " forced=" + forced + " byPlayer=" + isUndoableByPlayer()); return false; } } public boolean redoMoveSet () { if (currentMoveSet == null && lastIndex < moveStack.size() - 1) { ReportBuffer.add(LocalText.getText("REDO")); (moveStack.get(++lastIndex)).reexecute(); // log.debug ("MoveStack redo index is "+lastIndex); return true; } else { log.error("Invalid redo: index=" + lastIndex + " size=" + moveStack.size()); return false; } } public boolean isUndoableByPlayer() { return lastIndex >= 0 && moveStack.get(lastIndex).isUndoableByPlayer(); } public boolean isRedoable() { return lastIndex < moveStack.size() - 1; } public boolean isUndoableByManager() { return lastIndex >= 0; } public boolean isOpen() { return currentMoveSet != null; } } Index: ObjectMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/ObjectMove.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ObjectMove.java 4 Jun 2008 19:00:33 -0000 1.5 --- ObjectMove.java 7 Oct 2009 19:00:38 -0000 1.6 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: *************** *** 22,26 **** * a Base Token lay, which is physically removed from a PublicCompany and * added to a Station on a MapHex. ! * * @param moveableObject The moveableObject to be moved (e.g. a BaseToken). * @param from Where the moveableObject is removed from (e.g. a --- 22,26 ---- * a Base Token lay, which is physically removed from a PublicCompany and * added to a Station on a MapHex. ! * * @param moveableObject The moveableObject to be moved (e.g. a BaseToken). * @param from Where the moveableObject is removed from (e.g. a *************** *** 40,50 **** } ! public boolean execute() { ! return (from == null || from.removeObject(moveableObject)) && to.addObject(moveableObject); } ! public boolean undo() { return to.removeObject(moveableObject) --- 40,52 ---- } ! @Override ! public boolean execute() { ! return (from == null || from.removeObject(moveableObject)) && to.addObject(moveableObject); } ! @Override ! public boolean undo() { return to.removeObject(moveableObject) *************** *** 52,56 **** } ! public String toString() { if (moveableObject == null) log.error("Token is null"); if (from == null) log.warn("From is null"); --- 54,59 ---- } ! @Override ! public String toString() { if (moveableObject == null) log.error("Token is null"); if (from == null) log.warn("From is null"); |
From: Erik V. <ev...@us...> - 2009-10-07 18:56:37
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8689/rails/game/specific/_1856 Modified Files: OperatingRound_1856.java Log Message: Fixed bug that OR did not end if last-running company bought first 6-train and CGR formed. Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** OperatingRound_1856.java 6 Oct 2009 18:34:03 -0000 1.23 --- OperatingRound_1856.java 7 Oct 2009 18:56:22 -0000 1.24 *************** *** 485,491 **** //} ! if (operatingCompany != null) { ! operatingCompanyIndex = companies.indexOf(operatingCompany); ! } for (PublicCompanyI c : companies) { --- 485,491 ---- //} ! //if (operatingCompany != null) { ! // operatingCompanyIndex = companies.indexOf(operatingCompany); ! //} for (PublicCompanyI c : companies) { *************** *** 507,511 **** } else { message = LocalText.getText("CannotOperate", cgr.getName()); ! } } else { message = LocalText.getText("DoesNotForm", cgr.getName()); --- 507,515 ---- } else { message = LocalText.getText("CannotOperate", cgr.getName()); ! // Find the first company that has not yet operated ! // and is not closed. ! while (setNextOperatingCompany(false) ! && operatingCompany.isClosed()); ! } } else { message = LocalText.getText("DoesNotForm", cgr.getName()); *************** *** 515,521 **** operatingCompanyArray = companies.toArray(new PublicCompanyI[0]); - operatingCompanyIndexObject.set(operatingCompanyIndex); ! log.debug ("Next operating company: "+operatingCompany.getName()); } --- 519,530 ---- operatingCompanyArray = companies.toArray(new PublicCompanyI[0]); ! if (operatingCompanyIndex < operatingCompanyArray.length) { ! operatingCompanyIndexObject.set(operatingCompanyIndex); ! log.debug ("Next operating company: "+operatingCompany.getName()); ! } else { ! finishOR(); ! } ! } |
From: Erik V. <ev...@us...> - 2009-10-06 18:34:24
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4108/rails/game Modified Files: PublicCompanyI.java StockRound.java ShareSellingRound.java RoundI.java OperatingRound.java GameManagerI.java Round.java PublicCompany.java GameManager.java Log Message: CGR pres. must buy 2nd shars at first opportunity if not yet owned Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** PublicCompany.java 3 Oct 2009 14:02:28 -0000 1.63 --- PublicCompany.java 6 Oct 2009 18:34:04 -0000 1.64 *************** *** 672,676 **** } } ! if (destinationHexName != null) { destinationHex = mapManager.getHex(destinationHexName); --- 672,676 ---- } } ! if (destinationHexName != null) { destinationHex = mapManager.getHex(destinationHexName); *************** *** 907,912 **** public void setClosed() { super.setClosed(); for (PublicCertificateI cert : certificates) { ! cert.moveTo(bank.getScrapHeap()); } lastRevenue.setOption(MoneyModel.SUPPRESS_ZERO); --- 907,915 ---- public void setClosed() { super.setClosed(); + Portfolio scrapHeap = bank.getScrapHeap(); for (PublicCertificateI cert : certificates) { ! if (cert.getHolder() != scrapHeap) { ! cert.moveTo(scrapHeap); ! } } lastRevenue.setOption(MoneyModel.SUPPRESS_ZERO); *************** *** 1493,1497 **** // Move the money ! if (price > 0) new CashMove(bank, from.owner, price); privatesCostThisTurn.add(price); --- 1496,1500 ---- // Move the money ! if (price > 0) new CashMove(this, from.owner, price); privatesCostThisTurn.add(price); *************** *** 1821,1823 **** --- 1824,1832 ---- return clone; } + + /** Extra codes to be added to the president's indicator in the Game Status window. + * Normally nothing (see 1856 CGR for an exception). */ + public String getExtraShareMarks () { + return ""; + } } Index: RoundI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/RoundI.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RoundI.java 19 Jul 2009 19:24:21 -0000 1.11 --- RoundI.java 6 Oct 2009 18:34:04 -0000 1.12 *************** *** 26,28 **** --- 26,30 ---- public boolean wasInterrupted (); + + public void resume(); } Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** GameManager.java 3 Oct 2009 14:02:28 -0000 1.55 --- GameManager.java 6 Oct 2009 18:34:04 -0000 1.56 *************** *** 550,558 **** * @see rails.game.GameManagerI#startShareSellingRound(rails.game.OperatingRound, rails.game.PublicCompanyI, int) */ ! public void startShareSellingRound(OperatingRound or, ! PublicCompanyI companyNeedingTrain, int cashToRaise) { interruptedRound = getCurrentRound(); ! createRound (ShareSellingRound.class, interruptedRound).start(); } --- 550,559 ---- * @see rails.game.GameManagerI#startShareSellingRound(rails.game.OperatingRound, rails.game.PublicCompanyI, int) */ ! public void startShareSellingRound(Player player, int cashToRaise, ! PublicCompanyI unsellableCompany) { interruptedRound = getCurrentRound(); ! createRound (ShareSellingRound.class, interruptedRound) ! .start(player, cashToRaise, unsellableCompany); } *************** *** 630,636 **** new AddToList<PossibleAction>(executedActions, action, "ExecutedActions"); - if (MoveSet.isOpen()) MoveSet.finish(); - } else { - if (MoveSet.isOpen()) MoveSet.cancel(); } } --- 631,634 ---- *************** *** 640,643 **** --- 638,651 ---- getCurrentRound().setPossibleActions(); + // MoveSet closing is done here to allow state changes to occur + // when setting possible actions + if (action != null) { + if (result && !(action instanceof GameAction)) { + if (MoveSet.isOpen()) MoveSet.finish(); + } else { + if (MoveSet.isOpen()) MoveSet.cancel(); + } + } + for (PossibleAction pa : possibleActions.getList()) { log.debug(((Player) currentPlayer.getObject()).getName() + " may: " *************** *** 721,726 **** */ public void finishShareSellingRound() { ! setRound(interruptedRound); ! ((OperatingRound) getCurrentRound()).resume(); } --- 729,734 ---- */ public void finishShareSellingRound() { ! setRound(interruptedRound); ! getCurrentRound().resume(); } *************** *** 961,965 **** return stockMarket; } ! public MapManager getMapManager() { return mapManager; --- 969,973 ---- return stockMarket; } ! public MapManager getMapManager() { return mapManager; Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Round.java 3 Oct 2009 14:02:28 -0000 1.25 --- Round.java 6 Oct 2009 18:34:04 -0000 1.26 *************** *** 337,340 **** --- 337,348 ---- } + /** Generic stub to resume an interrupted round. + * Only valid if implemented in a subclass. + * + */ + public void resume() { + log.error("Calling Round.resume() is invalid"); + } + public boolean wasInterrupted () { return wasInterrupted.booleanValue(); *************** *** 357,372 **** } - /** - * Who receives the cash when a certificate is bought. - * Normally this is owner of the previously holding portfolio. - * This method must be called <i>before</i> transferring the certificate. - * @param cert - * @param newHolder - * @return - */ - protected CashHolder getSharePriceRecipient (Certificate cert, int price) { - return ((Portfolio)cert.getHolder()).getOwner(); - } - public GameManagerI getGameManager() { return gameManager; --- 365,368 ---- Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** PublicCompanyI.java 23 Sep 2009 21:38:57 -0000 1.36 --- PublicCompanyI.java 6 Oct 2009 18:34:04 -0000 1.37 *************** *** 349,351 **** --- 349,353 ---- public int sharesOwnedByPlayers(); + public String getExtraShareMarks (); + } Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ShareSellingRound.java 25 Sep 2009 19:13:01 -0000 1.22 --- ShareSellingRound.java 6 Oct 2009 18:34:04 -0000 1.23 *************** *** 19,26 **** public class ShareSellingRound extends StockRound { ! OperatingRound or; Player sellingPlayer; - PublicCompanyI companyNeedingCash; IntegerState cashToRaise; /** --- 19,26 ---- public class ShareSellingRound extends StockRound { ! RoundI parentRound; Player sellingPlayer; IntegerState cashToRaise; + PublicCompanyI unsellableCompany = null; /** *************** *** 38,58 **** super (gameManager); ! or = ((OperatingRound) parentRound); ! companyNeedingCash = or.getOperatingCompany(); ! cashToRaise = new IntegerState("CashToRaise", or.getCashToBeRaisedByPresident()); ! sellingPlayer = companyNeedingCash.getPresident(); ! currentPlayer = sellingPlayer; ! setCurrentPlayerIndex(sellingPlayer.getIndex()); ! } ! @Override ! public void start() { ! log.info("Share selling round started"); ReportBuffer.add (LocalText.getText("PlayerMustSellShares", sellingPlayer.getName(), ! Bank.format(cashToRaise.intValue()), ! companyNeedingCash.getName())); ! currentPlayer = sellingPlayer; setPossibleActions(); } --- 38,55 ---- super (gameManager); ! this.parentRound = parentRound; } ! public void start(Player sellingPlayer, int cashToRaise, ! PublicCompanyI unsellableCompany) { ! log.info("Share selling round started, player=" ! +sellingPlayer.getName()+" cash="+cashToRaise); ReportBuffer.add (LocalText.getText("PlayerMustSellShares", sellingPlayer.getName(), ! Bank.format(cashToRaise))); ! currentPlayer = this.sellingPlayer = sellingPlayer; ! this.cashToRaise = new IntegerState("CashToRaise", cashToRaise); ! this.unsellableCompany = unsellableCompany; ! setCurrentPlayerIndex(sellingPlayer.getIndex()); setPossibleActions(); } *************** *** 132,136 **** if (maxShareToSell > share - presidentShare) { dumpAllowed = false; ! if (company != companyNeedingCash) { int playerShare; List<Player> players = gameManager.getPlayers(); --- 129,133 ---- if (maxShareToSell > share - presidentShare) { dumpAllowed = false; ! if (company != unsellableCompany) { int playerShare; List<Player> players = gameManager.getPlayers(); *************** *** 266,270 **** && numberToSell <= presCert.getShares()) { // Not allowed to dump the company that needs the train ! if (company == companyNeedingCash) { errMsg = LocalText.getText("CannotDumpTrainBuyingPresidency"); --- 263,267 ---- && numberToSell <= presCert.getShares()) { // Not allowed to dump the company that needs the train ! if (company == unsellableCompany) { errMsg = LocalText.getText("CannotDumpTrainBuyingPresidency"); *************** *** 387,392 **** } ! public PublicCompanyI getCompanyNeedingTrain() { ! return companyNeedingCash; } --- 384,389 ---- } ! public PublicCompanyI getCompanyNeedingCash() { ! return unsellableCompany; } Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** OperatingRound.java 25 Sep 2009 19:13:01 -0000 1.69 --- OperatingRound.java 6 Oct 2009 18:34:04 -0000 1.70 *************** *** 1385,1390 **** savedAction = action; ! gameManager.startShareSellingRound(this, operatingCompany, ! cashToBeRaisedByPresident); return true; --- 1385,1390 ---- savedAction = action; ! gameManager.startShareSellingRound(operatingCompany.getPresident(), ! cashToBeRaisedByPresident, operatingCompany); return true; *************** *** 1471,1475 **** } ! public void resume() { if (savedAction instanceof BuyTrain) { --- 1471,1476 ---- } ! @Override ! public void resume() { if (savedAction instanceof BuyTrain) { *************** *** 1809,1814 **** log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! gameManager.startShareSellingRound(this, operatingCompany, ! cashToBeRaisedByPresident); return true; } --- 1810,1816 ---- log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! MoveSet.start(true); ! gameManager.startShareSellingRound(operatingCompany.getPresident(), ! cashToBeRaisedByPresident, operatingCompany); return true; } *************** *** 1842,1846 **** remainder = amount - payment; if (payment > 0) { ! new CashMove (operatingCompany, null, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoans", operatingCompany.getName(), --- 1844,1848 ---- remainder = amount - payment; if (payment > 0) { ! new CashMove (operatingCompany, bank, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoans", operatingCompany.getName(), Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** StockRound.java 25 Sep 2009 19:29:56 -0000 1.44 --- StockRound.java 6 Oct 2009 18:34:04 -0000 1.45 *************** *** 44,48 **** static protected final int SELL_BUY = 1; static protected final int SELL_BUY_OR_BUY_SELL = 2; ! /* Action comnstants */ static public final int BOUGHT = 0; --- 44,48 ---- static protected final int SELL_BUY = 1; static protected final int SELL_BUY_OR_BUY_SELL = 2; ! /* Action comnstants */ static public final int BOUGHT = 0; *************** *** 618,622 **** // The presidents share may not be in IPO ! if (company.getPresidentsShare().getHolder() == ipo) { errMsg = LocalText.getText("NotYetStarted", companyName); break; --- 618,625 ---- // The presidents share may not be in IPO ! //if (company.getPresidentsShare().getHolder() == ipo) { ! // There is an exception for 1856 CGR. Just chech 'started', ! // but even this might not be true for e.g. 1835 Prussi ! if (!company.hasStarted()) { errMsg = LocalText.getText("NotYetStarted", companyName); break; *************** *** 777,782 **** * @return */ ! @Override ! protected CashHolder getSharePriceRecipient (Certificate cert, int price) { Portfolio oldHolder = (Portfolio) cert.getHolder(); --- 780,784 ---- * @return */ ! protected CashHolder getSharePriceRecipient (PublicCertificateI cert, int price) { Portfolio oldHolder = (Portfolio) cert.getHolder(); *************** *** 784,788 **** CashHolder recipient; if (cert instanceof PublicCertificateI ! && (comp = ((PublicCertificateI) cert).getCompany()).hasFloated() && oldHolder == ipo && comp.getCapitalisation() == PublicCompanyI.CAPITALISE_INCREMENTAL) { --- 786,790 ---- CashHolder recipient; if (cert instanceof PublicCertificateI ! && (comp = (cert).getCompany()).hasFloated() && oldHolder == ipo && comp.getCapitalisation() == PublicCompanyI.CAPITALISE_INCREMENTAL) { *************** *** 991,995 **** } } ! company.adjustSharePrice (SOLD, numberToSell, gameManager.getStockMarket()); // Check if we still have the presidency --- 993,997 ---- } } ! company.adjustSharePrice (SOLD, numberToSell, gameManager.getStockMarket()); // Check if we still have the presidency *************** *** 1208,1213 **** public boolean mayPlayerBuyCompanyShare(Player player, PublicCompanyI company, int number) { // Check for per-company share limit ! if (player.getPortfolio().getShare(company) ! + number * company.getShareUnit() > gameManager.getPlayerShareLimit() && !company.getCurrentSpace().isNoHoldLimit()) return false; --- 1210,1215 ---- public boolean mayPlayerBuyCompanyShare(Player player, PublicCompanyI company, int number) { // Check for per-company share limit ! if (player.getPortfolio().getShare(company) ! + number * company.getShareUnit() > gameManager.getPlayerShareLimit() && !company.getCurrentSpace().isNoHoldLimit()) return false; *************** *** 1227,1231 **** * overrun the per-company share hold limit. */ ! public int maxAllowedNumberOfSharesToBuy(Player player, PublicCompanyI company, int shareSize) { --- 1229,1233 ---- * overrun the per-company share hold limit. */ ! public int maxAllowedNumberOfSharesToBuy(Player player, PublicCompanyI company, int shareSize) { Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GameManagerI.java 3 Oct 2009 14:02:28 -0000 1.12 --- GameManagerI.java 6 Oct 2009 18:34:04 -0000 1.13 *************** *** 37,42 **** public abstract int getSRNumber(); ! public abstract void startShareSellingRound(OperatingRound or, ! PublicCompanyI companyNeedingTrain, int cashToRaise); public abstract void startTreasuryShareTradingRound(); --- 37,42 ---- public abstract int getSRNumber(); ! public abstract void startShareSellingRound(Player sellingPlayer, ! int cashToRaise, PublicCompanyI unsellableCompany); public abstract void startTreasuryShareTradingRound(); |
From: Erik V. <ev...@us...> - 2009-10-06 18:34:16
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4108/rails/ui/swing Modified Files: StatusWindow.java Log Message: CGR pres. must buy 2nd shars at first opportunity if not yet owned Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** StatusWindow.java 4 Feb 2009 20:36:40 -0000 1.27 --- StatusWindow.java 6 Oct 2009 18:34:04 -0000 1.28 *************** *** 347,351 **** setTitle(LocalText.getText( "EMERGENCY_SHARE_SELLING_TITLE", ! (((ShareSellingRound) currentRound).getCompanyNeedingTrain().getName()))); gameStatus.initTurn(gameUIManager.getCurrentPlayer().getIndex()); gameStatus.setPriorityPlayer(gameUIManager.getPriorityPlayer().getIndex()); --- 347,351 ---- setTitle(LocalText.getText( "EMERGENCY_SHARE_SELLING_TITLE", ! (((ShareSellingRound) currentRound).getCompanyNeedingCash().getName()))); gameStatus.initTurn(gameUIManager.getCurrentPlayer().getIndex()); gameStatus.setPriorityPlayer(gameUIManager.getPriorityPlayer().getIndex()); |
From: Erik V. <ev...@us...> - 2009-10-06 18:34:16
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4108 Modified Files: LocalisedText.properties Log Message: CGR pres. must buy 2nd shars at first opportunity if not yet owned Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** LocalisedText.properties 23 Sep 2009 21:38:57 -0000 1.77 --- LocalisedText.properties 6 Oct 2009 18:34:04 -0000 1.78 *************** *** 128,132 **** DuplicateTilesetID=Duplicate tile {0} in TileSet.xml DuplicateTokenRemoved=Duplicate {0} token on hex {1} returned to company ! EMERGENCY_SHARE_SELLING_TITLE=Rails: Game Status - SELLING SHARES FOR EMERGENCY TRAIN BUYING END_OF_GAME_CLOSE_ALL_WINDOWS=Close all windows END_SR=All players have passed, end of SR {0} --- 128,132 ---- DuplicateTilesetID=Duplicate tile {0} in TileSet.xml DuplicateTokenRemoved=Duplicate {0} token on hex {1} returned to company ! EMERGENCY_SHARE_SELLING_TITLE=Rails: Game Status - SELLING SHARES FOR EMERGENCY CASH RAISING END_OF_GAME_CLOSE_ALL_WINDOWS=Close all windows END_SR=All players have passed, end of SR {0} *************** *** 230,233 **** --- 230,234 ---- MOVE=Move MODERATOR=Moderator + MustBuyExtraShareAsPresident={0} must buy an extra {1} {2}% share to obtain the President's certificate MustRepayLoans={0} must repay {1} loans of {2} for {3} NamesTrain={0} names {1}-train as {2} *************** *** 287,291 **** PlayerIs=Player {0} is {1}. PlayerIsBankrupt={0} is bankrupt. ! PlayerMustSellShares={0} must sell shares to raise at least {1} for {2} PleaseConfirm=Please confirm PleaseSelect=Please select --- 288,292 ---- PlayerIs=Player {0} is {1}. PlayerIsBankrupt={0} is bankrupt. ! PlayerMustSellShares={0} must sell shares to raise at least {1} PleaseConfirm=Please confirm PleaseSelect=Please select |
From: Erik V. <ev...@us...> - 2009-10-06 18:34:14
|
Update of /cvsroot/rails/18xx/rails/game/model In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4108/rails/game/model Modified Files: ShareModel.java Log Message: CGR pres. must buy 2nd shars at first opportunity if not yet owned Index: ShareModel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/model/ShareModel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ShareModel.java 4 Jun 2008 19:00:37 -0000 1.7 --- ShareModel.java 6 Oct 2009 18:34:04 -0000 1.8 *************** *** 2,8 **** package rails.game.model; ! import rails.game.Player; ! import rails.game.Portfolio; ! import rails.game.PublicCompanyI; public class ShareModel extends ModelObject { --- 2,6 ---- package rails.game.model; ! import rails.game.*; public class ShareModel extends ModelObject { *************** *** 41,44 **** --- 39,43 ---- b.append("P"); if (!company.hasFloated()) b.append("U"); + b.append(company.getExtraShareMarks()); } return b.toString(); |
From: Erik V. <ev...@us...> - 2009-10-06 18:34:14
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4108/rails/game/specific/_1856 Modified Files: CGRFormationRound.java PublicCompany_CGR.java StockRound_1856.java OperatingRound_1856.java Log Message: CGR pres. must buy 2nd shars at first opportunity if not yet owned Index: StockRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/StockRound_1856.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** StockRound_1856.java 25 Sep 2009 19:13:01 -0000 1.9 --- StockRound_1856.java 6 Oct 2009 18:34:03 -0000 1.10 *************** *** 2,5 **** --- 2,6 ---- import rails.game.*; + import rails.game.action.BuyCertificate; import rails.util.LocalText; *************** *** 47,51 **** @Override ! protected CashHolder getSharePriceRecipient(Certificate cert, int price) { CashHolder recipient; --- 48,52 ---- @Override ! protected CashHolder getSharePriceRecipient(PublicCertificateI cert, int price) { CashHolder recipient; *************** *** 54,60 **** if (price != 0 && cert instanceof PublicCertificateI && oldHolder == ipo) { ! PublicCompany_1856 comp = (PublicCompany_1856)((PublicCertificateI) cert).getCompany(); switch (comp.getTrainNumberAvailableAtStart()) { --- 55,62 ---- if (price != 0 && cert instanceof PublicCertificateI + && !cert.getCompany().getName().equalsIgnoreCase(PublicCompany_CGR.NAME) && oldHolder == ipo) { ! PublicCompany_1856 comp = (PublicCompany_1856)(cert).getCompany(); switch (comp.getTrainNumberAvailableAtStart()) { *************** *** 74,78 **** // fall through case 5: ! recipient = ((PublicCertificateI)cert).getCompany(); break; case 6: --- 76,80 ---- // fall through case 5: ! recipient = (cert).getCompany(); break; case 6: *************** *** 86,88 **** --- 88,161 ---- } + /** Check for the special condition that the CGR president + * has just bought his second share. + */ + @Override + protected void gameSpecificChecks (Portfolio boughtFrom, + PublicCompanyI company) { + + if (company.getName().equalsIgnoreCase(PublicCompany_CGR.NAME) + && ((PublicCompany_CGR)company).hasTemporaryPresident()) { + log.debug("Resetting temp. president"); + ipo.swapPresidentCertificate(company, + currentPlayer.getPortfolio()); + Player oldPresident = company.getPresident(); + ((PublicCompany_CGR)company).setTemporaryPresident(null); + company.getPresident().getPortfolio().getShareModel(company).update(); + if (currentPlayer != oldPresident) { + oldPresident.getPortfolio().getShareModel(company).update(); + } + } + } + + @Override + public void resume() { + } + + /** Check if the player is president of CGR and must buy a second share */ + @Override + public boolean setPossibleActions() { + + PublicCompany_CGR cgr = + (PublicCompany_CGR)companyManager.getCompanyByName(PublicCompany_CGR.NAME); + if (cgr.hasStarted() && cgr.getPresident() == currentPlayer + && cgr.hasTemporaryPresident()) { + + // Player MUST buy an extra single certificate to obtain + // the President's certificate + int cash = currentPlayer.getCash(); + PublicCertificateI cert1, cert2; + int price1 = 0; + int price2 = 0; + int lowestPrice = 999; + if ((cert1 = ipo.findCertificate(cgr, false)) != null) { + price1 = lowestPrice = cgr.getParPriceModel().getPrice().getPrice(); + } + if ((cert2 = pool.findCertificate(cgr, false)) != null) { + price2 = cgr.getCurrentPriceModel().getPrice().getPrice(); + if (price2 < lowestPrice) lowestPrice = price2; + } + DisplayBuffer.add(LocalText.getText("MustBuyExtraShareAsPresident", + currentPlayer.getName(), + cgr.getName(), + cgr.getShareUnit())); + //log.debug("MustBuyExtraShareMessageAdded", new Exception("HERE")); + if (lowestPrice > cash) { + gameManager.startShareSellingRound(currentPlayer, + lowestPrice - cash, cgr); + } else { + // Player has enough cash + if (cert1 != null && price1 <= cash) { + possibleActions.add(new BuyCertificate(cert1, ipo, price1)); + } + if (cert2 != null && price2 <= cash) { + possibleActions.add(new BuyCertificate(cert2, pool, price2)); + } + } + + return true; + } else { + return super.setPossibleActions(); + } + } } Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CGRFormationRound.java 25 Sep 2009 19:29:56 -0000 1.18 --- CGRFormationRound.java 6 Oct 2009 18:34:03 -0000 1.19 *************** *** 414,420 **** // Assign the new president ! if (temporaryPresident != newPresident) { ! temporaryPresident.getPortfolio().swapPresidentCertificate(cgr, ! newPresident.getPortfolio()); } --- 414,427 ---- // Assign the new president ! if (newPresident.getPortfolio().getShare(cgr) == cgr.getShareUnit()) { ! // Nobody has 2 shares, then takes the first player who has got one share ! log.debug("Nobody has two shares, creating a temp.pres.: "+firstCGRowner.getName()); ! cgr.setTemporaryPresident(firstCGRowner); ! newPresident = firstCGRowner; ! } else if (temporaryPresident != null && temporaryPresident != newPresident) { ! log.debug("Moving pres.share from "+temporaryPresident.getName() ! +" to "+newPresident.getName()); ! temporaryPresident.getPortfolio().swapPresidentCertificate(cgr, ! newPresident.getPortfolio()); } Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** OperatingRound_1856.java 25 Sep 2009 19:13:01 -0000 1.22 --- OperatingRound_1856.java 6 Oct 2009 18:34:03 -0000 1.23 *************** *** 194,199 **** log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! gameManager.startShareSellingRound(this, operatingCompany, ! cashToBeRaisedByPresident); // Return arbitrary negative value to signal end of processing to caller. return -remainder; --- 194,199 ---- log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; ! gameManager.startShareSellingRound(operatingCompany.getPresident(), ! cashToBeRaisedByPresident, operatingCompany); // Return arbitrary negative value to signal end of processing to caller. return -remainder; Index: PublicCompany_CGR.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/PublicCompany_CGR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PublicCompany_CGR.java 25 Sep 2009 19:13:01 -0000 1.3 --- PublicCompany_CGR.java 6 Oct 2009 18:34:03 -0000 1.4 *************** *** 6,11 **** import rails.game.*; import rails.game.move.*; ! import rails.game.state.BooleanState; ! import rails.game.state.IntegerState; public class PublicCompany_CGR extends PublicCompany { --- 6,10 ---- import rails.game.*; import rails.game.move.*; ! import rails.game.state.*; public class PublicCompany_CGR extends PublicCompany { *************** *** 16,19 **** --- 15,21 ---- private BooleanState hadPermanentTrain; + /** If no player has 2 shares, we need a separate attribute to mark the president. */ + private State temporaryPresident = null; + /* Cope with multiple 5% share sales in one turn */ private IntegerState sharesSoldSoFar; *************** *** 42,46 **** --- 44,76 ---- } + public boolean hasTemporaryPresident () { + return getTemporaryPresident() != null; + } + + public Player getTemporaryPresident() { + if (temporaryPresident != null) { + return (Player) temporaryPresident.getObject(); + } else { + return null; + } + } + @Override + public Player getPresident() { + if (hasTemporaryPresident()) { + return getTemporaryPresident(); + } else { + return super.getPresident(); + } + } + + public void setTemporaryPresident(Player temporaryPresident) { + if (this.temporaryPresident == null) { + this.temporaryPresident = new State ("CGR_TempPres", Player.class); + } + this.temporaryPresident.set(temporaryPresident); + } + + @Override public boolean canRunTrains() { if (!hadPermanentTrain()) { *************** *** 148,151 **** } ! } --- 178,184 ---- } ! @Override ! public String getExtraShareMarks () { ! return (hasTemporaryPresident() ? "T" : ""); ! } } |
From: Erik V. <ev...@us...> - 2009-10-03 14:02:43
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13750/rails/game/specific/_18EU Modified Files: StartCompany_18EU.java Log Message: Reduced dependence on static access to MapManager Index: StartCompany_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartCompany_18EU.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** StartCompany_18EU.java 3 Jan 2009 18:24:53 -0000 1.5 --- StartCompany_18EU.java 3 Oct 2009 14:02:28 -0000 1.6 *************** *** 122,131 **** } ! MapManager mmgr = MapManager.getInstance(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); for (String cityName : availableHomeStationNames.split(",")) { String[] parts = parseStationName (cityName); ! MapHex hex = mmgr.getHex(parts[0]); availableHomeStations.add (hex.getCity(Integer.parseInt(parts[1]))); } --- 122,131 ---- } ! MapManager mapManager = MapManager.getInstance(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); for (String cityName : availableHomeStationNames.split(",")) { String[] parts = parseStationName (cityName); ! MapHex hex = mapManager.getHex(parts[0]); availableHomeStations.add (hex.getCity(Integer.parseInt(parts[1]))); } *************** *** 133,137 **** if (selectedHomeStationName != null) { String[] parts = parseStationName (selectedHomeStationName); ! MapHex hex = mmgr.getHex(parts[0]); selectedHomeStation = hex.getCity(Integer.parseInt(parts[1])); } --- 133,137 ---- if (selectedHomeStationName != null) { String[] parts = parseStationName (selectedHomeStationName); ! MapHex hex = mapManager.getHex(parts[0]); selectedHomeStation = hex.getCity(Integer.parseInt(parts[1])); } |
From: Erik V. <ev...@us...> - 2009-10-03 14:02:41
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13750/rails/game Modified Files: Game.java Round.java Portfolio.java Tile.java PublicCompany.java MapManager.java MapHex.java GameManagerI.java GameManager.java Log Message: Reduced dependence on static access to MapManager Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Portfolio.java 25 Sep 2009 19:13:01 -0000 1.36 --- Portfolio.java 3 Oct 2009 14:02:28 -0000 1.37 *************** *** 582,585 **** --- 582,586 ---- for (PrivateCompanyI priv : privateCompanies) { + sps = priv.getSpecialProperties(); if (sps == null) continue; Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** PublicCompany.java 25 Sep 2009 19:29:56 -0000 1.62 --- PublicCompany.java 3 Oct 2009 14:02:28 -0000 1.63 *************** *** 51,58 **** --- 51,60 ---- /** Home hex & city * */ + protected String homeHexName = null; protected MapHex homeHex = null; protected int homeCityNumber = 1; /** Destination hex * */ + protected String destinationHexName = null; protected MapHex destinationHex = null; protected BooleanState hasReachedDestination = null; *************** *** 244,247 **** --- 246,250 ---- protected Bank bank; protected StockMarketI stockMarket; + protected MapManager mapManager; /** *************** *** 287,314 **** Tag homeBaseTag = tag.getChild("Home"); if (homeBaseTag != null) { ! String homeHexName = homeBaseTag.getAttributeAsString("hex"); ! MapHex hex = MapManager.getInstance().getHex(homeHexName); ! if (hex != null) { ! homeHex = hex; ! homeCityNumber = homeBaseTag.getAttributeAsInteger("city", 1); ! } else { ! throw new ConfigurationException("Invalid home hex " ! + homeHexName ! + " for company " + name); ! } } Tag destinationTag = tag.getChild("Destination"); if (destinationTag != null) { ! String destHexName = destinationTag.getAttributeAsString("hex"); ! MapHex hex = MapManager.getInstance().getHex(destHexName); ! if (hex != null) { ! destinationHex = hex; ! hasReachedDestination = new BooleanState (name+"_reachedDestination", false); ! } else { ! throw new ConfigurationException("Invalid destination hex " ! + destHexName ! + " for company " + name); ! } } --- 290,300 ---- Tag homeBaseTag = tag.getChild("Home"); if (homeBaseTag != null) { ! homeHexName = homeBaseTag.getAttributeAsString("hex"); ! homeCityNumber = homeBaseTag.getAttributeAsInteger("city", 1); } Tag destinationTag = tag.getChild("Destination"); if (destinationTag != null) { ! destinationHexName = destinationTag.getAttributeAsString("hex"); } *************** *** 645,648 **** --- 631,635 ---- bank = gameManager.getBank(); stockMarket = gameManager.getStockMarket(); + mapManager = gameManager.getMapManager(); if (hasStockPrice && Util.hasValue(startSpace)) { *************** *** 677,680 **** --- 664,686 ---- } + if (homeHexName != null) { + homeHex = mapManager.getHex(homeHexName); + if (homeHex == null) { + throw new ConfigurationException("Invalid home hex " + + homeHexName + + " for company " + name); + } + } + + if (destinationHexName != null) { + destinationHex = mapManager.getHex(destinationHexName); + if (destinationHex != null) { + hasReachedDestination = new BooleanState (name+"_reachedDestination", false); + } else { + throw new ConfigurationException("Invalid destination hex " + + destinationHexName + + " for company " + name); + } + } } Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** GameManager.java 25 Sep 2009 19:13:01 -0000 1.54 --- GameManager.java 3 Oct 2009 14:02:28 -0000 1.55 *************** *** 47,50 **** --- 47,51 ---- protected TrainManagerI trainManager; protected StockMarketI stockMarket; + protected MapManager mapManager; protected Bank bank; *************** *** 331,334 **** --- 332,336 ---- TrainManagerI trainManager, StockMarketI stockMarket, + MapManager mapManager, Bank bank) { this.playerManager = playerManager; *************** *** 337,340 **** --- 339,343 ---- this.trainManager = trainManager; this.stockMarket = stockMarket; + this.mapManager = mapManager; this.bank = bank; *************** *** 958,961 **** --- 961,968 ---- return stockMarket; } + + public MapManager getMapManager() { + return mapManager; + } public Bank getBank () { Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MapManager.java 4 Jun 2008 19:00:31 -0000 1.7 --- MapManager.java 3 Oct 2009 14:02:28 -0000 1.8 *************** *** 81,85 **** int maxY = 0; for (Tag hexTag : hexTags) { ! hex = new MapHex(); hex.configureFromXML(hexTag); mHexes.put(hex.getName(), hex); --- 81,85 ---- int maxY = 0; for (Tag hexTag : hexTags) { ! hex = new MapHex(this); hex.configureFromXML(hexTag); mHexes.put(hex.getName(), hex); Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Round.java 25 Sep 2009 19:29:56 -0000 1.24 --- Round.java 3 Oct 2009 14:02:28 -0000 1.25 *************** *** 35,39 **** protected Portfolio unavailable = null; protected Portfolio scrapHeap = null; ! protected StockMarketI stockMarket; protected Class<? extends RoundI> roundTypeForUI = null; --- 35,40 ---- protected Portfolio unavailable = null; protected Portfolio scrapHeap = null; ! protected StockMarketI stockMarket = null; ! protected MapManager mapManager = null; protected Class<? extends RoundI> roundTypeForUI = null; *************** *** 61,64 **** --- 62,66 ---- scrapHeap = bank.getScrapHeap(); stockMarket = aGameManager.getStockMarket(); + mapManager = aGameManager.getMapManager(); } *************** *** 184,188 **** cityNumber = 1; } ! hex = MapManager.getInstance().getHex(hexName); city = hex.getCity(cityNumber); --- 186,190 ---- cityNumber = 1; } ! hex = mapManager.getHex(hexName); city = hex.getCity(cityNumber); Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Game.java 25 Sep 2009 19:13:01 -0000 1.28 --- Game.java 3 Oct 2009 14:02:28 -0000 1.29 *************** *** 27,30 **** --- 27,31 ---- protected TrainManagerI trainManager; protected StockMarketI stockMarket; + protected MapManager mapManager; protected Bank bank; // protected ArrayList companyList; *************** *** 146,149 **** --- 147,158 ---- } + mapManager = + (MapManager) componentManager.findComponent("Map"); + if (mapManager == null) { + throw new ConfigurationException( + "No Map XML element found in file " + + GAME_XML_FILE); + } + /* * Initialisations that involve relations between components can *************** *** 152,156 **** playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, bank); companyManager.initCompanies(gameManager, playerManager.getPlayers()); --- 161,165 ---- playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, bank); companyManager.initCompanies(gameManager, playerManager.getPlayers()); Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MapHex.java 8 Sep 2009 21:48:59 -0000 1.24 --- MapHex.java 3 Oct 2009 14:02:28 -0000 1.25 *************** *** 93,101 **** /** Tokens that are not bound to a Station (City), such as Bonus tokens */ protected List<TokenI> offStationTokens; protected static Logger log = Logger.getLogger(MapHex.class.getPackage().getName()); ! public MapHex() {} /** --- 93,105 ---- /** Tokens that are not bound to a Station (City), such as Bonus tokens */ protected List<TokenI> offStationTokens; + + protected MapManager mapManager = null; protected static Logger log = Logger.getLogger(MapHex.class.getPackage().getName()); ! public MapHex(MapManager mapManager) { ! this.mapManager = mapManager; ! } /** *************** *** 957,960 **** --- 961,968 ---- return false; } + + public MapManager getMapManager() { + return mapManager; + } @Override Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Tile.java 15 Jan 2009 20:53:28 -0000 1.27 --- Tile.java 3 Oct 2009 14:02:28 -0000 1.28 *************** *** 481,485 **** } ! if (hexes != null) convertHexString(); if (allowedHexes != null) { --- 481,485 ---- } ! if (hexes != null) convertHexString(hex.getMapManager()); if (allowedHexes != null) { *************** *** 505,509 **** ! private void convertHexString() { boolean allowed = !hexes.startsWith("-"); --- 505,509 ---- ! private void convertHexString(MapManager mapManager) { boolean allowed = !hexes.startsWith("-"); *************** *** 512,516 **** MapHex hex; for (int i = 0; i < hexArray.length; i++) { ! hex = MapManager.getInstance().getHex(hexArray[i]); if (hex != null) { if (allowed) { --- 512,516 ---- MapHex hex; for (int i = 0; i < hexArray.length; i++) { ! hex = mapManager.getHex(hexArray[i]); if (hex != null) { if (allowed) { Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** GameManagerI.java 23 Sep 2009 21:38:57 -0000 1.11 --- GameManagerI.java 3 Oct 2009 14:02:28 -0000 1.12 *************** *** 21,25 **** CompanyManagerI companyManager, PhaseManager phaseManager, TrainManagerI trainManager, StockMarketI stockMarket, ! Bank bank); public abstract void startGame(); --- 21,25 ---- CompanyManagerI companyManager, PhaseManager phaseManager, TrainManagerI trainManager, StockMarketI stockMarket, ! MapManager mapManager, Bank bank); public abstract void startGame(); *************** *** 152,155 **** --- 152,156 ---- public PlayerManager getPlayerManager(); public StockMarketI getStockMarket(); + public MapManager getMapManager(); public Bank getBank (); |
From: Erik V. <ev...@us...> - 2009-10-03 14:02:36
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13750 Modified Files: .cvsignore Log Message: Reduced dependence on static access to MapManager Index: .cvsignore =================================================================== RCS file: /cvsroot/rails/18xx/.cvsignore,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** .cvsignore 30 Sep 2007 12:55:19 -0000 1.3 --- .cvsignore 3 Oct 2009 14:02:28 -0000 1.4 *************** *** 19,20 **** --- 19,21 ---- rails-*.jar tools + rails-?.*.* |
From: Erik V. <ev...@us...> - 2009-10-03 14:00:48
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13636/rails/game Modified Files: Bank.java Log Message: Spelling correction Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Bank.java 25 Sep 2009 19:13:01 -0000 1.12 --- Bank.java 3 Oct 2009 14:00:36 -0000 1.13 *************** *** 25,29 **** /** Collection of items that will (may) become available in the future */ private Portfolio unavailable = null; ! /** Collection of items that have bene discarded (but are kept to allow Undo) */ private Portfolio scrapHeap = null; --- 25,29 ---- /** Collection of items that will (may) become available in the future */ private Portfolio unavailable = null; ! /** Collection of items that have been discarded (but are kept to allow Undo) */ private Portfolio scrapHeap = null; |
From: Erik V. <ev...@us...> - 2009-10-03 14:00:15
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13532/rails/game/special Modified Files: SpecialTrainBuy.java SpecialProperty.java Log Message: Minor cleanups Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SpecialProperty.java 23 Sep 2009 21:38:57 -0000 1.14 --- SpecialProperty.java 3 Oct 2009 14:00:07 -0000 1.15 *************** *** 21,25 **** protected boolean usableIfOwnedByPlayer = false; protected boolean usableIfOwnedByCompany = false; - //protected boolean closeIfExercised = false; protected String conditionText = ""; --- 21,24 ---- *************** *** 42,48 **** public void configureFromXML(Tag tag) throws ConfigurationException { - //closeIfExercised = - // tag.getAttributeAsBoolean("closeIfExercised", closeIfExercised); - conditionText = tag.getAttributeAsString("condition"); if (!Util.hasValue(conditionText)) --- 41,44 ---- Index: SpecialTrainBuy.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTrainBuy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SpecialTrainBuy.java 4 Jun 2008 19:00:38 -0000 1.2 --- SpecialTrainBuy.java 3 Oct 2009 14:00:06 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- public void configureFromXML(Tag tag) throws ConfigurationException { + super.configureFromXML(tag); |
From: Erik V. <ev...@us...> - 2009-10-03 13:59:43
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13458/rails/game/special Modified Files: ExchangeForShare.java Log Message: Fixed bug that prevented 1830 M&H/NYC swap Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ExchangeForShare.java 25 Sep 2009 19:13:01 -0000 1.13 --- ExchangeForShare.java 3 Oct 2009 13:59:33 -0000 1.14 *************** *** 17,20 **** --- 17,22 ---- public void configureFromXML(Tag tag) throws ConfigurationException { + super.configureFromXML(tag); + Tag swapTag = tag.getChild("ExchangeForShare"); if (swapTag == null) { |
From: Erik V. <ev...@us...> - 2009-09-25 19:30:06
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6851/rails/game/move Modified Files: PriceTokenMove.java Log Message: Removed statics from StockMarket (no longer a singleton) Index: PriceTokenMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/PriceTokenMove.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PriceTokenMove.java 4 Jun 2008 19:00:33 -0000 1.3 --- PriceTokenMove.java 25 Sep 2009 19:29:56 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- import rails.game.PublicCompanyI; import rails.game.StockMarket; + import rails.game.StockMarketI; import rails.game.StockSpaceI; *************** *** 17,26 **** private PublicCompanyI company; private StockSpaceI from, to; public PriceTokenMove(PublicCompanyI company, StockSpaceI from, ! StockSpaceI to) { this.company = company; this.from = from; this.to = to; MoveSet.add(this); --- 18,29 ---- private PublicCompanyI company; private StockSpaceI from, to; + private StockMarketI stockMarket = null; public PriceTokenMove(PublicCompanyI company, StockSpaceI from, ! StockSpaceI to, StockMarketI stockMarket) { this.company = company; this.from = from; this.to = to; + this.stockMarket = stockMarket; MoveSet.add(this); *************** *** 28,37 **** public boolean execute() { ! StockMarket.getInstance().processMove(company, from, to); return true; } public boolean undo() { ! StockMarket.getInstance().processMove(company, to, from); return true; } --- 31,40 ---- public boolean execute() { ! stockMarket.processMove(company, from, to); return true; } public boolean undo() { ! stockMarket.processMove(company, to, from); return true; } |
From: Erik V. <ev...@us...> - 2009-09-25 19:30:05
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6851/rails/game/specific/_1856 Modified Files: CGRFormationRound.java Log Message: Removed statics from StockMarket (no longer a singleton) Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CGRFormationRound.java 25 Sep 2009 19:13:01 -0000 1.17 --- CGRFormationRound.java 25 Sep 2009 19:29:56 -0000 1.18 *************** *** 447,461 **** cgr.start(100); } else { - StockMarketI sm = StockMarket.getInstance(); int prevColPrice = 100; int colPrice; StockSpaceI startSpace; ! for (int col=6; col <= sm.getNumberOfColumns(); col++) { ! colPrice = sm.getStockSpace(1, col).getPrice(); if (cgrPrice > colPrice) continue; if (cgrPrice - prevColPrice < colPrice - cgrPrice) { ! startSpace = sm.getStockSpace(1, col-1); } else { ! startSpace = sm.getStockSpace(1, col); } cgr.start(startSpace); --- 447,460 ---- cgr.start(100); } else { int prevColPrice = 100; int colPrice; StockSpaceI startSpace; ! for (int col=6; col <= stockMarket.getNumberOfColumns(); col++) { ! colPrice = stockMarket.getStockSpace(1, col).getPrice(); if (cgrPrice > colPrice) continue; if (cgrPrice - prevColPrice < colPrice - cgrPrice) { ! startSpace = stockMarket.getStockSpace(1, col-1); } else { ! startSpace = stockMarket.getStockSpace(1, col); } cgr.start(startSpace); |
From: Erik V. <ev...@us...> - 2009-09-25 19:30:05
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6851/rails/game Modified Files: Round.java StartRound.java PublicCompany.java StockRound.java StockMarket.java Log Message: Removed statics from StockMarket (no longer a singleton) Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** StockMarket.java 6 Sep 2009 12:27:33 -0000 1.17 --- StockMarket.java 25 Sep 2009 19:29:56 -0000 1.18 *************** *** 21,26 **** protected int[] startPrices; - protected static StockMarketI instance; - /* Game-specific flags */ protected boolean upOrDownRight = false; /* --- 21,24 ---- *************** *** 37,48 **** ArrayList<PublicCertificate> ipoPile; - // ArrayList companiesStarted; - public StockMarket() { - instance = this; - } - - public static StockMarketI getInstance() { - return instance; } --- 35,39 ---- *************** *** 317,321 **** } company.setCurrentSpace(to); ! new PriceTokenMove(company, from, to); } --- 308,312 ---- } company.setCurrentSpace(to); ! new PriceTokenMove(company, from, to, this); } Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** PublicCompany.java 25 Sep 2009 19:13:01 -0000 1.61 --- PublicCompany.java 25 Sep 2009 19:29:56 -0000 1.62 *************** *** 243,246 **** --- 243,247 ---- protected GameManagerI gameManager; protected Bank bank; + protected StockMarketI stockMarket; /** *************** *** 643,649 **** this.gameManager = gameManager; bank = gameManager.getBank(); if (hasStockPrice && Util.hasValue(startSpace)) { ! parPrice.setPrice(StockMarket.getInstance().getStockSpace( startSpace)); if (parPrice.getPrice() == null) --- 644,651 ---- this.gameManager = gameManager; bank = gameManager.getBank(); + stockMarket = gameManager.getStockMarket(); if (hasStockPrice && Util.hasValue(startSpace)) { ! parPrice.setPrice(stockMarket.getStockSpace( startSpace)); if (parPrice.getPrice() == null) *************** *** 794,798 **** setParSpace(startSpace); // The current price is set via the Stock Market ! StockMarket.getInstance().start(this, startSpace); /* Final initialisations */ --- 796,800 ---- setParSpace(startSpace); // The current price is set via the Stock Market ! stockMarket.start(this, startSpace); /* Final initialisations */ *************** *** 809,813 **** public void start(int price) { ! StockSpaceI startSpace = StockMarket.getInstance().getStartSpace(price); if (startSpace == null) { log.error("Invalid start price " + Bank.format(price)); --- 811,815 ---- public void start(int price) { ! StockSpaceI startSpace = stockMarket.getStartSpace(price); if (startSpace == null) { log.error("Invalid start price " + Bank.format(price)); *************** *** 908,912 **** Util.moveObjects(laidBaseTokens, this); ! StockMarket.getInstance().close(this); } --- 910,914 ---- Util.moveObjects(laidBaseTokens, this); ! stockMarket.close(this); } Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Round.java 25 Sep 2009 19:13:01 -0000 1.23 --- Round.java 25 Sep 2009 19:29:56 -0000 1.24 *************** *** 35,38 **** --- 35,39 ---- protected Portfolio unavailable = null; protected Portfolio scrapHeap = null; + protected StockMarketI stockMarket; protected Class<? extends RoundI> roundTypeForUI = null; *************** *** 59,62 **** --- 60,64 ---- unavailable = bank.getUnavailable(); scrapHeap = bank.getScrapHeap(); + stockMarket = aGameManager.getStockMarket(); } Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** StartRound.java 19 Jul 2009 19:24:21 -0000 1.25 --- StartRound.java 25 Sep 2009 19:29:56 -0000 1.26 *************** *** 208,212 **** break; } ! if ((StockMarket.getInstance().getStartSpace(sharePrice)) == null) { errMsg = LocalText.getText("InvalidStartPrice", --- 208,212 ---- break; } ! if ((stockMarket.getStartSpace(sharePrice)) == null) { errMsg = LocalText.getText("InvalidStartPrice", Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** StockRound.java 25 Sep 2009 19:13:01 -0000 1.43 --- StockRound.java 25 Sep 2009 19:29:56 -0000 1.44 *************** *** 49,55 **** static public final int SOLD = 1; - /* Permanent memory */ - static protected StockMarketI stockMarket; - /* Rules */ protected int sequenceRule; --- 49,52 ---- *************** *** 69,73 **** if (numberOfPlayers == 0) numberOfPlayers = gameManager.getPlayers().size(); - if (stockMarket == null) stockMarket = StockMarket.getInstance(); sequenceRule = gameManager.getStockRoundSequenceRule(); --- 66,69 ---- |
From: Erik V. <ev...@us...> - 2009-09-25 19:13:21
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5549/rails/game/specific/_18AL Modified Files: OperatingRound_18AL.java Log Message: Rationalised Bank, removing statics Removed two unnecessary Util methods Index: OperatingRound_18AL.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/OperatingRound_18AL.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OperatingRound_18AL.java 15 Jan 2009 20:53:28 -0000 1.5 --- OperatingRound_18AL.java 25 Sep 2009 19:13:01 -0000 1.6 *************** *** 85,89 **** if (hex == operatingCompany.getDestinationHex()) { int payout = 100; ! new CashMove(Bank.getInstance(), operatingCompany, payout); ReportBuffer.add(LocalText.getText("DestinationReachedByToken", operatingCompany.getName(), --- 85,89 ---- if (hex == operatingCompany.getDestinationHex()) { int payout = 100; ! new CashMove(bank, operatingCompany, payout); ReportBuffer.add(LocalText.getText("DestinationReachedByToken", operatingCompany.getName(), |
From: Erik V. <ev...@us...> - 2009-09-25 19:13:17
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5549/rails/game/move Modified Files: CashMove.java Log Message: Rationalised Bank, removing statics Removed two unnecessary Util methods Index: CashMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/CashMove.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CashMove.java 4 Jun 2008 19:00:33 -0000 1.4 --- CashMove.java 25 Sep 2009 19:13:01 -0000 1.5 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: *************** *** 6,10 **** package rails.game.move; ! import rails.game.*; /** --- 6,11 ---- package rails.game.move; ! import rails.game.Bank; ! import rails.game.CashHolder; /** *************** *** 22,26 **** * Create a CashMove instance. In this specific case either from or to may * be null, in which case the Bank is implied. ! * * @param from The cash payer (null implies the Bank). * @param to The cash payee (null implies the Bank). --- 23,27 ---- * Create a CashMove instance. In this specific case either from or to may * be null, in which case the Bank is implied. ! * * @param from The cash payer (null implies the Bank). * @param to The cash payee (null implies the Bank). *************** *** 35,51 **** } ! public boolean execute() { ! Bank.transferCash(from, to, amount); return true; } ! public boolean undo() { ! Bank.transferCash(to, from, amount); return true; } ! public String toString() { return "CashMove: " + Bank.format(amount) + " from " + from.getName() + " to " + to.getName(); --- 36,60 ---- } ! @Override ! public boolean execute() { ! transferCash(from, to, amount); return true; } ! @Override ! public boolean undo() { ! transferCash(to, from, amount); return true; } ! private boolean transferCash(CashHolder from, CashHolder to, ! int amount) { ! return to.addCash(amount) && from.addCash(-amount); ! } ! ! @Override ! public String toString() { return "CashMove: " + Bank.format(amount) + " from " + from.getName() + " to " + to.getName(); |
From: Erik V. <ev...@us...> - 2009-09-25 19:13:16
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5549/rails/game/special Modified Files: ExchangeForShare.java Log Message: Rationalised Bank, removing statics Removed two unnecessary Util methods Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ExchangeForShare.java 4 Sep 2009 18:56:16 -0000 1.12 --- ExchangeForShare.java 25 Sep 2009 19:13:01 -0000 1.13 *************** *** 42,47 **** Player player = null; String errMsg = null; ! boolean ipoHasShare = Bank.getIpo().getShare(publicCompany) >= share; ! boolean poolHasShare = Bank.getPool().getShare(publicCompany) >= share; while (true) { --- 42,48 ---- Player player = null; String errMsg = null; ! Bank bank = Bank.getInstance(); ! boolean ipoHasShare = bank.getIpo().getShare(publicCompany) >= share; ! boolean poolHasShare = bank.getPool().getShare(publicCompany) >= share; while (true) { *************** *** 88,93 **** Certificate cert = ! ipoHasShare ? Bank.getIpo().findCertificate(publicCompany, ! false) : Bank.getPool().findCertificate(publicCompany, false); //player.buy(cert, 0); --- 89,94 ---- Certificate cert = ! ipoHasShare ? bank.getIpo().findCertificate(publicCompany, ! false) : bank.getPool().findCertificate(publicCompany, false); //player.buy(cert, 0); |