Update of /cvsroot/rails/18xx/rails/game
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv712/rails/game
Modified Files:
OperatingRound.java
Log Message:
Added fix to allow zero cost token lay after removal of default operating costs actions.
Index: OperatingRound.java
===================================================================
RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -d -r1.115 -r1.116
*** OperatingRound.java 12 Mar 2010 07:30:24 -0000 1.115
--- OperatingRound.java 14 Mar 2010 14:21:24 -0000 1.116
***************
*** 2272,2282 ****
// LayBaseToken Actions
if (operatingCompany.getNumberOfFreeBaseTokens() != 0) {
! int[] costs = operatingCompany.getBaseTokenLayCosts();
! for (int cost : costs) {
! if ((cost <= operatingCompany.getCash()) && (cost != 0 || costs.length == 1)) // distance method returns home base, but in sequence costs can be zero
possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, cost, false));
}
}
!
// Default OperatingCost Actions
// possibleActions.add(new OperatingCost(
--- 2272,2296 ----
// LayBaseToken Actions
if (operatingCompany.getNumberOfFreeBaseTokens() != 0) {
! int[] costsArray = operatingCompany.getBaseTokenLayCosts();
!
! // change to set to allow for identity and ordering
! Set<Integer> costsSet = new TreeSet<Integer>();
! for (int cost:costsArray)
! if (!(cost == 0 && costsArray.length != 1)) // fix for sequence based home token
! costsSet.add(cost);
!
! // SpecialTokenLay Actions - workaround for a better handling of those later
! for (SpecialTokenLay stl : getSpecialProperties(SpecialTokenLay.class)) {
! log.debug("Special tokenlay property: " + stl);
! if (stl.getTokenClass().equals(BaseToken.class) && stl.isFree())
! costsSet.add(0);
! }
!
! for (int cost : costsSet) {
! if (cost <= operatingCompany.getCash()) // distance method returns home base, but in sequence costsSet can be zero
possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, cost, false));
}
}
!
// Default OperatingCost Actions
// possibleActions.add(new OperatingCost(
|