From: <ste...@us...> - 2010-09-10 16:30:27
|
Revision: 1418 http://rails.svn.sourceforge.net/rails/?rev=1418&view=rev Author: stefanfrey Date: 2010-09-10 16:30:21 +0000 (Fri, 10 Sep 2010) Log Message: ----------- Removed check for special tile lay, that the new tile should be allowed in the current phase (breaks existing game files) Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-08 21:42:53 UTC (rev 1417) +++ trunk/18xx/rails/game/OperatingRound.java 2010-09-10 16:30:21 UTC (rev 1418) @@ -1339,9 +1339,11 @@ if (!operatingCompany.get().canUseSpecialProperties()) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { - if (getCurrentPhase().isTileColourAllowed(stl.getTile().getColourName()) + if ( +// stl.getTile() != null && getCurrentPhase().isTileColourAllowed(stl.getTile().getColourName()) && // if a tile is specified it must have a tile colour currently available - && (stl.isExtra() || !currentNormalTileLays.isEmpty())) { + // commented out as it is not required and makes 1856 save files invalid + (stl.isExtra() || !currentNormalTileLays.isEmpty())) { // If the special tile lay is not extra, it is only allowed if // normal tile lays are also (still) allowed currentSpecialTileLays.add(new LayTile(stl)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-02-11 22:53:33
|
Revision: 1484 http://rails.svn.sourceforge.net/rails/?rev=1484&view=rev Author: evos Date: 2011-02-11 22:53:26 +0000 (Fri, 11 Feb 2011) Log Message: ----------- Fixed ConcurrentModificationException in laying yellow tile in 1851 Phase 3. Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-02-08 19:52:24 UTC (rev 1483) +++ trunk/18xx/rails/game/OperatingRound.java 2011-02-11 22:53:26 UTC (rev 1484) @@ -473,13 +473,18 @@ log.debug("No more normal tile lays allowed"); //currentNormalTileLays.clear();// Shouldn't be needed anymore ?? } else { + List<String> coloursToRemove = new ArrayList<String>(); for (String key:tileLaysPerColour.viewKeySet()) { if (colour.equals(key)) { - tileLaysPerColour.put(colour, oldAllowedNumber-1); + tileLaysPerColour.put(key, oldAllowedNumber-1); } else { - tileLaysPerColour.remove(colour); + coloursToRemove.add(key); } } + // Two-step removal to prevent ConcurrentModificatioonException. + for (String key : coloursToRemove) { + tileLaysPerColour.remove(key); + } log.debug((oldAllowedNumber - 1) + " additional " + colour + " tile lays allowed; no other colours"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-02-28 21:12:54
|
Revision: 1491 http://rails.svn.sourceforge.net/rails/?rev=1491&view=rev Author: evos Date: 2011-02-28 21:12:48 +0000 (Mon, 28 Feb 2011) Log Message: ----------- Fix by Phil Davies to prevent CGR buying a 4-train Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-02-24 21:37:04 UTC (rev 1490) +++ trunk/18xx/rails/game/OperatingRound.java 2011-02-28 21:12:48 UTC (rev 1491) @@ -2718,7 +2718,7 @@ && getGameParameterAsBoolean(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS) || operatingCompany.get().mustTradeTrainsAtFixedPrice() || company.mustTradeTrainsAtFixedPrice()) { - if (cash >= train.getCost()) { + if ((cash >= train.getCost()) && (operatingCompany.get().mayBuyTrainType(train))) { bt = new BuyTrain(train, pf, train.getCost()); } else { continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-05-05 20:42:06
|
Revision: 1545 http://rails.svn.sourceforge.net/rails/?rev=1545&view=rev Author: evos Date: 2011-05-05 20:42:00 +0000 (Thu, 05 May 2011) Log Message: ----------- Train exchange fix (caused by typo when completing delayed train obsolescence) Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-05-04 19:10:44 UTC (rev 1544) +++ trunk/18xx/rails/game/OperatingRound.java 2011-05-05 20:42:00 UTC (rev 1545) @@ -1805,7 +1805,7 @@ TrainI oldTrain = operatingCompany.get().getPortfolio().getTrainOfType( exchangedTrain.getType()); - train.moveTo(train.isObsolete() ? scrapHeap : pool); + oldTrain.moveTo(train.isObsolete() ? scrapHeap : pool); ReportBuffer.add(LocalText.getText("ExchangesTrain", companyName, exchangedTrain.getName(), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-06-09 22:04:39
|
Revision: 1571 http://rails.svn.sourceforge.net/rails/?rev=1571&view=rev Author: evos Date: 2011-06-09 22:04:33 +0000 (Thu, 09 Jun 2011) Log Message: ----------- Allow special tile lay of an unspecified tile (for 1889 D private) Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-06-07 15:44:23 UTC (rev 1570) +++ trunk/18xx/rails/game/OperatingRound.java 2011-06-09 22:04:33 UTC (rev 1571) @@ -446,6 +446,11 @@ protected boolean checkNormalTileLay(TileI tile, boolean update) { + // Unspecified tile (e.g. 1889 D private, which is free on mountains) + if (tile == null) { + return !tileLaysPerColour.isEmpty(); + } + String colour = tile.getColourName(); Integer oldAllowedNumberObject = tileLaysPerColour.get(colour); @@ -1413,8 +1418,7 @@ if (stl.isExtra() // If the special tile lay is not extra, it is only allowed if // normal tile lays are also (still) allowed - || stl.getTile() != null - && checkNormalTileLay(stl.getTile(), false)) { + || checkNormalTileLay(stl.getTile(), false)) { LayTile lt = new LayTile(stl); String[] stlc = stl.getTileColours(); if (stlc != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wak...@us...> - 2011-06-30 18:27:58
|
Revision: 1596 http://rails.svn.sourceforge.net/rails/?rev=1596&view=rev Author: wakko666 Date: 2011-06-30 18:27:52 +0000 (Thu, 30 Jun 2011) Log Message: ----------- Commit Erik's changes to OperatingRound. Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-06-30 15:19:12 UTC (rev 1595) +++ trunk/18xx/rails/game/OperatingRound.java 2011-06-30 18:27:52 UTC (rev 1596) @@ -241,11 +241,6 @@ } else if (selectedAction instanceof ClosePrivate) { result = executeClosePrivate((ClosePrivate)selectedAction); - - } else if (selectedAction instanceof UseSpecialProperty - && ((UseSpecialProperty)selectedAction).getSpecialProperty() instanceof SpecialRight) { - - result = buyRight ((UseSpecialProperty)selectedAction); } else if (selectedAction instanceof NullAction) { @@ -2310,44 +2305,6 @@ return numberOfLoans * operatingCompany.get().getValuePerLoan(); } - protected boolean buyRight (UseSpecialProperty action) { - - String errMsg = null; - - SpecialPropertyI sp = action.getSpecialProperty(); - if (!(sp instanceof SpecialRight)) { - errMsg = "Wrong right property class: "+sp.toString(); - } - - SpecialRight right = (SpecialRight) sp; - String rightName = right.getName(); - String rightValue = right.getValue(); - - if (errMsg != null) { - DisplayBuffer.add(LocalText.getText("CannotBuyRight", - action.getCompanyName(), - rightName, - Bank.format(right.getCost()), - errMsg)); - - return false; - } - - moveStack.start(true); - - operatingCompany.get().setRight(rightName, rightValue); - new CashMove (operatingCompany.get(), bank, right.getCost()); - - ReportBuffer.add(LocalText.getText("BuysRight", - operatingCompany.get().getName(), - rightName, - Bank.format(right.getCost()))); - - sp.setExercised(); - - return true; - } - /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ /** @@ -2529,13 +2486,10 @@ // Are there other step-independent special properties owned by the company? List<SpecialPropertyI> orsps = operatingCompany.get().getPortfolio().getAllSpecialProperties(); - List<SpecialPropertyI> compsps = operatingCompany.get().getSpecialProperties(); - if (compsps != null) orsps.addAll(compsps); - if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() - && sp.isUsableDuringOR(step)) { + && sp.isUsableDuringOR()) { if (sp instanceof SpecialTokenLay) { if (getStep() != GameDef.OrStep.LAY_TOKEN) { possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); @@ -2551,7 +2505,7 @@ if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByPlayer() - && sp.isUsableDuringOR(step)) { + && sp.isUsableDuringOR()) { if (sp instanceof SpecialTokenLay) { if (getStep() != GameDef.OrStep.LAY_TOKEN) { possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wak...@us...> - 2011-06-30 18:56:06
|
Revision: 1597 http://rails.svn.sourceforge.net/rails/?rev=1597&view=rev Author: wakko666 Date: 2011-06-30 18:56:00 +0000 (Thu, 30 Jun 2011) Log Message: ----------- Commit Erik's changes, try #2. Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-06-30 18:27:52 UTC (rev 1596) +++ trunk/18xx/rails/game/OperatingRound.java 2011-06-30 18:56:00 UTC (rev 1597) @@ -33,19 +33,12 @@ protected ArrayListState<PublicCompanyI> operatingCompanies; - //protected IntegerState operatingCompanyIndexObject; - protected GenericState<PublicCompanyI> operatingCompany; // do not use a operatingCompany.getObject() as reference - // protected PublicCompanyI operatingCompany.getObject() = null; // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; - //protected List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>(); - - //protected List<LayTile> currentNormalTileLays = new ArrayList<LayTile>(); - protected HashMapState<String, Integer> tileLaysPerColour = new HashMapState<String, Integer>("tileLaysPerColour"); @@ -241,6 +234,11 @@ } else if (selectedAction instanceof ClosePrivate) { result = executeClosePrivate((ClosePrivate)selectedAction); + + } else if (selectedAction instanceof UseSpecialProperty + && ((UseSpecialProperty)selectedAction).getSpecialProperty() instanceof SpecialRight) { + + result = buyRight ((UseSpecialProperty)selectedAction); } else if (selectedAction instanceof NullAction) { @@ -1207,7 +1205,7 @@ /** Take the next step after a given one (see nextStep()) */ protected void nextStep(GameDef.OrStep step) { - PublicCompanyI company = operatingCompany.get(); + PublicCompanyI company = operatingCompany.get(); // Cycle through the steps until we reach one where a user action is // expected. @@ -1257,24 +1255,24 @@ int poolShare = pool.getShare(company); // Expensive, do it once // Can it buy? boolean canBuy = - ownShare < getGameParameterAsInt (GameDef.Parm.TREASURY_SHARE_LIMIT) - && company.getCash() >= company.getCurrentSpace().getPrice() - && poolShare > 0; + ownShare < getGameParameterAsInt (GameDef.Parm.TREASURY_SHARE_LIMIT) + && company.getCash() >= company.getCurrentSpace().getPrice() + && poolShare > 0; // Can it sell? boolean canSell = - company.getPortfolio().getShare(company) > 0 - && poolShare < getGameParameterAsInt (GameDef.Parm.POOL_SHARE_LIMIT); + company.getPortfolio().getShare(company) > 0 + && poolShare < getGameParameterAsInt (GameDef.Parm.POOL_SHARE_LIMIT); // Above we ignore the possible existence of double shares (as in 1835). if (!canBuy && !canSell) { // XXX For BACKWARDS COMPATIBILITY only, - // register a Done skip action during reloading. - if (gameManager.isReloading()) { - gameManager.setSkipDone(GameDef.OrStep.TRADE_SHARES); + // register a Done skip action during reloading. + if (gameManager.isReloading()) { + gameManager.setSkipDone(GameDef.OrStep.TRADE_SHARES); log.debug("If the next saved action is 'Done', skip it"); - } - log.info("Skipping Treasury share trading step"); - continue; + } + log.info("Skipping Treasury share trading step"); + continue; } gameManager.startTreasuryShareTradingRound(); @@ -1613,8 +1611,8 @@ company = newOperatingCompanies.get(i); if (company != operatingCompanies.get(i)) { log.debug("Company "+company.getName() - +" replaces "+operatingCompanies.get(i).getName() - +" in operating sequence"); + +" replaces "+operatingCompanies.get(i).getName() + +" in operating sequence"); operatingCompanies.move(company, i); } } @@ -2305,6 +2303,44 @@ return numberOfLoans * operatingCompany.get().getValuePerLoan(); } + protected boolean buyRight (UseSpecialProperty action) { + + String errMsg = null; + + SpecialPropertyI sp = action.getSpecialProperty(); + if (!(sp instanceof SpecialRight)) { + errMsg = "Wrong right property class: "+sp.toString(); + } + + SpecialRight right = (SpecialRight) sp; + String rightName = right.getName(); + String rightValue = right.getValue(); + + if (errMsg != null) { + DisplayBuffer.add(LocalText.getText("CannotBuyRight", + action.getCompanyName(), + rightName, + Bank.format(right.getCost()), + errMsg)); + + return false; + } + + moveStack.start(true); + + operatingCompany.get().setRight(rightName, rightValue); + new CashMove (operatingCompany.get(), bank, right.getCost()); + + ReportBuffer.add(LocalText.getText("BuysRight", + operatingCompany.get().getName(), + rightName, + Bank.format(right.getCost()))); + + sp.setExercised(); + + return true; + } + /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ /** @@ -2486,10 +2522,13 @@ // Are there other step-independent special properties owned by the company? List<SpecialPropertyI> orsps = operatingCompany.get().getPortfolio().getAllSpecialProperties(); + List<SpecialPropertyI> compsps = operatingCompany.get().getSpecialProperties(); + if (compsps != null) orsps.addAll(compsps); + if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() - && sp.isUsableDuringOR()) { + && sp.isUsableDuringOR(step)) { if (sp instanceof SpecialTokenLay) { if (getStep() != GameDef.OrStep.LAY_TOKEN) { possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); @@ -2505,7 +2544,7 @@ if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByPlayer() - && sp.isUsableDuringOR()) { + && sp.isUsableDuringOR(step)) { if (sp instanceof SpecialTokenLay) { if (getStep() != GameDef.OrStep.LAY_TOKEN) { possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |