From: Erik V. <ev...@us...> - 2011-08-14 14:28:34
|
data/1830/Map.xml | 17 data/1830/TileSet.xml | 3 data/1856/Map.xml | 4 data/18EU/Map.xml | 16 rails/algorithms/NetworkGraphBuilder.java | 8 rails/algorithms/NetworkVertex.java | 161 +++--- rails/game/BaseToken.java | 2 rails/game/City.java | 201 -------- rails/game/Game.java | 40 - rails/game/MapHex.java | 320 +++++++----- rails/game/MapManager.java | 103 ++++ rails/game/PublicCompany.java | 12 rails/game/Round.java | 4 rails/game/Station.java | 14 rails/game/Stop.java | 346 ++++++++++++++ rails/game/Tile.java | 153 +++++- rails/game/TileI.java | 21 rails/game/TileManager.java | 2 rails/game/correct/MapCorrectionManager.java | 4 rails/game/move/TileMove.java | 8 rails/game/specific/_1835/PrussianFormationRound.java | 2 rails/game/specific/_1856/CGRFormationRound.java | 14 rails/game/specific/_18EU/StartCompany_18EU.java | 20 rails/game/specific/_18EU/StockRound_18EU.java | 8 rails/ui/swing/GameUIManager.java | 4 rails/ui/swing/ORUIManager.java | 12 rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java | 4 rails/ui/swing/hexmap/GUIHex.java | 36 - 28 files changed, 980 insertions(+), 559 deletions(-) New commits: commit 2582e0ece356f1a6ed534d29c9b9fdbf5ea5fc84 Author: Erik Vos <eri...@xs...> Date: Sun Aug 14 16:26:41 2011 +0200 Stop properties wrap-up diff --git a/data/1830/Map.xml b/data/1830/Map.xml index d43649c..9a286e8 100644 --- a/data/1830/Map.xml +++ b/data/1830/Map.xml @@ -1,9 +1,10 @@ <Map tileOrientation="EW" letterOrientation="vertical" even="B"> <Defaults> - <Access type="offMap" runTo="yes" runThrough="no" loop="no"/> - <Access type="major" runTo="yes" runThrough="yes" loop="yes"/> + <Access type="offMap" runTo="yes" runThrough="no" loop="no" score="major"/> + <Access type="city" runTo="yes" runThrough="yes" loop="yes" score="major"/> + <Access type="town" runTo="yes" runThrough="yes" loop="yes" score="minor"/> </Defaults> - <!-- The above defaults are redundant, these settings are the defaults anyway --> + <!-- The above defaults are redundant, these settings are the system defaults anyway --> <Hex name="A9" tile="-901" orientation="0" value="30,50" city="Canadian West"/> <Hex name="A11" tile="-902" orientation="1" value="30,50" city="Canadian West"/> <Hex name="A17" tile="-7" orientation="1" city="Montreal"/> diff --git a/rails/algorithms/NetworkVertex.java b/rails/algorithms/NetworkVertex.java index b4c9056..952c971 100644 --- a/rails/algorithms/NetworkVertex.java +++ b/rails/algorithms/NetworkVertex.java @@ -53,7 +53,7 @@ public final class NetworkVertex implements Comparable<NetworkVertex> { this.hex = hex; this.station = station; this.side = -1; - this.city = hex.getRelatedCity(station); + this.city = hex.getRelatedStop(station); if (city != null) { log.info("Found city " + city); } else { diff --git a/rails/game/City.java b/rails/game/City.java deleted file mode 100644 index 75d5ba9..0000000 --- a/rails/game/City.java +++ /dev/null @@ -1,201 +0,0 @@ -/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/City.java,v 1.12 2010/04/18 15:08:57 evos Exp $ */ -package rails.game; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import rails.game.move.Moveable; -import rails.game.state.GenericState; -import rails.util.Util; - -/** - * A City object represents any junction on the map that is relevant for - * establishing train run length and revenue calculation. A City object is bound - * to (1) a MapHex, (2) to a Station object on the current Tile laid on that - * MapHex, and (3) any tokens laid on that tile and station. <p> Each City has a - * unique ID, that is derived from the MapHex name and the City number. The - * initial City numbers are derived from the Station numbers of the preprinted - * tile of that hex. <p> Please note, that during upgrades the Station numbers - * related to a city on a multiple-city hex may change: city 1 on one tile may - * be numbered 2 on its upgrade, depending on the rotation of the upgrading - * tile. However, the City numbers will not change, unless cities are merged - * during upgrades; but even then it is attempted to retain the old city numbers - * as much as possible. - * - * @author Erik Vos - */ -public class City implements TokenHolder { - private int number; - private String uniqueId; - //private Station relatedStation; - private GenericState<Station> relatedStation; - private int slots; - private ArrayList<TokenI> tokens; - private MapHex mapHex; - private String trackEdges; - - protected static Logger log = - Logger.getLogger(City.class.getPackage().getName()); - - public City(MapHex mapHex, int number, Station station) { - this.mapHex = mapHex; - this.number = number; - - uniqueId = mapHex.getName() + "_" + number; - relatedStation = new GenericState<Station>("City_"+uniqueId+"_station", station); - setRelatedStation(station); - - - tokens = new ArrayList<TokenI>(4); - } - - public String getName() { - return mapHex.getName() + "/" + number; - - } - - /** - * @return Returns the holder. - */ - public MapHex getHolder() { - return mapHex; - } - - public int getNumber() { - return number; - } - - public Station getRelatedStation() { - return relatedStation.get(); - } - - public void setRelatedStation(Station relatedStation) { - this.relatedStation.set(relatedStation); - slots = relatedStation.getBaseSlots(); - trackEdges = - mapHex.getConnectionString(mapHex.getCurrentTile(), - mapHex.getCurrentTileRotation(), - relatedStation.getNumber()); - } - - public void setSlots(int slots) { - this.slots = slots; - } - - /** - * @return Returns the id. - */ - public String getUniqueId() { - return uniqueId; - } - - public boolean addToken(TokenI token, int position) { - - if (tokens.contains(token)) return false; - - boolean result = Util.addToList(tokens, token, position); - if (result) token.setHolder(this); - return result; - } - - public boolean addObject(Moveable object, int[] position) { - if (object instanceof TokenI) { - return addToken((TokenI) object, position == null ? -1 : position[0]); - } else { - return false; - } - } - - public boolean removeObject(Moveable object) { - if (object instanceof TokenI) { - return removeToken((TokenI) object); - } else { - return false; - } - } - - public List<TokenI> getTokens() { - return tokens; - } - - public boolean hasTokens() { - return tokens.size() > 0; - } - - public int getSlots() { - return slots; - } - - public boolean hasTokenSlotsLeft() { - return tokens.size() < slots; - } - - public int getTokenSlotsLeft () { - return slots - tokens.size(); - } - - public boolean removeToken(TokenI token) { - - boolean result = tokens.remove(token); - return result; - } - - /** - * @param company - * @return true if this City already contains an instance of the specified - * company's token. Do this by calling the hasTokenOf with Company Name. - * Using a tokens.contains(company) fails since the tokens are a ArrayList - * of TokenI not a ArrayList of PublicCompanyI. - */ - public boolean hasTokenOf(PublicCompanyI company) { - return hasTokenOf (company.getName()); - } - - public boolean hasTokenOf (String companyName) { - for (TokenI token : tokens) { - if (token instanceof BaseToken - && ((BaseToken)token).getCompany().getName().equals(companyName)) { - return true; - } - } - return false; - } - - public int[] getListIndex (Moveable object) { - if (object instanceof BaseToken) { - return new int[] {tokens.indexOf(object)}; - } else { - return Moveable.AT_END; - } - } - - public void setTokens(ArrayList<TokenI> tokens) { - this.tokens = tokens; - } - - public String getTrackEdges() { - return trackEdges; - } - - public void setTrackEdges(String trackEdges) { - this.trackEdges = trackEdges; - } - - @Override - public String toString() { - StringBuffer b = new StringBuffer(); - b.append("Hex ").append(mapHex.getName()); - String cityName = mapHex.getCityName(); - b.append(" ("); - if (Util.hasValue(cityName)) { - b.append(cityName); - } - if (mapHex.getCities().size() > 1) { - b.append(" ").append(trackEdges); - } - b.append(")"); - return b.toString(); - } -} diff --git a/rails/game/MapHex.java b/rails/game/MapHex.java index f962f46..4093b0e 100644 --- a/rails/game/MapHex.java +++ b/rails/game/MapHex.java @@ -13,6 +13,7 @@ import rails.common.parser.*; import rails.game.Stop.Loop; import rails.game.Stop.RunThrough; import rails.game.Stop.RunTo; +import rails.game.Stop.Score; import rails.game.Stop.Type; import rails.game.action.LayTile; import rails.game.model.ModelObject; @@ -149,10 +150,14 @@ StationHolder, TokenHolder { /** Type of any stops on the hex. * Normally the type will be derived from the tile properties. - * Hex-specific types are known to be required in 18VA (mine and offmap). */ protected Type stopType = null; + /** + * Score type: do stops on this hex count as major or minor stops with respect to n+m trains? + */ + protected Score scoreType = null; + protected MapManager mapManager = null; protected static Logger log = @@ -302,7 +307,17 @@ StationHolder, TokenHolder { stopType = Type.valueOf(typeString.toUpperCase()); } catch (IllegalArgumentException e) { throw new ConfigurationException ("Illegal value for MapHex " - +name+" type property: "+typeString, e); + +name+" stop type property: "+typeString, e); + } + } + + String scoreTypeString = accessTag.getAttributeAsString("score"); + if (Util.hasValue(scoreTypeString)) { + try { + scoreType = Score.valueOf(scoreTypeString.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new ConfigurationException ("Illegal value for MapHex " + +name+" score type property: "+scoreTypeString, e); } } } @@ -1037,38 +1052,38 @@ StationHolder, TokenHolder { return 0; } - public List<Stop> getCities() { + public List<Stop> getStops() { return stops; } - public Stop getCity(int cityNumber) { - return mStops.get(cityNumber); + public Stop getStop(int stopNumber) { + return mStops.get(stopNumber); } - public Stop getRelatedCity(Station station) { - Stop foundCity = null; - for (Stop city:mStops.values()) { - if (station == city.getRelatedStation()) { - foundCity = city; + public Stop getRelatedStop(Station station) { + Stop foundStop = null; + for (Stop stop:mStops.values()) { + if (station == stop.getRelatedStation()) { + foundStop = stop; } } - return foundCity; + return foundStop; } - public void addHome(PublicCompanyI company, int cityNumber) throws ConfigurationException { + public void addHome(PublicCompanyI company, int stopNumber) throws ConfigurationException { if (homes == null) homes = new HashMap<PublicCompanyI, Stop>(); if (stops.isEmpty()) { log.error("No cities for home station on hex " + name); } else { // not yet decided - if (cityNumber == 0) { + if (stopNumber == 0) { homes.put(company, null); log.debug("Added home of " + company + " in hex " + this.toString() + " city not yet decided"); - } else if (cityNumber > stops.size()) { - throw new ConfigurationException ("Invalid city number "+cityNumber+" for hex "+name + } else if (stopNumber > stops.size()) { + throw new ConfigurationException ("Invalid city number "+stopNumber+" for hex "+name +" which has "+stops.size()+" cities"); } else { - Stop homeCity = stops.get(Math.max(cityNumber - 1, 0)); + Stop homeCity = stops.get(Math.max(stopNumber - 1, 0)); homes.put(company, homeCity); log.debug("Added home of " + company + " set to " + homeCity + " id= " +homeCity.getUniqueId()); } @@ -1178,7 +1193,7 @@ StationHolder, TokenHolder { // Return MapHex attribute if defined return isBlockedForTokenLays.booleanValue(); } else if (homes != null && !homes.isEmpty()) { - Stop cityToLay = this.getCity(cityNumber); + Stop cityToLay = this.getStop(cityNumber); if (cityToLay == null) { // city does not exist, this does not block itself return false; } @@ -1360,4 +1375,7 @@ StationHolder, TokenHolder { return stopType; } + public Score getScoreType() { + return scoreType; + } } \ No newline at end of file diff --git a/rails/game/MapManager.java b/rails/game/MapManager.java index 9ac030d..f5220f9 100644 --- a/rails/game/MapManager.java +++ b/rails/game/MapManager.java @@ -9,6 +9,7 @@ import rails.common.parser.*; import rails.game.Stop.Loop; import rails.game.Stop.RunThrough; import rails.game.Stop.RunTo; +import rails.game.Stop.Score; import rails.game.Stop.Type; import rails.util.Util; @@ -57,6 +58,7 @@ public class MapManager implements ConfigurableComponentI { protected Map<Type,RunTo> runToDefaults = new HashMap<Type, RunTo>(); protected Map<Type,RunThrough> runThroughDefaults = new HashMap<Type, RunThrough>(); protected Map<Type,Loop> loopDefaults = new HashMap<Type, Loop>(); + protected Map<Type,Score> scoreTypeDefaults = new HashMap<Type, Score>(); protected static Logger log = Logger.getLogger(MapManager.class.getPackage().getName()); @@ -165,6 +167,7 @@ public class MapManager implements ConfigurableComponentI { RunTo runTo; RunThrough runThrough; Loop loop; + Score score; String s; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { @@ -214,6 +217,17 @@ public class MapManager implements ConfigurableComponentI { } loopDefaults.put(type, loop); } + // Score type (not allowed for a null stop type) + s = accessTag.getAttributeAsString("scoreType", null); + if (type != null && Util.hasValue(s)) { + try { + score = Score.valueOf(s.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new ConfigurationException ("Illegal value for " + +type+" default score type property: "+s, e); + } + scoreTypeDefaults.put(type, score); + } } } } @@ -275,11 +289,6 @@ public class MapManager implements ConfigurableComponentI { hex.addDestination(company); } } - - // Define default Stop property defaults - if (!runToDefaults.containsKey(null)) runToDefaults.put(null, RunTo.YES); - if (!runThroughDefaults.containsKey(null)) runThroughDefaults.put(null, RunThrough.YES); - if (!loopDefaults.containsKey(null)) loopDefaults.put(null, Loop.YES); } /** @@ -379,7 +388,7 @@ public class MapManager implements ConfigurableComponentI { public List<Stop> getCurrentStations() { List<Stop> stations = new ArrayList<Stop>(); for (MapHex hex : mHexes.values()) { - stations.addAll(hex.getCities()); + stations.addAll(hex.getStops()); } return stations; } @@ -509,4 +518,8 @@ public class MapManager implements ConfigurableComponentI { return loopDefaults.containsKey(type) ? loopDefaults.get(type) : null; } + public Score getScoreTypeDefault(Type type) { + return scoreTypeDefaults.containsKey(type) ? scoreTypeDefaults.get(type) : null; + } + } diff --git a/rails/game/PublicCompany.java b/rails/game/PublicCompany.java index 3f95068..8888f6f 100644 --- a/rails/game/PublicCompany.java +++ b/rails/game/PublicCompany.java @@ -1828,14 +1828,14 @@ public class PublicCompany extends Company implements PublicCompanyI { } else { // Cover the case that there already is another token. // Allowing this is optional for 1856 Hamilton (THB home) - List<Stop> cities = homeHex.getCities(); - List<Stop> openCities = new ArrayList<Stop>(); - for (Stop city : cities) { - if (city.hasTokenSlotsLeft()) openCities.add (city); + List<Stop> stops = homeHex.getStops(); + List<Stop> openStops = new ArrayList<Stop>(); + for (Stop stop : stops) { + if (stop.hasTokenSlotsLeft()) openStops.add (stop); } - if (openCities.size() == 1) { + if (openStops.size() == 1) { // Just one spot: lay the home base there. - homeCityNumber = openCities.get(0).getNumber(); + homeCityNumber = openStops.get(0).getNumber(); } else { // ?? // TODO Will player be asked?? diff --git a/rails/game/Round.java b/rails/game/Round.java index 14cdbc4..b162080 100644 --- a/rails/game/Round.java +++ b/rails/game/Round.java @@ -220,7 +220,7 @@ public abstract class Round implements RoundI { cityNumber = 1; } hex = mapManager.getHex(hexName); - city = hex.getCity(cityNumber); + city = hex.getStop(cityNumber); if (token.isSelected()) { diff --git a/rails/game/Stop.java b/rails/game/Stop.java index 6a2068f..edffce5 100644 --- a/rails/game/Stop.java +++ b/rails/game/Stop.java @@ -41,6 +41,7 @@ public class Stop implements TokenHolder { private RunTo runToAllowed = null; private RunThrough runThroughAllowed = null; private Loop loopAllowed = null; + private Score scoreType = null; protected static Logger log = Logger.getLogger(Stop.class.getPackage().getName()); @@ -63,15 +64,37 @@ public class Stop implements TokenHolder { } public enum Type { + + CITY (RunTo.YES, RunThrough.YES, Loop.YES, Score.MAJOR), + TOWN (RunTo.YES, RunThrough.YES, Loop.YES, Score.MINOR), + OFFMAP (RunTo.YES, RunThrough.NO, Loop.NO, Score.MAJOR); + + private RunTo defaultRunToAllowed; + private RunThrough defaultRunThroughAllowed; + private Loop defaultLoopAllowed; + private Score defaultScoreType; + + Type (RunTo runTo, + RunThrough runThrough, + Loop loop, + Score scoreType) { + + this.defaultRunToAllowed = runTo; + this.defaultRunThroughAllowed = runThrough; + this.defaultLoopAllowed = loop; + this.defaultScoreType = scoreType; + } + + public RunTo getDefaultRunTo() { return defaultRunToAllowed; } + public RunThrough getDefaultRunThrough() { return defaultRunThroughAllowed; } + public Loop getDefaultLoop() { return defaultLoopAllowed; } + public Score getDefaultScoreType() { return defaultScoreType; } + + } + + public enum Score { MAJOR, - MINOR, - OFFMAP, - MEDIUM, - HALT, - PASS, - PORT, - MINE, - NULL + MINOR } public Stop(MapHex mapHex, int number, Station station) { @@ -94,23 +117,23 @@ public class Stop implements TokenHolder { MapManager mapManager = mapHex.getMapManager(); TileManager tileManager = tile.getTileManager(); - // Type + // Stop type type = mapHex.getStopType(); if (type == null) type = tile.getStopType(); if (type == null) { String stationType = relatedStation.get().getType(); if (stationType.equals(Station.CITY)) { - type = Type.MAJOR; + type = Type.CITY; } else if (stationType.equals(Station.TOWN)) { - type = Type.MINOR; + type = Type.TOWN; } else if (stationType.equals(Station.OFF_MAP_AREA)) { type = Type.OFFMAP; } else if (stationType.equals(Station.PASS)) { - type = Type.PASS; + type = Type.CITY; } else { // The above four types seem to be all that can be assigned in ConvertTileXML. // If all else fails, assume City. - type = Type.MAJOR; + type = Type.CITY; } } @@ -121,7 +144,7 @@ public class Stop implements TokenHolder { if (runToAllowed == null) runToAllowed = tileManager.getRunToDefault(type); if (runToAllowed == null) runToAllowed = mapManager.getRunToDefault(null); if (runToAllowed == null) runToAllowed = tileManager.getRunToDefault(null); - if (runToAllowed == null) runToAllowed = RunTo.YES; + if (runToAllowed == null) runToAllowed = type.getDefaultRunTo(); // RunThrough runThroughAllowed = mapHex.isRunThroughAllowed(); @@ -130,7 +153,7 @@ public class Stop implements TokenHolder { if (runThroughAllowed == null) runThroughAllowed = tileManager.getRunThroughDefault(type); if (runThroughAllowed == null) runThroughAllowed = mapManager.getRunThroughDefault(null); if (runThroughAllowed == null) runThroughAllowed = tileManager.getRunThroughDefault(null); - if (runThroughAllowed == null) runThroughAllowed = type == Type.OFFMAP ? RunThrough.NO : RunThrough.YES; + if (runThroughAllowed == null) runThroughAllowed = type.getDefaultRunThrough(); // Loop loopAllowed = mapHex.isLoopAllowed(); @@ -139,11 +162,18 @@ public class Stop implements TokenHolder { if (loopAllowed == null) loopAllowed = tileManager.getLoopDefault(type); if (loopAllowed == null) loopAllowed = mapManager.getLoopDefault(null); if (loopAllowed == null) loopAllowed = tileManager.getLoopDefault(null); - if (loopAllowed == null) loopAllowed = type == Type.OFFMAP ? Loop.NO : Loop.YES; + if (loopAllowed == null) loopAllowed = type.getDefaultLoop(); + + // Score type + scoreType = mapHex.getScoreType(); + if (scoreType == null) scoreType = tile.getScoreType(); + if (scoreType == null) scoreType = mapManager.getScoreTypeDefault(type); + if (scoreType == null) scoreType = tileManager.getScoreTypeDefault(type); + if (scoreType == null) scoreType = type.getDefaultScoreType(); log.debug("+++ Hex="+mapHex.getName()+" tile="+tile.getId()+" city="+number - +": type="+type+" runTo="+runToAllowed+" runThrough="+runThroughAllowed - +" loop="+loopAllowed); + +": stopType="+type+" runTo="+runToAllowed+" runThrough="+runThroughAllowed + +" loop="+loopAllowed+" scoreType="+scoreType); } public String getName() { @@ -282,6 +312,10 @@ public class Stop implements TokenHolder { return type; } + public Score getScoreType () { + return scoreType; + } + public RunTo isRunToAllowed() { return runToAllowed; } @@ -303,7 +337,7 @@ public class Stop implements TokenHolder { if (Util.hasValue(cityName)) { b.append(cityName); } - if (mapHex.getCities().size() > 1) { + if (mapHex.getStops().size() > 1) { b.append(" ").append(trackEdges); } b.append(")"); diff --git a/rails/game/Tile.java b/rails/game/Tile.java index bf25b17..10fe33c 100644 --- a/rails/game/Tile.java +++ b/rails/game/Tile.java @@ -12,6 +12,7 @@ import rails.common.parser.Tag; import rails.game.Stop.Loop; import rails.game.Stop.RunThrough; import rails.game.Stop.RunTo; +import rails.game.Stop.Score; import rails.game.Stop.Type; import rails.game.model.ModelObject; import rails.util.Util; @@ -64,6 +65,7 @@ public class Tile extends ModelObject implements TileI, StationHolder, Comparabl protected RunTo runToAllowed = null; protected RunThrough runThroughAllowed = null; protected Loop loopAllowed = null; + protected Score scoreType = null; protected TileManager tileManager; @@ -357,7 +359,17 @@ public class Tile extends ModelObject implements TileI, StationHolder, Comparabl stopType = Type.valueOf(typeString.toUpperCase()); } catch (IllegalArgumentException e) { throw new ConfigurationException ("Illegal value for Tile " - +name+" type property: "+typeString, e); + +name+" stop type property: "+typeString, e); + } + } + + String scoreTypeString = accessTag.getAttributeAsString("score"); + if (Util.hasValue(scoreTypeString)) { + try { + scoreType = Score.valueOf(scoreTypeString.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new ConfigurationException ("Illegal value for Tile " + +name+" sscore type property: "+scoreTypeString, e); } } } @@ -620,6 +632,10 @@ public class Tile extends ModelObject implements TileI, StationHolder, Comparabl return loopAllowed; } + public Score getScoreType() { + return scoreType; + } + public TileManager getTileManager () { return tileManager; } diff --git a/rails/game/TileI.java b/rails/game/TileI.java index 320f9cd..16e8afe 100644 --- a/rails/game/TileI.java +++ b/rails/game/TileI.java @@ -10,6 +10,7 @@ import rails.common.parser.Tag; import rails.game.Stop.Loop; import rails.game.Stop.RunThrough; import rails.game.Stop.RunTo; +import rails.game.Stop.Score; import rails.game.Stop.Type; public interface TileI { @@ -82,6 +83,7 @@ public interface TileI { public RunTo isRunToAllowed(); public RunThrough isRunThroughAllowed(); public Loop isLoopAllowed(); + public Score getScoreType(); public TileManager getTileManager(); diff --git a/rails/game/TileManager.java b/rails/game/TileManager.java index ed262a6..0878175 100644 --- a/rails/game/TileManager.java +++ b/rails/game/TileManager.java @@ -1 +1 @@ -/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/TileManager.java,v 1.17 2010/05/29 09:38:58 stefanfrey Exp $ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.common.LocalText; import rails.common.parser.*; import rails.game.Stop.Loop; import rails.game.Stop.RunThrough; import rails.game.Stop.RunTo; import rails.game.Stop.Type; import rails.util.Util; public class TileManager implements ConfigurableComponentI { protected Map<Integer, TileI> tileMap = new HashMap<Integer, TileI>(); protected List<Integer> tileIds = new ArrayList<Integer>(); // private static List<String> directories = new ArrayList<String>(); private List<String> directories = new ArrayList<String>(); // Stop property defaults per stop type protected Map<Type,RunTo> runToDefaults = new HashMap<Type, RunTo>(); protected Map<Type,RunThrough> runThroughDefaults = new HashMap<Type, RunThrough>(); protected Map<Type,Loop> loopDefaults = new HashMap<Type, Loop>(); protected static Logger log = Logger.getLogger(TileManager.class.getPackage().getName()); /** * No-args constructor. */ public TileManager() { } /** * @see rails.common.parser.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tileSetTop) throws ConfigurationException { /* * Note: prefix se is used for elements from TileSet.xml, prefix te for * elements from Tiles.xml. */ String tileDefFileName = tileSetTop.getAttributeAsString("tiles"); if (tileDefFileName == null) throw new ConfigurationException(LocalText.getText("NoTilesXML")); directories.add("data/" + GameManager.getInstance().getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = |