From: Erik V. <ev...@us...> - 2010-05-23 08:18:32
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv23595/rails/game Modified Files: ShareSellingRound.java OperatingRound.java Log Message: 18EU bankruptcy rules (Phase 2) Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -d -r1.132 -r1.133 *** OperatingRound.java 18 May 2010 22:07:18 -0000 1.132 --- OperatingRound.java 23 May 2010 08:18:24 -0000 1.133 *************** *** 1469,1480 **** protected void finishTurn() { ! operatingCompany.setOperated(); ! companiesOperatedThisRound.add(operatingCompany); ! ! // Check if any privates must be closed (now only applies to 1856 W&SR) ! // Copy list first to avoid concurrent modifications ! for (PrivateCompanyI priv : ! new ArrayList<PrivateCompanyI> (operatingCompany.getPortfolio().getPrivateCompanies())) { ! priv.checkClosingIfExercised(true); } --- 1469,1482 ---- protected void finishTurn() { ! if (!operatingCompany.isClosed()) { ! operatingCompany.setOperated(); ! companiesOperatedThisRound.add(operatingCompany); ! ! // Check if any privates must be closed (now only applies to 1856 W&SR) ! // Copy list first to avoid concurrent modifications ! for (PrivateCompanyI priv : ! new ArrayList<PrivateCompanyI> (operatingCompany.getPortfolio().getPrivateCompanies())) { ! priv.checkClosingIfExercised(true); ! } } Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ShareSellingRound.java 18 May 2010 22:07:18 -0000 1.32 --- ShareSellingRound.java 23 May 2010 08:18:24 -0000 1.33 *************** *** 23,26 **** --- 23,28 ---- IntegerState cashToRaise; PublicCompanyI unsellableCompany = null; + + private List<SellShares> sellableShares; /** *************** *** 54,58 **** this.unsellableCompany = unsellableCompany; setCurrentPlayerIndex(sellingPlayer.getIndex()); ! setPossibleActions(); } --- 56,60 ---- this.unsellableCompany = unsellableCompany; setCurrentPlayerIndex(sellingPlayer.getIndex()); ! getSellableShares(); } *************** *** 74,85 **** setSellableShares(); - if (possibleActions.isEmpty() && cashToRaise.intValue() > 0) { - DisplayBuffer.add(LocalText.getText("YouMustRaiseCashButCannot", - Bank.format(cashToRaise.intValue()))); - - gameManager.registerBankruptcy(); - if (gameManager.isGameOver()) return false; - } - for (PossibleAction pa : possibleActions.getList()) { log.debug(currentPlayer.getName() + " may: " + pa.toString()); --- 76,79 ---- *************** *** 89,100 **** } - /** - * Create a list of certificates that a player may sell in a Stock Round, - * taking all rules taken into account. - * - * @return List of sellable certificates. - */ @Override public void setSellableShares() { String compName; int price; --- 83,99 ---- } @Override public void setSellableShares() { + possibleActions.addAll(sellableShares); + } + + /** + * Create a list of certificates that a player may sell in an emergency + * share selling round, taking all rules taken into account. + */ + private List<SellShares> getSellableShares () { + + sellableShares = new ArrayList<SellShares> (); + String compName; int price; *************** *** 192,200 **** if (number > 0) { ! possibleActions.add(new SellShares(compName, i, number, price)); } } } } --- 191,200 ---- if (number > 0) { ! sellableShares.add(new SellShares(compName, i, number, price)); } } } + return sellableShares; } *************** *** 380,383 **** --- 380,388 ---- if (cashToRaise.intValue() <= 0) { gameManager.finishShareSellingRound(); + } else if (getSellableShares().isEmpty()) { + DisplayBuffer.add(LocalText.getText("YouMustRaiseCashButCannot", + Bank.format(cashToRaise.intValue()))); + + gameManager.registerBankruptcy(); } |