From: Erik V. <ev...@us...> - 2009-10-09 22:29:16
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21628/rails/game Modified Files: Game.java MapManager.java MapHex.java GameManagerI.java GameManager.java Log Message: MapManager & TrainManager config. updates Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MapHex.java 9 Oct 2009 20:20:34 -0000 1.26 --- MapHex.java 9 Oct 2009 22:29:01 -0000 1.27 *************** *** 162,177 **** currentTileRotation = tag.getAttributeAsInteger("orientation", 0); - currentTile = TileManager.get().getTile(preprintedTileId); impassable = tag.getAttributeAsString("impassable"); tileCost = tag.getAttributeAsIntegerArray("cost", new int[0]); // We need completely new objects, not just references to the Tile's // stations. cities = new ArrayList<City>(4); mCities = new HashMap<Integer, City>(4); ! // for (int i = 0; i < currentTile.getStations().size(); i++) ! for (Station s : currentTile.getStations()) { // sid, type, value, slots - // Station s = currentTile.getStations().get(i); City c = new City(this, s.getNumber(), s); cities.add(c); --- 162,185 ---- currentTileRotation = tag.getAttributeAsInteger("orientation", 0); impassable = tag.getAttributeAsString("impassable"); tileCost = tag.getAttributeAsIntegerArray("cost", new int[0]); + // Off-board revenue values + offBoardValues = tag.getAttributeAsIntegerArray("value", null); + + // City name + cityName = tag.getAttributeAsString("city", ""); + + } + + public void finishConfiguration (GameManager gameManager) { + + currentTile = gameManager.getTileManager().getTile(preprintedTileId); // We need completely new objects, not just references to the Tile's // stations. cities = new ArrayList<City>(4); mCities = new HashMap<Integer, City>(4); ! for (Station s : currentTile.getStations()) { // sid, type, value, slots City c = new City(this, s.getNumber(), s); cities.add(c); *************** *** 179,192 **** } - // Off-board revenue values - offBoardValues = tag.getAttributeAsIntegerArray("value", null); - - // City name - cityName = tag.getAttributeAsString("city", ""); - } - public void finishConfiguration (GameManager gameManager) {} - public boolean isNeighbour(MapHex neighbour, int direction) { /* --- 187,192 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** GameManager.java 9 Oct 2009 20:20:34 -0000 1.61 --- GameManager.java 9 Oct 2009 22:29:01 -0000 1.62 *************** *** 49,52 **** --- 49,53 ---- protected StockMarketI stockMarket; protected MapManager mapManager; + protected TileManager tileManager; protected Bank bank; *************** *** 381,384 **** --- 382,386 ---- StockMarketI stockMarket, MapManager mapManager, + TileManager tileManager, Bank bank) { this.playerManager = playerManager; *************** *** 388,391 **** --- 390,394 ---- this.stockMarket = stockMarket; this.mapManager = mapManager; + this.tileManager = tileManager; this.bank = bank; *************** *** 1021,1024 **** --- 1024,1031 ---- } + public TileManager getTileManager() { + return tileManager; + } + public Bank getBank () { return bank; Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MapManager.java 9 Oct 2009 20:20:34 -0000 1.9 --- MapManager.java 9 Oct 2009 22:29:01 -0000 1.10 *************** *** 22,25 **** --- 22,26 ---- protected static MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); + protected int maxX, maxY; protected static final int[] xDeltaNS = new int[] { 0, -1, -1, 0, +1, +1 }; *************** *** 78,83 **** List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! int maxX = 0; ! int maxY = 0; for (Tag hexTag : hexTags) { hex = new MapHex(this); --- 79,84 ---- List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! maxX = 0; ! maxY = 0; for (Tag hexTag : hexTags) { hex = new MapHex(this); *************** *** 94,97 **** --- 95,110 ---- hexes[hex.getX()][hex.getY()] = hex; } + } + + public void finishConfiguration (GameManager gameManager) { + + MapHex hex; + int i, j, k, dx, dy; + MapHex nb; + + for (String hexName : mHexes.keySet()) { + hex = mHexes.get(hexName); + hex.finishConfiguration(gameManager); + } // Initialise the neighbours *************** *** 100,108 **** * preprinted tiles. */ - int i, j, k, dx, dy; - MapHex nb; for (i = 0; i <= maxX; i++) { for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { --- 113,120 ---- * preprinted tiles. */ for (i = 0; i <= maxX; i++) { for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; + for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { *************** *** 126,133 **** } } - } - - public void finishConfiguration (GameManager gameManager) { - MapHex hex; for (PublicCompanyI company : gameManager.getCompanyManager().getAllPublicCompanies()) { --- 138,141 ---- Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Game.java 9 Oct 2009 20:20:34 -0000 1.31 --- Game.java 9 Oct 2009 22:29:01 -0000 1.32 *************** *** 28,31 **** --- 28,32 ---- protected StockMarketI stockMarket; protected MapManager mapManager; + protected TileManager tileManager; protected Bank bank; // protected ArrayList companyList; *************** *** 155,158 **** --- 156,167 ---- } + tileManager = + (TileManager) componentManager.findComponent("TileManager"); + if (tileManager == null) { + throw new ConfigurationException( + "No TileManager XML element found in file " + + GAME_XML_FILE); + } + /* * Initialisations that involve relations between components can *************** *** 161,165 **** playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, bank); companyManager.finishConfiguration(gameManager); --- 170,175 ---- playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, ! tileManager, bank); companyManager.finishConfiguration(gameManager); Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GameManagerI.java 9 Oct 2009 20:20:34 -0000 1.17 --- GameManagerI.java 9 Oct 2009 22:29:01 -0000 1.18 *************** *** 9,13 **** import rails.game.move.MoveableHolderI; import rails.game.special.SpecialPropertyI; - import rails.util.Tag; public interface GameManagerI extends MoveableHolderI, ConfigurableComponentI { --- 9,12 ---- *************** *** 19,23 **** CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, ! MapManager mapManager, Bank bank); public abstract void startGame(); --- 18,22 ---- CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, ! MapManager mapManager, TileManager tileManager, Bank bank); public abstract void startGame(); |