From: Erik V. <ev...@us...> - 2010-04-08 21:25:58
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1835 In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv5369/rails/game/specific/_1835 Modified Files: OperatingRound_1835.java Log Message: No token lay on L6 before BA has laid home token OBB extra tiles cannot be laid in the same round Index: OperatingRound_1835.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1835/OperatingRound_1835.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OperatingRound_1835.java 28 Mar 2010 20:14:20 -0000 1.1 --- OperatingRound_1835.java 8 Apr 2010 21:25:51 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- package rails.game.specific._1835; + import rails.game.Bank; + import rails.game.DisplayBuffer; import rails.game.GameDef; import rails.game.GameManagerI; *************** *** 6,10 **** --- 8,16 ---- import rails.game.PhaseI; import rails.game.action.DiscardTrain; + import rails.game.action.LayBaseToken; + import rails.game.action.LayTile; + import rails.game.special.SpecialTileLay; import rails.game.state.BooleanState; + import rails.util.LocalText; public class OperatingRound_1835 extends OperatingRound { *************** *** 12,15 **** --- 18,23 ---- private BooleanState needPrussianFormationCall = new BooleanState ("NeedPrussianFormationCall", false); + private BooleanState hasLaidExtraOBBTile + = new BooleanState ("HasLaidExtraOBBTile", false); public OperatingRound_1835 (GameManagerI gameManager) { *************** *** 17,20 **** --- 25,94 ---- } + protected void setSpecialTileLays() { + + /* Special-property tile lays */ + currentSpecialTileLays.clear(); + + if (!operatingCompany.canUseSpecialProperties()) return; + + for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { + if (stl.isExtra() || !currentNormalTileLays.isEmpty()) { + + // Exclude the second OBB free tile if the first was laid in this round + if (stl.getLocationNameString().matches("M1(7|9)") + && hasLaidExtraOBBTile.booleanValue()) continue; + + currentSpecialTileLays.add(new LayTile(stl)); + } + } + } + + public boolean layTile(LayTile action) { + + // The extra OBB tiles may not both be laid in the same round + if (action.getSpecialProperty() != null + && action.getSpecialProperty().getLocationNameString().matches("M1(5|7)")) { + if (hasLaidExtraOBBTile.booleanValue()) { + String errMsg = LocalText.getText("InvalidTileLay"); + DisplayBuffer.add(LocalText.getText("CannotLayTileOn", + action.getCompanyName(), + action.getLaidTile().getExternalId(), + action.getChosenHex().getName(), + Bank.format(0), + errMsg )); + return false; + } + } + + boolean result = super.layTile(action); + + if (result && action.getSpecialProperty() != null + && action.getSpecialProperty().getLocationNameString().matches("M1(5|7)")) { + hasLaidExtraOBBTile.set(true); + } + + return result; + } + + public boolean layBaseToken(LayBaseToken action) { + + // No tokens may be laid on the BA home hex before BA has done so + if (action.getChosenHex().getName().equalsIgnoreCase("L6") + && !action.getCompanyName().equalsIgnoreCase(GameManager_1835.BA_ID) + && !gameManager.getCompanyManager().getCompanyByName(GameManager_1835.BA_ID) + .hasLaidHomeBaseTokens()) { + String errMsg = LocalText.getText("NotYetOperated", GameManager_1835.BA_ID); + DisplayBuffer.add(LocalText.getText("CannotLayBaseTokenOn", + action.getCompanyName(), + action.getChosenHex().getName(), + Bank.format(0), + errMsg )); + return false; + + } else { + return super.layBaseToken(action); + } + } + protected void newPhaseChecks() { PhaseI phase = getCurrentPhase(); |