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(); |