From: <ste...@us...> - 2010-09-06 21:20:18
|
Revision: 1413 http://rails.svn.sourceforge.net/rails/?rev=1413&view=rev Author: stefanfrey Date: 2010-09-06 21:20:12 +0000 (Mon, 06 Sep 2010) Log Message: ----------- Fixed several bugs on 1835: - Tile 213 update: fixed - Pr funding money not given : fixed, (was missing and see TODO 1) - PR formation round acts as a stock round (side effect: price increase, wrong round names): fixed (removed call to super.finishRound()) - Undo inside PR formation round creates weird states: fixed (changed to linked moveSets) - Nationalisation does not check certificate limits before action (post-action check was ok): fixed (missing check) - Nationalisation prevents selling of stocks: fixed (removed self-nationalize) - Pr 5% shares only 1/4 of value, 10% shares only 1/2 of value(report window, executed correctly): fixed (fixed currentSellPrice, see TODO 2 and 3, adjusted output) - Closing of OBB not possible: fixed TODO: 1) Implement SharePriceUnits everywhere it is appropriate (e.g. Round method floating()) 2) SellPrices is not a stateful map (=> undo side effects!) 3) Selling PR president is shown as selling two 5 percent shares (which might be correct) but selling those creates all kind of crazy effects Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1835/CompanyManager.xml trunk/18xx/data/1835/TileSet.xml trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java trunk/18xx/rails/game/specific/_1835/StockRound_1835.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/LocalisedText.properties 2010-09-06 21:20:12 UTC (rev 1413) @@ -239,6 +239,7 @@ END_SR=\nAll players have passed, end of SR {0} EndOfExchangeRound=All minors are closed, end of Exchange Round EndOfFormationRound=\nEnd of {0} formation round, resuming {1} +EndOfFormationRoundNoInterrupt=\nEnd of {0} formation round ENTER_PRICE_OR_CANCEL=Enter a valid price or hit Cancel ERROR=Error EXCHANGED=exchanged Modified: trunk/18xx/data/1835/CompanyManager.xml =================================================================== --- trunk/18xx/data/1835/CompanyManager.xml 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/data/1835/CompanyManager.xml 2010-09-06 21:20:12 UTC (rev 1413) @@ -55,6 +55,7 @@ <ClosingConditions> <Phase>5</Phase> <SpecialProperties condition="ifAllExercised"/> + <CloseManually/> <!-- If second tile is laid not via special property --> </ClosingConditions> </Company> <Company name="PfB" longname="Pfalzbahnen" type="Private" basePrice="150" revenue="15"> Modified: trunk/18xx/data/1835/TileSet.xml =================================================================== --- trunk/18xx/data/1835/TileSet.xml 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/data/1835/TileSet.xml 2010-09-06 21:20:12 UTC (rev 1413) @@ -165,7 +165,7 @@ <Upgrade id="218"/> </Tile> <Tile id="213" quantity="1"> - <Upgrade id="218"/> + <Upgrade id="219"/> </Tile> <Tile id="214" quantity="1"> <Upgrade id="219"/> Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/StockRound.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -417,7 +417,9 @@ * original price is still valid */ price = getCurrentSellPrice(company); - price /= company.getShareUnitsForSharePrice(); + + // removed as this is done in getCurrentSellPrice + // price /= company.getShareUnitsForSharePrice(); /* Allow for different share units (as in 1835) */ for (int i = 1; i <= 4; i++) { @@ -802,7 +804,7 @@ if (number == 1) { ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", playerName, - shareUnit, + share, companyName, from.getName(), Bank.format(cost) )); @@ -810,8 +812,8 @@ ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", playerName, number, - shareUnit, - number * shareUnit, + share, + shares, companyName, from.getName(), Bank.format(cost) )); @@ -1055,17 +1057,17 @@ if (numberSold == 1) { ReportBuffer.add(LocalText.getText("SELL_SHARE_LOG", playerName, - company.getShareUnit(), + company.getShareUnit() * shareUnits, companyName, - Bank.format(numberSold * price) )); + Bank.format(numberSold * price * shareUnits) )); } else { ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", playerName, numberSold, - company.getShareUnit(), - numberSold * company.getShareUnit(), + company.getShareUnit() * shareUnits, + numberSold * company.getShareUnit() * shareUnits, companyName, - Bank.format(numberSold * price) )); + Bank.format(numberSold * price * shareUnits) )); } // Check if the presidency has changed @@ -1128,8 +1130,10 @@ && GameOption.convertValueToBoolean(getGameOption("SeparateSalesAtSamePrice"))) { price = (sellPrices.get(companyName)).getPrice(); } else { - price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + price = company.getCurrentSpace().getPrice(); } + // stored price is the previous unadjusted price + price = price / company.getShareUnitsForSharePrice(); return price; } Modified: trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -229,7 +229,8 @@ return false; } - moveStack.start(false); + // all actions linked during formation round to avoid serious undo problems + moveStack.start(false).linkToPreviousMoveSet(); if (folding) executeStartPrussian(false); @@ -246,6 +247,21 @@ ReportBuffer.add(message); if (display) DisplayBuffer.add(message); + // add money from sold shares + // Move cash and shares where required + int capFactor = getSoldPercentage(prussian) / (prussian.getShareUnit() * prussian.getShareUnitsForSharePrice()); + int cash = capFactor * prussian.getIPOPrice(); + + if (cash > 0) { + new CashMove(bank, prussian, cash); + ReportBuffer.add(LocalText.getText("FloatsWithCash", + prussian.getName(), + Bank.format(cash) )); + } else { + ReportBuffer.add(LocalText.getText("Floats", + prussian.getName())); + } + executeExchange (Arrays.asList(new CompanyI[]{m2}), true, false); prussian.setFloated(); } @@ -271,7 +287,8 @@ return false; } - moveStack.start(false); + // all actions linked during formation round to avoid serious undo problems + moveStack.start(false).linkToPreviousMoveSet(); // Execute if (folding) executeExchange (folded, false, false); @@ -415,9 +432,19 @@ @Override protected void finishRound() { + RoundI interruptedRound = gameManager.getInterruptedRound(); + if (interruptedRound != null) { + ReportBuffer.add(LocalText.getText("EndOfFormationRound", PR_ID, + interruptedRound.getRoundName())); + } else { + ReportBuffer.add(LocalText.getText("EndOfFormationRoundNoInterrupt", PR_ID)); + } + if (prussian.hasStarted()) prussian.checkPresidency(); prussian.setOperated(); // To allow immediate share selling - super.finishRound(); + // super.finishRound(); + // Inform GameManager + gameManager.nextRound(this); } public static boolean prussianIsComplete(GameManagerI gameManager) { Modified: trunk/18xx/rails/game/specific/_1835/StockRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -45,8 +45,13 @@ otherPlayers.clear(); for (PublicCertificateI cert : company.getCertificates()) { holder = (Portfolio)cert.getHolder(); - owner = holder.getOwner(); - if (owner instanceof Player) { + owner = holder.getOwner(); + /* Would the player exceed the total certificate limit? */ + StockSpaceI stockSpace = company.getCurrentSpace(); + if ((stockSpace == null || !stockSpace.isNoCertLimit()) && !mayPlayerBuyCertificate( + currentPlayer, company, cert.getCertificateCount())) continue; + // only nationalize other players + if (owner instanceof Player && owner != currentPlayer) { otherPlayer = (Player) owner; if (!otherPlayers.contains(otherPlayer)) { price = (int)(1.5 * company.getCurrentPriceModel().getPrice().getPrice()); @@ -88,9 +93,11 @@ if (sellPrices.containsKey(companyName)) { price = (sellPrices.get(companyName)).getPrice(); } else { - price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + price = company.getCurrentSpace().getPrice(); } - return price; + // stored price is the previous unadjusted price + price = price / company.getShareUnitsForSharePrice(); + return price; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |