Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6617/rails/game Modified Files: Bank.java TileManager.java Game.java GameDef.java GameManagerI.java ReportBuffer.java Round.java TrainManager.java ShareSellingRound.java StockRound.java TreasuryShareRound.java ComponentManager.java OperatingRound.java RoundI.java GameManager.java GameOption.java Log Message: Moved various non-changing variables to gameParameters (via GameDef.Parm). Cleanups. Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TreasuryShareRound.java 14 Jan 2010 20:57:23 -0000 1.16 --- TreasuryShareRound.java 15 Jan 2010 19:55:59 -0000 1.17 *************** *** 127,131 **** operatingCompany.getPortfolio().getShare(operatingCompany); // Max share that may be owned ! int maxShare = gameManager.getTreasuryShareLimit(); // Max number of shares to add int maxBuyable = --- 127,131 ---- operatingCompany.getPortfolio().getShare(operatingCompany); // Max share that may be owned ! int maxShare = getGameParameterAsInt(GameDef.Parm.TREASURY_SHARE_LIMIT); // Max number of shares to add int maxBuyable = *************** *** 179,183 **** /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, bank.getPoolShareLimit() - pool.getShare(company)); if (maxShareToSell == 0) continue; --- 179,184 ---- /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, ! getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT) - pool.getShare(company)); if (maxShareToSell == 0) continue; *************** *** 307,314 **** // Check if company would exceed the per-company share limit ! if (portfolio.getShare(company) + shares * company.getShareUnit() > gameManager.getTreasuryShareLimit()) { errMsg = LocalText.getText("TreasuryOverHoldLimit", ! String.valueOf(gameManager.getTreasuryShareLimit())); break; } --- 308,317 ---- // Check if company would exceed the per-company share limit ! int treasuryShareLimit = getGameParameterAsInt(GameDef.Parm.TREASURY_SHARE_LIMIT); ! if (portfolio.getShare(company) + shares * company.getShareUnit() ! > treasuryShareLimit) { errMsg = LocalText.getText("TreasuryOverHoldLimit", ! String.valueOf(treasuryShareLimit)); break; } *************** *** 424,428 **** // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() > bank.getPoolShareLimit()) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; --- 427,432 ---- // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() ! > getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; Index: ReportBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ReportBuffer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ReportBuffer.java 27 Nov 2009 20:34:01 -0000 1.7 --- ReportBuffer.java 15 Jan 2010 19:55:59 -0000 1.8 *************** *** 116,120 **** reportPathname = reportDirectory + "/" + GameManager.getInstance().getGameName() + "_" ! + GameManager.getInstance().getKey() + "_" + dateFormat.format(new Date()) + "." + reportFilenameExtension; --- 116,120 ---- reportPathname = reportDirectory + "/" + GameManager.getInstance().getGameName() + "_" ! + GameManager.getInstance().getGMKey() + "_" + dateFormat.format(new Date()) + "." + reportFilenameExtension; Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TileManager.java 4 Nov 2009 20:33:22 -0000 1.13 --- TileManager.java 15 Jan 2010 19:55:59 -0000 1.14 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; 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>(); /** * No-args constructor. */ public TileManager() { } /** * @see rails.game.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/" + ComponentManager.getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { for (TileI tile : tileMap.values()) { tile.finishConfiguration(this); } } public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; 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>(); /** * No-args constructor. */ public TileManager() { } /** * @see rails.game.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/" + ComponentManager.getGameName()); 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 = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { for (TileI tile : tileMap.values()) { tile.finishConfiguration(this); } } public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file Index: RoundI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/RoundI.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RoundI.java 25 Nov 2009 18:44:45 -0000 1.13 --- RoundI.java 15 Jan 2010 19:55:59 -0000 1.14 *************** *** 31,33 **** --- 31,34 ---- public String getRoundName(); + } Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** TrainManager.java 8 Dec 2009 19:31:32 -0000 1.24 --- TrainManager.java 15 Jan 2010 19:55:59 -0000 1.25 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected Map<String, TrainI> trainMap = new HashMap<String, TrainI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); for (TrainTypeI type : lTrainTypes) { type.finishConfiguration(gameManager); } // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } public void addTrain (String uniqueID, TrainI train) { trainMap.put(uniqueID, train); } public TrainI getTrainByUniqueId(String id) { return trainMap.get(id); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public String getTrainCostOverview() { StringBuffer b = new StringBuffer(); for (TrainTypeI type : lTrainTypes) { if (b.length() > 1) b.append(" "); b.append(type.getName()).append(":").append(Bank.format(type.getCost())); if (type.getFirstExchangeCost() > 0) { b.append("(").append(Bank.format(type.getFirstExchangeCost())).append(")"); } } return b.toString(); } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected Map<String, TrainI> trainMap = new HashMap<String, TrainI>(); // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special GameManager.getInstance().setGameParameter(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS, rulesTag.getChild("FaceValueIfDifferentPresidents") != null); } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); for (TrainTypeI type : lTrainTypes) { type.finishConfiguration(gameManager); } // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } public void addTrain (String uniqueID, TrainI train) { trainMap.put(uniqueID, train); } public TrainI getTrainByUniqueId(String id) { return trainMap.get(id); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public String getTrainCostOverview() { StringBuffer b = new StringBuffer(); for (TrainTypeI type : lTrainTypes) { if (b.length() > 1) b.append(" "); b.append(type.getName()).append(":").append(Bank.format(type.getCost())); if (type.getFirstExchangeCost() > 0) { b.append("(").append(Bank.format(type.getFirstExchangeCost())).append(")"); } } return b.toString(); } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } } \ No newline at end of file Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Bank.java 26 Nov 2009 20:11:39 -0000 1.17 --- Bank.java 15 Jan 2010 19:55:55 -0000 1.18 *************** *** 12,16 **** /** Default limit of shares in the bank pool */ - private static final int DEFAULT_POOL_SHARE_LIMIT = 50; private static final int DEFAULT_BANK_AMOUNT = 12000; private static final String DEFAULT_MONEY_FORMAT = "$@"; --- 12,15 ---- *************** *** 41,46 **** private String moneyFormat = null; - private int poolShareLimit = DEFAULT_POOL_SHARE_LIMIT; - protected static Logger log = Logger.getLogger(Bank.class.getPackage().getName()); --- 40,43 ---- *************** *** 119,129 **** /** - * @param percentage of a company allowed to be in the Bank pool. - */ - public void setPoolShareLimit(int percentage) { - poolShareLimit = percentage; - } - - /** * @return IPO Portfolio */ --- 116,119 ---- *************** *** 203,215 **** } - /** - * Get the maximum share percentage that may be sold to the Bank Pool. - * - * @return The maximum percentage. - */ - public int getPoolShareLimit() { - return poolShareLimit; - } - public static String format(int amount) { // Replace @ with the amount --- 193,196 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** GameManager.java 14 Jan 2010 21:02:39 -0000 1.75 --- GameManager.java 15 Jan 2010 19:55:59 -0000 1.76 *************** *** 67,72 **** new HashMap<String, Portfolio> (); - protected int playerShareLimit = 60; - protected int treasuryShareLimit = 50; // For some games protected IntegerState playerCertificateLimit = new IntegerState ("PlayerCertificateLimit", 0); --- 67,70 ---- *************** *** 110,115 **** new EnumMap<GuiDef.Parm, Boolean>(GuiDef.Parm.class); - //protected int stockRoundSequenceRule = StockRound.SELL_BUY_SELL; - /** * Map of GameManager instances. --- 108,111 ---- *************** *** 128,135 **** * This is possible,because the server processes all player actions * in one thread. The key will be set in process(), which is where server ! * processing currently starts (in the furtire it will probably be moved ! * to the then needed communication interface). The key ! * can be retrieved (via NDC.peek()) anywhere. ! * <p>For now, the key is a fixed string, but that may change in the future. */ protected static Map<String, GameManagerI> gameManagerMap --- 124,132 ---- * This is possible,because the server processes all player actions * in one thread. The key will be set in process(), which is where server ! * processing currently starts (in the future it will probably be moved ! * to the communication interface that will be added by then). ! * The key can be retrieved (via NDC.peek()) anywhere. ! * <p> ! * For now, the key is a fixed string, but that may change in the future. */ protected static Map<String, GameManagerI> gameManagerMap *************** *** 161,165 **** protected String gmName; ! protected String key; protected StartPacket startPacket; --- 158,162 ---- protected String gmName; ! protected String gmKey; protected StartPacket startPacket; *************** *** 180,186 **** --- 177,185 ---- /* Some standard tags for conditional attributes */ public static final String VARIANT_KEY = "Variant"; + /* No longer used (temporarily?) public static final String OPTION_TAG = "GameOption"; public static final String IF_OPTION_TAG = "IfOption"; public static final String ATTRIBUTES_TAG = "Attributes"; + */ protected static Logger log = *************** *** 193,197 **** public GameManager() { gmName = GM_NAME; ! key = GM_KEY; NDC.clear(); NDC.push (GM_KEY); --- 192,196 ---- public GameManager() { gmName = GM_NAME; ! gmKey = GM_KEY; NDC.clear(); NDC.push (GM_KEY); *************** *** 212,216 **** --- 211,220 ---- throw new ConfigurationException("No name specified in Game tag"); + gameOptions = tag.getGameOptions(); + + initGameParameters(); + // Get any available game options + /* THIS IS NOT CURRENTLY USED, but I leave it in for another while (EV) GameOption option; String optionName, optionType, optionValues, optionDefault; *************** *** 238,317 **** } } ! // StockRound class and other properties ! // Set default rule(s) ! gameParameters.put(GameDef.Parm.STOCK_ROUND_SEQUENCE, ! GameDef.Parm.STOCK_ROUND_SEQUENCE.defaultValueAsInt()); - Tag srTag = tag.getChild("StockRound"); - if (srTag != null) { - String srClassName = - srTag.getAttributeAsString("class", "rails.game.StockRound"); - try { - stockRoundClass = - Class.forName(srClassName).asSubclass(StockRound.class); - } catch (ClassNotFoundException e) { - throw new ConfigurationException("Cannot find class " - + srClassName, e); - } - String stockRoundSequenceRuleString = - srTag.getAttributeAsString("sequence"); - if (Util.hasValue(stockRoundSequenceRuleString)) { - if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuySell")) { - //stockRoundSequenceRule = StockRound.SELL_BUY_SELL; - gameParameters.put(GameDef.Parm.STOCK_ROUND_SEQUENCE, - StockRound.SELL_BUY_SELL); - } else if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuy")) { - //stockRoundSequenceRule = StockRound.SELL_BUY; - gameParameters.put(GameDef.Parm.STOCK_ROUND_SEQUENCE, - StockRound.SELL_BUY); - } else if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuyOrBuySell")) { - //stockRoundSequenceRule = StockRound.SELL_BUY_OR_BUY_SELL; - gameParameters.put(GameDef.Parm.STOCK_ROUND_SEQUENCE, - StockRound.SELL_BUY_OR_BUY_SELL); - } - } ! skipFirstStockRound = ! srTag.getAttributeAsBoolean("skipFirst", ! skipFirstStockRound); ! } ! // OperatingRound class ! Tag orTag = tag.getChild("OperatingRound"); ! if (orTag != null) { ! String orClassName = ! orTag.getAttributeAsString("class", ! "rails.game.OperatingRound"); ! try { ! operatingRoundClass = ! Class.forName(orClassName).asSubclass( ! OperatingRound.class); ! } catch (ClassNotFoundException e) { ! throw new ConfigurationException("Cannot find class " ! + orClassName, e); ! } ! } ! /* Max. % of shares of one company that a player may hold */ ! Tag shareLimitTag = tag.getChild("PlayerShareLimit"); ! if (shareLimitTag != null) { ! playerShareLimit = shareLimitTag.getAttributeAsInteger("percentage", playerShareLimit); ! } ! /* Max. % of shares of one company that the bank pool may hold */ ! Tag poolLimitTag = tag.getChild("BankPoolShareLimit"); ! if (poolLimitTag != null) { ! bank.setPoolShareLimit(poolLimitTag.getAttributeAsInteger("percentage")); ! } ! /* Max. % of own shares that a company treasury may hold */ ! Tag treasuryLimitTag = tag.getChild("TreasuryShareLimit"); ! if (treasuryLimitTag != null) { ! treasuryShareLimit = ! treasuryLimitTag.getAttributeAsInteger("percentage", ! treasuryShareLimit); } /* End of rails.game criteria */ Tag endOfGameTag = tag.getChild("EndOfGame"); --- 242,325 ---- } } + */ ! Tag gameParmTag = tag.getChild("GameParameters"); ! if (gameParmTag != null) { ! // StockRound class and other properties ! Tag srTag = gameParmTag.getChild("StockRound"); ! if (srTag != null) { ! String srClassName = ! srTag.getAttributeAsString("class", "rails.game.StockRound"); ! try { ! stockRoundClass = ! Class.forName(srClassName).asSubclass(StockRound.class); ! } catch (ClassNotFoundException e) { ! throw new ConfigurationException("Cannot find class " ! + srClassName, e); ! } ! String stockRoundSequenceRuleString = ! srTag.getAttributeAsString("sequence"); ! if (Util.hasValue(stockRoundSequenceRuleString)) { ! if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuySell")) { ! setGameParameter(GameDef.Parm.STOCK_ROUND_SEQUENCE, ! StockRound.SELL_BUY_SELL); ! } else if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuy")) { ! setGameParameter(GameDef.Parm.STOCK_ROUND_SEQUENCE, ! StockRound.SELL_BUY); ! } else if (stockRoundSequenceRuleString.equalsIgnoreCase("SellBuyOrBuySell")) { ! setGameParameter(GameDef.Parm.STOCK_ROUND_SEQUENCE, ! StockRound.SELL_BUY_OR_BUY_SELL); ! } ! } ! skipFirstStockRound = ! srTag.getAttributeAsBoolean("skipFirst", ! skipFirstStockRound); ! } ! // OperatingRound class ! Tag orTag = gameParmTag.getChild("OperatingRound"); ! if (orTag != null) { ! String orClassName = ! orTag.getAttributeAsString("class", ! "rails.game.OperatingRound"); ! try { ! operatingRoundClass = ! Class.forName(orClassName).asSubclass( ! OperatingRound.class); ! } catch (ClassNotFoundException e) { ! throw new ConfigurationException("Cannot find class " ! + orClassName, e); ! } ! } ! /* Max. % of shares of one company that a player may hold */ ! Tag shareLimitTag = gameParmTag.getChild("PlayerShareLimit"); ! if (shareLimitTag != null) { ! setGameParameter (GameDef.Parm.PLAYER_SHARE_LIMIT, ! shareLimitTag.getAttributeAsInteger("percentage", ! GameDef.Parm.PLAYER_SHARE_LIMIT.defaultValueAsInt())); ! } ! /* Max. % of shares of one company that the bank pool may hold */ ! Tag poolLimitTag = gameParmTag.getChild("BankPoolShareLimit"); ! if (poolLimitTag != null) { ! setGameParameter (GameDef.Parm.POOL_SHARE_LIMIT, ! shareLimitTag.getAttributeAsInteger("percentage", ! GameDef.Parm.POOL_SHARE_LIMIT.defaultValueAsInt())); ! } ! ! /* Max. % of own shares that a company treasury may hold */ ! Tag treasuryLimitTag = gameParmTag.getChild("TreasuryShareLimit"); ! if (treasuryLimitTag != null) { ! setGameParameter (GameDef.Parm.TREASURY_SHARE_LIMIT, ! shareLimitTag.getAttributeAsInteger("percentage", ! GameDef.Parm.TREASURY_SHARE_LIMIT.defaultValueAsInt())); ! } } + /* End of rails.game criteria */ Tag endOfGameTag = tag.getChild("EndOfGame"); *************** *** 334,382 **** } ! // GameUIManager class ! Tag gameUIMgrTag = tag.getChild("GameUIManager"); ! if (gameUIMgrTag != null) { ! gameUIManagerClassName = ! gameUIMgrTag.getAttributeAsString("class", gameUIManagerClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (gameUIManagerClassName); ! } ! // ORUIManager class ! Tag orMgrTag = tag.getChild("ORUIManager"); ! if (orMgrTag != null) { ! orUIManagerClassName = ! orMgrTag.getAttributeAsString("class", orUIManagerClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (orUIManagerClassName); ! } ! // GameStatus class ! Tag gameStatusTag = tag.getChild("GameStatus"); ! if (gameStatusTag != null) { ! gameStatusClassName = ! gameStatusTag.getAttributeAsString("class", gameStatusClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (gameStatusClassName); ! } ! // StatusWindow class ! Tag statusWindowTag = tag.getChild("StatusWindow"); ! if (statusWindowTag != null) { ! statusWindowClassName = ! statusWindowTag.getAttributeAsString("class", ! statusWindowClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (statusWindowClassName); ! } ! // ORWindow class ! Tag orWindowTag = tag.getChild("ORWindow"); ! if (orWindowTag != null) { ! orWindowClassName = ! orWindowTag.getAttributeAsString("class", ! orWindowClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (orWindowClassName); } } --- 342,394 ---- } ! Tag guiClassesTag = tag.getChild("GuiClasses"); ! if (guiClassesTag != null) { ! // GameUIManager class ! Tag gameUIMgrTag = guiClassesTag.getChild("GameUIManager"); ! if (gameUIMgrTag != null) { ! gameUIManagerClassName = ! gameUIMgrTag.getAttributeAsString("class", gameUIManagerClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (gameUIManagerClassName); ! } ! // ORUIManager class ! Tag orMgrTag = guiClassesTag.getChild("ORUIManager"); ! if (orMgrTag != null) { ! orUIManagerClassName = ! orMgrTag.getAttributeAsString("class", orUIManagerClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (orUIManagerClassName); ! } ! // GameStatus class ! Tag gameStatusTag = guiClassesTag.getChild("GameStatus"); ! if (gameStatusTag != null) { ! gameStatusClassName = ! gameStatusTag.getAttributeAsString("class", gameStatusClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (gameStatusClassName); ! } ! // StatusWindow class ! Tag statusWindowTag = guiClassesTag.getChild("StatusWindow"); ! if (statusWindowTag != null) { ! statusWindowClassName = ! statusWindowTag.getAttributeAsString("class", ! statusWindowClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (statusWindowClassName); ! } ! ! // ORWindow class ! Tag orWindowTag = guiClassesTag.getChild("ORWindow"); ! if (orWindowTag != null) { ! orWindowClassName = ! orWindowTag.getAttributeAsString("class", ! orWindowClassName); ! // Check instantiatability (not sure if this belongs here) ! canClassBeInstantiated (orWindowClassName); ! } } } *************** *** 434,438 **** this.gameOptions = gameOptions; ! setGameParameters(); if (startPacket == null) --- 446,450 ---- this.gameOptions = gameOptions; ! setGuiParameters(); if (startPacket == null) *************** *** 451,455 **** } ! private void setGameParameters () { for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { --- 463,467 ---- } ! private void setGuiParameters () { for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { *************** *** 472,475 **** --- 484,494 ---- } + private void initGameParameters() { + + for (GameDef.Parm parm : GameDef.Parm.values()) { + gameParameters.put(parm, parm.defaultValue()); + } + } + /** * @return instance of GameManager *************** *** 1018,1025 **** } - public int getPlayerShareLimit() { - return playerShareLimit; - } - /* (non-Javadoc) * @see rails.game.GameManagerI#getAllPublicCompanies() --- 1037,1040 ---- *************** *** 1158,1175 **** /* (non-Javadoc) - * @see rails.game.GameManagerI#getStockRoundSequenceRule() - */ - public int getStockRoundSequenceRule() { - return (Integer) gameParameters.get(GameDef.Parm.STOCK_ROUND_SEQUENCE); - } - - /* (non-Javadoc) - * @see rails.game.GameManagerI#getTreasuryShareLimit() - */ - public int getTreasuryShareLimit() { - return treasuryShareLimit; - } - - /* (non-Javadoc) * @see rails.game.GameManagerI#getCommonParameter(rails.common.Defs.Parm) */ --- 1173,1176 ---- *************** *** 1280,1285 **** } ! public String getKey () { ! return key; } --- 1281,1286 ---- } ! public String getGMKey () { ! return gmKey; } Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Round.java 14 Jan 2010 21:00:30 -0000 1.34 --- Round.java 15 Jan 2010 19:55:59 -0000 1.35 *************** *** 401,404 **** --- 401,424 ---- } + protected Object getGameParameter (GameDef.Parm key) { + return gameManager.getGameParameter(key); + } + + public int getGameParameterAsInt (GameDef.Parm key) { + if (key.defaultValue() instanceof Integer) { + return (Integer) gameManager.getGameParameter(key); + } else { + return -1; + } + } + + public boolean getGameParameterAsBoolean (GameDef.Parm key) { + if (key.defaultValue() instanceof Boolean) { + return (Boolean) gameManager.getGameParameter(key); + } else { + return false; + } + } + public String getRoundName() { return this.getClass().getSimpleName(); Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Game.java 14 Jan 2010 21:03:47 -0000 1.44 --- Game.java 15 Jan 2010 19:55:59 -0000 1.45 *************** *** 73,77 **** try { - // Have the ComponentManager work through the other rails.game files componentManagerTag = Tag.findTopTagInFile(GAME_XML_FILE, directories, --- 73,76 ---- *************** *** 82,88 **** } ! ComponentManager.configureInstance(name, componentManagerTag, gameOptions); ! ! componentManager = ComponentManager.getInstance(); log.info("========== Start of rails.game " + name + " =========="); --- 81,87 ---- } ! componentManagerTag.setGameOptions(gameOptions); ! componentManager = ! ComponentManager.configureInstance(name, componentManagerTag, gameOptions); log.info("========== Start of rails.game " + name + " =========="); Index: GameOption.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameOption.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GameOption.java 23 Nov 2009 18:32:45 -0000 1.8 --- GameOption.java 15 Jan 2010 19:55:59 -0000 1.9 *************** *** 21,25 **** public static final String OPTION_VALUE_NO = "no"; ! public static final String NUMBER_OF_PLAYERS = "numberOfPlayers"; public GameOption(String name) { --- 21,26 ---- public static final String OPTION_VALUE_NO = "no"; ! // A default option that will always be set ! public static final String NUMBER_OF_PLAYERS = "NumberOfPlayers"; public GameOption(String name) { Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ShareSellingRound.java 14 Jan 2010 20:59:19 -0000 1.27 --- ShareSellingRound.java 15 Jan 2010 19:55:59 -0000 1.28 *************** *** 118,122 **** /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, bank.getPoolShareLimit() - pool.getShare(company)); if (maxShareToSell == 0) continue; --- 118,123 ---- /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, ! getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT) - pool.getShare(company)); if (maxShareToSell == 0) continue; *************** *** 238,242 **** // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() > bank.getPoolShareLimit()) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; --- 239,244 ---- // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() ! > getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** OperatingRound.java 14 Jan 2010 22:10:47 -0000 1.89 --- OperatingRound.java 15 Jan 2010 19:55:59 -0000 1.90 *************** *** 2198,2202 **** if (train.isObsolete()) continue; if (i != currentPlayerIndex ! && trainMgr.buyAtFaceValueBetweenDifferentPresidents() || operatingCompany.mustTradeTrainsAtFixedPrice() || company.mustTradeTrainsAtFixedPrice()) { --- 2198,2203 ---- if (train.isObsolete()) continue; if (i != currentPlayerIndex ! //&& trainMgr.buyAtFaceValueBetweenDifferentPresidents() ! && getGameParameterAsBoolean(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS) || operatingCompany.mustTradeTrainsAtFixedPrice() || company.mustTradeTrainsAtFixedPrice()) { Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** StockRound.java 14 Jan 2010 20:58:39 -0000 1.54 --- StockRound.java 15 Jan 2010 19:55:59 -0000 1.55 *************** *** 67,71 **** numberOfPlayers = gameManager.getPlayers().size(); ! sequenceRule = gameManager.getStockRoundSequenceRule(); guiHints.setVisibilityHint(GuiDef.Panel.MAP, true); --- 67,71 ---- numberOfPlayers = gameManager.getPlayers().size(); ! sequenceRule = getGameParameterAsInt(GameDef.Parm.STOCK_ROUND_SEQUENCE); guiHints.setVisibilityHint(GuiDef.Panel.MAP, true); *************** *** 299,303 **** /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, bank.getPoolShareLimit() - pool.getShare(company)); if (maxShareToSell == 0) continue; --- 299,304 ---- /* May not sell more than the Pool can accept */ maxShareToSell = ! Math.min(maxShareToSell, ! getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT) - pool.getShare(company)); if (maxShareToSell == 0) continue; *************** *** 872,876 **** // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() > bank.getPoolShareLimit()) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; --- 873,878 ---- // The pool may not get over its limit. ! if (pool.getShare(company) + numberToSell * company.getShareUnit() ! > getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)) { errMsg = LocalText.getText("PoolOverHoldLimit"); break; *************** *** 1074,1078 **** errMsg = LocalText.getText("WouldExceedHoldLimit", ! String.valueOf(gameManager.getPlayerShareLimit())); break; } --- 1076,1080 ---- errMsg = LocalText.getText("WouldExceedHoldLimit", ! String.valueOf(getGameParameterAsInt(GameDef.Parm.PLAYER_SHARE_LIMIT))); break; } *************** *** 1285,1289 **** if (player.getPortfolio().getShare(company) + number * company.getShareUnit() ! > gameManager.getPlayerShareLimit() && !company.getCurrentSpace().isNoHoldLimit()) return false; return true; --- 1287,1292 ---- if (player.getPortfolio().getShare(company) + number * company.getShareUnit() ! //> gameManager.getPlayerShareLimit() ! > getGameParameterAsInt(GameDef.Parm.PLAYER_SHARE_LIMIT) && !company.getCurrentSpace().isNoHoldLimit()) return false; return true; *************** *** 1307,1316 **** int limit; if (!company.hasStarted()) { ! limit = gameManager.getPlayerShareLimit(); } else { limit = company.getCurrentSpace().isNoHoldLimit() ? 100 ! : gameManager.getPlayerShareLimit(); } return (limit - player.getPortfolio().getShare(company)) / shareSize; --- 1310,1320 ---- int limit; + int playerShareLimit = getGameParameterAsInt (GameDef.Parm.PLAYER_SHARE_LIMIT); if (!company.hasStarted()) { ! limit = playerShareLimit; } else { limit = company.getCurrentSpace().isNoHoldLimit() ? 100 ! : playerShareLimit; } return (limit - player.getPortfolio().getShare(company)) / shareSize; Index: GameDef.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameDef.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GameDef.java 14 Jan 2010 21:03:19 -0000 1.1 --- GameDef.java 15 Jan 2010 19:55:59 -0000 1.2 *************** *** 13,17 **** NO_SALE_IN_FIRST_SR (false), NO_SALE_IF_NOT_OPERATED (false), ! STOCK_ROUND_SEQUENCE(StockRound.SELL_BUY_SELL); private Object defaultValue; --- 13,22 ---- NO_SALE_IN_FIRST_SR (false), NO_SALE_IF_NOT_OPERATED (false), ! STOCK_ROUND_SEQUENCE(StockRound.SELL_BUY_SELL), ! PLAYER_SHARE_LIMIT (60), ! POOL_SHARE_LIMIT(50), ! TREASURY_SHARE_LIMIT(50), ! FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS(false), ! SKIP_FIRST_STOCK_ROUND(false); private Object defaultValue; *************** *** 20,23 **** --- 25,29 ---- Parm (int defaultValue) { this.defaultValue = defaultValue; } + public Object defaultValue() { return defaultValue; } public boolean defaultValueAsBoolean() { return (Boolean) defaultValue; } public int defaultValueAsInt() { return (Integer) defaultValue; } Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ComponentManager.java 31 Oct 2009 17:08:27 -0000 1.15 --- ComponentManager.java 15 Jan 2010 19:55:59 -0000 1.16 *************** *** 17,21 **** public class ComponentManager { ! private static String gameName; /** The name of the XML tag used to configu... [truncated message content] |