From: Erik V. <ev...@us...> - 2009-10-30 21:53:12
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/game/special Modified Files: SpecialTileLay.java SpecialProperty.java Log Message: More rationalising of static method usage Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SpecialProperty.java 9 Oct 2009 20:20:34 -0000 1.16 --- SpecialProperty.java 30 Oct 2009 21:53:04 -0000 1.17 *************** *** 5,11 **** import java.util.Map; ! import rails.game.ConfigurationException; ! import rails.game.GameManager; ! import rails.game.PrivateCompanyI; import rails.game.move.MoveableHolderI; import rails.game.move.ObjectMove; --- 5,9 ---- import java.util.Map; ! import rails.game.*; import rails.game.move.MoveableHolderI; import rails.game.move.ObjectMove; *************** *** 31,34 **** --- 29,35 ---- protected int uniqueId; + /** To give subclasses access to the various 'managers' */ + protected GameManagerI gameManager; + protected static Map<Integer, SpecialPropertyI> spMap = new HashMap<Integer, SpecialPropertyI>(); *************** *** 38,41 **** --- 39,43 ---- uniqueId = ++lastIndex; spMap.put(uniqueId, this); + gameManager = GameManager.getInstance(); } *************** *** 57,62 **** transferText = tag.getAttributeAsString("transfer", ""); } ! ! public void finishConfiguration (GameManager gameManager) {} public int getUniqueId() { --- 59,67 ---- transferText = tag.getAttributeAsString("transfer", ""); } ! ! public void finishConfiguration (GameManager gameManager) ! throws ConfigurationException { ! ! } public int getUniqueId() { Index: SpecialTileLay.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTileLay.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SpecialTileLay.java 4 Jun 2008 19:00:38 -0000 1.6 --- SpecialTileLay.java 30 Oct 2009 21:53:04 -0000 1.7 *************** *** 19,23 **** boolean free = false; ! public void configureFromXML(Tag tag) throws ConfigurationException { super.configureFromXML(tag); --- 19,24 ---- boolean free = false; ! @Override ! public void configureFromXML(Tag tag) throws ConfigurationException { super.configureFromXML(tag); *************** *** 30,35 **** if (!Util.hasValue(locationCodes)) throw new ConfigurationException("SpecialTileLay: location missing"); ! MapManager mmgr = MapManager.getInstance(); MapHex hex; locations = new ArrayList<MapHex>(); for (String hexName : locationCodes.split(",")) { --- 31,56 ---- if (!Util.hasValue(locationCodes)) throw new ConfigurationException("SpecialTileLay: location missing"); ! ! tileNumber = tileLayTag.getAttributeAsInteger("tile", 0); ! ! name = tileLayTag.getAttributeAsString("name"); ! ! extra = tileLayTag.getAttributeAsBoolean("extra", extra); ! free = tileLayTag.getAttributeAsBoolean("free", free); ! closingValue = ! tileLayTag.getAttributeAsInteger("closingValue", closingValue); ! } ! ! public void finishConfiguration (GameManagerI gameManager) ! throws ConfigurationException { ! ! TileManager tmgr = gameManager.getTileManager(); ! MapManager mmgr = gameManager.getMapManager(); MapHex hex; + + if (tileNumber > 0) { + tile = tmgr.getTile(tileNumber); + } + locations = new ArrayList<MapHex>(); for (String hexName : locationCodes.split(",")) { *************** *** 41,55 **** } - tileNumber = tileLayTag.getAttributeAsInteger("tile", 0); - if (tileNumber > 0) { - tile = TileManager.get().getTile(tileNumber); - } - - name = tileLayTag.getAttributeAsString("name"); - - extra = tileLayTag.getAttributeAsBoolean("extra", extra); - free = tileLayTag.getAttributeAsBoolean("free", free); - closingValue = - tileLayTag.getAttributeAsInteger("closingValue", closingValue); } --- 62,65 ---- *************** *** 67,71 **** /** @deprecated */ ! public MapHex getLocation() { if (locations != null) { return locations.get(0); --- 77,82 ---- /** @deprecated */ ! @Deprecated ! public MapHex getLocation() { if (locations != null) { return locations.get(0); *************** *** 95,99 **** } ! public String toString() { return "SpecialTileLay comp=" + privateCompany.getName() + " hex=" + locationCodes + " extra=" + extra + " cost=" + free; --- 106,111 ---- } ! @Override ! public String toString() { return "SpecialTileLay comp=" + privateCompany.getName() + " hex=" + locationCodes + " extra=" + extra + " cost=" + free; |