You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: Erik V. <ev...@us...> - 2009-11-05 22:50:47
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv17929 Modified Files: games.properties .project Added Files: build.xml Log Message: Fixed some bugs: - 1830: free D&H token wasn't free - 18EU: only one 8-train buyable Also added Rails version and date in saved files and reportng in the log of same. Bulld date included in BuildInfo, which is rewritten on each build via a new build.xml Ant script. Index: .project =================================================================== RCS file: /cvsroot/rails/18xx/.project,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** .project 11 Aug 2005 13:36:52 -0000 1.4 --- .project 5 Nov 2009 22:50:38 -0000 1.5 *************** *** 1,5 **** <?xml version="1.0" encoding="UTF-8"?> <projectDescription> ! <name>18xx</name> <comment></comment> <projects> --- 1,5 ---- <?xml version="1.0" encoding="UTF-8"?> <projectDescription> ! <name>Rails</name> <comment></comment> <projects> *************** *** 7,10 **** --- 7,20 ---- <buildSpec> <buildCommand> + <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + <dictionary> + <key>LaunchConfigHandle</key> + <value><project>/.externalToolBuilders/Create BuildInfo.launch</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> Index: games.properties =================================================================== RCS file: /cvsroot/rails/18xx/games.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** games.properties 3 Aug 2007 21:08:19 -0000 1.3 --- games.properties 5 Nov 2009 22:50:37 -0000 1.4 *************** *** 20,29 **** game.1835.description=All companies buyable from the start. Prussian formation is not supported yet. ### 1856 ! game.1856.note=(partly playable) ! game.1856.description=Aspects not present in 1830 have not been implemented yet. ### 1870 game.1870.note=(partly playable) game.1870.description=Aspects not present in 1830 have not been implemented yet. ### 18AL ! game.18AL.note=(partly playable) ! game.18AL.description=Aspects not present in 1830 have not been implemented yet. --- 20,29 ---- game.1835.description=All companies buyable from the start. Prussian formation is not supported yet. ### 1856 ! game.1856.note=(fully playable) ### 1870 game.1870.note=(partly playable) game.1870.description=Aspects not present in 1830 have not been implemented yet. ### 18AL ! game.18AL.note=(fully playable) ! ### 18EU ! game.18EU.note=(fully playable) --- NEW FILE: build.xml --- <!-- Generate a java class with the current svn revision number --> <project name="build" default="makeBuildInfo" basedir="."> <target name="makeBuildInfo" description="Create a BuildInfo source"> <tstamp> <format property="TODAY" pattern="yyyy/MM/dd"/> </tstamp> <!-- the source code of the java class --> <echo file="${basedir}/rails/game/BuildInfo.java"> package rails.game; public class BuildInfo { public static final String timeStamp="${TODAY}"; } </echo> </target> </project> |
From: Erik V. <ev...@us...> - 2009-11-05 22:50:47
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv17929/rails/ui/swing Modified Files: ORUIManager.java UpgradesPanel.java Log Message: Fixed some bugs: - 1830: free D&H token wasn't free - 18EU: only one 8-train buyable Also added Rails version and date in saved files and reportng in the log of same. Bulld date included in BuildInfo, which is rewritten on each build via a new build.xml Ant script. Index: UpgradesPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/UpgradesPanel.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** UpgradesPanel.java 30 Oct 2009 21:53:04 -0000 1.18 --- UpgradesPanel.java 5 Nov 2009 22:50:38 -0000 1.19 *************** *** 119,122 **** --- 119,125 ---- bgColour = comp.getBgColour(); description = text = comp.getName(); + if (action.getSpecialProperty() != null) { + description += " (" + action.getSpecialProperty().getCompany().getName()+")"; + } } else if (action instanceof LayBonusToken) { fgColour = Color.BLACK; Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ORUIManager.java 2 Nov 2009 23:30:35 -0000 1.31 --- ORUIManager.java 5 Nov 2009 22:50:38 -0000 1.32 *************** *** 594,606 **** } ! public void layBaseToken() { GUIHex selectedHex = map.getSelectedHex(); if (selectedHex != null) { ! List<LayBaseToken> allowances = map.getBaseTokenAllowanceForHex(selectedHex.getHexModel()); ! // Pick the first one (unknown if we will ever need more than one) ! LayBaseToken allowance = allowances.get(0); int station; List<City> stations = selectedHex.getHexModel().getCities(); --- 594,611 ---- } ! public void layBaseToken(LayBaseToken action) { GUIHex selectedHex = map.getSelectedHex(); + LayBaseToken allowance; if (selectedHex != null) { ! if (action != null) { ! allowance = action; ! } else { ! List<LayBaseToken> allowances = map.getBaseTokenAllowanceForHex(selectedHex.getHexModel()); ! // Pick the first one (unknown if we will ever need more than one) ! allowance = allowances.get(0); ! } int station; List<City> stations = selectedHex.getHexModel().getCities(); *************** *** 978,982 **** public void executeUpgrade() { GUIHex selectedHex = map.getSelectedHex(); - if (tileLayingEnabled) { if (selectedHex == null) { --- 983,986 ---- *************** *** 993,997 **** orWindow.displayORUIMessage(LocalText.getText("SelectAToken")); } else if (selectedTokenAllowance instanceof LayBaseToken) { ! layBaseToken(); } else { layBonusToken(selectedTokenAllowance); --- 997,1001 ---- orWindow.displayORUIMessage(LocalText.getText("SelectAToken")); } else if (selectedTokenAllowance instanceof LayBaseToken) { ! layBaseToken((LayBaseToken)selectedTokenAllowance); } else { layBonusToken(selectedTokenAllowance); |
From: Erik V. <ev...@us...> - 2009-11-04 21:57:56
|
Update of /cvsroot/rails/18xx/data In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27502/data Modified Files: GamesList.xml Log Message: 1856 marked "Fully playable" Index: GamesList.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/GamesList.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GamesList.xml 23 Sep 2009 21:38:57 -0000 1.12 --- GamesList.xml 4 Nov 2009 21:57:48 -0000 1.13 *************** *** 51,61 **** </Game> <Game name="1856"> ! <Note>Almost playable</Note> <Description>1856 - Railroading in Upper Canada (c) 1992, 1995 Mayfair Games, Inc. Designed by Bill Dixon - - Current limitation: - - No Bridge and Tunnel bonuses. </Description> <Players minimum="3" maximum="6"/> --- 51,58 ---- </Game> <Game name="1856"> ! <Note>Fully playable</Note> <Description>1856 - Railroading in Upper Canada (c) 1992, 1995 Mayfair Games, Inc. Designed by Bill Dixon </Description> <Players minimum="3" maximum="6"/> |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:41
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/game/action Modified Files: StartCompany.java DiscardTrain.java BuyTrain.java BuyBonusToken.java BuyCertificate.java Log Message: More rationalising of static method usage Index: BuyBonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/BuyBonusToken.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BuyBonusToken.java 29 Oct 2009 19:41:30 -0000 1.2 --- BuyBonusToken.java 4 Nov 2009 20:33:21 -0000 1.3 *************** *** 9,13 **** import java.io.ObjectInputStream; ! import rails.game.*; import rails.game.special.SellBonusToken; import rails.game.special.SpecialProperty; --- 9,14 ---- import java.io.ObjectInputStream; ! import rails.game.CashHolder; ! import rails.game.PrivateCompanyI; import rails.game.special.SellBonusToken; import rails.game.special.SpecialProperty; *************** *** 118,122 **** getCompanyManager().getPrivateCompany(privateCompanyName); if (sellerName.equalsIgnoreCase("Bank")) { ! seller = Bank.getInstance(); } else if (sellerName != null) { seller = --- 119,123 ---- getCompanyManager().getPrivateCompany(privateCompanyName); if (sellerName.equalsIgnoreCase("Bank")) { ! seller = gameManager.getBank(); } else if (sellerName != null) { seller = Index: BuyTrain.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/BuyTrain.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BuyTrain.java 4 Jun 2008 19:00:29 -0000 1.10 --- BuyTrain.java 4 Nov 2009 20:33:21 -0000 1.11 *************** *** 222,232 **** in.defaultReadObject(); ! train = Train.getByUniqueId(trainUniqueId); ! from = Portfolio.getByName(fromName); if (trainsForExchangeUniqueIds != null && trainsForExchangeUniqueIds.length > 0) { trainsForExchange = new ArrayList<TrainI>(); for (int i = 0; i < trainsForExchangeUniqueIds.length; i++) { ! trainsForExchange.add(Train.getByUniqueId(trainsForExchangeUniqueIds[i])); } } --- 222,235 ---- in.defaultReadObject(); ! GameManagerI gameManager = GameManager.getInstance(); ! TrainManager trainManager = gameManager.getTrainManager(); ! ! train = trainManager.getTrainByUniqueId(trainUniqueId); ! from = gameManager.getPortfolioByName(fromName); if (trainsForExchangeUniqueIds != null && trainsForExchangeUniqueIds.length > 0) { trainsForExchange = new ArrayList<TrainI>(); for (int i = 0; i < trainsForExchangeUniqueIds.length; i++) { ! trainsForExchange.add(trainManager.getTrainByUniqueId(trainsForExchangeUniqueIds[i])); } } *************** *** 238,242 **** if (Util.hasValue(exchangedTrainUniqueId)) { ! exchangedTrain = Train.getByUniqueId(exchangedTrainUniqueId); } } --- 241,245 ---- if (Util.hasValue(exchangedTrainUniqueId)) { ! exchangedTrain = trainManager.getTrainByUniqueId(exchangedTrainUniqueId); } } Index: BuyCertificate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/BuyCertificate.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** BuyCertificate.java 2 Nov 2008 19:52:48 -0000 1.11 --- BuyCertificate.java 4 Nov 2009 20:33:22 -0000 1.12 *************** *** 9,16 **** import java.io.ObjectInputStream; ! import rails.game.Bank; ! import rails.game.Portfolio; ! import rails.game.PublicCertificate; ! import rails.game.PublicCertificateI; /** --- 9,13 ---- import java.io.ObjectInputStream; ! import rails.game.*; /** *************** *** 125,130 **** in.defaultReadObject(); certificate = PublicCertificate.getByUniqueId(certUniqueId); ! from = Portfolio.getByName(fromName); } --- 122,130 ---- in.defaultReadObject(); + + GameManagerI gameManager = GameManager.getInstance(); + certificate = PublicCertificate.getByUniqueId(certUniqueId); ! from = gameManager.getPortfolioByName(fromName); } Index: StartCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/StartCompany.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StartCompany.java 25 Sep 2009 19:13:01 -0000 1.8 --- StartCompany.java 4 Nov 2009 20:33:21 -0000 1.9 *************** *** 1,6 **** package rails.game.action; ! import rails.game.Bank; ! import rails.game.PublicCertificateI; public class StartCompany extends BuyCertificate { --- 1,5 ---- package rails.game.action; ! import rails.game.*; public class StartCompany extends BuyCertificate { *************** *** 13,17 **** public StartCompany(PublicCertificateI certificate, int[] prices, int maximumNumber) { ! super(certificate, Bank.getInstance().getIpo(), 0, maximumNumber); this.startPrices = prices.clone(); } --- 12,16 ---- public StartCompany(PublicCertificateI certificate, int[] prices, int maximumNumber) { ! super(certificate, GameManager.getInstance().getBank().getIpo(), 0, maximumNumber); this.startPrices = prices.clone(); } *************** *** 23,27 **** public StartCompany(PublicCertificateI certificate, int price, int maximumNumber) { ! super(certificate, Bank.getInstance().getIpo(), 0, maximumNumber); this.price = price; } --- 22,26 ---- public StartCompany(PublicCertificateI certificate, int price, int maximumNumber) { ! super(certificate, GameManager.getInstance().getBank().getIpo(), 0, maximumNumber); this.price = price; } Index: DiscardTrain.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/DiscardTrain.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DiscardTrain.java 4 May 2009 20:29:15 -0000 1.9 --- DiscardTrain.java 4 Nov 2009 20:33:21 -0000 1.10 *************** *** 95,100 **** in.defaultReadObject(); if (discardedTrainUniqueId != null) { ! discardedTrain = Train.getByUniqueId(discardedTrainUniqueId); } --- 95,102 ---- in.defaultReadObject(); + TrainManager trainManager = GameManager.getInstance().getTrainManager(); + if (discardedTrainUniqueId != null) { ! discardedTrain = trainManager.getTrainByUniqueId(discardedTrainUniqueId); } *************** *** 102,106 **** ownedTrains = new ArrayList<TrainI>(); for (int i = 0; i < ownedTrainsUniqueIds.length; i++) { ! ownedTrains.add(Train.getByUniqueId(ownedTrainsUniqueIds[i])); } } --- 104,108 ---- ownedTrains = new ArrayList<TrainI>(); for (int i = 0; i < ownedTrainsUniqueIds.length; i++) { ! ownedTrains.add(trainManager.getTrainByUniqueId(ownedTrainsUniqueIds[i])); } } |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:37
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/ui/swing/hexmap Modified Files: GUITile.java Log Message: More rationalising of static method usage Index: GUITile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUITile.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GUITile.java 2 Nov 2009 23:30:36 -0000 1.17 --- GUITile.java 4 Nov 2009 20:33:22 -0000 1.18 *************** *** 30,36 **** protected double tileScale = GUIHex.NORMAL_SCALE; ! protected static double baseRotation; ! ! protected static boolean initialised = false; protected MapHex hex = null; --- 30,34 ---- protected double tileScale = GUIHex.NORMAL_SCALE; ! protected double baseRotation; protected MapHex hex = null; *************** *** 48,58 **** this.tileId = tileId; this.hex = hex; ! tile = TileManager.get().getTile(tileId); tileImage = imageLoader.getTile(tileId); - if (!initialised) initialise(); - } - - private void initialise() { if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; --- 46,52 ---- this.tileId = tileId; this.hex = hex; ! tile = GameManager.getInstance().getTileManager().getTile(tileId); tileImage = imageLoader.getTile(tileId); if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; *************** *** 60,64 **** baseRotation = 0.0; } - initialised = true; } --- 54,57 ---- |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:33
|
Update of /cvsroot/rails/18xx/rails/game/model In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/game/model Modified Files: TrainsModel.java Log Message: More rationalising of static method usage Index: TrainsModel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/model/TrainsModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TrainsModel.java 4 Jun 2008 19:00:37 -0000 1.6 --- TrainsModel.java 4 Nov 2009 20:33:22 -0000 1.7 *************** *** 3,7 **** import rails.game.Portfolio; - import rails.game.TrainManager; public class TrainsModel extends ModelObject { --- 3,6 ---- *************** *** 16,24 **** } ! public String getText() { if (option == FULL_LIST) { ! return TrainManager.makeFullList(portfolio); } else if (option == ABBR_LIST) { ! return TrainManager.makeAbbreviatedList(portfolio); } else { return ""; --- 15,24 ---- } ! @Override ! public String getText() { if (option == FULL_LIST) { ! return portfolio.makeFullListOfTrains(); } else if (option == ABBR_LIST) { ! return portfolio.makeAbbreviatedListOfTrains(); } else { return ""; |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:32
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/game Modified Files: Portfolio.java BonusToken.java Bank.java GameManagerI.java TileManager.java TrainType.java PrivateCompany.java Train.java Company.java TrainManager.java TrainTypeI.java GameManager.java Log Message: More rationalising of static method usage Index: TrainTypeI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainTypeI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TrainTypeI.java 10 Oct 2009 15:25:49 -0000 1.10 --- TrainTypeI.java 4 Nov 2009 20:33:22 -0000 1.11 *************** *** 2,6 **** package rails.game; ! public interface TrainTypeI extends ConfigurableComponentI, Cloneable { --- 2,6 ---- package rails.game; ! public interface TrainTypeI extends ConfigurableComponentI, Cloneable { *************** *** 95,110 **** public String getRustedTrainTypeName(); ! public boolean isPermanent(); ! public void setPermanent(boolean permanent); ! public void setReleasedTrainType(TrainTypeI releasedTrainType); public void setRustedTrainType(TrainTypeI rustedTrainType); ! public TrainI cloneTrain(); ! public int getIndex(); } --- 95,111 ---- public String getRustedTrainTypeName(); ! public boolean isPermanent(); ! public void setPermanent(boolean permanent); ! public void setReleasedTrainType(TrainTypeI releasedTrainType); public void setRustedTrainType(TrainTypeI rustedTrainType); ! public TrainI cloneTrain(); ! public int getIndex(); + public TrainManager getTrainManager(); } Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Portfolio.java 31 Oct 2009 17:08:26 -0000 1.38 --- Portfolio.java 4 Nov 2009 20:33:22 -0000 1.39 *************** *** 73,79 **** protected String name; ! /** A map allowing finding portfolios by name, for use in deserialization */ ! protected static Map<String, Portfolio> portfolioMap = ! new HashMap<String, Portfolio>(); protected static Logger log = --- 73,81 ---- protected String name; ! /** Specific portfolio names */ ! public static final String IPO_NAME = "IPO"; ! public static final String POOL_NAME = "Pool"; ! public static final String SCRAPHEAP_NAME = "ScrapHeap"; ! public static final String UNAVAILABLE_NAME = "Unavailable"; protected static Logger log = *************** *** 83,87 **** this.name = name; this.owner = holder; ! portfolioMap.put(name, this); if (owner instanceof PublicCompanyI) { --- 85,90 ---- this.name = name; this.owner = holder; ! //portfolioMap.put(name, this); ! GameManager.getInstance().addPortfolio(this); if (owner instanceof PublicCompanyI) { *************** *** 95,102 **** } - public static Portfolio getByName(String name) { - return portfolioMap.get(name); - } - public void transferAssetsFrom(Portfolio otherPortfolio) { --- 98,101 ---- *************** *** 377,382 **** trains.add(train); TrainTypeI type = train.getType(); ! if (trainsPerType.get(type) == null) trainsPerType.put(type, new ArrayList<TrainI>()); trainsPerType.get(train.getType()).add(train); train.setHolder(this); --- 376,382 ---- trains.add(train); TrainTypeI type = train.getType(); ! if (!trainsPerType.containsKey(type)) { trainsPerType.put(type, new ArrayList<TrainI>()); + } trainsPerType.get(train.getType()).add(train); train.setHolder(this); *************** *** 398,402 **** public void discardTrain(TrainI train) { ! train.moveTo(Bank.getInstance().getPool()); ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", name, train.getName() )); --- 398,402 ---- public void discardTrain(TrainI train) { ! train.moveTo(GameManager.getInstance().getBank().getPool()); ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", name, train.getName() )); *************** *** 453,456 **** --- 453,514 ---- /** + * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the + * IPO. + * + * @param holder The Portfolio for which this list will be made (always + * IPO). + */ + + public String makeAbbreviatedListOfTrains() { + + if (trains == null || trains.isEmpty()) return ""; + + StringBuffer b = new StringBuffer(); + List<TrainI> trainsOfType; + + for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { + trainsOfType = trainsPerType.get(type); + if (trainsOfType != null && !trainsOfType.isEmpty()) { + if (b.length() > 0) b.append(" "); + b.append(type.getName()).append("("); + if (type.hasInfiniteAmount()) { + b.append("+"); + } else { + b.append(trainsOfType.size()); + } + b.append(")"); + } + } + + return b.toString(); + } + + /** + * Make a full list of trains, like "2 2 3 3", to show in any field + * describing train possessions, except the IPO. + * + * @param holder The Portfolio for which this list will be made. + */ + public String makeFullListOfTrains() { + + if (trains == null || trains.isEmpty()) return ""; + + List<TrainI> trainsOfType; + StringBuffer b = new StringBuffer(); + + for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { + trainsOfType = trainsPerType.get(type); + if (trainsOfType != null && !trainsOfType.isEmpty()) { + for (TrainI train : trainsOfType) { + if (b.length() > 0) b.append(" "); + b.append(train.getName()); + } + } + } + + return b.toString(); + } + + /** * Add a special property. Used to make special properties independent of * the private company that originally held it. Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TileManager.java 31 Oct 2009 17:08:26 -0000 1.12 --- TileManager.java 4 Nov 2009 20:33:22 -0000 1.13 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; 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() { instance = this; } public static TileManager get() { return instance; } /** * @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()); 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: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** TrainManager.java 31 Oct 2009 17:08:26 -0000 1.22 --- TrainManager.java 4 Nov 2009 20:33:22 -0000 1.23 *************** *** 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 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); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * 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 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>(); 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 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 Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PrivateCompany.java 31 Oct 2009 17:08:27 -0000 1.25 --- PrivateCompany.java 4 Nov 2009 20:33:22 -0000 1.26 *************** *** 104,110 **** } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! for (SpecialPropertyI sp : specialProperties) { sp.finishConfiguration(gameManager); --- 104,110 ---- } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! for (SpecialPropertyI sp : specialProperties) { sp.finishConfiguration(gameManager); *************** *** 180,184 **** super.setClosed(); unblockHexes(); ! moveTo(Bank.getInstance().getScrapHeap()); ReportBuffer.add(LocalText.getText("PrivateCloses", name)); --- 180,184 ---- super.setClosed(); unblockHexes(); ! moveTo(GameManager.getInstance().getBank().getScrapHeap()); ReportBuffer.add(LocalText.getText("PrivateCloses", name)); *************** *** 186,190 **** for (SpecialPropertyI sp : specialProperties) { if (sp instanceof SellBonusToken) { ! ((SellBonusToken)sp).setSeller(Bank.getInstance()); } } --- 186,190 ---- for (SpecialPropertyI sp : specialProperties) { if (sp instanceof SellBonusToken) { ! ((SellBonusToken)sp).setSeller(GameManager.getInstance().getBank()); } } Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Bank.java 31 Oct 2009 17:08:27 -0000 1.15 --- Bank.java 4 Nov 2009 20:33:22 -0000 1.16 *************** *** 46,56 **** Logger.getLogger(Bank.class.getPackage().getName()); - /** - * @return an instance of the Bank object - */ - public static Bank getInstance() { - return instance; - } - public Bank() { --- 46,49 ---- *************** *** 59,66 **** money = new CashModel(this); // Create the IPO and the Bank Pool. ! ipo = new Portfolio("IPO", this); ! pool = new Portfolio("Pool", this); ! unavailable = new Portfolio("Unavailable", this); ! scrapHeap = new Portfolio("ScrapHeap", this); String configFormat = Config.get("money_format"); --- 52,59 ---- money = new CashModel(this); // Create the IPO and the Bank Pool. ! ipo = new Portfolio(Portfolio.IPO_NAME, this); ! pool = new Portfolio(Portfolio.POOL_NAME, this); ! unavailable = new Portfolio(Portfolio.UNAVAILABLE_NAME, this); ! scrapHeap = new Portfolio(Portfolio.SCRAPHEAP_NAME, this); String configFormat = Config.get("money_format"); *************** *** 100,104 **** public void finishConfiguration (GameManagerI gameManager) { ! ReportBuffer.add(LocalText.getText("BankSizeIs", format(money.getCash()))); --- 93,97 ---- public void finishConfiguration (GameManagerI gameManager) { ! ReportBuffer.add(LocalText.getText("BankSizeIs", format(money.getCash()))); *************** *** 124,128 **** } } ! /** * @param percentage of a company allowed to be in the Bank pool. --- 117,121 ---- } } ! /** * @param percentage of a company allowed to be in the Bank pool. Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** GameManager.java 31 Oct 2009 17:08:26 -0000 1.65 --- GameManager.java 4 Nov 2009 20:33:22 -0000 1.66 *************** *** 61,64 **** --- 61,68 ---- protected State priorityPlayer = new State("PriorityPlayer", Player.class); + /** Map relating portfolio names and objects, to enable deserialization */ + protected Map<String, Portfolio> portfolioMap = + new HashMap<String, Portfolio> (); + protected int playerShareLimit = 60; protected int treasuryShareLimit = 50; // For some games *************** *** 993,996 **** --- 997,1008 ---- } + public void addPortfolio (Portfolio portfolio) { + portfolioMap.put(portfolio.getName(), portfolio); + } + + public Portfolio getPortfolioByName (String name) { + return portfolioMap.get(name); + } + /* (non-Javadoc) * @see rails.game.GameManagerI#getStartPacket() Index: Company.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Company.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Company.java 3 Dec 2008 20:15:15 -0000 1.9 --- Company.java 4 Nov 2009 20:33:22 -0000 1.10 *************** *** 10,14 **** Cloneable { - protected static int numberOfCompanies = 0; protected String name; protected String longName; --- 10,13 ---- *************** *** 34,38 **** public Company() { - this.companyNumber = numberOfCompanies++; } --- 33,36 ---- *************** *** 45,55 **** /** - * @return Number of Companies - */ - public static int getNumberOfCompanies() { - return numberOfCompanies; - } - - /** * @return This company's number */ --- 43,46 ---- Index: Train.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Train.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Train.java 10 Oct 2009 15:25:49 -0000 1.14 --- Train.java 4 Nov 2009 20:33:22 -0000 1.15 *************** *** 2,8 **** package rails.game; - import java.util.HashMap; - import java.util.Map; - import org.apache.log4j.Logger; --- 2,5 ---- *************** *** 23,35 **** protected String uniqueId; - protected static Map<String, TrainI> trainMap = - new HashMap<String, TrainI>(); protected Portfolio holder; protected BooleanState obsolete; - protected static final Portfolio unavailable = Bank.getInstance().getUnavailable(); - protected static final Portfolio ipo = Bank.getInstance().getIpo(); - protected static Logger log = Logger.getLogger(Train.class.getPackage().getName()); --- 20,27 ---- *************** *** 48,60 **** uniqueId = type.getName() + "_" + index; ! trainMap.put(uniqueId, this); obsolete = new BooleanState(uniqueId, false); } - public static TrainI getByUniqueId(String id) { - return trainMap.get(id); - } - public String getUniqueId() { return uniqueId; --- 40,48 ---- uniqueId = type.getName() + "_" + index; ! type.getTrainManager().addTrain(uniqueId, this); obsolete = new BooleanState(uniqueId, false); } public String getUniqueId() { return uniqueId; *************** *** 136,144 **** new ObjectMove(this, holder, to); ! } public void setRusted() { ! new ObjectMove(this, holder, Bank.getInstance().getScrapHeap()); } --- 124,132 ---- new ObjectMove(this, holder, to); ! } public void setRusted() { ! new ObjectMove(this, holder, GameManager.getInstance().getBank().getScrapHeap()); } *************** *** 154,157 **** return getName(); } ! } --- 142,145 ---- return getName(); } ! } Index: BonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/BonusToken.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** BonusToken.java 25 Sep 2009 19:13:01 -0000 1.11 --- BonusToken.java 4 Nov 2009 20:33:22 -0000 1.12 *************** *** 63,67 **** public void close() { ! new ObjectMove(this, holder, Bank.getInstance().getScrapHeap()); user.removeBonus(name); } --- 63,67 ---- public void close() { ! new ObjectMove(this, holder, GameManager.getInstance().getBank().getScrapHeap()); user.removeBonus(name); } Index: TrainType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainType.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** TrainType.java 31 Oct 2009 17:08:26 -0000 1.25 --- TrainType.java 4 Nov 2009 20:33:22 -0000 1.26 *************** *** 12,16 **** import rails.util.Tag; ! public class TrainType implements TrainTypeI { --- 12,16 ---- import rails.util.Tag; ! public class TrainType implements TrainTypeI { *************** *** 25,29 **** protected int amount; protected boolean infiniteAmount = false; ! /** Index: used for sorting trains lists in configured order. */ protected int index; --- 25,29 ---- protected int amount; protected boolean infiniteAmount = false; ! /** Index: used for sorting trains lists in configured order. */ protected int index; *************** *** 45,49 **** protected boolean obsoleting = false; ! protected boolean permanent = true; --- 45,49 ---- protected boolean obsoleting = false; ! protected boolean permanent = true; *************** *** 66,70 **** protected ArrayList<TrainI> trains = null; ! protected int lastIndex = 0; --- 66,70 ---- protected ArrayList<TrainI> trains = null; ! protected int lastIndex = 0; *************** *** 72,75 **** --- 72,77 ---- protected BooleanState rusted; + protected TrainManager trainManager; + /** In some cases, trains start their life in the Pool */ protected String initialPortfolio = "IPO"; *************** *** 222,236 **** public void finishConfiguration (GameManagerI gameManager) { ! index = gameManager.getTrainManager().getTrainTypes().indexOf(this); ! Portfolio unavailable = gameManager.getBank().getUnavailable(); ! for (TrainI train : trains) { unavailable.addTrain(train); } } ! protected TrainI createTrain () throws ConfigurationException { ! TrainI train; try { --- 224,241 ---- public void finishConfiguration (GameManagerI gameManager) { ! ! trainManager = gameManager.getTrainManager(); ! index = trainManager.getTrainTypes().indexOf(this); ! Portfolio unavailable = gameManager.getBank().getUnavailable(); ! for (TrainI train : trains) { + train.init(this, lastIndex++); unavailable.addTrain(train); } } ! protected TrainI createTrain () throws ConfigurationException { ! TrainI train; try { *************** *** 244,256 **** + "constructor", e); } - train.init(this, lastIndex++); return train; } ! ! /** Create train without throwing exceptions. ! * To be used <b>after</b> completing initialization, ! * i.e. in cloning infinitely available trains. */ ! public TrainI cloneTrain () { TrainI train = null; --- 249,260 ---- + "constructor", e); } return train; } ! ! /** Create train without throwing exceptions. ! * To be used <b>after</b> completing initialization, ! * i.e. in cloning infinitely available trains. */ ! public TrainI cloneTrain () { TrainI train = null; *************** *** 462,469 **** return clone; } ! public int getIndex() { return index; } ! } --- 466,477 ---- return clone; } ! public int getIndex() { return index; } ! ! public TrainManager getTrainManager() { ! return trainManager; ! } ! } Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GameManagerI.java 30 Oct 2009 21:53:03 -0000 1.20 --- GameManagerI.java 4 Nov 2009 20:33:22 -0000 1.21 *************** *** 134,138 **** public abstract void setNextPlayer(); ! /** * @return the StartPacket */ --- 134,141 ---- public abstract void setNextPlayer(); ! public void addPortfolio (Portfolio portfolio); ! public Portfolio getPortfolioByName (String name); ! ! /** * @return the StartPacket */ |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:32
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/game/specific/_18AL Modified Files: AssignNamedTrains.java Log Message: More rationalising of static method usage Index: AssignNamedTrains.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/AssignNamedTrains.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AssignNamedTrains.java 31 Oct 2009 17:08:27 -0000 1.5 --- AssignNamedTrains.java 4 Nov 2009 20:33:22 -0000 1.6 *************** *** 6,15 **** import java.util.List; ! import rails.game.Token; ! import rails.game.Train; ! import rails.game.TrainI; import rails.game.action.UseSpecialProperty; - import rails.game.specific._18AL.NamedTrainToken; - import rails.game.specific._18AL.NameTrains; public class AssignNamedTrains extends UseSpecialProperty { --- 6,11 ---- import java.util.List; ! import rails.game.*; import rails.game.action.UseSpecialProperty; public class AssignNamedTrains extends UseSpecialProperty { *************** *** 67,75 **** } ! public String toMenu() { return ((NameTrains) specialProperty).toMenu(); } ! public String toString() { StringBuffer b = new StringBuffer("AssignNamedTrains "); for (NamedTrainToken token : ((NameTrains) getSpecialProperty()).getTokens()) { --- 63,73 ---- } ! @Override ! public String toMenu() { return ((NameTrains) specialProperty).toMenu(); } ! @Override ! public String toString() { StringBuffer b = new StringBuffer("AssignNamedTrains "); for (NamedTrainToken token : ((NameTrains) getSpecialProperty()).getTokens()) { *************** *** 106,113 **** in.defaultReadObject(); nameableTrains = new ArrayList<NameableTrain>(); if (trainIds != null) { for (String trainId : trainIds) { ! nameableTrains.add((NameableTrain) Train.getByUniqueId(trainId)); } } --- 104,113 ---- in.defaultReadObject(); + TrainManager trainManager = GameManager.getInstance().getTrainManager(); + nameableTrains = new ArrayList<NameableTrain>(); if (trainIds != null) { for (String trainId : trainIds) { ! nameableTrains.add((NameableTrain) trainManager.getTrainByUniqueId(trainId)); } } |
From: Erik V. <ev...@us...> - 2009-11-04 20:33:32
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21355/rails/game/move Modified Files: CashMove.java Log Message: More rationalising of static method usage Index: CashMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/CashMove.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CashMove.java 25 Sep 2009 19:13:01 -0000 1.5 --- CashMove.java 4 Nov 2009 20:33:22 -0000 1.6 *************** *** 6,11 **** package rails.game.move; ! import rails.game.Bank; ! import rails.game.CashHolder; /** --- 6,10 ---- package rails.game.move; ! import rails.game.*; /** *************** *** 18,22 **** CashHolder to; ! private static Bank bank = Bank.getInstance(); /** --- 17,21 ---- CashHolder to; ! private static Bank bank = GameManager.getInstance().getBank(); /** |
From: Erik V. <ev...@us...> - 2009-11-02 23:31:00
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29771/rails/game Modified Files: MapHex.java MapManager.java PublicCompany.java Log Message: More rationalising of static method usage Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MapManager.java 31 Oct 2009 17:08:27 -0000 1.11 --- MapManager.java 2 Nov 2009 23:30:36 -0000 1.12 *************** *** 12,24 **** private String mapUIClassName = null; - private static MapManager instance = null; // The next attributes are duplicates in MapHex. We'll see what we really // need. ! protected static int tileOrientation; ! protected static boolean lettersGoHorizontal; ! protected static boolean letterAHasEvenNumbers; ! protected static MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); protected int maxX, maxY; --- 12,23 ---- private String mapUIClassName = null; // The next attributes are duplicates in MapHex. We'll see what we really // need. ! protected int tileOrientation; ! protected boolean lettersGoHorizontal; ! protected boolean letterAHasEvenNumbers; ! protected MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); protected int maxX, maxY; *************** *** 36,40 **** public MapManager() { - instance = this; } --- 35,38 ---- *************** *** 53,60 **** if (attr.equals("EW")) { tileOrientation = MapHex.EW; - MapHex.setTileOrientation(MapHex.EW); } else if (attr.equals("NS")) { tileOrientation = MapHex.NS; - MapHex.setTileOrientation(MapHex.NS); } else { throw new ConfigurationException("Invalid tile orientation: " --- 51,56 ---- *************** *** 71,79 **** + attr); } - MapHex.setLettersGoHorizontal(lettersGoHorizontal); attr = tag.getAttributeAsString("even"); letterAHasEvenNumbers = ((attr.toUpperCase().charAt(0) - 'A')) % 2 == 0; - MapHex.setLetterAHasEvenNumbers(letterAHasEvenNumbers); List<Tag> hexTags = tag.getChildren("Hex"); --- 67,73 ---- *************** *** 116,120 **** for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; ! for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { --- 110,114 ---- for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; ! for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { *************** *** 150,163 **** /** - * @return an instance of the MapManager - */ - public static MapManager getInstance() { - return instance; - } - - /** * @return Returns the letterAHasEvenNumbers. */ ! public static boolean letterAHasEvenNumbers() { return letterAHasEvenNumbers; } --- 144,150 ---- /** * @return Returns the letterAHasEvenNumbers. */ ! public boolean letterAHasEvenNumbers() { return letterAHasEvenNumbers; } *************** *** 166,170 **** * @return Returns the lettersGoHorizontal. */ ! public static boolean lettersGoHorizontal() { return lettersGoHorizontal; } --- 153,157 ---- * @return Returns the lettersGoHorizontal. */ ! public boolean lettersGoHorizontal() { return lettersGoHorizontal; } *************** *** 173,177 **** * @return Returns the currentTileOrientation. */ ! public static int getTileOrientation() { return tileOrientation; } --- 160,164 ---- * @return Returns the currentTileOrientation. */ ! public int getTileOrientation() { return tileOrientation; } *************** *** 202,207 **** return stations; } ! ! public List<MapHex> parseLocations (String locationCodes) throws ConfigurationException { --- 189,194 ---- return stations; } ! ! public List<MapHex> parseLocations (String locationCodes) throws ConfigurationException { *************** *** 218,222 **** } } ! return locations; } --- 205,209 ---- } } ! return locations; } Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** MapHex.java 31 Oct 2009 17:08:26 -0000 1.28 --- MapHex.java 2 Nov 2009 23:30:36 -0000 1.29 *************** *** 42,48 **** public static final int EW = 0; public static final int NS = 1; - protected static int tileOrientation; - protected static boolean lettersGoHorizontal; - protected static boolean letterAHasEvenNumbers; private static final String[] ewOrNames = --- 42,45 ---- *************** *** 93,97 **** /** Tokens that are not bound to a Station (City), such as Bonus tokens */ protected List<TokenI> offStationTokens; ! protected MapManager mapManager = null; --- 90,94 ---- /** Tokens that are not bound to a Station (City), such as Bonus tokens */ protected List<TokenI> offStationTokens; ! protected MapManager mapManager = null; *************** *** 125,132 **** * drawing. */ ! if (lettersGoHorizontal) { row = number; column = letter - '@'; ! if (tileOrientation == MapHex.EW) { // Tiles with flat EW sides, letters go horizontally. // Example: 1841 (NOT TESTED, PROBABLY WRONG). --- 122,129 ---- * drawing. */ ! if (lettersGoHorizontal()) { row = number; column = letter - '@'; ! if (getTileOrientation() == MapHex.EW) { // Tiles with flat EW sides, letters go horizontally. // Example: 1841 (NOT TESTED, PROBABLY WRONG). *************** *** 144,152 **** row = letter - '@'; column = number; ! if (tileOrientation == MapHex.EW) { // Tiles with flat EW sides, letters go vertically. // Most common case. // Tested for 1830 and 1870. ! x = (column + (letterAHasEvenNumbers ? 1 : 0)) / 2; y = row; } else { --- 141,149 ---- row = letter - '@'; column = number; ! if (getTileOrientation() == MapHex.EW) { // Tiles with flat EW sides, letters go vertically. // Most common case. // Tested for 1830 and 1870. ! x = (column + (letterAHasEvenNumbers() ? 1 : 0)) / 2; y = row; } else { *************** *** 174,178 **** public void finishConfiguration (GameManagerI gameManager) { ! currentTile = gameManager.getTileManager().getTile(preprintedTileId); // We need completely new objects, not just references to the Tile's --- 171,175 ---- public void finishConfiguration (GameManagerI gameManager) { ! currentTile = gameManager.getTileManager().getTile(preprintedTileId); // We need completely new objects, not just references to the Tile's *************** *** 210,223 **** } ! public static void setTileOrientation(int orientation) { ! tileOrientation = orientation; ! } ! ! public static int getTileOrientation() { ! return tileOrientation; ! } ! ! public static void setLettersGoHorizontal(boolean b) { ! lettersGoHorizontal = b; } --- 207,212 ---- } ! public int getTileOrientation() { ! return mapManager.getTileOrientation(); } *************** *** 225,237 **** * @return Returns the letterAHasEvenNumbers. */ ! public static boolean hasLetterAEvenNumbers() { ! return letterAHasEvenNumbers; ! } ! ! /** ! * @param letterAHasEvenNumbers The letterAHasEvenNumbers to set. ! */ ! public static void setLetterAHasEvenNumbers(boolean letterAHasEvenNumbers) { ! MapHex.letterAHasEvenNumbers = letterAHasEvenNumbers; } --- 214,219 ---- * @return Returns the letterAHasEvenNumbers. */ ! public boolean letterAHasEvenNumbers() { ! return mapManager.letterAHasEvenNumbers(); } *************** *** 239,249 **** * @return Returns the lettersGoHorizontal. */ ! public static boolean isLettersGoHorizontal() { ! return lettersGoHorizontal; } ! public static String getOrientationName(int orientation) { ! if (tileOrientation == EW) { return ewOrNames[orientation % 6]; } else { --- 221,231 ---- * @return Returns the lettersGoHorizontal. */ ! public boolean lettersGoHorizontal() { ! return mapManager.lettersGoHorizontal(); } ! public String getOrientationName(int orientation) { ! if (getTileOrientation() == EW) { return ewOrNames[orientation % 6]; } else { *************** *** 322,352 **** } - /** Look for the Hex matching the Label in the terrain static map */ - /* EV: useful, but needs to be rewritten */ - public static MapHex getHexByLabel(String terrain, String label) { - /* - * int x = 0; int y = Integer.parseInt(new String(label.substring(1))); - * switch (label.charAt(0)) { case 'A': case 'a': x = 0; break; - * - * case 'B': case 'b': x = 1; break; - * - * case 'C': case 'c': x = 2; break; - * - * case 'D': case 'd': x = 3; break; - * - * case 'E': case 'e': x = 4; break; - * - * case 'F': case 'f': x = 5; break; - * - * case 'X': case 'x': // entrances GUIHex[] gameEntrances = (GUIHex[]) - * entranceHexes.get(terrain); return gameEntrances[y].getMapHexModel(); - * - * default: Log.error("Label " + label + " is invalid"); } y = 6 - y - - * (int) Math.abs(((x - 3) / 2)); GUIHex[][] correctHexes = (GUIHex[][]) - * terrainH.get(terrain); return correctHexes[x][y].getMapHexModel(); - */ - return null; - } - public int getTileCost() { if (currentTile.getId() == preprintedTileId) { --- 304,307 ---- *************** *** 963,967 **** return false; } ! public MapManager getMapManager() { return mapManager; --- 918,922 ---- return false; } ! public MapManager getMapManager() { return mapManager; *************** *** 1001,1005 **** int direction = rotation + endPoint; if (b.length() > 0) b.append(","); ! b.append(MapHex.getOrientationName(direction)); } } --- 956,960 ---- int direction = rotation + endPoint; if (b.length() > 0) b.append(","); ! b.append(getOrientationName(direction)); } } Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** PublicCompany.java 31 Oct 2009 17:08:26 -0000 1.70 --- PublicCompany.java 2 Nov 2009 23:30:36 -0000 1.71 *************** *** 1550,1554 **** String tileLaid = "#" + tile.getExternalId() + "/" + hex.getName() + "/" ! + MapHex.getOrientationName(orientation); tilesLaidThisTurn.appendWithDelimiter(tileLaid, ", "); --- 1550,1554 ---- String tileLaid = "#" + tile.getExternalId() + "/" + hex.getName() + "/" ! + hex.getOrientationName(orientation); tilesLaidThisTurn.appendWithDelimiter(tileLaid, ", "); |
From: Erik V. <ev...@us...> - 2009-11-02 23:30:52
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29771/rails/game/specific/_18AL Modified Files: NamedTrainToken.java Log Message: More rationalising of static method usage Index: NamedTrainToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/NamedTrainToken.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NamedTrainToken.java 31 Oct 2009 17:08:27 -0000 1.3 --- NamedTrainToken.java 2 Nov 2009 23:30:36 -0000 1.4 *************** *** 1,14 **** package rails.game.specific._18AL; - import java.util.ArrayList; import java.util.List; ! import rails.game.Bank; ! import rails.game.ConfigurableComponentI; ! import rails.game.ConfigurationException; ! import rails.game.GameManagerI; ! import rails.game.MapHex; ! import rails.game.MapManager; ! import rails.game.Token; import rails.util.Tag; import rails.util.Util; --- 1,7 ---- package rails.game.specific._18AL; import java.util.List; ! import rails.game.*; import rails.util.Tag; import rails.util.Util; *************** *** 52,58 **** } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! if (hexesString != null) { hexes = gameManager.getMapManager().parseLocations(hexesString); --- 45,51 ---- } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { ! if (hexesString != null) { hexes = gameManager.getMapManager().parseLocations(hexesString); *************** *** 72,76 **** } ! public String toString() { return description; } --- 65,70 ---- } ! @Override ! public String toString() { return description; } |
From: Erik V. <ev...@us...> - 2009-11-02 23:30:48
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29771/rails/ui/swing Modified Files: MapPanel.java GameSetupWindow.java ORUIManager.java ORWindow.java GameUIManager.java Log Message: More rationalising of static method usage Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GameUIManager.java 30 Oct 2009 21:53:04 -0000 1.20 --- GameUIManager.java 2 Nov 2009 23:30:35 -0000 1.21 *************** *** 28,32 **** public ORWindow orWindow; // TEMPORARY private StartRoundWindow startRoundWindow; - public GameSetupWindow gameSetupWindow; public static ImageLoader imageLoader; --- 28,31 ---- *************** *** 56,63 **** } ! public void init (GameSetupWindow gameSetupWindow) { instance = this; ! this.gameSetupWindow = gameSetupWindow; saveDirectory = Config.get("save.directory"); --- 55,62 ---- } ! public void init (GameManagerI gameManager) { instance = this; ! this.gameManager = gameManager; saveDirectory = Config.get("save.directory"); *************** *** 75,84 **** } - //gameSetupWindow = new GameSetupWindow(this); - } public void gameUIInit() { - gameManager = GameManager.getInstance(); imageLoader = new ImageLoader(); stockChart = new StockChart(this); --- 74,80 ---- *************** *** 438,472 **** } - /* - public boolean loadGame() { - - JFileChooser jfc = new JFileChooser(); - if (providedName != null) { - jfc.setSelectedFile(new File(providedName)); - } else { - jfc.setCurrentDirectory(new File(saveDirectory)); - } - - if (jfc.showOpenDialog(gameSetupWindow.getContentPane()) == JFileChooser.APPROVE_OPTION) { - File selectedFile = jfc.getSelectedFile(); - String filepath = selectedFile.getPath(); - saveDirectory = selectedFile.getParent(); - - if (!Game.load(filepath)) { - JOptionPane.showMessageDialog(gameSetupWindow, - DisplayBuffer.get(), "", JOptionPane.ERROR_MESSAGE); - return false; - } - DisplayBuffer.clear(); - - gameUIInit(); - processOnServer(null); - statusWindow.setGameActions(); - } - - return true; - } - */ - public PossibleAction getLastAction() { return lastAction; --- 434,437 ---- *************** *** 481,484 **** --- 446,457 ---- } + public void setORUIManager(ORUIManager orUIManager) { + this.orUIManager = orUIManager; + } + + public ORUIManager getORUIManager() { + return orUIManager; + } + public RoundI getCurrentRound() { return gameManager.getCurrentRound(); Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** ORUIManager.java 30 Oct 2009 21:53:04 -0000 1.30 --- ORUIManager.java 2 Nov 2009 23:30:35 -0000 1.31 *************** *** 81,88 **** } public void init(ORWindow orWindow) { this.orWindow = orWindow; - gameUIManager = orWindow.getGameUIManager(); orPanel = orWindow.getORPanel(); --- 81,91 ---- } + public void setGameUIManager (GameUIManager gameUIManager) { + this.gameUIManager = gameUIManager; + } + public void init(ORWindow orWindow) { this.orWindow = orWindow; orPanel = orWindow.getORPanel(); Index: GameSetupWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameSetupWindow.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GameSetupWindow.java 4 May 2009 20:29:15 -0000 1.13 --- GameSetupWindow.java 2 Nov 2009 23:30:35 -0000 1.14 *************** *** 389,398 **** private void startGameUIManager(Game game) { ! String gameUIManagerClassName = game.getGameManager().getClassName(Defs.ClassName.GAME_UI_MANAGER); try { Class<? extends GameUIManager> gameUIManagerClass = Class.forName(gameUIManagerClassName).asSubclass(GameUIManager.class); gameUIManager = gameUIManagerClass.newInstance(); ! gameUIManager.init(this); } catch (Exception e) { log.fatal("Cannot instantiate class " + gameUIManagerClassName, e); --- 389,399 ---- private void startGameUIManager(Game game) { ! GameManagerI gameManager = game.getGameManager(); ! String gameUIManagerClassName = gameManager.getClassName(Defs.ClassName.GAME_UI_MANAGER); try { Class<? extends GameUIManager> gameUIManagerClass = Class.forName(gameUIManagerClassName).asSubclass(GameUIManager.class); gameUIManager = gameUIManagerClass.newInstance(); ! gameUIManager.init(gameManager); } catch (Exception e) { log.fatal("Cannot instantiate class " + gameUIManagerClassName, e); Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ORWindow.java 2 Sep 2009 21:47:47 -0000 1.25 --- ORWindow.java 2 Nov 2009 23:30:35 -0000 1.26 *************** *** 56,59 **** --- 56,61 ---- System.exit(1); } + gameUIManager.setORUIManager(orUIManager); + orUIManager.setGameUIManager(gameUIManager); getContentPane().setLayout(new BorderLayout()); *************** *** 62,66 **** getContentPane().add(messagePanel, BorderLayout.NORTH); ! mapPanel = new MapPanel(orUIManager); getContentPane().add(mapPanel, BorderLayout.CENTER); --- 64,68 ---- getContentPane().add(messagePanel, BorderLayout.NORTH); ! mapPanel = new MapPanel(gameUIManager); getContentPane().add(mapPanel, BorderLayout.CENTER); Index: MapPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/MapPanel.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MapPanel.java 31 Oct 2009 17:08:26 -0000 1.10 --- MapPanel.java 2 Nov 2009 23:30:34 -0000 1.11 *************** *** 24,43 **** private HexMap map; private JScrollPane scrollPane; ! private ORUIManager orUIManager; protected static Logger log = Logger.getLogger(MapPanel.class.getPackage().getName()); ! public MapPanel(ORUIManager orUIManager) { ! this.orUIManager = orUIManager; Scale.set(15); setLayout(new BorderLayout()); ! //mmgr = orUIManager.getGameUIManager().getGameManager().getMapManager(); ! mmgr = MapManager.getInstance(); try { map = (HexMap) Class.forName(mmgr.getMapUIClassName()).newInstance(); ! map.setORUIManager(orUIManager); } catch (Exception e) { log.fatal("Map class instantiation error:", e); --- 24,42 ---- private HexMap map; private JScrollPane scrollPane; ! private GameUIManager gameUIManager; protected static Logger log = Logger.getLogger(MapPanel.class.getPackage().getName()); ! public MapPanel(GameUIManager gameUIManager) { ! this.gameUIManager = gameUIManager; Scale.set(15); setLayout(new BorderLayout()); ! mmgr = gameUIManager.getGameManager().getMapManager(); try { map = (HexMap) Class.forName(mmgr.getMapUIClassName()).newInstance(); ! map.init(gameUIManager.getORUIManager(), mmgr); } catch (Exception e) { log.fatal("Map class instantiation error:", e); *************** *** 68,72 **** public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { ! HelpWindow.displayHelp(orUIManager.gameUIManager.getHelp()); e.consume(); } --- 67,71 ---- public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { ! HelpWindow.displayHelp(gameUIManager.getHelp()); e.consume(); } |
From: Erik V. <ev...@us...> - 2009-11-02 23:30:46
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29771/rails/ui/swing/hexmap Modified Files: GUIHex.java EWHexMap.java GUITile.java HexMap.java NSHexMap.java Log Message: More rationalising of static method usage Index: NSHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/NSHexMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NSHexMap.java 31 Oct 2009 17:08:27 -0000 1.8 --- NSHexMap.java 2 Nov 2009 23:30:36 -0000 1.9 *************** *** 5,10 **** import java.util.ArrayList; ! import rails.game.*; ! import rails.ui.swing.*; /** --- 5,10 ---- import java.util.ArrayList; ! import rails.game.MapHex; ! import rails.ui.swing.Scale; /** *************** *** 16,30 **** public NSHexMap() { - setupHexes(); cx = 0; cy = -scale / 2; } ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); scale = Scale.get(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 16,30 ---- public NSHexMap() { cx = 0; cy = -scale / 2; } ! @Override ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); scale = Scale.get(); ! hexArray = mapManager.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; Index: EWHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/EWHexMap.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EWHexMap.java 31 Oct 2009 17:08:27 -0000 1.9 --- EWHexMap.java 2 Nov 2009 23:30:36 -0000 1.10 *************** *** 5,9 **** import java.util.ArrayList; ! import rails.game.*; /** --- 5,9 ---- import java.util.ArrayList; ! import rails.game.MapHex; /** *************** *** 15,27 **** public EWHexMap() { - setupHexes(); cx = scale / 2; cy = 0; } ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 15,27 ---- public EWHexMap() { cx = scale / 2; cy = 0; } ! @Override ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); ! hexArray = mapManager.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; Index: HexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/HexMap.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** HexMap.java 31 Oct 2009 17:08:27 -0000 1.17 --- HexMap.java 2 Nov 2009 23:30:36 -0000 1.18 *************** *** 4,8 **** import java.awt.*; import java.awt.event.*; - import java.awt.geom.Point2D; import java.util.*; import java.util.List; --- 4,7 ---- *************** *** 12,21 **** import org.apache.log4j.Logger; ! import rails.game.MapHex; ! import rails.game.MapManager; ! import rails.game.PhaseI; import rails.game.action.*; ! import rails.ui.swing.ORUIManager; ! import rails.ui.swing.Scale; /** --- 11,17 ---- import org.apache.log4j.Logger; ! import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.*; /** *************** *** 30,34 **** protected ORUIManager orUIManager; ! //protected MapManager mapManager; // Abstract Methods --- 26,30 ---- protected ORUIManager orUIManager; ! protected MapManager mapManager; // Abstract Methods *************** *** 40,48 **** protected MapHex[][] hexArray; protected Map<String, GUIHex> hexesByName = new HashMap<String, GUIHex>(); ! protected static ArrayList<GUIHex> hexes; protected int scale = 2 * Scale.get(); protected int cx; protected int cy; ! protected static GUIHex selectedHex = null; protected Dimension preferredSize; --- 36,44 ---- protected MapHex[][] hexArray; protected Map<String, GUIHex> hexesByName = new HashMap<String, GUIHex>(); ! protected ArrayList<GUIHex> hexes; protected int scale = 2 * Scale.get(); protected int cx; protected int cy; ! protected GUIHex selectedHex = null; protected Dimension preferredSize; *************** *** 63,69 **** protected boolean bonusTokenLayingEnabled = false; ! public void setORUIManager(ORUIManager orUIManager) { this.orUIManager = orUIManager; ! //this.mapManager = orUIManager.getGameUIManager().getGameManager().getMapManager(); } --- 59,66 ---- protected boolean bonusTokenLayingEnabled = false; ! public void init(ORUIManager orUIManager, MapManager mapManager) { this.orUIManager = orUIManager; ! this.mapManager = mapManager; ! setupHexes(); } *************** *** 74,91 **** } - /** - * Return the GUIBattleHex that contains the given point, or null if none - * does. - */ - GUIHex getHexContainingPoint(Point2D.Double point) { - for (GUIHex hex : hexes) { - if (hex.contains(point)) { - return hex; - } - } - - return null; - } - GUIHex getHexContainingPoint(Point point) { for (GUIHex hex : hexes) { --- 71,74 ---- *************** *** 294,304 **** public PhaseI getPhase () { if (orUIManager != null) { ! return orUIManager.getGameUIManager().getGameManager().getPhaseManager().getCurrentPhase(); ! } else { ! return null; } } ! public void mouseClicked(MouseEvent arg0) { Point point = arg0.getPoint(); GUIHex clickedHex = getHexContainingPoint(point); --- 277,294 ---- public PhaseI getPhase () { if (orUIManager != null) { ! //return orUIManager.getGameUIManager().getGameManager().getPhaseManager().getCurrentPhase(); ! GameUIManager u = orUIManager.getGameUIManager(); ! GameManagerI g = u.getGameManager(); ! PhaseManager p = g.getPhaseManager(); ! return p.getCurrentPhase(); } + return null; } ! public MapManager getMapManager() { ! return mapManager; ! } ! ! public void mouseClicked(MouseEvent arg0) { Point point = arg0.getPoint(); GUIHex clickedHex = getHexContainingPoint(point); Index: GUITile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUITile.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** GUITile.java 6 Sep 2009 16:16:56 -0000 1.16 --- GUITile.java 2 Nov 2009 23:30:36 -0000 1.17 *************** *** 55,59 **** private void initialise() { ! if (MapManager.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; } else { --- 55,59 ---- private void initialise() { ! if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; } else { *************** *** 68,73 **** /** ! * Rotate right (clockwise) until a valid orientation is found. ! * * @param initial: First rotation to try. Should be 0 for the initial tile * drop, and 1 at subsequent rotation attempts. --- 68,73 ---- /** ! * Rotate right (clockwise) until a valid orientation is found. ! * * @param initial: First rotation to try. Should be 0 for the initial tile * drop, and 1 at subsequent rotation attempts. *************** *** 140,152 **** oldTrack.getEndPoint(prevTileSide)); } else { ! // Assume there are only two exits ! // (this is the only known case for downgrading: // #3->#7, #4->#9, #58->#8). // Find the other new exit int otherNewEndPoint = newTracks.get(0).getEndPoint(tempTileSide); ! // Calculate the corresponding old tile side number int otherOldEndPoint = (otherNewEndPoint + tempRot - prevTileRotation + 6) % 6; // That old tile side must have track too ! if (prevTile.getTracksPerSide(otherOldEndPoint) == null || prevTile.getTracksPerSide(otherOldEndPoint).isEmpty()) { continue rot; --- 140,152 ---- oldTrack.getEndPoint(prevTileSide)); } else { ! // Assume there are only two exits ! // (this is the only known case for downgrading: // #3->#7, #4->#9, #58->#8). // Find the other new exit int otherNewEndPoint = newTracks.get(0).getEndPoint(tempTileSide); ! // Calculate the corresponding old tile side number int otherOldEndPoint = (otherNewEndPoint + tempRot - prevTileRotation + 6) % 6; // That old tile side must have track too ! if (prevTile.getTracksPerSide(otherOldEndPoint) == null || prevTile.getTracksPerSide(otherOldEndPoint).isEmpty()) { continue rot; Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GUIHex.java 29 Oct 2009 19:41:27 -0000 1.22 --- GUIHex.java 2 Nov 2009 23:30:35 -0000 1.23 *************** *** 85,89 **** this.hexMap = hexMap; ! if (MapManager.getTileOrientation() == MapHex.EW) { len = scale; xVertex[0] = cx + SQRT3 / 2 * scale; --- 85,89 ---- this.hexMap = hexMap; ! if (hexMap.getMapManager().getTileOrientation() == MapHex.EW) { len = scale; xVertex[0] = cx + SQRT3 / 2 * scale; |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:47
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game/specific/_18EU Modified Files: StartCompany_18EU.java Log Message: More rationalising of static method usage Index: StartCompany_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartCompany_18EU.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StartCompany_18EU.java 29 Oct 2009 19:41:30 -0000 1.7 --- StartCompany_18EU.java 31 Oct 2009 17:08:27 -0000 1.8 *************** *** 122,126 **** } ! MapManager mapManager = MapManager.getInstance(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); --- 122,126 ---- } ! MapManager mapManager = GameManager.getInstance().getMapManager(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game Modified Files: Portfolio.java Tile.java StockRound.java StockMarket.java PhaseManager.java MapHex.java TileManager.java TrainType.java PlayerManager.java ConfigurableComponentI.java PublicCompany.java TrainManager.java GameManager.java Phase.java OperatingRound.java CompanyManager.java CompanyType.java Bank.java StockSpace.java ComponentManager.java MapManager.java PrivateCompany.java Bonus.java Log Message: More rationalising of static method usage Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Bank.java 9 Oct 2009 20:20:34 -0000 1.14 --- Bank.java 31 Oct 2009 17:08:27 -0000 1.15 *************** *** 99,103 **** } ! public void finishConfiguration (GameManager gameManager) { ReportBuffer.add(LocalText.getText("BankSizeIs", --- 99,103 ---- } ! public void finishConfiguration (GameManagerI gameManager) { ReportBuffer.add(LocalText.getText("BankSizeIs", Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** PublicCompany.java 29 Oct 2009 19:40:31 -0000 1.69 --- PublicCompany.java 31 Oct 2009 17:08:26 -0000 1.70 *************** *** 627,631 **** * Final initialisation, after all XML has been processed. */ ! public void finishConfiguration(GameManager gameManager) throws ConfigurationException { --- 627,631 ---- * Final initialisation, after all XML has been processed. */ ! public void finishConfiguration(GameManagerI gameManager) throws ConfigurationException { Index: CompanyType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyType.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CompanyType.java 9 Oct 2009 20:20:34 -0000 1.9 --- CompanyType.java 31 Oct 2009 17:08:27 -0000 1.10 *************** *** 61,65 **** } ! public void finishConfiguration (GameManager gameManager) { } --- 61,65 ---- } ! public void finishConfiguration (GameManagerI gameManager) { } Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** StockMarket.java 29 Oct 2009 19:41:28 -0000 1.20 --- StockMarket.java 31 Oct 2009 17:08:26 -0000 1.21 *************** *** 144,148 **** * The purpose is to register fixed company start prices. */ ! public void finishConfiguration (GameManager gameManager) { for (PublicCompanyI comp : GameManager.getInstance().getCompanyManager().getAllPublicCompanies()) { --- 144,148 ---- * The purpose is to register fixed company start prices. */ ! public void finishConfiguration (GameManagerI gameManager) { for (PublicCompanyI comp : GameManager.getInstance().getCompanyManager().getAllPublicCompanies()) { Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ComponentManager.java 30 Oct 2009 21:53:03 -0000 1.14 --- ComponentManager.java 31 Oct 2009 17:08:27 -0000 1.15 *************** *** 64,68 **** instance = this; this.gameOptions = gameOptions; - log.debug("+++GameOptions="+gameOptions); ComponentManager.gameName = gameName; --- 64,67 ---- *************** *** 140,144 **** } - log.debug("+++ Before configuring" +name+": gameOptions="+gameOptions); configElement.setGameOptions(gameOptions); --- 139,142 ---- Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CompanyManager.java 30 Oct 2009 21:53:03 -0000 1.17 --- CompanyManager.java 31 Oct 2009 17:08:27 -0000 1.18 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void finishConfiguration (GameManager gameManager) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.finishConfiguration(gameManager); } for (PrivateCompanyI comp : lPrivateCompanies) { comp.finishConfiguration(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.finishConfiguration(gameManager); } for (PrivateCompanyI comp : lPrivateCompanies) { comp.finishConfiguration(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TrainManager.java 10 Oct 2009 15:25:49 -0000 1.21 --- TrainManager.java 31 Oct 2009 17:08:26 -0000 1.22 *************** *** 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 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 (GameManager 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); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * 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 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 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); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * 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 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 Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PrivateCompany.java 30 Oct 2009 21:53:03 -0000 1.24 --- PrivateCompany.java 31 Oct 2009 17:08:27 -0000 1.25 *************** *** 27,30 **** --- 27,31 ---- protected boolean closeAtEndOfTurn = false; // E.g. 1856 W&SR + protected String blockedHexesString = null; protected List<MapHex> blockedHexes = null; *************** *** 46,59 **** Tag blockedTag = tag.getChild("Blocking"); if (blockedTag != null) { ! String[] hexes = ! blockedTag.getAttributeAsString("hex").split(","); ! if (hexes != null && hexes.length > 0) { ! blockedHexes = new ArrayList<MapHex>(); ! for (String hexName : hexes) { ! MapHex hex = MapManager.getInstance().getHex(hexName); ! blockedHexes.add(hex); ! hex.setBlocked(true); ! } ! } } --- 47,52 ---- Tag blockedTag = tag.getChild("Blocking"); if (blockedTag != null) { ! blockedHexesString = ! blockedTag.getAttributeAsString("hex"); } *************** *** 111,115 **** } ! public void finishConfiguration (GameManager gameManager) throws ConfigurationException { --- 104,108 ---- } ! public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { *************** *** 117,121 **** sp.finishConfiguration(gameManager); } ! } /** Initialisation, to be called directly after instantiation (cloning) */ --- 110,124 ---- sp.finishConfiguration(gameManager); } ! ! if (Util.hasValue(blockedHexesString)) { ! MapManager mapManager = gameManager.getMapManager(); ! blockedHexes = new ArrayList<MapHex>(); ! for (String hexName : blockedHexesString.split(",")) { ! MapHex hex = mapManager.getHex(hexName); ! blockedHexes.add(hex); ! hex.setBlocked(true); ! } ! } ! } /** Initialisation, to be called directly after instantiation (cloning) */ *************** *** 183,187 **** for (SpecialPropertyI sp : specialProperties) { if (sp instanceof SellBonusToken) { ! ((SellBonusToken)sp).setSeller((CashHolder)Bank.getInstance()); } } --- 186,190 ---- for (SpecialPropertyI sp : specialProperties) { if (sp instanceof SellBonusToken) { ! ((SellBonusToken)sp).setSeller(Bank.getInstance()); } } Index: StockSpace.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockSpace.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StockSpace.java 2 Sep 2009 21:44:34 -0000 1.7 --- StockSpace.java 31 Oct 2009 17:08:27 -0000 1.8 *************** *** 40,44 **** this.type = type; this.row = Integer.parseInt(name.substring(1)) - 1; ! this.column = (int) (name.toUpperCase().charAt(0) - '@') - 1; } --- 40,44 ---- this.type = type; this.row = Integer.parseInt(name.substring(1)) - 1; ! this.column = (name.toUpperCase().charAt(0) - '@') - 1; } Index: ConfigurableComponentI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ConfigurableComponentI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConfigurableComponentI.java 10 Oct 2009 15:25:49 -0000 1.6 --- ConfigurableComponentI.java 31 Oct 2009 17:08:26 -0000 1.7 *************** *** 32,36 **** * static calls where possible. */ ! void finishConfiguration (GameManager parent) throws ConfigurationException; --- 32,36 ---- * static calls where possible. */ ! void finishConfiguration (GameManagerI parent) throws ConfigurationException; Index: Bonus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bonus.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Bonus.java 23 Sep 2009 21:38:57 -0000 1.1 --- Bonus.java 31 Oct 2009 17:08:27 -0000 1.2 *************** *** 2,6 **** package rails.game; - import java.util.ArrayList; import java.util.List; --- 2,5 ---- *************** *** 20,24 **** private PublicCompanyI owner; - private String locationCodes = null; private List<MapHex> locations = null; private String name; --- 19,22 ---- *************** *** 28,37 **** public Bonus (PublicCompanyI owner, ! String name, int value, String locationCodes) { ! this.owner = owner; ! this.name = name; ! this.value = value; ! this.locationCodes = locationCodes; ! parseLocations(); } --- 26,34 ---- public Bonus (PublicCompanyI owner, ! String name, int value, List<MapHex> locations) { ! this.owner = owner; ! this.name = name; ! this.value = value; ! this.locations = locations; } *************** *** 49,53 **** public String getLocationNameString() { ! return locationCodes; } --- 46,58 ---- public String getLocationNameString() { ! ! if (locations == null || locations.isEmpty()) return ""; ! ! StringBuffer b = new StringBuffer(); ! for (MapHex location : locations) { ! if (b.length() > 0) b.append(","); ! b.append(location.getName()); ! } ! return b.toString(); } *************** *** 60,74 **** } - private void parseLocations () { - - MapManager mmgr = MapManager.getInstance(); - MapHex hex; - locations = new ArrayList<MapHex>(); - for (String hexName : locationCodes.split(",")) { - hex = mmgr.getHex(hexName); - if (hex != null) locations.add(hex); - } - } - /** * Remove the token. --- 65,68 ---- *************** *** 106,110 **** public String toString() { return "Bonus "+name+" hex=" ! + locationCodes + " value=" + value; } --- 100,104 ---- public String toString() { return "Bonus "+name+" hex=" ! + getLocationNameString() + " value=" + value; } Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MapManager.java 9 Oct 2009 22:29:01 -0000 1.10 --- MapManager.java 31 Oct 2009 17:08:27 -0000 1.11 *************** *** 97,101 **** } ! public void finishConfiguration (GameManager gameManager) { MapHex hex; --- 97,101 ---- } ! public void finishConfiguration (GameManagerI gameManager) { MapHex hex; *************** *** 202,204 **** --- 202,225 ---- return stations; } + + public List<MapHex> parseLocations (String locationCodes) + throws ConfigurationException { + + List<MapHex> locations = new ArrayList<MapHex>(); + MapHex hex; + locations = new ArrayList<MapHex>(); + for (String hexName : locationCodes.split(",")) { + hex = getHex(hexName); + if (hex != null) { + locations.add(hex); + } else { + throw new ConfigurationException ("Invalid hex "+hexName+ + " specified in location string "+locationCodes); + } + } + + return locations; + } + + } Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** OperatingRound.java 9 Oct 2009 19:03:49 -0000 1.73 --- OperatingRound.java 31 Oct 2009 17:08:27 -0000 1.74 *************** *** 673,677 **** operatingCompany.addBonus(new Bonus(operatingCompany, token.getName(), ! token.getValue(), hex.getName())); token.setUser(operatingCompany); --- 673,677 ---- operatingCompany.addBonus(new Bonus(operatingCompany, token.getName(), ! token.getValue(), Collections.singletonList(hex))); token.setUser(operatingCompany); *************** *** 736,740 **** operatingCompany.addBonus(new Bonus(operatingCompany, sbt.getName(), ! sbt.getValue(), sbt.getLocationNameString())); ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom", --- 736,741 ---- operatingCompany.addBonus(new Bonus(operatingCompany, sbt.getName(), ! sbt.getValue(), ! sbt.getLocations())); ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom", Index: PhaseManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PhaseManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PhaseManager.java 9 Oct 2009 20:20:34 -0000 1.17 --- PhaseManager.java 31 Oct 2009 17:08:26 -0000 1.18 *************** *** 49,53 **** } ! public void finishConfiguration (GameManager gameManager) { this.gameManager = gameManager; PhaseI initialPhase = phaseList.get(0); --- 49,53 ---- } ! public void finishConfiguration (GameManagerI gameManager) { this.gameManager = gameManager; PhaseI initialPhase = phaseList.get(0); Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** MapHex.java 9 Oct 2009 22:29:01 -0000 1.27 --- MapHex.java 31 Oct 2009 17:08:26 -0000 1.28 *************** *** 173,177 **** } ! public void finishConfiguration (GameManager gameManager) { currentTile = gameManager.getTileManager().getTile(preprintedTileId); --- 173,177 ---- } ! public void finishConfiguration (GameManagerI gameManager) { currentTile = gameManager.getTileManager().getTile(preprintedTileId); Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Portfolio.java 3 Oct 2009 14:02:28 -0000 1.37 --- Portfolio.java 31 Oct 2009 17:08:26 -0000 1.38 *************** *** 474,478 **** LocatedBonus locBonus = (LocatedBonus)property; Bonus bonus = new Bonus(company, locBonus.getName(), locBonus.getValue(), ! locBonus.getLocationNameString()); company.addBonus(bonus); ReportBuffer.add(LocalText.getText("AcquiresBonus", --- 474,478 ---- LocatedBonus locBonus = (LocatedBonus)property; Bonus bonus = new Bonus(company, locBonus.getName(), locBonus.getValue(), ! locBonus.getLocations()); company.addBonus(bonus); ReportBuffer.add(LocalText.getText("AcquiresBonus", Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Tile.java 30 Oct 2009 21:53:03 -0000 1.29 --- Tile.java 31 Oct 2009 17:08:26 -0000 1.30 *************** *** 122,127 **** colourNumber -= TILE_NUMBER_OFFSET; - TileManager tileManager = GameManager.getInstance().getTileManager(); - /* Stations */ List<Tag> stationTags = defTag.getChildren("Station"); --- 122,125 ---- *************** *** 216,220 **** int id; String[] idArray; - TileI upgradeTile; Upgrade upgrade; String hexes; --- 214,217 ---- Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TileManager.java 30 Oct 2009 21:53:03 -0000 1.11 --- TileManager.java 31 Oct 2009 17:08:26 -0000 1.12 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; 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() { instance = this; } public static TileManager get() { return instance; } /** * @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 (GameManager 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 static TileManager instance = null; 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() { instance = this; } public static TileManager get() { return instance; } /** * @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 *... [truncated message content] |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:38
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/ui/swing/hexmap Modified Files: EWHexMap.java HexMap.java NSHexMap.java Log Message: More rationalising of static method usage Index: NSHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/NSHexMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NSHexMap.java 4 May 2009 20:29:15 -0000 1.7 --- NSHexMap.java 31 Oct 2009 17:08:27 -0000 1.8 *************** *** 26,31 **** scale = Scale.get(); ! MapManager mmgr = MapManager.getInstance(); ! hexArray = mmgr.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 26,30 ---- scale = Scale.get(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; *************** *** 35,39 **** if (mh != null) { GUIHex hex = ! new GUIHex(this, (int) Math.round(cx + 3 * i * scale), (int) Math.round(cy + (2 * j + (i & 1)) --- 34,38 ---- if (mh != null) { GUIHex hex = ! new GUIHex(this, Math.round(cx + 3 * i * scale), (int) Math.round(cy + (2 * j + (i & 1)) Index: EWHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/EWHexMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EWHexMap.java 4 May 2009 20:29:15 -0000 1.8 --- EWHexMap.java 31 Oct 2009 17:08:27 -0000 1.9 *************** *** 23,28 **** hexes = new ArrayList<GUIHex>(); ! MapManager mmgr = MapManager.getInstance(); ! hexArray = mmgr.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 23,27 ---- hexes = new ArrayList<GUIHex>(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; Index: HexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/HexMap.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** HexMap.java 8 Sep 2009 21:48:58 -0000 1.16 --- HexMap.java 31 Oct 2009 17:08:27 -0000 1.17 *************** *** 13,16 **** --- 13,17 ---- import rails.game.MapHex; + import rails.game.MapManager; import rails.game.PhaseI; import rails.game.action.*; *************** *** 29,32 **** --- 30,34 ---- protected ORUIManager orUIManager; + //protected MapManager mapManager; // Abstract Methods *************** *** 63,66 **** --- 65,69 ---- public void setORUIManager(ORUIManager orUIManager) { this.orUIManager = orUIManager; + //this.mapManager = orUIManager.getGameUIManager().getGameManager().getMapManager(); } |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:38
|
Update of /cvsroot/rails/18xx/rails/ui/swing/elements In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/ui/swing/elements Modified Files: GUIStockSpace.java Log Message: More rationalising of static method usage Index: GUIStockSpace.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/elements/GUIStockSpace.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GUIStockSpace.java 4 Jun 2008 19:00:39 -0000 1.6 --- GUIStockSpace.java 31 Oct 2009 17:08:27 -0000 1.7 *************** *** 99,103 **** for (int k = tokenList.size() - 1; k >= 0; k--) { ! co = (PublicCompanyI) tokenList.get(k); bgColour = co.getBgColour(); fgColour = co.getFgColour(); --- 99,103 ---- for (int k = tokenList.size() - 1; k >= 0; k--) { ! co = tokenList.get(k); bgColour = co.getBgColour(); fgColour = co.getFgColour(); |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:38
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game/action Modified Files: UseSpecialProperty.java Log Message: More rationalising of static method usage Index: UseSpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/UseSpecialProperty.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UseSpecialProperty.java 4 Jun 2008 19:00:29 -0000 1.4 --- UseSpecialProperty.java 31 Oct 2009 17:08:27 -0000 1.5 *************** *** 64,69 **** if (specialPropertyId > 0) { ! specialProperty = ! (SpecialPropertyI) SpecialProperty.getByUniqueId(specialPropertyId); } } --- 64,68 ---- if (specialPropertyId > 0) { ! specialProperty = SpecialProperty.getByUniqueId(specialPropertyId); } } |
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++; |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:37
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game/specific/_1856 Modified Files: CGRFormationRound.java StockRound_1856.java Log Message: More rationalising of static method usage Index: StockRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/StockRound_1856.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** StockRound_1856.java 7 Oct 2009 21:03:36 -0000 1.11 --- StockRound_1856.java 31 Oct 2009 17:08:26 -0000 1.12 *************** *** 54,58 **** if (price != 0 - && cert instanceof PublicCertificateI && !cert.getCompany().getName().equalsIgnoreCase(PublicCompany_CGR.NAME) && oldHolder == ipo) { --- 54,57 ---- Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CGRFormationRound.java 7 Oct 2009 21:03:36 -0000 1.21 --- CGRFormationRound.java 31 Oct 2009 17:08:26 -0000 1.22 *************** *** 514,518 **** List<Bonus> bonuses = new ArrayList<Bonus> (comp.getBonuses()); for (Bonus bonus : bonuses) { ! cgr.addBonus(new Bonus(cgr, bonus.getName(), bonus.getValue(), bonus.getLocationNameString())); comp.removeBonus(bonus); } --- 514,519 ---- List<Bonus> bonuses = new ArrayList<Bonus> (comp.getBonuses()); for (Bonus bonus : bonuses) { ! cgr.addBonus(new Bonus(cgr, bonus.getName(), bonus.getValue(), ! bonus.getLocations())); comp.removeBonus(bonus); } |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:37
|
Update of /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/ui/swing/gamespecific/_18AL Modified Files: NameTrainsDialog.java Log Message: More rationalising of static method usage Index: NameTrainsDialog.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18AL/NameTrainsDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NameTrainsDialog.java 4 Jun 2008 19:00:40 -0000 1.3 --- NameTrainsDialog.java 31 Oct 2009 17:08:27 -0000 1.4 *************** *** 176,181 **** // Find the coordinates of the selected button for (NamedTrainToken token : tokens) { ! List<JRadioButton> buttons = ! (List<JRadioButton>) buttonsPerToken.get(token); for (JRadioButton button : buttons) { if (button == radioButton) { --- 176,180 ---- // Find the coordinates of the selected button for (NamedTrainToken token : tokens) { ! List<JRadioButton> buttons = buttonsPerToken.get(token); for (JRadioButton button : buttons) { if (button == radioButton) { *************** *** 201,205 **** if (otherToken != token) { List<JRadioButton> otherButtons = ! (List<JRadioButton>) buttonsPerToken.get(otherToken); JRadioButton otherButton = otherButtons.get(x); if (otherButton.isSelected()) { --- 200,204 ---- if (otherToken != token) { List<JRadioButton> otherButtons = ! buttonsPerToken.get(otherToken); JRadioButton otherButton = otherButtons.get(x); if (otherButton.isSelected()) { |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:37
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/game/specific/_18AL Modified Files: NameTrains.java AssignNamedTrains.java NamedTrainToken.java Log Message: More rationalising of static method usage Index: NameTrains.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/NameTrains.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NameTrains.java 23 Sep 2009 21:38:57 -0000 1.3 --- NameTrains.java 31 Oct 2009 17:08:27 -0000 1.4 *************** *** 5,8 **** --- 5,9 ---- import rails.game.ConfigurationException; + import rails.game.GameManagerI; import rails.game.move.Moveable; import rails.game.special.SpecialProperty; *************** *** 65,68 **** --- 66,77 ---- } + public void finishConfiguration (GameManagerI gameManager) + throws ConfigurationException { + + for (NamedTrainToken token : tokens) { + token.finishConfiguration(gameManager); + } + } + public List<NamedTrainToken> getTokens() { return tokens; Index: NamedTrainToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/NamedTrainToken.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NamedTrainToken.java 4 Jun 2008 19:00:34 -0000 1.2 --- NamedTrainToken.java 31 Oct 2009 17:08:27 -0000 1.3 *************** *** 5,9 **** --- 5,11 ---- import rails.game.Bank; + import rails.game.ConfigurableComponentI; import rails.game.ConfigurationException; + import rails.game.GameManagerI; import rails.game.MapHex; import rails.game.MapManager; *************** *** 12,16 **** import rails.util.Util; ! public class NamedTrainToken extends Token { private String name; --- 14,18 ---- import rails.util.Util; ! public class NamedTrainToken extends Token implements ConfigurableComponentI { private String name; *************** *** 45,56 **** hexesString = tag.getAttributeAsString("ifRouteIncludes"); - if (hexesString != null) { - MapHex hex; - hexes = new ArrayList<MapHex>(2); - for (String hexName : hexesString.split(",")) { - hex = MapManager.getInstance().getHex(hexName); - hexes.add(hex); - } - } description = --- 47,50 ---- *************** *** 58,61 **** --- 52,63 ---- } + public void finishConfiguration (GameManagerI gameManager) + throws ConfigurationException { + + if (hexesString != null) { + hexes = gameManager.getMapManager().parseLocations(hexesString); + } + } + public String getName() { return name; Index: AssignNamedTrains.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/AssignNamedTrains.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AssignNamedTrains.java 4 Jun 2008 19:00:36 -0000 1.4 --- AssignNamedTrains.java 31 Oct 2009 17:08:27 -0000 1.5 *************** *** 56,60 **** for (NameableTrain train : nameableTrains) { trainIds[trainIndex] = train.getUniqueId(); ! NamedTrainToken token = ((NameableTrain) train).getNameToken(); if (token != null) { preTrainPerToken.set(tokens.indexOf(token), train); --- 56,60 ---- for (NameableTrain train : nameableTrains) { trainIds[trainIndex] = train.getUniqueId(); ! NamedTrainToken token = train.getNameToken(); if (token != null) { preTrainPerToken.set(tokens.indexOf(token), train); |
From: Erik V. <ev...@us...> - 2009-10-31 17:08:34
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12071/rails/ui/swing Modified Files: MapPanel.java Log Message: More rationalising of static method usage Index: MapPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/MapPanel.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MapPanel.java 30 Jun 2008 20:35:29 -0000 1.9 --- MapPanel.java 31 Oct 2009 17:08:26 -0000 1.10 *************** *** 34,37 **** --- 34,38 ---- setLayout(new BorderLayout()); + //mmgr = orUIManager.getGameUIManager().getGameManager().getMapManager(); mmgr = MapManager.getInstance(); try { |
From: Erik V. <ev...@us...> - 2009-10-30 22:45:04
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/game Modified Files: TileI.java Tile.java CompanyManager.java ReportBuffer.java GameManagerI.java TileManager.java Game.java ComponentManager.java PrivateCompany.java GameManager.java Log Message: More rationalising of static method usage Index: ReportBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ReportBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReportBuffer.java 8 Oct 2009 21:14:14 -0000 1.5 --- ReportBuffer.java 30 Oct 2009 21:53:03 -0000 1.6 *************** *** 115,119 **** /* Create the pathname */ reportPathname = ! reportDirectory + "/" + Game.getName() + "_" + GameManager.getInstance().getKey() + "_" + dateFormat.format(new Date()) + "." --- 115,119 ---- /* Create the pathname */ reportPathname = ! reportDirectory + "/" + GameManager.getInstance().getGameName() + "_" + GameManager.getInstance().getKey() + "_" + dateFormat.format(new Date()) + "." Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Tile.java 3 Oct 2009 14:02:28 -0000 1.28 --- Tile.java 30 Oct 2009 21:53:03 -0000 1.29 *************** *** 122,125 **** --- 122,127 ---- colourNumber -= TILE_NUMBER_OFFSET; + TileManager tileManager = GameManager.getInstance().getTileManager(); + /* Stations */ List<Tag> stationTags = defTag.getChildren("Station"); *************** *** 228,242 **** try { id = Integer.parseInt(idArray[j]); ! upgradeTile = TileManager.get().getTile(id); ! if (upgradeTile != null) { ! upgrade = new Upgrade(upgradeTile); ! upgrades.add(upgrade); ! newUpgrades.add(upgrade); ! } else { ! throw new ConfigurationException( ! LocalText.getText("UpgradeNotFound", ! name, ! id )); ! } } catch (NumberFormatException e) { throw new ConfigurationException(LocalText.getText( --- 230,236 ---- try { id = Integer.parseInt(idArray[j]); ! upgrade = new Upgrade(id); ! upgrades.add(upgrade); ! newUpgrades.add(upgrade); } catch (NumberFormatException e) { throw new ConfigurationException(LocalText.getText( *************** *** 279,282 **** --- 273,291 ---- } + public void finishConfiguration (TileManager tileManager) + throws ConfigurationException { + + for (Upgrade upgrade : upgrades) { + + TileI tile = tileManager.getTile(upgrade.getTileId()); + if (tile != null) { + upgrade.setTile(tile); + } else { + throw new ConfigurationException ("Cannot find upgrade tile #" + +upgrade.getTileId()+" for tile #"+id); + } + } + } + /** * @return Returns the colour. *************** *** 445,448 **** --- 454,460 ---- protected class Upgrade { + + /** The upgrade tile id */ + int tileId; /** The upgrade tile */ *************** *** 470,475 **** String hexes = null; ! protected Upgrade(TileI tile) { ! this.tile = tile; } --- 482,487 ---- String hexes = null; ! protected Upgrade(int tileId) { ! this.tileId = tileId; } *************** *** 492,499 **** --- 504,519 ---- } + public void setTile(TileI tile) { + this.tile = tile; + } + protected TileI getTile() { return tile; } + public int getTileId() { + return tileId; + } + protected void setHexes(String hexes) { this.hexes = hexes; Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TileManager.java 9 Oct 2009 20:20:34 -0000 1.10 --- TileManager.java 30 Oct 2009 21:53:03 -0000 1.11 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; 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() { instance = this; } public static TileManager get() { return instance; } /** * @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 (GameManager gameManager) {} 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 static TileManager instance = null; 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() { instance = this; } public static TileManager get() { return instance; } /** * @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 (GameManager 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: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PrivateCompany.java 9 Oct 2009 20:20:34 -0000 1.23 --- PrivateCompany.java 30 Oct 2009 21:53:03 -0000 1.24 *************** *** 111,115 **** } ! public void finishConfiguration (GameManager gameManager) {} /** Initialisation, to be called directly after instantiation (cloning) */ --- 111,121 ---- } ! public void finishConfiguration (GameManager gameManager) ! throws ConfigurationException { ! ! for (SpecialPropertyI sp : specialProperties) { ! sp.finishConfiguration(gameManager); ! } ! } /** Initialisation, to be called directly after instantiation (cloning) */ Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** GameManager.java 29 Oct 2009 19:41:29 -0000 1.63 --- GameManager.java 30 Oct 2009 21:53:03 -0000 1.64 *************** *** 52,55 **** --- 52,56 ---- protected Bank bank; + protected String gameName; protected Map<String, String> gameOptions; *************** *** 129,133 **** */ protected static final String GM_KEY = "01"; ! protected static final String GM_NAME = "GameManager"; /** --- 130,134 ---- */ protected static final String GM_KEY = "01"; ! public static final String GM_NAME = "GameManager"; /** *************** *** 193,198 **** throw new ConfigurationException( "No Game tag specified in GameManager tag"); ! name = gameTag.getAttributeAsString("name"); ! if (name == null) throw new ConfigurationException("No name specified in Game tag"); --- 194,199 ---- throw new ConfigurationException( "No Game tag specified in GameManager tag"); ! gameName = gameTag.getAttributeAsString("name"); ! if (gameName == null) throw new ConfigurationException("No name specified in Game tag"); *************** *** 378,382 **** * @see rails.game.GameManagerI#startGame(rails.game.PlayerManager, rails.game.CompanyManagerI, rails.game.PhaseManager) */ ! public void init(PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, --- 379,384 ---- * @see rails.game.GameManagerI#startGame(rails.game.PlayerManager, rails.game.CompanyManagerI, rails.game.PhaseManager) */ ! public void init(String gameName, ! PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, *************** *** 386,389 **** --- 388,392 ---- TileManager tileManager, Bank bank) { + this.gameName = gameName; this.playerManager = playerManager; this.companyManager = companyManager; *************** *** 764,768 **** oos.writeObject(saveFileVersionID); oos.writeObject(name); ! oos.writeObject(Game.getGameOptions()); oos.writeObject(playerNames); oos.writeObject(executedActions); --- 767,771 ---- oos.writeObject(saveFileVersionID); oos.writeObject(name); ! oos.writeObject(gameOptions); oos.writeObject(playerNames); oos.writeObject(executedActions); *************** *** 997,1014 **** } - /* (non-Javadoc) - * @see rails.game.GameManagerI#getCurrentPhase() - */ public PhaseI getCurrentPhase() { return phaseManager.getCurrentPhase(); } - /* (non-Javadoc) - * @see rails.game.GameManagerI#getPhaseManager() - */ public PhaseManager getPhaseManager() { return phaseManager; } public PlayerManager getPlayerManager() { return playerManager; --- 1000,1015 ---- } public PhaseI getCurrentPhase() { return phaseManager.getCurrentPhase(); } public PhaseManager getPhaseManager() { return phaseManager; } + public String getGameName () { + return gameName; + } + public PlayerManager getPlayerManager() { return playerManager; Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Game.java 29 Oct 2009 19:41:29 -0000 1.33 --- Game.java 30 Oct 2009 21:53:03 -0000 1.34 *************** *** 14,22 **** public static final String version = "1.0.5"; - /** - * Game is a singleton class. - */ - protected static Game instance; - /** The component Manager */ protected ComponentManager componentManager; --- 14,17 ---- *************** *** 30,36 **** protected TileManager tileManager; protected Bank bank; - // protected ArrayList companyList; protected String name; - // protected Element componentManagerElement; protected Tag componentManagerTag; protected static String GAME_XML_FILE = "Game.xml"; --- 25,29 ---- *************** *** 46,51 **** public Game(String name, List<String> players, Map<String, String> options) { - instance = this; - this.name = name; this.gameOptions = options; --- 39,42 ---- *************** *** 64,68 **** directories.add("data/" + name); - //playerManager = new PlayerManager(players); this.players = players; } --- 55,58 ---- *************** *** 78,84 **** try { // Have the ComponentManager work through the other rails.game files - // componentManagerTag = XmlUtils.findElementInFile(GAME_XML_FILE, - // directories, - // ComponentManager.ELEMENT_ID); componentManagerTag = Tag.findTopTagInFile(GAME_XML_FILE, directories, --- 68,71 ---- *************** *** 169,173 **** */ playerManager.setPlayers(players, bank); ! gameManager.init(playerManager, companyManager, phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); --- 156,160 ---- */ playerManager.setPlayers(players, bank); ! gameManager.init(name, playerManager, companyManager, phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); *************** *** 178,184 **** mapManager.finishConfiguration(gameManager); bank.finishConfiguration(gameManager); - //StartPacket.init(); - //companyManager.initCompanies(gameManager); stockMarket.finishConfiguration(gameManager); } catch (Exception e) { String message = --- 165,170 ---- mapManager.finishConfiguration(gameManager); bank.finishConfiguration(gameManager); stockMarket.finishConfiguration(gameManager); + tileManager.finishConfiguration(gameManager); } catch (Exception e) { String message = *************** *** 230,234 **** log.debug("Starting to execute loaded actions"); ! instance.gameManager.processOnReload(executedActions); return game; --- 216,220 ---- log.debug("Starting to execute loaded actions"); ! game.getGameManager().processOnReload(executedActions); return game; *************** *** 244,271 **** /*----- Getters -----*/ - public static String getGameOption(String optionName) { - return instance.gameOptions.get(optionName); - } - - public static Map<String, String> getGameOptions() { - return instance.gameOptions; - } - - /** - * @return The company manager - */ - public static StockMarketI getStockMarket() { - return instance.stockMarket; - } - public GameManagerI getGameManager() { return gameManager; } - /** - * @return Game Name - */ - public static String getName() { - return instance.name; - } } --- 230,236 ---- Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CompanyManager.java 9 Oct 2009 20:20:34 -0000 1.16 --- CompanyManager.java 30 Oct 2009 21:53:03 -0000 1.17 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void finishConfiguration (GameManager gameManager) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.finishConfiguration(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void finishConfiguration (GameManager gameManager) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.finishConfiguration(gameManager); } for (PrivateCompanyI comp : lPrivateCompanies) { comp.finishConfiguration(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file Index: TileI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileI.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** TileI.java 24 Dec 2008 14:52:47 -0000 1.15 --- TileI.java 30 Oct 2009 21:53:03 -0000 1.16 *************** *** 11,14 **** --- 11,17 ---- public void configureFromXML(Tag se, Tag te) throws ConfigurationException; + public void finishConfiguration (TileManager tileManager) + throws ConfigurationException; + public String getColourName(); Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ComponentManager.java 29 Oct 2009 19:41:29 -0000 1.13 --- ComponentManager.java 30 Oct 2009 21:53:03 -0000 1.14 *************** *** 64,67 **** --- 64,68 ---- instance = this; this.gameOptions = gameOptions; + log.debug("+++GameOptions="+gameOptions); ComponentManager.gameName = gameName; *************** *** 70,74 **** String compName = component.getAttributeAsString("name"); log.debug("Found component " + compName); ! if (compName.equalsIgnoreCase("GameManager")) { configureComponent(component); break; --- 71,75 ---- String compName = component.getAttributeAsString("name"); log.debug("Found component " + compName); ! if (compName.equalsIgnoreCase(GameManager.GM_NAME)) { configureComponent(component); break; *************** *** 79,87 **** public synchronized void finishPreparation() throws ConfigurationException { ! for (Tag component : componentTags) { ! String compName = component.getAttributeAsString("name"); ! if (compName.equalsIgnoreCase("GameManager")) continue; log.debug("Found component " + compName); ! configureComponent(component); } } --- 80,89 ---- public synchronized void finishPreparation() throws ConfigurationException { ! for (Tag componentTag : componentTags) { ! componentTag.setGameOptions(gameOptions); ! String compName = componentTag.getAttributeAsString("name"); ! if (compName.equalsIgnoreCase(GameManager.GM_NAME)) continue; log.debug("Found component " + compName); ! configureComponent(componentTag); } } *************** *** 138,141 **** --- 140,146 ---- } + log.debug("+++ Before configuring" +name+": gameOptions="+gameOptions); + configElement.setGameOptions(gameOptions); + try { component.configureFromXML(configElement); Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GameManagerI.java 29 Oct 2009 19:41:28 -0000 1.19 --- GameManagerI.java 30 Oct 2009 21:53:03 -0000 1.20 *************** *** 16,20 **** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ ! public abstract void init(PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, --- 16,20 ---- * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ ! public abstract void init(String gameName, PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, *************** *** 149,156 **** --- 149,158 ---- public abstract TrainManager getTrainManager (); public PlayerManager getPlayerManager(); + public TileManager getTileManager(); public StockMarketI getStockMarket(); public MapManager getMapManager(); public Bank getBank (); + public String getGameName (); public String getGameOption (String key); |
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/ui/swing Modified Files: RemainingTilesWindow.java StockChart.java ORUIManager.java StartRoundWindow.java UpgradesPanel.java GameUIManager.java Log Message: More rationalising of static method usage Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ORUIManager.java 23 Sep 2009 21:38:57 -0000 1.29 --- ORUIManager.java 30 Oct 2009 21:53:04 -0000 1.30 *************** *** 513,517 **** GUIHex hex = map.getSelectedHex(); ! TileI tile = TileManager.get().getTile(tileId); // Check if the new tile must be connected to some other track --- 513,517 ---- GUIHex hex = map.getSelectedHex(); ! TileI tile = gameUIManager.getGameManager().getTileManager().getTile(tileId); // Check if the new tile must be connected to some other track Index: UpgradesPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/UpgradesPanel.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** UpgradesPanel.java 11 Sep 2009 19:26:44 -0000 1.17 --- UpgradesPanel.java 30 Oct 2009 21:53:04 -0000 1.18 *************** *** 343,347 **** protected void setToolTip() { ! TileI currentTile = TileManager.get().getTile(internalId); StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or --- 343,347 ---- protected void setToolTip() { ! TileI currentTile = orUIManager.getGameUIManager().getGameManager().getTileManager().getTile(internalId); StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or Index: StockChart.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StockChart.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StockChart.java 3 Dec 2008 20:16:39 -0000 1.6 --- StockChart.java 30 Oct 2009 21:53:03 -0000 1.7 *************** *** 7,11 **** import javax.swing.*; ! import rails.game.*; import rails.ui.swing.elements.GUIStockSpace; --- 7,12 ---- import javax.swing.*; ! import rails.game.GameManager; ! import rails.game.StockSpaceI; import rails.ui.swing.elements.GUIStockSpace; *************** *** 22,28 **** private GridBagConstraints gc; private StockSpaceI[][] market; ! public StockChart() { super(); initialize(); --- 23,31 ---- private GridBagConstraints gc; private StockSpaceI[][] market; + private GameUIManager gameUIManager; ! public StockChart(GameUIManager gameUIManager) { super(); + this.gameUIManager = gameUIManager; initialize(); *************** *** 59,63 **** gc = new GridBagConstraints(); ! market = Game.getStockMarket().getStockChart(); gc.gridx = 0; --- 62,66 ---- gc = new GridBagConstraints(); ! market = gameUIManager.getGameManager().getStockMarket().getStockChart(); gc.gridx = 0; Index: RemainingTilesWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/RemainingTilesWindow.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RemainingTilesWindow.java 9 Oct 2009 19:03:49 -0000 1.5 --- RemainingTilesWindow.java 30 Oct 2009 21:53:03 -0000 1.6 *************** *** 58,62 **** private void init() { ! TileManager tmgr = TileManager.get(); TileI tile; Field label; --- 58,62 ---- private void init() { ! TileManager tmgr = gameUIManager.getGameManager().getTileManager(); TileI tile; Field label; Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GameUIManager.java 25 Sep 2009 19:13:01 -0000 1.19 --- GameUIManager.java 30 Oct 2009 21:53:04 -0000 1.20 *************** *** 53,61 **** public GameUIManager() { ! } ! public void init (GameSetupWindow gameSetupWindow) { ! instance = this; this.gameSetupWindow = gameSetupWindow; --- 53,61 ---- public GameUIManager() { ! } ! public void init (GameSetupWindow gameSetupWindow) { ! instance = this; this.gameSetupWindow = gameSetupWindow; *************** *** 82,86 **** gameManager = GameManager.getInstance(); imageLoader = new ImageLoader(); ! stockChart = new StockChart(); reportWindow = new ReportWindow(gameManager); orWindow = new ORWindow(this); --- 82,86 ---- gameManager = GameManager.getInstance(); imageLoader = new ImageLoader(); ! stockChart = new StockChart(this); reportWindow = new ReportWindow(gameManager); orWindow = new ORWindow(this); *************** *** 101,105 **** } ! public void startLoadedGame() { gameUIInit(); --- 101,105 ---- } ! public void startLoadedGame() { gameUIInit(); *************** *** 113,117 **** lastAction = action; if (action != null) action.setActed(); ! log.debug("==Passing to server: " + action); --- 113,117 ---- lastAction = action; if (action != null) action.setActed(); ! log.debug("==Passing to server: " + action); *************** *** 120,127 **** action.setPlayerName(player.getName()); } ! // Process the action on the server boolean result = gameManager.process(action); ! // Follow-up the result log.debug("==Result from server: " + result); --- 120,127 ---- action.setPlayerName(player.getName()); } ! // Process the action on the server boolean result = gameManager.process(action); ! // Follow-up the result log.debug("==Result from server: " + result); *************** *** 176,183 **** * Actual round type is the class of the active Round subclass. * Visible round type is the class of one of the three 'basic' ! * round types: Start, Stock or Operating. * The latter type determines what UI windows will become visible. */ ! /* Process actual round type changes */ if (previousRound == null || !previousRound.equals(currentRound)) { --- 176,183 ---- * Actual round type is the class of the active Round subclass. * Visible round type is the class of one of the three 'basic' ! * round types: Start, Stock or Operating. * The latter type determines what UI windows will become visible. */ ! /* Process actual round type changes */ if (previousRound == null || !previousRound.equals(currentRound)) { *************** *** 297,304 **** } } ! ! /** Stub, to be overridden in subclasses for special round types */ protected void updateStatus(ActionPerformer activeWindow) { ! } --- 297,304 ---- } } ! ! /** Stub, to be overridden in subclasses for special round types */ protected void updateStatus(ActionPerformer activeWindow) { ! } *************** *** 419,423 **** } else { filename = ! saveDirectory + "/" + Game.getName() + "_" + saveDateTimeFormat.format(new Date()) + "." + saveExtension; --- 419,423 ---- } else { filename = ! saveDirectory + "/" + gameManager.getGameName() + "_" + saveDateTimeFormat.format(new Date()) + "." + saveExtension; Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** StartRoundWindow.java 9 Oct 2009 20:20:34 -0000 1.31 --- StartRoundWindow.java 30 Oct 2009 21:53:04 -0000 1.32 *************** *** 574,578 **** if (activeItem.hasSharePriceToSet()) { String compName = activeItem.getCompanyToSetPriceFor(); ! StockMarketI stockMarket = Game.getStockMarket(); // Get a sorted prices List --- 574,578 ---- if (activeItem.hasSharePriceToSet()) { String compName = activeItem.getCompanyToSetPriceFor(); ! StockMarketI stockMarket = gameUIManager.getGameManager().getStockMarket(); // Get a sorted prices List |