From: <ev...@us...> - 2010-09-17 22:24:19
|
Revision: 1426 http://rails.svn.sourceforge.net/rails/?rev=1426&view=rev Author: evos Date: 2010-09-17 22:24:13 +0000 (Fri, 17 Sep 2010) Log Message: ----------- Added GameStatus row to display the increase of player worth in th elast complete OR Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/Player.java trunk/18xx/rails/ui/swing/GameStatus.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/LocalisedText.properties 2010-09-17 22:24:13 UTC (rev 1426) @@ -436,6 +436,7 @@ OK=OK OPTIONS=Options OR=or +ORWORTHINCR=OR +/- PAR=Par PASS=Pass PASSES={0} passes. Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/game/OperatingRound.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -10,10 +10,7 @@ import rails.game.move.CashMove; import rails.game.move.MapChange; import rails.game.special.*; -import rails.game.state.ArrayListState; -import rails.game.state.EnumState; -import rails.game.state.GenericState; -import rails.game.state.HashMapState; +import rails.game.state.*; import rails.util.LocalText; import rails.util.SequenceUtil; @@ -41,8 +38,8 @@ protected GenericState<PublicCompanyI> operatingCompany; // do not use a operatingCompany.getObject() as reference - // protected PublicCompanyI operatingCompany.getObject() = null; - + // protected PublicCompanyI operatingCompany.getObject() = null; + // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; @@ -114,6 +111,10 @@ ReportBuffer.add(LocalText.getText("START_OR", thisOrNumber)); + for (Player player : gameManager.getPlayers()) { + player.setWorthAtORStart(); + } + privatesPayOut(); if (operatingCompanies.size() > 0) { @@ -800,7 +801,7 @@ ReportBuffer.add(LocalText.getText("CompanyRevenue", action.getCompanyName(), Bank.format(action.getActualRevenue()))); - + int remainingAmount = checkForDeductions (action); if (remainingAmount < 0) { // A share selling round will be run to raise cash to pay debts @@ -1298,8 +1299,8 @@ * of the tile laying step. */ protected void getNormalTileLays() { - - // duplicate the phase colours + + // duplicate the phase colours Map<String, Integer> newTileColours = new HashMap<String, Integer>(getCurrentPhase().getTileColours()); for (String colour : newTileColours.keySet()) { int allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); @@ -1307,7 +1308,7 @@ newTileColours.put(colour, new Integer(allowedNumber)); } // store to state - tileLaysPerColour.initFromMap(newTileColours); + tileLaysPerColour.initFromMap(newTileColours); } protected void setNormalTileLays() { @@ -1529,6 +1530,11 @@ // priv.checkClosingIfExercised(true); //} + // Update the worth increase per player + for (Player player : gameManager.getPlayers()) { + player.setLastORWorthIncrease(); + } + // OR done. Inform GameManager. ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); finishRound(); Modified: trunk/18xx/rails/game/Player.java =================================================================== --- trunk/18xx/rails/game/Player.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/game/Player.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -3,6 +3,7 @@ import rails.game.model.*; import rails.game.state.BooleanState; +import rails.game.state.IntegerState; /** * Player class holds all player-specific data @@ -26,6 +27,8 @@ private CalculatedMoneyModel freeCash; private CalculatedMoneyModel worth; private BooleanState bankrupt; + private MoneyModel lastORWorthIncrease; + private IntegerState worthAtORStart; private boolean hasBoughtStockThisTurn = false; @@ -42,6 +45,9 @@ worth = new CalculatedMoneyModel(this, "getWorth"); wallet.addDependent(worth); bankrupt = new BooleanState (name+"_isBankrupt", false); + lastORWorthIncrease = new MoneyModel (name+"_lastORIncome"); + lastORWorthIncrease.setOption(MoneyModel.ALLOW_NEGATIVE); + worthAtORStart = new IntegerState (name+"_worthAtORStart"); } /** @@ -88,10 +94,10 @@ int worth; if (bankrupt.booleanValue()) { worth = 0; - } else { + } else { worth = wallet.getCash(); } - + for (PublicCertificateI cert : portfolio.getCertificates()) { worth += cert.getCompany().getGameEndPrice() * cert.getShares(); } @@ -105,6 +111,18 @@ return worth; } + public MoneyModel getLastORWorthIncrease () { + return lastORWorthIncrease; + } + + public void setWorthAtORStart () { + worthAtORStart.set(getWorth()); + } + + public void setLastORWorthIncrease () { + lastORWorthIncrease.set(getWorth() - worthAtORStart.intValue()); + } + public void updateWorth () { worth.update(); } Modified: trunk/18xx/rails/ui/swing/GameStatus.java =================================================================== --- trunk/18xx/rails/ui/swing/GameStatus.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/ui/swing/GameStatus.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -68,6 +68,8 @@ protected int playerPrivatesXOffset, playerPrivatesYOffset; protected Field playerWorth[]; protected int playerWorthXOffset, playerWorthYOffset; + protected Field playerORWorthIncrease[]; + protected int playerORWorthIncreaseXOffset, playerORWorthIncreaseYOffset; protected Field playerCertCount[]; protected int playerCertCountXOffset, playerCertCountYOffset; protected int certLimitXOffset, certLimitYOffset; @@ -173,6 +175,7 @@ playerCashButton = new ClickField[np]; playerPrivates = new Field[np]; playerWorth = new Field[np]; + playerORWorthIncrease = new Field[np]; playerCertCount = new Field[np]; upperPlayerCaption = new Caption[np]; lowerPlayerCaption = new Caption[np]; @@ -219,6 +222,8 @@ playerPrivatesYOffset = ++lastY; playerWorthXOffset = certPerPlayerXOffset; playerWorthYOffset = ++lastY; + playerORWorthIncreaseXOffset = certPerPlayerXOffset; + playerORWorthIncreaseYOffset = ++lastY; playerCertCountXOffset = certPerPlayerXOffset; playerCertCountYOffset = ++lastY; certLimitXOffset = certInPoolXOffset; @@ -455,6 +460,13 @@ addField(f, playerWorthXOffset + i, playerWorthYOffset, 1, 1, 0, true); } + addField(new Caption(LocalText.getText("ORWORTHINCR")), 0, + playerORWorthIncreaseYOffset, 1, 1, WIDE_RIGHT, true); + for (int i = 0; i < np; i++) { + f = playerORWorthIncrease[i] = new Field(players[i].getLastORWorthIncrease()); + addField(f, playerORWorthIncreaseXOffset + i, playerORWorthIncreaseYOffset, 1, 1, 0, true); + } + addField(new Caption("Certs"), 0, playerCertCountYOffset, 1, 1, WIDE_RIGHT + WIDE_TOP, true); for (int i = 0; i < np; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |