From: Erik V. <ev...@us...> - 2010-05-18 22:07:26
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv15623/rails/game Modified Files: ShareSellingRound.java Player.java OperatingRound.java GameManager.java Log Message: 18EU bankruptcy rules Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Player.java 23 Mar 2010 18:44:30 -0000 1.25 --- Player.java 18 May 2010 22:07:18 -0000 1.26 *************** *** 3,6 **** --- 3,7 ---- import rails.game.model.*; + import rails.game.state.BooleanState; /** *************** *** 25,28 **** --- 26,30 ---- private CalculatedMoneyModel freeCash; private CalculatedMoneyModel worth; + private BooleanState bankrupt; private boolean hasBoughtStockThisTurn = false; *************** *** 40,43 **** --- 42,46 ---- worth = new CalculatedMoneyModel(this, "getWorth"); wallet.addDependent(worth); + bankrupt = new BooleanState (name+"_isBankrupt", false); } *************** *** 174,177 **** --- 177,188 ---- } + public void setBankrupt () { + bankrupt.set(true); + } + + public boolean isBankrupt () { + return bankrupt.booleanValue(); + } + /** * Compare Players by their total worth, in descending order. This method Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** OperatingRound.java 16 May 2010 20:59:12 -0000 1.131 --- OperatingRound.java 18 May 2010 22:07:18 -0000 1.132 *************** *** 12,16 **** import rails.game.state.EnumState; import rails.game.state.GenericState; - import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.SequenceUtil; --- 12,15 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** GameManager.java 18 May 2010 04:12:23 -0000 1.102 --- GameManager.java 18 May 2010 22:07:18 -0000 1.103 *************** *** 7,11 **** import java.util.*; - import org.apache.log4j.Logger; import org.apache.log4j.NDC; --- 7,10 ---- *************** *** 58,62 **** protected RevenueManager revenueManager; protected Bank bank; ! // map of correctionManagers protected Map<CorrectionType, CorrectionManagerI> correctionManagers = --- 57,61 ---- protected RevenueManager revenueManager; protected Bank bank; ! // map of correctionManagers protected Map<CorrectionType, CorrectionManagerI> correctionManagers = *************** *** 660,666 **** /** Stub, can be overridden in subclasses with actual actions */ public void newPhaseChecks (RoundI round) { ! } ! public String getORId () { if (showCompositeORNumber) { --- 659,665 ---- /** Stub, can be overridden in subclasses with actual actions */ public void newPhaseChecks (RoundI round) { ! } ! public String getORId () { if (showCompositeORNumber) { *************** *** 944,948 **** protected boolean export(GameAction exportAction) { ! String filename = exportAction.getFilepath(); boolean result = false; --- 943,947 ---- protected boolean export(GameAction exportAction) { ! String filename = exportAction.getFilepath(); boolean result = false; *************** *** 950,979 **** try { PrintWriter pw = new PrintWriter(filename); ! // write map information MapHex[][] allHexes =mapManager.getHexes(); ! for (MapHex[] hexRow:allHexes) for (MapHex hex:hexRow) if (hex != null) { ! pw.println(hex.getName() + "," + hex.getCurrentTile().getExternalId() + "," ! + hex.getCurrentTileRotation() + "," + hex.getOrientationName(hex.getCurrentTileRotation()) ) ; } ! pw.close(); result = true; ! ! } catch (IOException e) { log.error("Save failed", e); DisplayBuffer.add(LocalText.getText("SaveFailed", e.getMessage())); } ! return result; } ! ! /* (non-Javadoc) * @see rails.game.GameManagerI#finishShareSellingRound() --- 949,978 ---- try { PrintWriter pw = new PrintWriter(filename); ! // write map information MapHex[][] allHexes =mapManager.getHexes(); ! for (MapHex[] hexRow:allHexes) for (MapHex hex:hexRow) if (hex != null) { ! pw.println(hex.getName() + "," + hex.getCurrentTile().getExternalId() + "," ! + hex.getCurrentTileRotation() + "," + hex.getOrientationName(hex.getCurrentTileRotation()) ) ; } ! pw.close(); result = true; ! ! } catch (IOException e) { log.error("Save failed", e); DisplayBuffer.add(LocalText.getText("SaveFailed", e.getMessage())); } ! return result; } ! ! /* (non-Javadoc) * @see rails.game.GameManagerI#finishShareSellingRound() *************** *** 1015,1019 **** int maxShare; int share; ! // Assume default case as in 18EU: all assets to Bank/Pool Player bankrupter = getCurrentPlayer(); --- 1014,1018 ---- int maxShare; int share; ! // Assume default case as in 18EU: all assets to Bank/Pool Player bankrupter = getCurrentPlayer(); *************** *** 1028,1032 **** newPresident = null; maxShare = 0; ! for (int index=getCurrentPlayerIndex()+1; index<getCurrentPlayerIndex()+numberOfPlayers; index++) { player = getPlayerByIndex(index%numberOfPlayers); --- 1027,1031 ---- newPresident = null; maxShare = 0; ! for (int index=getCurrentPlayerIndex()+1; index<getCurrentPlayerIndex()+numberOfPlayers; index++) { player = getPlayerByIndex(index%numberOfPlayers); *************** *** 1039,1043 **** } if (newPresident != null) { ! bankrupter.getPortfolio().swapPresidentCertificate(company, newPresident.getPortfolio()); } else { --- 1038,1042 ---- } if (newPresident != null) { ! bankrupter.getPortfolio().swapPresidentCertificate(company, newPresident.getPortfolio()); } else { *************** *** 1048,1054 **** // Dump all shares Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); } } ! public void registerBrokenBank(){ ReportBuffer.add(LocalText.getText("BankIsBrokenReportText")); --- 1047,1060 ---- // Dump all shares Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); + + bankrupter.setBankrupt(); + + // Finish the share selling round + if (getCurrentRound() instanceof ShareSellingRound) { + finishShareSellingRound(); + } } } ! public void registerBrokenBank(){ ReportBuffer.add(LocalText.getText("BankIsBrokenReportText")); *************** *** 1071,1079 **** ReportBuffer.add(""); ! List<String> gameReport = getGameReport(); for (String s:gameReport) ReportBuffer.add(s); ! // activate gameReport for UI setGameOverReportedUI(false); --- 1077,1085 ---- ReportBuffer.add(""); ! List<String> gameReport = getGameReport(); for (String s:gameReport) ReportBuffer.add(s); ! // activate gameReport for UI setGameOverReportedUI(false); *************** *** 1088,1092 **** return gameOver.booleanValue(); } ! public void setGameOverReportedUI(boolean b){ gameOverReportedUI = b; --- 1094,1098 ---- return gameOver.booleanValue(); } ! public void setGameOverReportedUI(boolean b){ gameOverReportedUI = b; *************** *** 1096,1100 **** return(gameOverReportedUI); } ! /* (non-Javadoc) * @see rails.game.GameManagerI#getGameReport() --- 1102,1106 ---- return(gameOverReportedUI); } ! /* (non-Javadoc) * @see rails.game.GameManagerI#getGameReport() *************** *** 1257,1261 **** public void setNextPlayer() { int currentPlayerIndex = getCurrentPlayerIndex(); ! currentPlayerIndex = ++currentPlayerIndex % numberOfPlayers; setCurrentPlayerIndex(currentPlayerIndex); } --- 1263,1269 ---- public void setNextPlayer() { int currentPlayerIndex = getCurrentPlayerIndex(); ! do { ! currentPlayerIndex = ++currentPlayerIndex % numberOfPlayers; ! } while (players.get(currentPlayerIndex).isBankrupt()); setCurrentPlayerIndex(currentPlayerIndex); } *************** *** 1510,1514 **** return guiHints; } ! public CorrectionManagerI getCorrectionManager(CorrectionType ct) { CorrectionManagerI cm = correctionManagers.get(ct); --- 1518,1522 ---- return guiHints; } ! public CorrectionManagerI getCorrectionManager(CorrectionType ct) { CorrectionManagerI cm = correctionManagers.get(ct); *************** *** 1520,1524 **** return cm; } ! } --- 1528,1532 ---- return cm; } ! } Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ShareSellingRound.java 27 Mar 2010 18:27:08 -0000 1.31 --- ShareSellingRound.java 18 May 2010 22:07:18 -0000 1.32 *************** *** 79,83 **** gameManager.registerBankruptcy(); ! return false; } --- 79,83 ---- gameManager.registerBankruptcy(); ! if (gameManager.isGameOver()) return false; } |