|
From: <ev...@us...> - 2011-05-06 19:27:43
|
Revision: 1546
http://rails.svn.sourceforge.net/rails/?rev=1546&view=rev
Author: evos
Date: 2011-05-06 19:27:33 +0000 (Fri, 06 May 2011)
Log Message:
-----------
Added runTo and runThrough properties and getters to MapHex.
Possible values: "yes", "no" and "tokenOnly" (values of a new enum MapHex.Run).
These new properties are intended to facilitate certain special cases as the names indicate.
As an example, runThrough="tokenOnly" has been specified for 1830 Altoona and for the Reading home city in the 1830 Reading variant.
Note: These properties are not actually used yet by any code.
Modified Paths:
--------------
trunk/18xx/data/1830/Map.xml
trunk/18xx/rails/game/MapHex.java
Modified: trunk/18xx/data/1830/Map.xml
===================================================================
--- trunk/18xx/data/1830/Map.xml 2011-05-05 20:42:00 UTC (rev 1545)
+++ trunk/18xx/data/1830/Map.xml 2011-05-06 19:27:33 UTC (rev 1546)
@@ -86,16 +86,16 @@
<Hex name="H8" tile="0"/>
<Hex name="H10" tile="-10"/>
<IfOption name="Variant" value="Basegame,Pere Marquette">
- <Hex name="H12" tile="-101" city="Altoona"/>
+ <Hex name="H12" tile="-101" city="Altoona" runThrough="tokenOnly"/>
</IfOption>
<IfOption name="Variant" value="Coalfields,Reading,Coalfields&Reading">
- <Hex name="H12" tile="-30003" pic="-30002" city="Altoona"/>
+ <Hex name="H12" tile="-30003" pic="-30002" city="Altoona" runThrough="tokenOnly"/>
</IfOption>
<IfOption name="Variant" value="Basegame,Pere Marquette,Coalfields">
<Hex name="H14" tile="0"/>
</IfOption>
<IfOption name="Variant" value="Reading,Coalfields&Reading">
- <Hex name="H14" tile="-30007" pic="-30006" city="Reading"/>
+ <Hex name="H14" tile="-30007" pic="-30006" city="Reading" runThrough="tokenOnly"/>
</IfOption>
<Hex name="H16" tile="-10"/>
Modified: trunk/18xx/rails/game/MapHex.java
===================================================================
--- trunk/18xx/rails/game/MapHex.java 2011-05-05 20:42:00 UTC (rev 1545)
+++ trunk/18xx/rails/game/MapHex.java 2011-05-06 19:27:33 UTC (rev 1546)
@@ -12,6 +12,7 @@
import rails.game.model.ModelObject;
import rails.game.move.Moveable;
import rails.game.move.TileMove;
+
import rails.game.state.BooleanState;
import rails.util.*;
@@ -115,6 +116,35 @@
/** Any open sides against which track may be laid even at board edges (1825) */
protected boolean[] openHexSides;
+
+ /** Run-through status of any "city"-type stations on the hex (whether visible or not).
+ * Indicates whether or not a single train can run through such stations, i.e. both enter and leave it.
+ * Has no meaning if no "city"-type stations exist on this hex.
+ * <p>Values (see Run below for definitions):
+ * <br>- "yes" (default for all except off-map hexes) means that trains of all companies
+ * may run through this station, unless it is completely filled with foreign base tokens.
+ * <br>- "tokenOnly" means that trains may only run through the station if it contains a base token of the operating company.
+ * <br>- "no" (default for off-map hexes) means that no train may run through this hex.
+ */
+ protected Run runThroughAllowed = null;
+
+ /** Run-to status of any "city"-type stations on the hex (whether visible or not).
+ * Indicates whether or not a single train can run from or to such stations, i.e. either enter or leave it.
+ * Has no meaning if no "city"-type stations exist on this hex.
+ * <p>Values (see Run below for definitions):
+ * <br>- "yes" (default) means that trains of all companies may run to/from this station.
+ * <br>- "tokenOnly" means that trains may only access the station if it contains a base token of the operating company.
+ * <br>- "no" would mean that the hex is inaccessible (like 18AL Birmingham in the early game),
+ * but this option is not yet useful as there is no provision yet to change this setting
+ * in an undoable way (no state variable).
+ */
+ protected Run runToAllowed = null;
+
+ public enum Run {
+ YES,
+ NO,
+ TOKENONLY
+ }
protected MapManager mapManager = null;
@@ -225,6 +255,24 @@
if (openHexSides == null) openHexSides = new boolean[6];
openHexSides[side%6] = true;
}
+
+ String runThroughString = tag.getAttributeAsString("runThrough");
+ if (Util.hasValue(runThroughString)) {
+ try {
+ runThroughAllowed = Run.valueOf(runThroughString.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ throw new ConfigurationException ("Illegal value for MapHex runThrough property: "+runThroughString, e);
+ }
+ }
+
+ String runToString = tag.getAttributeAsString("runTo");
+ if (Util.hasValue(runToString)) {
+ try {
+ runToAllowed = Run.valueOf(runToString.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ throw new ConfigurationException ("Illegal value for MapHex runTo property: "+runToString, e);
+ }
+ }
}
public void finishConfiguration (GameManagerI gameManager) {
@@ -240,6 +288,13 @@
cities.add(c);
mCities.put(c.getNumber(), c);
}
+
+ if (runThroughAllowed == null) {
+ runThroughAllowed = currentTile.getColourName().equalsIgnoreCase("red") ? Run.NO : Run.YES;
+ }
+ if (runToAllowed == null) {
+ runToAllowed = Run.YES;
+ }
}
public void addImpassableSide (int orientation) {
@@ -1239,4 +1294,12 @@
return endpoints;
}
+ public Run isRunThroughAllowed() {
+ return runThroughAllowed;
+ }
+
+ public Run isRunToAllowed() {
+ return runToAllowed;
+ }
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|