From: Erik V. <ev...@us...> - 2009-10-31 17:08:38
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game/special Modified Files: SellBonusToken.java SpecialProperty.java SpecialTokenLay.java LocatedBonus.java Log Message: More rationalising of static method usage Index: SpecialTokenLay.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTokenLay.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SpecialTokenLay.java 23 Sep 2009 21:38:57 -0000 1.10 --- SpecialTokenLay.java 31 Oct 2009 17:08:26 -0000 1.11 *************** *** 2,6 **** package rails.game.special; - import java.util.ArrayList; import java.util.List; --- 2,5 ---- *************** *** 34,47 **** throw new ConfigurationException( "SpecialTokenLay: location missing"); - MapManager mmgr = MapManager.getInstance(); - MapHex hex; - locations = new ArrayList<MapHex>(); - for (String hexName : locationCodes.split(",")) { - hex = mmgr.getHex(hexName); - if (hex == null) - throw new ConfigurationException("Location " + hexName - + " does not exist"); - locations.add(hex); - } extra = tokenLayTag.getAttributeAsBoolean("extra", extra); --- 33,36 ---- *************** *** 74,77 **** --- 63,73 ---- } + @Override + public void finishConfiguration (GameManagerI gameManager) + throws ConfigurationException { + + locations = gameManager.getMapManager().parseLocations(locationCodes); + } + public boolean isExecutionable() { return true; Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SpecialProperty.java 30 Oct 2009 21:53:04 -0000 1.17 --- SpecialProperty.java 31 Oct 2009 17:08:26 -0000 1.18 *************** *** 5,8 **** --- 5,10 ---- import java.util.Map; + import org.apache.log4j.Logger; + import rails.game.*; import rails.game.move.MoveableHolderI; *************** *** 35,38 **** --- 37,43 ---- new HashMap<Integer, SpecialPropertyI>(); protected static int lastIndex = 0; + + protected static Logger log = + Logger.getLogger(SpecialProperty.class.getPackage().getName()); public SpecialProperty() { *************** *** 60,64 **** } ! public void finishConfiguration (GameManager gameManager) throws ConfigurationException { --- 65,69 ---- } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { Index: LocatedBonus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/LocatedBonus.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LocatedBonus.java 23 Sep 2009 21:38:57 -0000 1.1 --- LocatedBonus.java 31 Oct 2009 17:08:26 -0000 1.2 *************** *** 2,6 **** package rails.game.special; - import java.util.ArrayList; import java.util.List; --- 2,5 ---- *************** *** 36,40 **** if (!Util.hasValue(locationCodes)) throw new ConfigurationException("LocatedBonus: location missing"); - parseLocations (); name = bonusTag.getAttributeAsString("name"); --- 35,38 ---- *************** *** 45,48 **** --- 43,52 ---- } + public void finishConfiguration (GameManager gameManager) + throws ConfigurationException { + + locations = gameManager.getMapManager().parseLocations(locationCodes); + } + public boolean isExecutionable() { return false; *************** *** 65,82 **** } - private void parseLocations () - throws ConfigurationException { - - MapManager mmgr = MapManager.getInstance(); - MapHex hex; - locations = new ArrayList<MapHex>(); - for (String hexName : locationCodes.split(",")) { - hex = mmgr.getHex(hexName); - if (hex == null) - throw new ConfigurationException("Location " + hexName - + " does not exist"); - locations.add(hex); - } - } @Override --- 69,72 ---- *************** *** 85,88 **** + locationCodes + " value=" + value; } - } --- 75,77 ---- Index: SellBonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SellBonusToken.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SellBonusToken.java 23 Sep 2009 21:38:57 -0000 1.1 --- SellBonusToken.java 31 Oct 2009 17:08:26 -0000 1.2 *************** *** 2,6 **** package rails.game.special; - import java.util.ArrayList; import java.util.List; --- 2,5 ---- *************** *** 34,47 **** if (!Util.hasValue(locationCodes)) throw new ConfigurationException("SellBonusToken: location missing"); - MapManager mmgr = MapManager.getInstance(); - MapHex hex; - locations = new ArrayList<MapHex>(); - for (String hexName : locationCodes.split(",")) { - hex = mmgr.getHex(hexName); - if (hex == null) - throw new ConfigurationException("Location " + hexName - + " does not exist"); - locations.add(hex); - } name = sellBonusTokenTag.getAttributeAsString("name"); --- 33,36 ---- *************** *** 60,64 **** } ! @Override public void setExercised () { numberSold++; --- 49,59 ---- } ! public void finishConfiguration (GameManager gameManager) ! throws ConfigurationException { ! ! locations = gameManager.getMapManager().parseLocations(locationCodes); ! } ! ! @Override public void setExercised () { numberSold++; |