From: <ev...@us...> - 2010-09-22 21:38:25
|
Revision: 1431 http://rails.svn.sourceforge.net/rails/?rev=1431&view=rev Author: evos Date: 2010-09-22 21:38:18 +0000 (Wed, 22 Sep 2010) Log Message: ----------- Added parametrized options. Added 1825 Unit 2/3 and R/1/2/3 map (except not yet created special tiles). Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1825/Game.xml trunk/18xx/data/1825/Map.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameOption.java trunk/18xx/rails/game/GamesInfo.java trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/hexmap/HexMap.java trunk/18xx/rails/util/Tag.java trunk/18xx/tiles/TileDictionary.18t Property Changed: ---------------- trunk/18xx/test/ Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/LocalisedText.properties 2010-09-22 21:38:18 UTC (rev 1431) @@ -303,6 +303,7 @@ HoldMoneyInEscrow=The price of {0} is paid to the Bank, which now holds {1} in escrow for {2} HOW_MANY_SHARES=How many shares? IMPORT=Import +Include=Include {0} INFO=Game Notes Info=Info Insert=Insert Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/1825/Game.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -12,6 +12,12 @@ - optionally, a default value (only affects a toggle; in a dropdown the first item is always the default). --> + <GameOption name="Include" parm="Unit1" type="toggle" default="yes"/> + <GameOption name="Include" parm="Unit2" type="toggle" default="no"/> + <GameOption name="Include" parm="Unit3" type="toggle" default="no"/> + <GameOption name="Include" parm="R1" type="toggle" default="no"/> + <GameOption name="Include" parm="R2" type="toggle" default="no"/> + <GameOption name="Include" parm="R3" type="toggle" default="no"/> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/1825/Map.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -1,6 +1,96 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> + <IfOption name="Include" parm="Unit3" value="yes"> + <Hex name="B8" tile="-5" orientation="1" city="Inverness"/> + <!--Hex name="B12" tile="-25011" city="Aberdeen"/--> + <Hex name="C7" tile="-1" cost="100" city="Pitlochry" open="1,2"/> + <Hex name="C9" tile="0" cost="100" open="3"/> + <Hex name="C11" tile="0" open="2"/> + <Hex name="D2" tile="0" cost="100"/> + <Hex name="D4" tile="0" cost="100"/> + <Hex name="D6" tile="0" cost="100"/> + <Hex name="D8" tile="0" cost="100"/> + <Hex name="D10" tile="-1" city="Montrose"/> + <Hex name="E1" tile="-5" orientation="5" cost="40" city="Oban"/> + <Hex name="E3" tile="0" cost="100"/> + <Hex name="E5" tile="0" cost="100"/> + <Hex name="E7" tile="-25005" orientation="1" city="Perth"/> + <Hex name="E9" tile="-10" cost="80" city="Dundee"/> + <!--Hex name="F2" tile="-25012" city="Helensburgh, Gourock"/--> + <Hex name="F4" tile="-1" cost="40" city="Dumbarton"/> + <Hex name="F6" tile="-1" city="Stirling"/> + <Hex name="F8" tile="-2" orientation="3" cost="120" city="Dumfermline, Kirkaldy"/> + <!--Hex name="F10" tile="-25013" city="Anstruther"/--> + <Hex name="G3" tile="-10" city="Greenock"/> + <Hex name="G5" tile="-25002" city="Glasgow"/> + <Hex name="G7" tile="-2" city="Coatbridge, Airdrie"/> + <Hex name="G9" tile="-20" city="Edinburgh, Leith"/> + <Hex name="G11" tile="0"/> + <Hex name="H4" tile="-2" city="Ayr, Kilmarnock"/> + <Hex name="H6" tile="-10" city="Motherwell"/> + <Hex name="H8" tile="0" cost="100"/> + <Hex name="H10" tile="0" cost="100"/> + <Hex name="H12" tile="0"/> + <Hex name="H14" tile="0"/> + <Hex name="I3" tile="0" cost="100"/> + <Hex name="I5" tile="0"/> + <Hex name="I7" tile="0" cost="100"/> + <Hex name="I9" tile="0" cost="100"/> + <Hex name="I11" tile="0" cost="100"/> + <Hex name="I13" tile="-2"/> + <Hex name="J2" tile="-10" city="Stranraer"/> + <Hex name="J4" tile="0" cost="100"/> + <Hex name="J6" tile="-10" city="Dumfries"/> + <Hex name="J8" tile="0"/> + <Hex name="J10" tile="-10" ciry="Carlisle"/> + <Hex name="J12" tile="0" cost="100"/> + <Hex name="J14" tile="-20" cost="40" city="Newcastle u/T, Sunderland"/> + <!--Hex name="K7" tile="-25014" orientation="2" city="Maryport"/--> + <Hex name="K9" tile="0" cost="100" open="0,5"/> + <Hex name="K11" tile="0" cost="100" open="0,5"/> + <Hex name="K13" tile="-1" city="Durham" open="0,5"/> + <Hex name="K15" tile="-2" city="Stockton, Middlesbro" open="0,5"/> + </IfOption> + <IfOption name="Include" parm="Unit2" value="yes"> + <Hex name="L8" tile="0" open="2,3"/> + <Hex name="L10" tile="0" open="2,3"/> + <Hex name="L12" tile="0" cost="100" open="2,3"/> + <Hex name="L14" tile="-10" city="Darlington" open="2,3"/> + <Hex name="L16" tile="0" open="2"/> + <Hex name="L18" tile="-1" city="Scarborough"/> + <!--Hex name="M9" tile="-25008" city="Barrow"/--> + <Hex name="M11" tile="0" cost="100"/> + <Hex name="M13" tile="0" cost="100"/> + <Hex name="M15" tile="-2" city="Harrogate, York"/> + <Hex name="M17" tile="0"/> + <Hex name="M19" tile="0"/> + <Hex name="N10" tile="-10" city="Preston"/> + <Hex name="N12" tile="-2" city="Burnley, Halifax"/> + <Hex name="N14" tile="-20" city="Bradford, Leeds"/> + <Hex name="N16" tile="0"/> + <Hex name="N18" tile="-10" cost="40" city="Hull"/> + <!--Hex name="O9" tile="-25009" cost="40" city="Liverpool"/--> + <Hex name="O11" tile="-25002" city="Manchester"/> + <Hex name="O13" tile="0" cost="100"/> + <!--Hex name="O15" tile="-25010" city="Barnsley, Doncaster"/--> + <Hex name="O17" tile="0" cost="40"/> + <Hex name="O19" tile="0"/> + <Hex name="P8" tile="-41" orientation="4"/> + <Hex name="P10" tile="0" cost="40"/> + <Hex name="P12" tile="0" cost="100"/> + <Hex name="P14" tile="0" cost="100"/> + <Hex name="P16" tile="-20" city="Sheffield, Rotherham"/> + <Hex name="P18" tile="-1" city="Lincoln"/> + <Hex name="P20" tile="0"/> + <Hex name="Q9" tile="0" open="0,5"/> + <Hex name="Q11" tile="-25004" city="Wolverton"/> + <Hex name="Q13" tile="-2" city="Newcastle u/L, Hanley" open="0,5"/> + <Hex name="Q15" tile="-10" city="Derby" open="0,5"/> + <Hex name="Q17" tile="-10" city="Nottingham" open="0,5"/> + <Hex name="Q19" tile="0" open="0,5"/> + </IfOption> + <IfOption name="Include" parm="Unit1" value="yes"> <Hex name="R8" tile="0" open="0,1,2,3"/> - <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="2,3"/> + <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="2"/> <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall" open="2,3"/> <Hex name="R14" tile="0" open="2,3"/> <Hex name="R16" tile="-10" city="Leicester" open="2,3"/> @@ -70,5 +160,39 @@ <Hex name="Y13" tile="-25007" city="Bournemouth"/> <Hex name="Y17" tile="-7" orientation="4" /> <Hex name="Y19" tile="-7" orientation="4" /> - + <IfOption name="Include" parm="R1" value="yes"> + <Hex name="P4" tile="-5" city="Holyhead"/> + <Hex name="P6" tile="0" cost="40"/> + <Hex name="Q5" tile="-1" city="Portmadoc"/> + <Hex name="Q7" tile="0" cost="100"/> + <Hex name="R6" tile="0"/> + <Hex name="S5" tile="-1" city="Aberystwyth"/> + <Hex name="S7" tile="0" cost="100"/> + <Hex name="T2" tile="-10" city="Fishguard"/> + <Hex name="T4" tile="0"/> + <Hex name="T6" tile="0" cost="100"/> + <!--Hex name="U1" tile="-25015" city="Milford Haven"/--> + <Hex name="U3" tile="0"/> + <Hex name="U5" tile="0"/> + <Hex name="V8" tile="-25007" orientation="1" city="Swansea"/> + </IfOption> + <IfOption name="Include" parm="R2" value="yes"> + <Hex name="X4" tile="-1" city="Barnstaple"/> + <Hex name="X6" tile="0" cost="100"/> + <Hex name="Y1" tile="0"/> + <Hex name="Y3" tile="0"/> + <Hex name="Y5" tile="0" cost="100"/> + <Hex name="Y7" tile="-10" city="Exeter"/> + <Hex name="Z0" tile="0"/> + <Hex name="Z2" tile="-1" city="Fowey"/> + <Hex name="Z4" tile="-20" city="Devenport, Plymouth"/> + <Hex name="Z6" tile="-1" city="Torquay"/> + <!--Hex name="AA-1" tile="-1" city="Penzance"/> + <Hex name="AA1" tile="-10" city="Falmouth"/--> + </IfOption> + <IfOption name="Include" parm="R3" value="yes"> + <!--Hex name="Q23" tile="-25014" orientation="1" city="Melton Constable"/--> + <Hex name="Q25" tile="0"/> + </IfOption> + </IfOption> </Map> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/GamesList.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -227,6 +227,12 @@ - Not implemented: receivership </Description> <Players minimum="3" maximum="5" /> + <Option name="Include" parm="Unit1" type="toggle" default="yes"/> + <Option name="Include" parm="Unit2" type="toggle" default="no"/> + <Option name="Include" parm="Unit3" type="toggle" default="no"/> + <Option name="Include" parm="R1" type="toggle" default="no"/> + <Option name="Include" parm="R2" type="toggle" default="no"/> + <Option name="Include" parm="R3" type="toggle" default="no"/> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="UnlimitedTiles" type="toggle" default="no"/> Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GameManager.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -233,21 +233,28 @@ GameOption option; String optionName, optionType, optionValues, optionDefault; String optionNameParameters; + String[] optionParameters; List<Tag> optionTags = tag.getChildren("GameOption"); if (optionTags != null) { for (Tag optionTag : optionTags) { optionName = optionTag.getAttributeAsString("name"); if (optionName == null) throw new ConfigurationException("GameOption without name"); + optionParameters = null; + optionNameParameters = + optionTag.getAttributeAsString("parm"); + if (optionNameParameters != null) { + optionParameters = optionNameParameters.split(","); + } + optionName = GameOption.constructParametrisedName ( + optionName, optionParameters); + if (gameOptions.containsKey(optionName)) continue; // Include missing option - option = new GameOption(optionName); + option = new GameOption(optionName, optionParameters); availableGameOptions.add(option); - optionNameParameters = optionTag.getAttributeAsString("parm"); - if (optionNameParameters != null) { - option.setParameters(optionNameParameters.split(",")); - } + optionType = optionTag.getAttributeAsString("type"); if (optionType != null) option.setType(optionType); optionValues = optionTag.getAttributeAsString("values"); Modified: trunk/18xx/rails/game/GameOption.java =================================================================== --- trunk/18xx/rails/game/GameOption.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GameOption.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -8,6 +8,7 @@ public class GameOption { private String name; + private String parametrisedName; private boolean isBoolean = false; private String type; private String defaultValue = null; @@ -22,14 +23,16 @@ // A default option that will always be set public static final String NUMBER_OF_PLAYERS = "NumberOfPlayers"; - + // Some other common game options - public static final String VARIANT = "Variant"; - + public static final String VARIANT = "Variant"; - public GameOption(String name) { - this.name = name; - optionsMap.put(name, this); + + public GameOption(String name, String[] parameters) { + this.name = name; + if (parameters != null) parm = parameters.clone(); + parametrisedName = constructParametrisedName (name, parameters); + optionsMap.put(parametrisedName, this); } public void setType(String type) { @@ -43,7 +46,7 @@ } public String getName() { - return name; + return parametrisedName; } public String getLocalisedName() { @@ -58,14 +61,12 @@ return isBoolean; } + /* public void setParameters(String[] parameters) { parm = parameters.clone(); } + */ - public String[] getParameters() { - return parm; - } - public void setAllowedValues(List<String> values) { allowedValues = values; } @@ -107,7 +108,18 @@ /** Get GameOption Value as Boolean Value */ public static boolean convertValueToBoolean(String value) { - return value != null + return value != null && OPTION_VALUE_YES.equalsIgnoreCase(value); } + + public static String constructParametrisedName (String optionName, + String[] optionNameParameters) { + String parametrisedName = optionName; + if (optionNameParameters != null) { + for (String parameter : optionNameParameters) { + parametrisedName += "_" + parameter; + } + } + return parametrisedName; + } } Modified: trunk/18xx/rails/game/GamesInfo.java =================================================================== --- trunk/18xx/rails/game/GamesInfo.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GamesInfo.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -129,7 +129,6 @@ // Get the options List<Tag> optionTagList = gameTag.getChildren(OPTION_TAG); List<GameOption> gameOptions = new ArrayList<GameOption>(); - options.put(gameName, gameOptions); if (optionTagList != null) { for (Tag optionTag : optionTagList) { @@ -141,14 +140,16 @@ throw new ConfigurationException("Option name missing in " + GAMES_XML); } - GameOption option = new GameOption(optionName); - gameOptions.add(option); + // Option name parameters (optional) + String[] optionParameters = null; String optionNameParameters = - optionTag.getAttributeAsString("parm"); - if (optionNameParameters != null) { - option.setParameters(optionNameParameters.split(",")); - } + optionTag.getAttributeAsString("parm"); + if (optionNameParameters != null) { + optionParameters = optionNameParameters.split(","); + } + GameOption option = new GameOption(optionName, optionParameters); + gameOptions.add(option); // Option type (optional). // "toggle" means this is a boolean option, @@ -173,6 +174,7 @@ } } } + options.put(gameName, gameOptions); } Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/MapHex.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -114,7 +114,7 @@ /** Any open sides against which track may be laid even at board edges (1825) */ protected boolean[] openHexSides; - + protected MapManager mapManager = null; protected static Logger log = @@ -128,16 +128,22 @@ * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { - Pattern namePattern = Pattern.compile("(\\D)(\\d+)"); + Pattern namePattern = Pattern.compile("(\\D+?)(-?\\d+)"); infoText = name = tag.getAttributeAsString("name"); Matcher m = namePattern.matcher(name); if (!m.matches()) { throw new ConfigurationException("Invalid name format: " + name); } - letter = m.group(1).charAt(0); + String letters = m.group(1); + if (letters.length() == 1) { + letter = letters.charAt(0); + } else { // for row 'AA' in 1825U1 + letter = 26 + letters.charAt(1); + } try { number = Integer.parseInt(m.group(2)); + if (number > 90) number -= 100; // For 1825U1 column 99 (= -1) } catch (NumberFormatException e) { // Cannot occur! } @@ -266,7 +272,7 @@ return true; } - + public boolean isOpenSide (int side) { return openHexSides != null && openHexSides[side%6]; } Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -41,7 +41,7 @@ Game game; private ConfigWindow configWindow; - + // Used by the player selection combo box. static final int NONE_PLAYER = 0; static final int HUMAN_PLAYER = 1; @@ -219,13 +219,13 @@ setVisible(false); killConfigWindow(); } - + private void killConfigWindow() { if (configWindow == null) return; configWindow.dispose(); configWindow = null; } - + public void actionPerformed(ActionEvent arg0) { if (arg0.getSource().equals(newButton)) { startNewGame(); @@ -297,14 +297,14 @@ playerNameFields[Integer.parseInt(boxName[1])].setEnabled(false); break; } - } + } } else if (arg0.getSource().equals(randomizeButton)) { // randomize the order of the players - if (playerNameFields.length > 0) { + if (playerNameFields.length > 0) { List<String> playerList = new ArrayList<String>(); for (int i = 0; i < playerNameFields.length; i++) { if (playerNameFields[i] != null - && playerNameFields[i].getText().length() > 0) { + && playerNameFields[i].getText().length() > 0) { playerList.add(playerNameFields[i].getText()); playerNameFields[i].setText(""); } @@ -312,7 +312,7 @@ Collections.shuffle(playerList); for (int i = 0; i < playerList.size(); i++) { playerNameFields[i].setText(playerList.get(i)); - + } } } Modified: trunk/18xx/rails/ui/swing/hexmap/HexMap.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -13,10 +13,9 @@ import rails.game.*; import rails.game.action.*; -import rails.ui.swing.GameUIManager; -import rails.ui.swing.ORUIManager; -import rails.ui.swing.Scale; -import rails.util.*; +import rails.ui.swing.*; +import rails.util.Config; +import rails.util.Util; /** * Base class that stores common info for HexMap independant of Hex @@ -64,10 +63,10 @@ protected Map<MapHex, List<LayToken>> allowedTokensPerHex = null; protected boolean bonusTokenLayingEnabled = false; - + /** list of generalpath elements to indicate train runs */ protected List<GeneralPath> trainPaths; - + private static Color colour1, colour2, colour3, colour4; protected int strokeWidth = 5; protected int strokeCap = BasicStroke.CAP_ROUND; @@ -83,7 +82,7 @@ protected double tileYOffset; protected double coordinateXMargin; protected double coordinateYMargin; - + public static void setRouteColours () { try { colour1 = Util.parseColour(Config.get("route.colour.1", null)); @@ -114,12 +113,12 @@ maxCol = mapManager.getMaxCol(); log.debug("HexMap init: minX="+ minX + ",minY=" + minY + ",maxX=" +maxX + ",maxY=" + maxY); log.debug("HexMap init: minCol="+ minCol + ",minRow=" + minRow + ",maxCol=" +maxCol + ",maxRow=" + maxRow); - + setScale(); setupHexes(); initializeSettings(); - + setRouteColours(); } @@ -143,22 +142,22 @@ } } - - + + protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); hexArray = mapManager.getHexes(); MapHex mh; - + h = new GUIHex[hexArray.length][hexArray[0].length]; for (int i = minX; i < hexArray.length; i++) { for (int j = minY; j < hexArray[0].length; j++) { mh = hexArray[i][j]; - if (mh != null) { - GUIHex hex = new GUIHex(this, calcXCoordinates(mh.getColumn(), tileXOffset), + if (mh != null) { + GUIHex hex = new GUIHex(this, calcXCoordinates(mh.getColumn(), tileXOffset), calcYCoordinates(mh.getRow(), tileYOffset), scale, i-minX+1, j-minY+1); hex.setHexModel(mh); @@ -171,7 +170,7 @@ } setSize(); } - + protected void scaleHexesGUI () { hexArray = mapManager.getHexes(); GUIHex hex; @@ -189,19 +188,33 @@ } protected void drawLabel(Graphics2D g2, int index, int xCoordinate, int yCoordinate, boolean letter) { - String label = letter - ? String.valueOf((char)('@'+index)) - : String.valueOf(index); + String label = letter ? getLetterLabel (index) : getNumberLabel (index); xCoordinate -= 4.0*label.length(); yCoordinate += 4.0; g2.drawString(label, xCoordinate, yCoordinate); - + // log.debug("Draw Label " + label + " for " + index + " at x = " + xCoordinate + ", y = " + yCoordinate); } + private String getLetterLabel (int index) { + if (index > 26) { + return "A" + String.valueOf((char)('@'+(index-26))); // For 1825U1 row "AA" + } else { + return String.valueOf((char)('@'+index)); + } + } + + private String getNumberLabel (int index) { + if (index < 0) { + return String.valueOf(100 + index); // For 1825U1 column "99" + } else { + return String.valueOf(index); + } + } + @Override public void paint(Graphics g) { @@ -214,7 +227,7 @@ int yTop = (int)calcYCoordinates(minRow, - coordinateYMargin); int yBottom = (int)calcYCoordinates(maxRow, coordinateYMargin); - + for (int iCol = minCol; iCol <= maxCol; iCol++) { int xCoordinate = (int)(calcXCoordinates(iCol, 0)); drawLabel(g2, iCol, xCoordinate, yTop, lettersGoHorizontal); @@ -230,7 +243,7 @@ } - + public void setupHexes() { setupHexesGUI(); setupBars(); @@ -293,10 +306,10 @@ hex.paintBars(g); } } - + // paint train paths Graphics2D g2 = (Graphics2D) g; - Stroke trainStroke = + Stroke trainStroke = new BasicStroke((int)(strokeWidth * zoomFactor), strokeCap, strokeJoin); g2.setStroke(trainStroke); @@ -506,7 +519,7 @@ public void setTrainPaths(List<GeneralPath> trainPaths) { this.trainPaths = trainPaths; } - + /** * Off-board tiles must be able to retrieve the current phase. * Modified: trunk/18xx/rails/util/Tag.java =================================================================== --- trunk/18xx/rails/util/Tag.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/util/Tag.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -287,6 +287,11 @@ "IfOption has no optionName attribute"); name = nameAttr.getNodeValue(); + Node parmAttr = nnp.getNamedItem("parm"); + if (parmAttr != null) { + value = parmAttr.getNodeValue(); + name = GameOption.constructParametrisedName(name, value.split(",")); + } Node valueAttr = nnp.getNamedItem("value"); if (valueAttr == null) throw new ConfigurationException( @@ -301,7 +306,19 @@ } String optionValue = gameOptions.get(name); + + // For backwards compatibility: search for an extended name if (optionValue == null) { + for (String optName : gameOptions.keySet()) { + if (optName.startsWith(name)) { + optionValue = gameOptions.get(optName); + log.warn("Option name "+name+" replaced by "+optName); + break; + } + } + } + + if (optionValue == null) { // Take the default value GameOption go = GameOption.getByName(name); optionValue = go != null ? go.getDefaultValue() : ""; @@ -309,6 +326,7 @@ + " but no assigned value found, assumed "+optionValue); } + if (optionValue.equalsIgnoreCase(value)) { parseSubTags(childElement); } Property changes on: trunk/18xx/test ___________________________________________________________________ Added: svn:ignore + Test.java Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |