From: Erik V. <ev...@us...> - 2010-02-20 23:08:50
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5192/rails/game Modified Files: OperatingRound.java Log Message: Use explicit allowance to use special properties. Fixed problem where special token lay was offered twice (1835 PfB) Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** OperatingRound.java 20 Feb 2010 12:34:46 -0000 1.103 --- OperatingRound.java 20 Feb 2010 23:08:42 -0000 1.104 *************** *** 600,605 **** --- 600,609 ---- log.debug("This was a normal token lay"); } + if (currentNormalTokenLays.isEmpty()) { log.debug("No more normal token lays are allowed"); + } else if (operatingCompany.getNumberOfFreeBaseTokens() == 0) { + log.debug("Normal token lay allowed by no more tokens"); + currentNormalTokenLays.clear(); } else { log.debug("A normal token lay is still allowed"); *************** *** 1203,1211 **** /* Special-property tile lays */ currentSpecialTileLays.clear(); ! /* ! * In 1835, this only applies to major companies. TODO: For now, ! * hardcode this, but it must become configurable later. ! */ ! if (operatingCompany.getType().getName().equals("Minor")) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { --- 1207,1212 ---- /* Special-property tile lays */ currentSpecialTileLays.clear(); ! ! if (!operatingCompany.canUseSpecialProperties()) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { *************** *** 1243,1246 **** --- 1244,1249 ---- currentSpecialTokenLays.clear(); + if (!operatingCompany.canUseSpecialProperties()) return; + /* * In 1835, this only applies to major companies. TODO: For now, *************** *** 2150,2196 **** } ! // Are there any "common" special properties, ! // i.e. properties that are available to everyone? ! List<SpecialPropertyI> commonSP = gameManager.getCommonSpecialProperties(); ! if (commonSP != null) { ! SellBonusToken sbt; ! loop: for (SpecialPropertyI sp : commonSP) { ! if (sp instanceof SellBonusToken) { ! sbt = (SellBonusToken) sp; ! // Can't buy if already owned ! if (operatingCompany.getBonuses() != null) { ! for (Bonus bonus : operatingCompany.getBonuses()) { ! if (bonus.getName().equals(sp.getName())) continue loop; } } - possibleActions.add (new BuyBonusToken (sbt)); } } ! } ! ! // Are there other step-independent special properties owned by the company? ! List<SpecialPropertyI> orsps = operatingCompany.getPortfolio().getAllSpecialProperties(); ! if (orsps != null) { ! for (SpecialPropertyI sp : orsps) { ! if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() ! && sp.isUsableDuringOR()) { ! if (sp instanceof SpecialTokenLay) { ! possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); ! } else { ! possibleActions.add(new UseSpecialProperty(sp)); } } } ! } ! // Are there other step-independent special properties owned by teh president? ! orsps = getCurrentPlayer().getPortfolio().getAllSpecialProperties(); ! if (orsps != null) { ! for (SpecialPropertyI sp : orsps) { ! if (!sp.isExercised() && sp.isUsableIfOwnedByPlayer() ! && sp.isUsableDuringOR()) { ! if (sp instanceof SpecialTokenLay) { ! possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); ! } else { ! possibleActions.add(new UseSpecialProperty(sp)); } } --- 2153,2206 ---- } ! if (operatingCompany.canUseSpecialProperties()) { ! ! // Are there any "common" special properties, ! // i.e. properties that are available to everyone? ! List<SpecialPropertyI> commonSP = gameManager.getCommonSpecialProperties(); ! if (commonSP != null) { ! SellBonusToken sbt; ! loop: for (SpecialPropertyI sp : commonSP) { ! if (sp instanceof SellBonusToken) { ! sbt = (SellBonusToken) sp; ! // Can't buy if already owned ! if (operatingCompany.getBonuses() != null) { ! for (Bonus bonus : operatingCompany.getBonuses()) { ! if (bonus.getName().equals(sp.getName())) continue loop; ! } } + possibleActions.add (new BuyBonusToken (sbt)); } } } ! ! // Are there other step-independent special properties owned by the company? ! List<SpecialPropertyI> orsps = operatingCompany.getPortfolio().getAllSpecialProperties(); ! if (orsps != null) { ! for (SpecialPropertyI sp : orsps) { ! if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() ! && sp.isUsableDuringOR()) { ! if (sp instanceof SpecialTokenLay) { ! if (getStep() != GameDef.OrStep.LAY_TOKEN) { ! possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); ! } ! } else { ! possibleActions.add(new UseSpecialProperty(sp)); ! } } } } ! // Are there other step-independent special properties owned by the president? ! orsps = getCurrentPlayer().getPortfolio().getAllSpecialProperties(); ! if (orsps != null) { ! for (SpecialPropertyI sp : orsps) { ! if (!sp.isExercised() && sp.isUsableIfOwnedByPlayer() ! && sp.isUsableDuringOR()) { ! if (sp instanceof SpecialTokenLay) { ! if (getStep() != GameDef.OrStep.LAY_TOKEN) { ! possibleActions.add(new LayBaseToken((SpecialTokenLay)sp)); ! } ! } else { ! possibleActions.add(new UseSpecialProperty(sp)); ! } } } |