From: <ev...@us...> - 2010-08-01 15:28:30
|
Revision: 1366 http://rails.svn.sourceforge.net/rails/?rev=1366&view=rev Author: evos Date: 2010-08-01 15:28:24 +0000 (Sun, 01 Aug 2010) Log Message: ----------- Implemented option to sell shares in same turn at decreasong prices for all games except 1835. Modified Paths: -------------- trunk/18xx/data/1825/Game.xml trunk/18xx/data/1851/Game.xml trunk/18xx/data/1856/Game.xml trunk/18xx/data/1870/Game.xml trunk/18xx/data/1889/Game.xml trunk/18xx/data/18AL/Game.xml trunk/18xx/data/18EU/Game.xml trunk/18xx/data/18Kaas/Game.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/specific/_1835/StockRound_1835.java Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/1825/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -14,6 +14,7 @@ --> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <PlayerShareLimit percentage="100"/> <BankPoolLimit percentage="100"></BankPoolLimit> <EndOfGame> Modified: trunk/18xx/data/1851/Game.xml =================================================================== --- trunk/18xx/data/1851/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/1851/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -7,6 +7,7 @@ <GameOption name="NoMapMode" type="toggle" default="no" /> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="UnlimitedTopTrains" parm="8" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <PlayerShareLimit percentage="60"/> <BankPoolLimit percentage="50"/> Modified: trunk/18xx/data/1856/Game.xml =================================================================== --- trunk/18xx/data/1856/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/1856/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -8,6 +8,7 @@ <GameOption name="UnlimitedBonusTokens" type="toggle" default="no"/> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <StockRound class="rails.game.specific._1856.StockRound_1856" sequence="SellBuyOrBuySell"> Modified: trunk/18xx/data/1870/Game.xml =================================================================== --- trunk/18xx/data/1870/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/1870/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -6,6 +6,7 @@ <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <PlayerShareLimit percentage="60"> <PriceProtection/> Modified: trunk/18xx/data/1889/Game.xml =================================================================== --- trunk/18xx/data/1889/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/1889/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -22,6 +22,7 @@ <GameOption name="WithOptional6Train" type="toggle" default="no"/> <GameOption name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <GameOption name="TwoPlayersCertLimit70Percent" type="toggle" default="yes"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <PlayerShareLimit percentage="60"> <!-- Option "NumberOfPlayers" is automatically set Modified: trunk/18xx/data/18AL/Game.xml =================================================================== --- trunk/18xx/data/18AL/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/18AL/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -9,6 +9,7 @@ <GameOption name="Obsolete4Trains" type="toggle" default="yes"/> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <OperatingRound class="rails.game.specific._18AL.OperatingRound_18AL"/> <PlayerShareLimit percentage="60"/> Modified: trunk/18xx/data/18EU/Game.xml =================================================================== --- trunk/18xx/data/18EU/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/18EU/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -8,6 +8,7 @@ <GameOption name="Extra4Trains" values="0,1" default="0"/> <GameOption name="NoMapMode" type="toggle" default="no" /> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <StockRound class="rails.game.specific._18EU.StockRound_18EU" sequence="sellBuy" Modified: trunk/18xx/data/18Kaas/Game.xml =================================================================== --- trunk/18xx/data/18Kaas/Game.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/18Kaas/Game.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -9,6 +9,7 @@ <GameOption name="WithOptional6Train" type="toggle" default="no"/> <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> + <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <GameParameters> <PlayerShareLimit percentage="60"/> <BankPoolLimit percentage="50"/> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/data/GamesList.xml 2010-08-01 15:28:24 UTC (rev 1366) @@ -47,6 +47,7 @@ <Option name="NoMapMode" type="toggle" default="no" /> <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="UnlimitedTopTrains" parm="8" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <Players minimum="3" maximum="5"/> </Game> @@ -65,6 +66,7 @@ <Option name="UnlimitedBonusTokens" type="toggle" default="no"/> <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="LeaveAuctionOnPass" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <Players minimum="3" maximum="6"/> </Game> @@ -85,6 +87,7 @@ <Option name="WithOptional6Train" type="toggle" default="no"/> <Option name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <Option name="TwoPlayersCertLimit70Percent" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> </Game> <Game name="18AL"> @@ -105,6 +108,7 @@ <Option name="Obsolete4Trains" type="toggle" default="yes"/> <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="LeaveAuctionOnPass" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <Players minimum="3" maximum="5"/> </Game> @@ -142,6 +146,7 @@ <Option name="UnlimitedTopTrains" parm="D" type="toggle" default="no"/> <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="LeaveAuctionOnPass" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <Players minimum="3" maximum="6"/> </Game> @@ -185,6 +190,7 @@ <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="LeaveAuctionOnPass" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> <Players minimum="2" maximum="6"/> </Game> @@ -201,13 +207,14 @@ <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="UnlimitedTiles" type="toggle" default="no"/> + <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> </Game> <Credits>Rails is a computer implementation of a number of railroad board games, that are collectively known as the "18xx" railway game system. Rails is a Sourceforge project. Project founder: Brett Lentz. -Developers: Erik Vos and Brett Lentz. +Developers: Erik Vos, Stefan Frey and Brett Lentz. The 18xx railway game system was originated by Francis Tresham and Hartland Trefoil Ltd. Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/rails/game/StockRound.java 2010-08-01 15:28:24 UTC (rev 1366) @@ -412,12 +412,7 @@ * Check the price. If a cert was sold before this turn, the * original price is still valid */ - if (sellPrices.containsKey(compName) - && GameOption.convertValueToBoolean(getGameOption("SeparateSalesAtSamePrice"))) { - price = (sellPrices.get(compName)).getPrice(); - } else { - price = company.getMarketPrice(); - } + price = getCurrentSellPrice(company); price /= company.getShareUnitsForSharePrice(); /* Allow for different share units (as in 1835) */ @@ -1035,18 +1030,14 @@ } // All seems OK, now do the selling. - StockSpaceI sellPrice; - int price; + // Selling price + int price = getCurrentSellPrice (company); + + // Save original price as it may be reused in subsequent sale actions in the same turn boolean soldBefore = sellPrices.containsKey(companyName); - // Get the sell price (does not change within a turn) - if (soldBefore - && GameOption.convertValueToBoolean(getGameOption("SeparateSalesAtSamePrice"))) { - price = (sellPrices.get(companyName)).getPrice(); - } else { - sellPrice = company.getCurrentSpace(); - price = sellPrice.getPrice() / company.getShareUnitsForSharePrice(); - sellPrices.put(companyName, sellPrice); + if (!soldBefore) { + sellPrices.put(companyName, company.getCurrentSpace()); } moveStack.start(true); @@ -1118,6 +1109,20 @@ return true; } + protected int getCurrentSellPrice (PublicCompanyI company) { + + String companyName = company.getName(); + int price; + + if (sellPrices.containsKey(companyName) + && GameOption.convertValueToBoolean(getGameOption("SeparateSalesAtSamePrice"))) { + price = (sellPrices.get(companyName)).getPrice(); + } else { + price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + } + return price; + } + protected void adjustSharePrice (PublicCompanyI company, int numberSold, boolean soldBefore) { if (company.canSharePriceVary()) { Modified: trunk/18xx/rails/game/specific/_1835/StockRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-08-01 12:17:26 UTC (rev 1365) +++ trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-08-01 15:28:24 UTC (rev 1366) @@ -78,6 +78,22 @@ return price; } + @Override + // The sell-in-same-turn-at-decreasing-price option does not apply here + protected int getCurrentSellPrice (PublicCompanyI company) { + + String companyName = company.getName(); + int price; + + if (sellPrices.containsKey(companyName)) { + price = (sellPrices.get(companyName)).getPrice(); + } else { + price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + } + return price; + } + + /** Share price goes down 1 space for any number of shares sold. */ @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |