From: Erik V. <ev...@us...> - 2010-01-19 19:55:26
|
Update of /cvsroot/rails/18xx/rails/game/special In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20972/rails/game/special Modified Files: SpecialPropertyI.java SpecialProperty.java SpecialTileLay.java SpecialTokenLay.java Log Message: Added and improved Info messages. Index: SpecialTokenLay.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTokenLay.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SpecialTokenLay.java 31 Oct 2009 17:08:26 -0000 1.11 --- SpecialTokenLay.java 19 Jan 2010 19:54:47 -0000 1.12 *************** *** 5,10 **** import rails.game.*; ! import rails.util.Tag; ! import rails.util.Util; public class SpecialTokenLay extends SpecialProperty { --- 5,9 ---- import rails.game.*; ! import rails.util.*; public class SpecialTokenLay extends SpecialProperty { *************** *** 43,46 **** --- 42,49 ---- tokenLayTag.getAttributeAsString("class", "rails.game.BaseToken"); + + String tokenName = ""; + int tokenValue = 0; + try { tokenClass = Class.forName(tokenClassName).asSubclass(Token.class); *************** *** 50,53 **** --- 53,58 ---- bToken.configureFromXML(tokenLayTag); + tokenName = bToken.getName(); + tokenValue = bToken.getValue(); numberAvailable = tokenLayTag.getAttributeAsInteger("number", *************** *** 61,71 **** + tokenClassName, e); } } @Override ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { locations = gameManager.getMapManager().parseLocations(locationCodes); } --- 66,92 ---- + tokenClassName, e); } + + if (tokenClass == BaseToken.class) { + description = LocalText.getText("LayBaseTokenInfo", + locationCodes, + (extra ? LocalText.getText("extra"):LocalText.getText("notExtra")), + (free ? LocalText.getText("noCost") : LocalText.getText("normalCost"))); + } else if (tokenClass == BonusToken.class) { + description = LocalText.getText("LayBonusTokenInfo", + tokenName, + Bank.format(tokenValue), + locationCodes); + } } @Override ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { locations = gameManager.getMapManager().parseLocations(locationCodes); + + if (token instanceof BonusToken) { + ((BonusToken)token).prepareForRemoval(gameManager.getPhaseManager()); + } } *************** *** 113,115 **** --- 134,146 ---- + locationCodes + " extra=" + extra + " cost=" + free; } + + @Override + public String toMenu() { + return description; + } + + @Override + public String getInfo() { + return description; + } } Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SpecialProperty.java 8 Jan 2010 21:30:53 -0000 1.20 --- SpecialProperty.java 19 Jan 2010 19:54:43 -0000 1.21 *************** *** 11,16 **** import rails.game.move.ObjectMove; import rails.game.state.BooleanState; ! import rails.util.Tag; ! import rails.util.Util; public abstract class SpecialProperty implements SpecialPropertyI { --- 11,15 ---- import rails.game.move.ObjectMove; import rails.game.state.BooleanState; ! import rails.util.*; public abstract class SpecialProperty implements SpecialPropertyI { *************** *** 29,32 **** --- 28,36 ---- protected boolean isSRProperty = false; + /** Optional descriptive text, for display in menus and info text. + * Subclasses may put real text in it. + */ + protected String description = ""; + protected int uniqueId; *************** *** 37,41 **** new HashMap<Integer, SpecialPropertyI>(); protected static int lastIndex = 0; ! protected static Logger log = Logger.getLogger(SpecialProperty.class.getPackage().getName()); --- 41,45 ---- new HashMap<Integer, SpecialPropertyI>(); protected static int lastIndex = 0; ! protected static Logger log = Logger.getLogger(SpecialProperty.class.getPackage().getName()); *************** *** 65,71 **** } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! } --- 69,75 ---- } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! } *************** *** 125,129 **** setExercised(true); } ! public void setExercised (boolean value) { exercised.set(value); --- 129,133 ---- setExercised(true); } ! public void setExercised (boolean value) { exercised.set(value); *************** *** 175,177 **** --- 179,192 ---- return toString(); } + + /** Default Info text. To be overridden where useful. */ + public String getInfo() { + return toString(); + } + + /** Default Help text: "You can " + the menu description */ + public String getHelp() { + return LocalText.getText ("YouCan", Util.lowerCaseFirst(toMenu())); + + } } Index: SpecialPropertyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialPropertyI.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SpecialPropertyI.java 8 Jan 2010 21:30:54 -0000 1.7 --- SpecialPropertyI.java 19 Jan 2010 19:54:42 -0000 1.8 *************** *** 39,42 **** --- 39,44 ---- public String getName(); + public String getInfo(); + public void moveTo(MoveableHolder newHolder); Index: SpecialTileLay.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTileLay.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SpecialTileLay.java 30 Oct 2009 21:53:04 -0000 1.7 --- SpecialTileLay.java 19 Jan 2010 19:54:43 -0000 1.8 *************** *** 6,11 **** import rails.game.*; ! import rails.util.Tag; ! import rails.util.Util; public class SpecialTileLay extends SpecialProperty { --- 6,10 ---- import rails.game.*; ! import rails.util.*; public class SpecialTileLay extends SpecialProperty { *************** *** 40,48 **** closingValue = tileLayTag.getAttributeAsInteger("closingValue", closingValue); } ! ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! TileManager tmgr = gameManager.getTileManager(); MapManager mmgr = gameManager.getMapManager(); --- 39,63 ---- closingValue = tileLayTag.getAttributeAsInteger("closingValue", closingValue); + + if (tileNumber > 0) { + description = LocalText.getText("LayNamedTileInfo", + tileNumber, + name, + locationCodes, + (extra ? LocalText.getText("extra"):LocalText.getText("notExtra")), + (free ? LocalText.getText("noCost") : LocalText.getText("normalCost"))); + } else { + description = LocalText.getText("LayTileInfo", + locationCodes, + (extra ? LocalText.getText("extra"):LocalText.getText("notExtra")), + (free ? LocalText.getText("noCost") : LocalText.getText("normalCost"))); + } + } ! ! @Override ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! TileManager tmgr = gameManager.getTileManager(); MapManager mmgr = gameManager.getMapManager(); *************** *** 76,89 **** } - /** @deprecated */ - @Deprecated - public MapHex getLocation() { - if (locations != null) { - return locations.get(0); - } else { - return null; - } - } - public List<MapHex> getLocations() { return locations; --- 91,94 ---- *************** *** 112,114 **** --- 117,128 ---- } + @Override + public String toMenu() { + return description; + } + + @Override + public String getInfo() { + return description; + } } |