From: Erik V. <ev...@us...> - 2012-01-25 14:01:30
|
LocalisedText.properties | 6 data/1880/CompanyManager.xml | 59 + data/1880/Game.xml | 29 data/1880/StockMarket.xml | 8 data/1880/Tiles.xml | 2 rails/game/Company.java | 2 rails/game/GameManager.java | 16 rails/game/PublicCompany.java | 5 rails/game/PublicCompanyI.java | 2 rails/game/Round.java | 3 rails/game/StockMarket.java | 13 rails/game/StockMarketI.java | 1 rails/game/StockRound.java | 4 rails/game/StockSpace.java | 2 rails/game/StockSpaceI.java | 5 rails/game/StockSpaceType.java | 17 rails/game/StockSpaceTypeI.java | 16 rails/game/action/BuyStartItem.java | 12 rails/game/specific/_1880/BuyStartItem_1880.java | 164 +++++ rails/game/specific/_1880/GameManager_1880.java | 102 +++ rails/game/specific/_1880/OperatingRound_1880.java | 334 ++++++++++- rails/game/specific/_1880/PublicCompany_1880.java | 169 +++++ rails/game/specific/_1880/StartRound_1880.java | 70 +- rails/game/specific/_1880/StockMarket_1880.java | 169 +++++ rails/game/specific/_1880/StockRound_1880.java | 121 +++ rails/ui/swing/StartRoundWindow.java | 46 - rails/ui/swing/gamespecific/_1880/StartRoundWindow_1880.java | 121 +++ rails/ui/swing/gamespecific/_1880/StatusWindow_1880.java | 34 + tiles/TileDictionary.18t | 25 tiles/TileDictionary.xml | 4 tiles/svg/tile235.svg | 145 ++++ 31 files changed, 1577 insertions(+), 129 deletions(-) New commits: commit b1d3ff5d36d8bfd9c0a226e6c5f433c917ecd8fd Author: Erik Vos <eri...@xs...> Date: Wed Jan 25 14:55:51 2012 +0100 1880 tile 235 added to TileDesigner diff --git a/tiles/TileDictionary.18t b/tiles/TileDictionary.18t index d14e28d..9038379 100644 --- a/tiles/TileDictionary.18t +++ b/tiles/TileDictionary.18t @@ -17417,5 +17417,30 @@ object TTilesWrapper JunType = jtCity Revenue = 40 end> + end + item + Code = 235 + LongName = 'OO' + Category = 'OO' + CategoryPosition = tp2CornerC + Level = tlMapUpgradableToGreen + Connections = < + item + Position1 = tp2SideF + Position2 = tp4SideF + end> + Junctions = < + item + JunType = jtCity + Position = tp2SideD + Revenue = 30 + RevenuePosition = tp3CornerB + end + item + JunType = jtCity + Position = tp2SideF + Revenue = 30 + RevenuePosition = tp3CornerB + end> end> end commit 90483652116407d14af524316c5482d9db3687bc Author: Martin Brumm <dr....@t-...> Date: Wed Jan 25 14:30:11 2012 +0100 1880 patches diff --git a/LocalisedText.properties b/LocalisedText.properties index ee9b8a4..27d1085 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -688,9 +688,11 @@ Version=Version VersionOf=version of {0} WantToReplaceToken=Do you want to replace the {0} home token with one of {1}? WarningNeedCash=Warning: {0} will be deducted from the company revenue or from your personal cash +WHICH_BUILDING_RIGHT={0} please choose the Building Rights for {1} WHICH_PRICE=Which price? WHICH_PRIVATE=Which Private? -WHICH_PRIVATE_PRICE=Buy {0} for which price (valid range {1} to {2})? +WHICH_PRIVATE_PRICE=Buy {0} for which price (valid range {1} to {2})? +WHICH_RIGHT=Which Building Right ? WHICH_START_PRICE={0} please set the start price for {1} WhichStation=Which Station? WHICH_TRAIN=Which train @@ -729,4 +731,4 @@ YouMustRaiseCash=You must raise {0} cash by selling shares YouMustRaiseCashButCannot=You must still raise {0}, but you can''t sell any more shares. YouMustSelect1=You must select {0} item(s) YouMustSelect2=You must select between {0} and {1} items -YourTurn={0}, it''s your turn again \ No newline at end of file +YourTurn={0}, it''s your turn again diff --git a/data/1880/CompanyManager.xml b/data/1880/CompanyManager.xml index ecaea80..c4b55f7 100644 --- a/data/1880/CompanyManager.xml +++ b/data/1880/CompanyManager.xml @@ -12,7 +12,7 @@ <Payout split="no"/> </CompanyType> - <CompanyType name="Minor" class="rails.game.PublicCompany"> + <CompanyType name="Minor" class="rails.game.specific._1880.PublicCompany_1880"> <ShareUnit percentage="100"/> <Certificate type="President" shares="1"/> <StockPrice market="no"/> @@ -21,18 +21,18 @@ </BaseTokens> <Payout split="no"/> <Trains limit="1" mandatory="no"/> + <CanUseSpecialProperties/> + <!-- Specialproperties --> + <!-- Specialproperty condition="ifNotConnected" when="orTurn" + class="rails.game.special.TrainLoan" --> + <!-- /Specialproperty--> + <!-- /Specialproperties--> </CompanyType> <CompanyType name="Private" class="rails.game.PrivateCompany"/> - <CompanyType name="Major" class="rails.game.PublicCompany" - capitalisation="incremental"> - <Capitalisation Type="incremental"/> - <!--TileLays> - <Number colour="yellow" phase="2+2,3,3+3,4,4+4,6,6e,8,8e,10" - number="2"/> - </TileLays--> - <Float percentage="60"/> + <CompanyType name="Major" class="rails.game.specific._1880.PublicCompany_1880"> + <Float percentage="20"/> <StockPrice par="yes"/> <ShareUnit percentage="10"/> <Certificate type="President" shares="2"/> @@ -40,9 +40,9 @@ <BaseTokens> <LayCost method="sequence" cost="0,40,100"/> </BaseTokens> - <Capitalisation type="incremental"/> <Trains limit="4,3,2"/> <CanUseSpecialProperties/> + </CompanyType> <Company name="WR" longname="Woosong Railway" type="Private" basePrice="5" @@ -60,28 +60,40 @@ <Phase>4</Phase> </ClosingConditions> </Company> - <Company name="YC" longname="Yanda Ferry - Company" type="Private" + <Company name="YC" longname="Yanda Ferry Company" type="Private" basePrice="25" revenue="10"> - <!-- SpecialProperty condition="ifOwnedByPlayer" when="revenuecalcStep" revenue="10" --> + <SpecialProperties> + <SpecialProperty condition="ifOwnedByPlayer" when="revenueStep" + class="rails.game.special.LocatedBonus" transfer="toCompany"> + <LocatedBonus name="Ferry" location="F12,F14,I15" value="10"/> + </SpecialProperty> + </SpecialProperties> </Company> <Company name="TL" longname="Taiwan Western Line" type="Private" basePrice="45" revenue="15"> - <!-- SpecialProperty condition="ifOwnedByPlayer" when="revenuecalcStep" revenue="20" --> - </Company> - <Company name="CC" longname="Chinese Rivers Ferry - Company" type="Private" + <SpecialProperties> + <SpecialProperty condition="ifOwnedByPlayer" when="revenueStep" + class="rails.game.special.LocatedBonus" transfer="toCompany"> + <LocatedBonus name="Taiwan" location="N16" value="20"/> + </SpecialProperty> + </SpecialProperties> + </Company> + <Company name="CC" longname="Chinese Rivers Ferry Company" type="Private" basePrice="70" revenue="20"> + <SpecialProperties> <SpecialProperty condition="ifOwnedByPlayer" when="tileLayingStep" class="rails.game.special.SpecialTileLay"> <SpecialTileLay location="M15" extra="no" free="yes"/> </SpecialProperty> + </SpecialProperties> </Company> <Company name="JO" longname="Jeme Tien Yow Engineer Office" type="Private" basePrice="70" revenue="20"> - <SpecialProperty condition="ifOwnedByPlayer" when="tileLayingStep" - class="rails.game.specific._1880.BuildingPermit"> - </SpecialProperty> + <!-- SpecialProperties--> + <!-- SpecialProperty condition="ifOwnedByPlayer" when="tileLayingStep" + class="rails.game.specific._1880.BuildingPermit"--> + <!-- /SpecialProperty--> + <!-- -->/SpecialProperties--> </Company> <Company name="IG" longname="Imperial Qing Government" type="Private" basePrice="160" revenue="20"> @@ -89,17 +101,18 @@ </Company> <Company name="RC" longname="Rocket Company" type="Private" basePrice="70" revenue="0"> - <SpecialProperty condition="ifOwnedByPlayer" when="trainBuyingStep" - class="rails.game.special.SpecialTrainBuy"/> + <!-- SpecialProperties--> + <!-- SpecialProperty condition="ifOwnedByPlayer" when="trainBuyingStep" + class="rails.game.special.SpecialTrainBuy"/--> <!-- Kostenfreie Lok bei Phasenwechsel durch Lokkauf --> <!-- Can exchange Certificate for actual train in one phase 2,2+3,3,3+3,4 as soon as train has been bought --> <!-- The train can be moved upon purchase into one company owned by the owner of the certificate --> <!-- Company must have space for the new train, but can hand back an older train to bank (2+2,3,3+3) --> + <!-- /SpecialProperties--> <ClosingConditions> <Phase>5</Phase> - <SpecialProperties condition="ifExercised"/> </ClosingConditions> </Company> <Company name="BCR" longname="Baocheng Railway" type="Major" tokens="3" diff --git a/data/1880/Game.xml b/data/1880/Game.xml index 1a0ff10..814f622 100644 --- a/data/1880/Game.xml +++ b/data/1880/Game.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <ComponentManager> - <Component name="GameManager" class="rails.game.GameManager"> + <Component name="GameManager" class="rails.game.specific._1880.GameManager_1880"> <Game name="1880"/> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate"/> @@ -23,7 +23,7 @@ <StatusWindow class="rails.ui.swing.StatusWindow"/> <StartRoundWindow class="rails.ui.swing.gamespecific._1880.StartRoundWindow_1880"/> - </GuiClasses> + </GuiClasses> <EndOfGame/> <!-- need to implement the 3 OR set limit after purchase of first 8 TrainType --> @@ -92,7 +92,8 @@ <Component name="PhaseManager" class="rails.game.PhaseManager"> <Phase name="2" realName="A1"> <Tiles colour="yellow"> - <Lays companyType="Major" colour="yellow" number="2"/> + <Lays companyType="Major" colour="yellow" number="1"/> + <Lays companyType="Minor" colour="yellow" number="1"/> </Tiles> <OperatingRounds number="-1"/> <Float percentage="20"/> @@ -103,28 +104,37 @@ </Phase> <Phase name="3" realName="B1"> <Tiles colour="yellow,green"/> + <Lays companyType="Major" colour="yellow" number="2"/> + <Lays companyType="Minor" colour="yellow" number="1"/> + <Lays companyType="Major" colour="green" number="1"/> + <Lays companyType="Minor" colour="green" number="1"/> + <Float percentage="30"/> <Stocks avail="10"/> <OffBoardRevenue step="2"/> + <Action name="RaisingCertAvailability"/> </Phase> <Phase name="3+3" realName="B2"> <OffBoardRevenue step="2"/> </Phase> <Phase name="4" realName="B3"> + <Action name="CommunistTakeOver"/> <OffBoardRevenue step="2"/> <Privates close="yes"/> <Investors active="no"/> - <Communists active="yes"/> <Float percentage="40"/> <Trains limitStep="2" rusted="2"/> </Phase> <Phase name="4+4" realName="C1"> <Tiles colour="yellow,green,brown"/> + <Lays companyType="Major" colour="yellow" number="2"/> + <Lays companyType="Major" colour="green" number="1"/> + <Lays companyType="Major" colour="brown" number="1"/> <OffBoardRevenue step="3"/> <Trains rusted="2+2"/> </Phase> <Phase name="6" realName="C2"> - <Communists active="no"/> + <Action name="ShanghaiExchangeOpen"/> <Float percentage="60"/> <OffBoardRevenue step="3"/> <Trains limitStep="3" rusted="3"/> @@ -135,6 +145,10 @@ </Phase> <Phase name="8" realName="D1"> <Tiles colour="yellow,green,brown,grey"/> + <Lays companyType="Major" colour="yellow" number="2"/> + <Lays companyType="Major" colour="green" number="1"/> + <Lays companyType="Major" colour="brown" number="1"/> + <Lays companyType="Major" colour="grey" number="1"/> <OffBoardRevenue step="4"/> <Trains limitStep="3" rusted="4"/> </Phase> @@ -150,8 +164,5 @@ class="rails.game.specific._1880.ExpressTrainRevenueModifier"/> </Component> </Component> - <Component name="RevenueManager" class="rails.algorithms.RevenueManager"> - <Modifier class="rails.game.specific._1826.TGVModifier"/> - </Component> - + </ComponentManager> \ No newline at end of file diff --git a/data/1880/StockMarket.xml b/data/1880/StockMarket.xml index 5960108..c3dfccf 100644 --- a/data/1880/StockMarket.xml +++ b/data/1880/StockMarket.xml @@ -42,19 +42,19 @@ <StockSpace name="C9" price="60" /> <StockSpace name="D1" price="105" /> <StockSpace name="D2" price="100" > - <StartSpace parslots="4"/> + <StartSpace/> </StockSpace> <StockSpace name="D3" price="95" /> <StockSpace name="D4" price="90" > - <StartSpace parslots="4"/> + <StartSpace/> </StockSpace> <StockSpace name="D5" price="85" /> <StockSpace name="D6" price="80" > - <StartSpace parslots="4"/> + <StartSpace/> </StockSpace> <StockSpace name="D7" price="75" /> <StockSpace name="D8" price="70" > - <StartSpace parslots="4"/> + <StartSpace/> </StockSpace> <StockSpace name="D9" price="65" /> <StockSpace name="E1" price="110" /> diff --git a/data/1880/Tiles.xml b/data/1880/Tiles.xml index 34f548a..6ed5fd7 100644 --- a/data/1880/Tiles.xml +++ b/data/1880/Tiles.xml @@ -62,7 +62,7 @@ <Track from="city1" gauge="normal" to="side0"/> </Tile><Tile colour="yellow" id="235" name="235"> <Station id="city1" position="502" slots="1" type="City" value="20"/> - <Station id="city2" position="352" slots="1" type="City" value="20"/> + <Station id="city2" position="352" slots="1" type="City"/> <Track from="city1" gauge="normal" to="side5"/> </Tile><Tile colour="yellow" id="8850" name="8850"> <Station id="city1" position="352" type="Town" value="20"/> diff --git a/rails/game/Company.java b/rails/game/Company.java index f96b3a8..0b2aa2f 100644 --- a/rails/game/Company.java +++ b/rails/game/Company.java @@ -46,7 +46,7 @@ Cloneable, Comparable<Company> { /** Closed state */ protected BooleanState closedObject; - // Moved here from PrivayeCOmpany on behalf of 1835 + // Moved here from PrivateCompany on behalf of 1835 protected List<SpecialPropertyI> specialProperties = null; protected static Logger log = diff --git a/rails/game/GameManager.java b/rails/game/GameManager.java index 8046968..8058d91 100644 --- a/rails/game/GameManager.java +++ b/rails/game/GameManager.java @@ -226,6 +226,10 @@ public class GameManager implements ConfigurableComponentI, GameManagerI { protected static Logger log = Logger.getLogger(GameManager.class.getPackage().getName()); + //State variable to be able to determine a changed playerorder after a Startround Sub Phase + //Currently use in 1880 (1853, 1844, 1837, or any other game that reorders players after result of startinground) + public BooleanState playerOrderHasChanged = new BooleanState("PlayerOrderHasChange", false); + public GameManager() { gmName = GM_NAME; gmKey = GM_KEY; @@ -1341,7 +1345,7 @@ public class GameManager implements ConfigurableComponentI, GameManagerI { addToNextPlayerMessages(msg, true); } - private void finishGame() { + protected void finishGame() { gameOver.set(true); String message = LocalText.getText("GameOver"); @@ -1885,21 +1889,21 @@ public class GameManager implements ConfigurableComponentI, GameManagerI { public Player reorderPlayersByCash (boolean ascending) { final boolean _ascending = ascending; - Collections.sort (players, new Comparator<Player>() { + Collections.sort (this.players, new Comparator<Player>() { public int compare (Player p1, Player p2) { return _ascending ? p1.getCash() - p2.getCash() : p2.getCash() - p1.getCash(); } }); Player player; - for (int i=0; i<players.size(); i++) { - player = players.get(i); + for (int i=0; i<this.players.size(); i++) { + player = this.players.get(i); player.setIndex (i); - playerNames.set (i, player.getName()); + this.playerNames.set (i, player.getName()); log.debug("New player "+i+" is "+player.getName() +" (cash="+Bank.format(player.getCash())+")"); } - return players.get(0); + return this.players.get(0); } public void resetStorage() { diff --git a/rails/game/PublicCompany.java b/rails/game/PublicCompany.java index 16c25ee..3ad1c2c 100644 --- a/rails/game/PublicCompany.java +++ b/rails/game/PublicCompany.java @@ -792,6 +792,7 @@ public class PublicCompany extends Company implements PublicCompanyI { name + "_" + colour + "_ExtraTileTurns", turns)); } + /** Reset turn objects */ public void initTurn() { @@ -1963,6 +1964,7 @@ public class PublicCompany extends Company implements PublicCompanyI { // New style int tileLays = phase.getTileLaysPerColour(getTypeName(), tileColour); + if (tileLays <= 1) { extraTileLays = null; return tileLays; @@ -1973,6 +1975,8 @@ public class PublicCompany extends Company implements PublicCompanyI { if (turnsWithExtraTileLays != null) { extraTiles = turnsWithExtraTileLays.get(tileColour); } + + if (extraTiles != null) { if (extraTiles.intValue() == 0) { extraTiles = null; @@ -2091,4 +2095,5 @@ public class PublicCompany extends Company implements PublicCompanyI { public boolean hasRoute() { return true; } + } diff --git a/rails/game/PublicCompanyI.java b/rails/game/PublicCompanyI.java index f39b619..ab08a06 100644 --- a/rails/game/PublicCompanyI.java +++ b/rails/game/PublicCompanyI.java @@ -16,7 +16,7 @@ public interface PublicCompanyI extends CompanyI, CashHolder, TokenHolder { public static final int CAPITALISE_INCREMENTAL = 1; public static final int CAPITALISE_WHEN_BOUGHT = 2; - + public void setIndex (int index); diff --git a/rails/game/Round.java b/rails/game/Round.java index b162080..0dcfd98 100644 --- a/rails/game/Round.java +++ b/rails/game/Round.java @@ -13,6 +13,7 @@ import rails.common.*; import rails.game.action.*; import rails.game.move.*; import rails.game.special.SpecialPropertyI; +import rails.game.specific._1880.PublicCompany_1880; import rails.game.state.BooleanState; /** @@ -373,7 +374,7 @@ public abstract class Round implements RoundI { } else if (capitalisationMode == PublicCompanyI.CAPITALISE_WHEN_BOUGHT) { // Cash goes directly to treasury at each buy (as in 1856 before phase 6) capFactor = 0; - } + } int price = company.getIPOPrice(); cash = capFactor * price; } else { diff --git a/rails/game/StockMarket.java b/rails/game/StockMarket.java index c117ead..d64e167 100644 --- a/rails/game/StockMarket.java +++ b/rails/game/StockMarket.java @@ -130,6 +130,7 @@ public class StockMarket implements StockMarketI, ConfigurableComponentI { if (spaceTag.getChild(StockSpaceI.START_SPACE_TAG) != null) { space.setStart(true); startSpaces.add(space); + } space.setClosesCompany(spaceTag.getChild(StockSpaceI.CLOSES_COMPANY_TAG) != null); space.setEndsGame(spaceTag.getChild(StockSpaceI.GAME_OVER_TAG) != null); @@ -344,14 +345,14 @@ public class StockMarket implements StockMarketI, ConfigurableComponentI { public int[] getStartPrices() { return startPrices; } - + public StockSpaceI getStartSpace(int price) { for (StockSpaceI square : startSpaces) { if (square.getPrice() == price) return square; } return null; } - + public PublicCertificate removeShareFromPile(PublicCertificate stock) { if (ipoPile.contains(stock)) { int index = ipoPile.lastIndexOf(stock); @@ -378,4 +379,12 @@ public class StockMarket implements StockMarketI, ConfigurableComponentI { return numRows; } + public int getNumberOfStartPrices() { + int result = 0; + for(int i=0; i< startPrices.length; i++) { + if (startPrices[i]!= 0) result++; + } + return result; + } + } diff --git a/rails/game/StockMarketI.java b/rails/game/StockMarketI.java index a878360..96ed186 100644 --- a/rails/game/StockMarketI.java +++ b/rails/game/StockMarketI.java @@ -48,4 +48,5 @@ public interface StockMarketI extends ConfigurableComponentI { public void processMoveToStackPosition(PublicCompanyI company, StockSpaceI from, StockSpaceI to, int toStackPosition); + } diff --git a/rails/game/StockRound.java b/rails/game/StockRound.java index ca25bf3..0d3fcf8 100644 --- a/rails/game/StockRound.java +++ b/rails/game/StockRound.java @@ -1657,4 +1657,8 @@ public class StockRound extends Round { sellObligationLifted.add(company); } + /* (non-Javadoc) + * @see rails.game.Round#floatCompany(rails.game.PublicCompanyI) + */ + } diff --git a/rails/game/StockSpace.java b/rails/game/StockSpace.java index 1945cbf..5853946 100644 --- a/rails/game/StockSpace.java +++ b/rails/game/StockSpace.java @@ -247,7 +247,7 @@ public class StockSpace extends ModelObject implements StockSpaceI { public void setStart(boolean b) { start = b; } - + /** * @param set if token is left of ledge */ diff --git a/rails/game/StockSpaceI.java b/rails/game/StockSpaceI.java index 83cc3e7..578a6d5 100644 --- a/rails/game/StockSpaceI.java +++ b/rails/game/StockSpaceI.java @@ -29,6 +29,9 @@ public interface StockSpaceI // extends TokenHolderI */ public static final String START_SPACE_TAG = "StartSpace"; + /** The name of the XML tag for the number of Parslots per Startprice */ + public static final String START_SPACE_SLOTS_TAG ="ParSlots"; + /** The name of the XML tag for the "below ledge" property. */ public static final String BELOW_LEDGE_TAG = "BelowLedge"; @@ -38,7 +41,7 @@ public interface StockSpaceI // extends TokenHolderI /** The name of the XML tag for the "closes company" property. */ public static final String CLOSES_COMPANY_TAG = "ClosesCompany"; - /** The name of the XML tag for the "gamn over" property. */ + /** The name of the XML tag for the "game over" property. */ public static final String GAME_OVER_TAG = "GameOver"; // No constructors (yet) for the booleans, which are rarely needed. Use the diff --git a/rails/game/StockSpaceType.java b/rails/game/StockSpaceType.java index 6e5295f..c1e965d 100644 --- a/rails/game/StockSpaceType.java +++ b/rails/game/StockSpaceType.java @@ -22,6 +22,7 @@ public class StockSpaceType implements StockSpaceTypeI { protected boolean noCertLimit = false; // In yellow zone protected boolean noHoldLimit = false; // In orange zone (1830) protected boolean noBuyLimit = false; // In brown zone (1830) + protected int addRevenue = 0; // additional revenue for company listed at that space (1880) public static final String WHITE = "FFFFFF"; @@ -72,6 +73,14 @@ public class StockSpaceType implements StockSpaceTypeI { public boolean isNoHoldLimit() { return noHoldLimit; } + + /** + * @return returns the additional revenue per 10% share + */ + public int hasAddRevenue() { + return addRevenue; + } + /*--- Setters ---*/ /** @@ -94,5 +103,11 @@ public class StockSpaceType implements StockSpaceTypeI { public void setNoHoldLimit(boolean b) { noHoldLimit = b; } - + /** + * @param revenue additional Revenue for a company listed at this space + */ + public void setAddRevenue(int revenue) { + addRevenue = revenue; + } + } diff --git a/rails/game/StockSpaceTypeI.java b/rails/game/StockSpaceTypeI.java index ca896f7..a84aa63 100644 --- a/rails/game/StockSpaceTypeI.java +++ b/rails/game/StockSpaceTypeI.java @@ -41,8 +41,8 @@ public interface StockSpaceTypeI { * The name of the XML tag for the "NoBuyLimit" property. (1830: brown area) */ public static final String NO_BUY_LIMIT_TAG = "NoBuyLimit"; - - /** + + /** * @return Color */ public abstract Color getColour(); @@ -67,6 +67,11 @@ public interface StockSpaceTypeI { * @return if space triggers Stock not counting toward certificate limit */ public boolean isNoHoldLimit(); + + /** + * @return returns the additional revenue per 10% share + */ + public int hasAddRevenue(); /** * @param b @@ -82,5 +87,10 @@ public interface StockSpaceTypeI { * @param b */ public void setNoHoldLimit(boolean b); - + + /** + * @param revenue additional Revenue for a company listed at this space + */ + public void setAddRevenue(int revenue); + } diff --git a/rails/game/action/BuyStartItem.java b/rails/game/action/BuyStartItem.java index 2b203a7..a66ac7e 100644 --- a/rails/game/action/BuyStartItem.java +++ b/rails/game/action/BuyStartItem.java @@ -5,6 +5,8 @@ */ package rails.game.action; +import java.util.BitSet; + import rails.game.PublicCompanyI; import rails.game.StartItem; @@ -16,12 +18,13 @@ public class BuyStartItem extends StartItemAction { /* Server-provided fields */ private int price; private boolean selected; - private boolean sharePriceToSet = false; - private String companyNeedingSharePrice = null; - private boolean setSharePriceOnly = false; + protected boolean sharePriceToSet = false; + protected String companyNeedingSharePrice = null; + protected boolean setSharePriceOnly = false; // Client-provided fields private int associatedSharePrice; + private BitSet associatedBuildingRight; public static final long serialVersionUID = 1L; @@ -38,7 +41,7 @@ public class BuyStartItem extends StartItemAction { PublicCompanyI company; if ((company = startItem.needsPriceSetting()) != null) { - sharePriceToSet = true; + sharePriceToSet=true; companyNeedingSharePrice = company.getName(); } } @@ -102,4 +105,5 @@ public class BuyStartItem extends StartItemAction { return b.toString(); } + } diff --git a/rails/game/specific/_1880/BuyStartItem_1880.java b/rails/game/specific/_1880/BuyStartItem_1880.java new file mode 100644 index 0000000..3efa52c --- /dev/null +++ b/rails/game/specific/_1880/BuyStartItem_1880.java @@ -0,0 +1,164 @@ +/** + * + */ +package rails.game.specific._1880; + +import rails.game.StartItem; +import rails.game.action.BuyStartItem; + +import java.util.BitSet; + +import rails.game.PublicCompanyI; +import rails.game.action.PossibleAction; +/** + * @author Martin Brumm + * + */ +public class BuyStartItem_1880 extends BuyStartItem { + + public static final long serialVersionUID = 1L; + + private BitSet buildingRights; + + private BitSet associatedBuildingRight; + /** + * @param startItem + * @param price + * @param selected + * @param setSharePriceOnly + */ + public BuyStartItem_1880(StartItem startItem, int price, boolean selected, + boolean setSharePriceOnly) { + + + super(startItem, price, selected, setSharePriceOnly); + // TODO Auto-generated constructor stub + this.buildingRights = new BitSet(4); + } + + + public BuyStartItem_1880(StartItem startItem, int price, boolean selected, + boolean setSharePriceOnly, BitSet buildingRight) { + + super(startItem,price,selected,setSharePriceOnly); + this.buildingRights = buildingRight; + + PublicCompanyI company; + if ((company = startItem.needsPriceSetting()) != null) { + sharePriceToSet = true; + companyNeedingSharePrice = company.getName(); + } + } + + /** + * @param startItem + * @param price + * @param selected + */ + public BuyStartItem_1880(StartItem startItem, int price, boolean selected) { + super(startItem, price, selected); + // TODO Auto-generated constructor stub + this.buildingRights = new BitSet(4); + } + + public boolean equalsAsOption(PossibleAction action) { + if (!(action instanceof BuyStartItem_1880)) return false; + BuyStartItem_1880 a = (BuyStartItem_1880) action; + return a.startItem == startItem && a.itemIndex == itemIndex + && a.getPrice() == getPrice() && a.buildingRights == buildingRights; + } + public boolean equalsAsAction(PossibleAction action) { + if (!(action instanceof BuyStartItem_1880)) return false; + BuyStartItem_1880 a = (BuyStartItem_1880) action; + return a.equalsAsOption(this) + && a.getAssociatedSharePrice() == getAssociatedSharePrice() + && a.associatedBuildingRight == associatedBuildingRight; + } + public String toString() { + StringBuffer b = new StringBuffer(); + b.append("BuyStartItem_1880 ").append(startItemName).append(" price=").append( + getPrice()).append(" selected=").append(isSelected()); + + if (sharePriceToSet) { + b.append(" shareprice=").append(getAssociatedSharePrice()).append(" BuildingRight=").append(buildingRightToString(buildingRights)).append( + " for company " + companyNeedingSharePrice); + } + return b.toString(); + } + + /** + * @return the buildingRights + */ + public BitSet getAssociatedBuildingRight() { + return associatedBuildingRight; + } + /** + * @param buildingRights the buildingRights to set + */ + public void setAssociatedBuildingRight(BitSet buildingRight ) { + this.associatedBuildingRight = buildingRight; + } + + public void setAssociatedBuildingRight(String buildingRightString ) { + BitSet buildingRight = new BitSet(); + + if (buildingRightString == "A") { + buildingRight.set(0); + } else if (buildingRightString == "B") { + buildingRight.set(1); + } else if (buildingRightString == "C") { + buildingRight.set(2); + } else if (buildingRightString == "D") { + buildingRight.set(3); + } else if (buildingRightString == "A+B") { + buildingRight.set(0,1); + } else if (buildingRightString == "A+B+C") { + buildingRight.set(0,2); + } else if (buildingRightString == "B+C") { + buildingRight.set(1,2); + } else if (buildingRightString == "B+C+D") { + buildingRight.set(1,3); + } else if (buildingRightString == "C+D") { + buildingRight.set(2,3); + } + + this.associatedBuildingRight = buildingRight; + } + + public String buildingRightToString (BitSet buildingRight){ + String buildingRightString = null; + + if (! buildingRight.isEmpty()){ + if (buildingRight.get(0)== true) { + buildingRightString = "A"; + if (buildingRight.get(1) == true) { + buildingRightString = "A+B"; + if (buildingRight.get(2) == true) { + buildingRightString = "A+B+C"; + } + } + } + else if (buildingRight.get(1) == true) { + buildingRightString = "B"; + if (buildingRight.get(2) == true) { + buildingRightString = "B+C"; + if (buildingRight.get(3) == true){ + buildingRightString = "B+C+D"; + } + } + } + else if (buildingRight.get(2) == true){ + buildingRightString = "C"; + if (buildingRight.get(3) == true){ + buildingRightString = "C+D"; + } + } + else if (buildingRight.get(3) == true){ + buildingRightString= "D"; + } + return buildingRightString; + } + return "None"; + } + +} \ No newline at end of file diff --git a/rails/game/specific/_1880/GameManager_1880.java b/rails/game/specific/_1880/GameManager_1880.java new file mode 100644 index 0000000..6fded62 --- /dev/null +++ b/rails/game/specific/_1880/GameManager_1880.java @@ -0,0 +1,102 @@ +/** + * + */ +package rails.game.specific._1880; + +import rails.game.GameManager; +import rails.game.PhaseI; +import rails.game.RoundI; +import rails.game.StartRound; +import rails.game.StockRound; +import rails.game.state.IntegerState; + +/** + * @author Martin Brumm + * @date 21.1.2012 + * + */ +public class GameManager_1880 extends GameManager { + + private RoundI previousRound = null; + public IntegerState numOfORs = new IntegerState("numOfORs"); + //Keeps track of the company that purchased the last train + private PublicCompany_1880 lastTrainBuyingCompany; + /** + * + */ + public GameManager_1880() { + super(); + } + + /* (non-Javadoc) + * @see rails.game.GameManager#nextRound(rails.game.RoundI) + */ + @Override + public void nextRound(RoundI round) { + if (round instanceof StartRound) { // BCR Operates only if all privates are sold out + if (startPacket != null && !startPacket.areAllSold()) { + startOperatingRound(runIfStartPacketIsNotCompletelySold()); + } else { + startStockRound(); + } + numOfORs.set(10); + } else if (round instanceof StockRound) { + if (interruptedRound != null) { + setRound(interruptedRound); + interruptedRound.resume(); + interruptedRound = null; + } else { // First StockRound after StartRound... + PhaseI currentPhase = getCurrentPhase(); + if (currentPhase == null) log.error ("Current Phase is null??", new Exception ("")); + // Create a new OperatingRound (never more than one Stock Round) + // OperatingRound.resetRelativeORNumber(); + + relativeORNumber.set(1); + + startOperatingRound(true); + } + } else if ( round instanceof OperatingRound_1880) { + if (gameOverPending.booleanValue() && !gameEndsAfterSetOfORs) { + + finishGame(); + + } else if (relativeORNumber.add(1) <= numOfORs.intValue()) { + // There will be another OR + startOperatingRound(true); + } else if (startPacket != null && !startPacket.areAllSold()) { + startStartRound(); + } else { + if (gameOverPending.booleanValue() && gameEndsAfterSetOfORs) { + finishGame(); + } + } + } + }// End of nextRound + + /** + * @return the lastTrainBuyingCompany + */ + public PublicCompany_1880 getLastTrainBuyingCompany() { + return lastTrainBuyingCompany; + } + + /** + * @param lastTrainBuyingCompany the lastTrainBuyingCompany to set + */ + public void setLastTrainBuyingCompany(PublicCompany_1880 lastTrainBuyingCompany) { + this.lastTrainBuyingCompany = lastTrainBuyingCompany; + } + + /* (non-Javadoc) + * @see rails.game.GameManager#startStockRound() + */ + + protected void startStockRound_1880(OperatingRound_1880 or) { + // TODO Auto-generated method stub + interruptedRound = or; + super.startStockRound(); + } + + + +} diff --git a/rails/game/specific/_1880/OperatingRound_1880.java b/rails/game/specific/_1880/OperatingRound_1880.java index 3471cfa..7d9a9ee 100644 --- a/rails/game/specific/_1880/OperatingRound_1880.java +++ b/rails/game/specific/_1880/OperatingRound_1880.java @@ -3,8 +3,52 @@ */ package rails.game.specific._1880; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import rails.common.DisplayBuffer; +import rails.common.GuiDef; +import rails.common.LocalText; +import rails.game.Bank; +import rails.game.Bonus; +import rails.game.GameDef; import rails.game.GameManagerI; +import rails.game.MapHex; import rails.game.OperatingRound; +import rails.game.PhaseI; +import rails.game.Player; +import rails.game.Portfolio; +import rails.game.PrivateCompanyI; +import rails.game.PublicCompanyI; +import rails.game.ReportBuffer; +import rails.game.TrainCertificateType; +import rails.game.TrainI; +import rails.game.TrainManager; +import rails.game.TrainType; +import rails.game.action.BuyBonusToken; +import rails.game.action.BuyPrivate; +import rails.game.action.BuyTrain; +import rails.game.action.DiscardTrain; +import rails.game.action.LayBaseToken; +import rails.game.action.NullAction; +import rails.game.action.PossibleAction; +import rails.game.action.PossibleORAction; +import rails.game.action.SetDividend; +import rails.game.action.UseSpecialProperty; +import rails.game.correct.ClosePrivate; +import rails.game.move.AddToList; +import rails.game.move.CashMove; +import rails.game.move.ObjectMove; +import rails.game.special.SellBonusToken; +import rails.game.special.SpecialPropertyI; +import rails.game.special.SpecialTileLay; +import rails.game.special.SpecialTokenLay; +import rails.game.special.SpecialTrainBuy; +import rails.game.specific._1880.PublicCompany_1880; +import rails.game.specific._1880.GameManager_1880; +import rails.game.state.EnumState; +import rails.sound.BackgroundMusicManager; /** * @author Martin @@ -12,12 +56,298 @@ import rails.game.OperatingRound; */ public class OperatingRound_1880 extends OperatingRound { + + protected GameDef.OrStep[] steps = + new GameDef.OrStep[] { + GameDef.OrStep.INITIAL, + GameDef.OrStep.LAY_TRACK, + GameDef.OrStep.LAY_TOKEN, + GameDef.OrStep.CALC_REVENUE, + GameDef.OrStep.PAYOUT, + GameDef.OrStep.BUY_TRAIN, + GameDef.OrStep.TRADE_SHARES, + GameDef.OrStep.FINAL }; + /** * @param gameManager */ - public OperatingRound_1880(GameManagerI gameManager) { - super(gameManager); + public OperatingRound_1880(GameManagerI gameManager_1880) { + super(gameManager_1880); // TODO Auto-generated constructor stub } + @Override + public void processPhaseAction (String name, String value) { + if (name.equalsIgnoreCase("RaisingCertAvailability")){ + for (PublicCompanyI company : gameManager.getAllPublicCompanies()){ + if (!company.hasFloated()){ + ((PublicCompany_1880) company).setFloatPercentage(30); + } + } + } + if (name.equalsIgnoreCase("CommunistTakeOver")) { + for (PublicCompanyI company : getOperatingCompanies()) { + if (company.hasFloated()) { + ((PublicCompany_1880)company).setCommunistTakeOver(true); + } + } + for (PublicCompanyI company : gameManager.getAllPublicCompanies()){ + if (!company.hasFloated()){ + ((PublicCompany_1880) company).setFloatPercentage(40); + } + } + } + if (name.equalsIgnoreCase("ShanghaiExchangeOpen")) { + for (PublicCompanyI company : getOperatingCompanies()) { + if (company.hasFloated()) { + ((PublicCompany_1880)company).setCommunistTakeOver(false); + } + } + for (PublicCompanyI company : gameManager.getAllPublicCompanies()){ + if (!company.hasFloated()){ + ((PublicCompany_1880) company).setFloatPercentage(60); + } + } + } + } + + @Override + protected void prepareRevenueAndDividendAction () { + + int[] allowedRevenueActions = new int[] {}; + // There is only revenue if there are any trains + if (operatingCompany.get().canRunTrains()) { + if (operatingCompany.get().hasStockPrice()) { + allowedRevenueActions = + operatingCompany.get().isSplitAlways() + ? new int[] { SetDividend.SPLIT } + : operatingCompany.get().isSplitAllowed() + ? new int[] { SetDividend.PAYOUT, + SetDividend.SPLIT, + SetDividend.WITHHOLD } + : new int[] { SetDividend.PAYOUT, + SetDividend.WITHHOLD }; + } + else { //Minors in 1880 are not allowed to hand out Cash except in Closing + allowedRevenueActions = new int[] {SetDividend.WITHHOLD }; + } + + possibleActions.add(new SetDividend( + operatingCompany.get().getLastRevenue(), true, + allowedRevenueActions)); + } + } + + /* (non-Javadoc) + * @see rails.game.OperatingRound#initNormalTileLays() + */ + @Override + protected void initNormalTileLays() { + /** + * Create a List of allowed normal tile lays (see LayTile class). This + * method should be called only once per company turn in an OR: at the start + * of the tile laying step. + */ + String opCompany = operatingCompany.get().getName(); + // duplicate the phase colours + Map<String, Integer> newTileColours = new HashMap<String, Integer>(); + for (String colour : getCurrentPhase().getTileColours()) { + int allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); + // Replace the null map value with the allowed number of lays + newTileColours.put(colour, new Integer(allowedNumber)); + } + // store to state + tileLaysPerColour.initFromMap(newTileColours); + } + + /* (non-Javadoc) + * @see rails.game.OperatingRound#start() + */ + @Override + public void start() { + thisOrNumber = gameManager.getORId(); + + ReportBuffer.add(LocalText.getText("START_OR", thisOrNumber)); + + BackgroundMusicManager.notifyOfOperatingRoundStart(); + + for (Player player : gameManager.getPlayers()) { + player.setWorthAtORStart(); + } + + privatesPayOut(); + + if ((operatingCompanies.size() > 0) && (gameManager.getAbsoluteORNumber()>= 1)){ + // even if the BCR is sold she doesn't operate until all privates have been sold + //the absolute OR value is not incremented if not the startpacket has been sold completely + + StringBuilder msg = new StringBuilder(); + for (PublicCompanyI company : operatingCompanies.viewList()) { + msg.append(",").append(company.getName()); + } + if (msg.length() > 0) msg.deleteCharAt(0); + log.info("Initial operating sequence is "+msg.toString()); + + if (stepObject == null) { + stepObject = new EnumState<GameDef.OrStep>("ORStep", GameDef.OrStep.INITIAL); + stepObject.addObserver(this); + } + + if (setNextOperatingCompany(true)){ + setStep(GameDef.OrStep.INITIAL); + } + return; + } + + // No operating companies yet: close the round. + String text = LocalText.getText("ShortORExecuted"); + ReportBuffer.add(text); + DisplayBuffer.add(text); + finishRound(); + } + + /* (non-Javadoc) + * @see rails.game.OperatingRound#buyTrain(rails.game.action.BuyTrain) + */ + @Override + public boolean buyTrain(BuyTrain action) { + + SpecialTrainBuy stb = null; + PublicCompany_1880 oldLastTrainBuyingCompany = null; + TrainManager TrainMgr=gameManager.getTrainManager(); + List<TrainI> trains; + boolean lastTrainOfType = false; + + stb = action.getSpecialProperty(); + + trains=TrainMgr.getAvailableNewTrains(); + + if ((trains.size() == 1)&& (ipo.getTrainsPerType(trains.get(0).getType()).length==1 )){ // Last available train of a type is on for grabs.. + lastTrainOfType=true; + } + + if (stb != null) { // A special Train buying right that gets exercised doesnt prolong the train rush + + oldLastTrainBuyingCompany= ((GameManager_1880) gameManager).getLastTrainBuyingCompany(); + + if (super.buyTrain(action)) { + if (stb.isExercised()){ + ((GameManager_1880) gameManager).setLastTrainBuyingCompany(oldLastTrainBuyingCompany); + } else { + ((GameManager_1880) gameManager).setLastTrainBuyingCompany((PublicCompany_1880) operatingCompany.get()); + } + //Check: Did we just buy the last Train of that Type ? Then we fire up the Stockround + if (lastTrainOfType) { + ((GameManager_1880) gameManager).startStockRound_1880(this); + } + return true; + } else { + return false; + } + } else { + if (super.buyTrain(action)) { + ((GameManager_1880) gameManager).setLastTrainBuyingCompany((PublicCompany_1880) operatingCompany.get()); + //Check: Did we just buy the last Train of that Type ? Then we fire up the Stockround + if (lastTrainOfType) { + ((GameManager_1880) gameManager).startStockRound_1880(this); + } + return true; + } else { + return false; + } + } + } + + /* (non-Javadoc) + * @see rails.game.OperatingRound#newPhaseChecks() + */ + @Override + protected void newPhaseChecks() { + PhaseI newPhase = getCurrentPhase(); + if (newPhase.getName()=="8") { + ((GameManager_1880) gameManager).numOfORs.set(2); // After the first 8 has been bought there will be a last Stockround and two ORs. + } + else { + if (newPhase.getName() == "8e") { + return; + } + } + + } + + @Override + public void resume () { + + guiHints.setActivePanel(GuiDef.Panel.MAP); + guiHints.setCurrentRoundType(getClass()); + + if (getOperatingCompany() != null) { + setStep(GameDef.OrStep.BUY_TRAIN); + } else { + finishOR(); + } + wasInterrupted.set(true); + } + + /* (non-Javadoc) + * @see rails.game.OperatingRound#process(rails.game.action.PossibleAction) + */ + @Override + public boolean process(PossibleAction action) { + + boolean result = false; + + if (action instanceof PossibleORAction + && !(action instanceof DiscardTrain)) { + PublicCompanyI company = ((PossibleORAction) action).getCompany(); + if (company != operatingCompany.get()) { + DisplayBuffer.add(LocalText.getText("WrongCompany", + company.getName(), + operatingCompany.get().getName() )); + return false; + } + } + + selectedAction = action; + + if (selectedAction instanceof NullAction) { + + NullAction nullAction = (NullAction) action; + switch (nullAction.getMode()) { + case NullAction.DONE: //Making Sure that the NullAction.DONE is in the Buy_Train Step.. + if (getStep() != GameDef.OrStep.BUY_TRAIN){ + result = done(); + break; + } + if (operatingCompany.get() == ((GameManager_1880) gameManager).getLastTrainBuyingCompany()){ + if (trainsBoughtThisTurn.isEmpty()) { + // The current Company is the Company that has bought the last train and that purchase was not in this OR.. + // we now discard the remaining active trains of that Subphase and start a stockround... + List<TrainI> trains = trainManager.getAvailableNewTrains(); + TrainType currentType = trains.get(0).getType(); + for (TrainI train: trains){ + new ObjectMove(train,ipo,scrapHeap); + } + ((GameManager_1880) gameManager).startStockRound_1880(this); + } + } + result = done(); + break; + case NullAction.PASS: + result = done(); + break; + case NullAction.SKIP: + skip(); + result = true; + break; + } + return result; + } + else { + return super.process(action); + } + } + } + + diff --git a/rails/game/specific/_1880/PublicCompany_1880.java b/rails/game/specific/_1880/PublicCompany_1880.java index 0add471..885d364 100644 --- a/rails/game/specific/_1880/PublicCompany_1880.java +++ b/rails/game/specific/_1880/PublicCompany_1880.java @@ -3,8 +3,16 @@ */ package rails.game.specific._1880; +import java.util.BitSet; + +import rails.common.GuiDef; +import rails.common.parser.ConfigurationException; +import rails.common.parser.Tag; import rails.game.*; -import rails.game.state.IntegerState; +import rails.game.model.ModelObject; +import rails.game.state.BooleanState; +import rails.game.state.HashMapState; + /** * @author Martin @@ -12,12 +20,169 @@ import rails.game.state.IntegerState; */ public class PublicCompany_1880 extends PublicCompany { + + /** + * Buildingrights belong to Phases in 1880 the player will be asked to choose which combination + * he wants and subsequently his company will be granted the appropriate rights. Further the value + * of the presidents share depends on the building right. + * A Player has the maximum of 3 phases without the use of a special power of a certain private paper. + * Example : A) Player chooses to build in Phase A+B+C (or B+C+D) this will lead to a president share value of 20% + * B) Player chooses to build in Phase A+B (or B+C or C+D) this will lead to a president share value of 30 % + * C) Player chooses to build in Phase A (or B or C or D) this will lead to a president share value of 40 % + * The BitSet BuildingRights should be able to handle the information : + * Bit 0 set True Player can build in Phase A + * Bit 1 set True Player can build in Phase B + * Bit 2 set True Player can build in Phase C + * Bit 3 set True Player can build in Phase D + * + */ + private BitSet buildingRights = new BitSet(4); + + + + //Implementation of PhaseAction to be able to handle the CommunistPhase + private BooleanState communistTakeOver = new BooleanState ("communistTakeOver",false); + + //Implementation of PhaseAction to be able to handle the Change in Capitalisation + private BooleanState capitalChanged = new BooleanState ("capitalChanged",false); + + //Implementation of Phase Action to be able to handle the Post Communist Phase + private BooleanState shanghaiExchangeFounded = new BooleanState ("shanghaiExchangeFounded",false); + + + /** * */ + public PublicCompany_1880() { + super(); + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see rails.game.PublicCompany#configureFromXML(rails.common.parser.Tag) + */ + @Override + public void configureFromXML(Tag tag) throws ConfigurationException { + // TODO Auto-generated method stub + super.configureFromXML(tag); + } + + /* (non-Javadoc) + * @see rails.game.PublicCompany#finishConfiguration(rails.game.GameManagerI) + */ + @Override + public void finishConfiguration(GameManagerI gameManager) + throws ConfigurationException { + // TODO Auto-generated method stub + super.finishConfiguration(gameManager); + // Introducing the rights field in the Display to be used by Building Rights Display and other Special Properties... + gameManager.setGuiParameter (GuiDef.Parm.HAS_ANY_RIGHTS, true); + if (rights == null) rights = new HashMapState<String, String>(name+"_Rights"); + } + + /** + * @return the buildingRights + */ + public BitSet getBuildingRights() { + return buildingRights; + } + /** + * @param buildingRights the buildingRights to set + */ + public void setBuildingRights(BitSet buildingRights) { + this.buildingRights = buildingRights; + } - + public void setCommunistTakeOver(boolean b) { + communistTakeOver.set(b); + + } + /** + * @return the communistTakeOver + */ + public Boolean isCommunistPhase() { + return communistTakeOver.booleanValue(); + } + + public ModelObject getCommunistTakeOver() { + return communistTakeOver; + } + + /** Don't move the space if the company is withholding train income during the CommunistPhase + * + */ + @Override + public void withhold(int amount) { + if (isCommunistPhase()) return; + if (hasStockPrice) stockMarket.withhold(this); + } + + public void setFloatPercentage(int i) { + this.floatPerc=i; + + } + + @Override + public boolean canRunTrains() { + if (!isCommunistPhase() && (!hasStockPrice()) ){ + return true; + } + return portfolio.getNumberOfTrains() > 0; + + } + + + + /* (non-Javadoc) + * @see rails.game.PublicCompany#getNumberOfTileLays(java.lang.String) + */ + @Override + public int getNumberOfTileLays(String tileColour) { + + if ((tileColour.equals("yellow")) && (this.getName().equals("BCR"))) { + int result=2; + return result; + } else { + return super.getNumberOfTileLays(tileColour); + } + } + + /** + * @return the capitalChanged + */ + public BooleanState getCapitalChanged() { + return capitalChanged; + } + + /** + * @param capitalChanged the capitalChanged to set + */ + public void setCapitalChanged(BooleanState capitalChanged) { + this.capitalChanged = capitalChanged; + } + + public boolean shouldBeCapitalisedFull() { + return this.capitalChanged.booleanValue(); + } + + /** + * @return the shanghaiExchangeFounded + */ + public BooleanState getShanghaiExchangeFounded() { + return shanghaiExchangeFounded; + } + + /** + * @param shanghaiExchangeFounded the shanghaiExchangeFounded to set + */ + public void setShanghaiExchangeFounded(BooleanState shanghaiExchangeFounded) { + this.shanghaiExchangeFounded = shanghaiExchangeFounded; + } + public boolean shanghaiExchangeIsOperational(){ + return this.shanghaiExchangeFounded.booleanValue(); + } } diff --git a/rails/game/specific/_1880/StartRound_1880.java b/rails/game/specific/_1880/StartRound_1880.java index ca9a01d..b7433e2 100644 --- a/rails/game/specific/_1880/StartRound_1880.java +++ b/rails/game/specific/_1880/StartRound_1880.java @@ -7,6 +7,7 @@ import rails.common.DisplayBuffer; import rails.common.LocalText; import rails.game.*; import rails.game.action.*; +import rails.game.move.CashMove; import rails.game.state.IntegerState; import rails.game.state.State; import rails.game.state.ArrayListState; @@ -96,18 +97,18 @@ public class StartRound_1880 extends StartRound { if (item.getStatus() == StartItem.NEEDS_SHARE_PRICE) { //still necessary ?? /* This status is set in buy() if a share price is missing */ setPlayer(item.getBidder()); - possibleActions.add(new BuyStartItem(item, item.getBid(), false, true)); + possibleActions.add(new BuyStartItem_1880(item, item.getBid(), false, true)); return true; // No more actions } if ((item.getBidder() == currentPlayer) && (numPasses.intValue() == getNumberOfPlayers()-1)){ // Current Player is highest Bidder & all others have passed if (item.needsPriceSetting() != null ){ - BuyStartItem possibleAction = new BuyStartItem(item,item.getBid(), true, true); + BuyStartItem_1880 possibleAction = new BuyStartItem_1880(item,item.getBid(), true, true); possibleActions.add(possibleAction); return true; // No more actions// no further Actions possible }else{ - BuyStartItem possibleAction = new BuyStartItem(item,item.getBid(),true); + BuyStartItem_1880 possibleAction = new BuyStartItem_1880(item,item.getBid(),true); possibleActions.add(possibleAction); return true; // No more actions// no further Actions possible @@ -148,21 +149,11 @@ public class StartRound_1880 extends StartRound { startingPlayer.set(currentPlayer); gameManager.setPriorityPlayer((Player) startingPlayer.get()); // Method doesn't exist in Startround ??? } - if (investorChosen.intValue() == getNumberOfPlayers()) { - for ( StartItem item1 : itemsToSell) { - if (!item1.isSold()){ - item1.setStatus(StartItem.UNAVAILABLE); - item1.setStatus(StartItem.SOLD); - - } - } - finishRound(); - return false; - } else { - for ( StartItem item1 : itemsToSell) { + + for ( StartItem item1 : itemsToSell) { if (!item1.isSold()){ item1.setStatus(StartItem.BUYABLE); - BuyStartItem possibleAction = new BuyStartItem(item1, 0, false); + BuyStartItem_1880 possibleAction = new BuyStartItem_1880(item1, 0, false); possibleActions.add(possibleAction); } } @@ -170,8 +161,7 @@ public class StartRound_1880 extends StartRound { return true; } - } - } + } /* (non-Javadoc) * @see rails.game.StartRound#bid(java.lang.String, rails.game.action.BidStartItem) @@ -381,5 +371,49 @@ public class StartRound_1880 extends StartRound { startingPlayer.set(gameManager.getPlayerB... [truncated message content] |