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: Stefan F. <ste...@us...> - 2010-02-06 14:57:40
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32248/rails/game Modified Files: PrivateCompany.java Log Message: Check for null in preventClosingConditions (just in case) Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** PrivateCompany.java 5 Feb 2010 19:55:44 -0000 1.34 --- PrivateCompany.java 6 Feb 2010 14:57:31 -0000 1.35 *************** *** 243,247 **** public boolean isCloseable() { ! if (preventClosingConditions.isEmpty()) return true; if (preventClosingConditions.contains("doesNotClose")) { --- 243,247 ---- public boolean isCloseable() { ! if ((preventClosingConditions == null) || preventClosingConditions.isEmpty()) return true; if (preventClosingConditions.contains("doesNotClose")) { *************** *** 256,259 **** --- 256,260 ---- return true; } + public List<String> getPreventClosingConditions() { return preventClosingConditions; |
From: Stefan F. <ste...@us...> - 2010-02-06 14:56:22
|
Update of /cvsroot/rails/18xx/data/1889 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32163/data/1889 Modified Files: Game.xml Log Message: 1889 stockround sequence corrected (SellBuyOrBuySell) Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1889/Game.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Game.xml 4 Feb 2010 22:23:02 -0000 1.3 --- Game.xml 6 Feb 2010 14:56:13 -0000 1.4 *************** *** 27,31 **** </PlayerShareLimit> <BankPoolLimit percentage="50"/> ! <StockRound> <NoSaleInFirstSR/> </StockRound> --- 27,31 ---- </PlayerShareLimit> <BankPoolLimit percentage="50"/> ! <StockRound sequence="SellBuyOrBuySell"> <NoSaleInFirstSR/> </StockRound> |
From: Erik V. <ev...@us...> - 2010-02-05 19:59:21
|
Update of /cvsroot/rails/18xx In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6363 Modified Files: LocalisedText.properties Log Message: Added State (for 1835) Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** LocalisedText.properties 4 Feb 2010 21:27:59 -0000 1.106 --- LocalisedText.properties 5 Feb 2010 19:59:12 -0000 1.107 *************** *** 422,425 **** --- 422,426 ---- StartsPhase=Starts phase {0} StartStockRound=\n==================\nStart of Stock Round {0}\n================== + State=State Status_Unavailable=Currently unavailable Status_Biddable=Click to bid on this item |
From: Erik V. <ev...@us...> - 2010-02-05 19:59:00
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6242/rails/game Modified Files: StockRound.java Log Message: Force selling excess shares Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** StockRound.java 31 Jan 2010 22:22:28 -0000 1.58 --- StockRound.java 5 Feb 2010 19:58:45 -0000 1.59 *************** *** 95,103 **** public boolean setPossibleActions() { ! boolean passAllowed = true; ! ! setBuyableCerts(); setSellableShares(); setSpecialActions(); --- 95,107 ---- public boolean setPossibleActions() { ! boolean passAllowed = false; setSellableShares(); + + if (isPlayerOverLimits (currentPlayer)) return true; + + passAllowed = true; + + setBuyableCerts(); setSpecialActions(); |
From: Erik V. <ev...@us...> - 2010-02-05 19:58:26
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6144/rails/game Modified Files: StartRound_1835.java Log Message: Fixed hung state when start packet not sold out Index: StartRound_1835.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1835.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StartRound_1835.java 31 Jan 2010 22:22:28 -0000 1.23 --- StartRound_1835.java 5 Feb 2010 19:58:18 -0000 1.24 *************** *** 55,65 **** } - /** - * Get a list of items that may be bought immediately. <p> In an 1835-style - * auction this method will usually return several items. - * - * @return An array of start items that can be bought. - */ - // public StartItem[] getBuyableItems() {return null;} @Override public boolean setPossibleActions() { --- 55,58 ---- *************** *** 131,139 **** DisplayBuffer.add(message); numPasses.add(1); ! if (numPasses.intValue() == numPlayers) { /* * No-one has enough cash left to buy anything, so close the * Start Round. */ return false; } --- 124,139 ---- DisplayBuffer.add(message); numPasses.add(1); ! if (numPasses.intValue() >= numPlayers) { /* * No-one has enough cash left to buy anything, so close the * Start Round. */ + numPasses.set(0); + finishRound(); + + // This code may be called recursively. + // Jump out as soon as we have something to do + if (!possibleActions.isEmpty()) break; + return false; } |
From: Erik V. <ev...@us...> - 2010-02-05 19:57:40
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5928/rails/game Modified Files: StartRound_1830.java Log Message: Minor cleanup Index: StartRound_1830.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1830.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** StartRound_1830.java 31 Jan 2010 22:22:28 -0000 1.29 --- StartRound_1830.java 5 Feb 2010 19:57:26 -0000 1.30 *************** *** 61,65 **** possibleActions.clear(); - //if (startPacket.areAllSold()) return false; // SHOULDN'T GET HERE THEN if (currentPlayer == startPlayer) ReportBuffer.add(""); --- 61,64 ---- *************** *** 164,168 **** possibleActions.add(new NullAction(NullAction.PASS)); } ! return true; } --- 163,167 ---- possibleActions.add(new NullAction(NullAction.PASS)); } ! return true; } |
From: Erik V. <ev...@us...> - 2010-02-05 19:57:15
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5888/rails/game Modified Files: Round.java Log Message: Added space before financials report Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Round.java 31 Jan 2010 22:22:28 -0000 1.37 --- Round.java 5 Feb 2010 19:57:06 -0000 1.38 *************** *** 359,363 **** protected void finishRound() { ! // TEMPORARY? Report financials for (PublicCompanyI c : companyManager.getAllPublicCompanies()) { if (c.hasFloated() && !c.isClosed()) { --- 359,364 ---- protected void finishRound() { ! // Report financials ! ReportBuffer.add(""); for (PublicCompanyI c : companyManager.getAllPublicCompanies()) { if (c.hasFloated() && !c.isClosed()) { |
From: Erik V. <ev...@us...> - 2010-02-05 19:56:50
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5762/rails/game Modified Files: PublicCompany.java Log Message: Moved creating home and destination info text to allow including the city name Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** PublicCompany.java 4 Feb 2010 21:27:58 -0000 1.82 --- PublicCompany.java 5 Feb 2010 19:56:32 -0000 1.83 *************** *** 294,298 **** homeHexName = homeBaseTag.getAttributeAsString("hex"); homeCityNumber = homeBaseTag.getAttributeAsInteger("city", 1); - infoText += "<br>Home=" + homeHexName; } --- 294,297 ---- *************** *** 300,304 **** if (destinationTag != null) { destinationHexName = destinationTag.getAttributeAsString("hex"); - infoText += " Destination="+destinationHexName; } --- 299,302 ---- *************** *** 683,686 **** --- 681,685 ---- + " for company " + name); } + infoText += "<br>Home: " + homeHex.getInfo(); } *************** *** 694,697 **** --- 693,697 ---- + " for company " + name); } + infoText += "<br>Destination: "+destinationHex.getInfo(); } |
From: Erik V. <ev...@us...> - 2010-02-05 19:55:52
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5638/rails/game Modified Files: PrivateCompany.java Log Message: Minor change Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** PrivateCompany.java 4 Feb 2010 21:27:58 -0000 1.33 --- PrivateCompany.java 5 Feb 2010 19:55:44 -0000 1.34 *************** *** 56,60 **** blockedHexesString = blockedTag.getAttributeAsString("hex"); ! infoText += "<br>Blocking "+blockedHexesString; } --- 56,60 ---- blockedHexesString = blockedTag.getAttributeAsString("hex"); ! infoText += "<br>Blocking: "+blockedHexesString; } *************** *** 116,120 **** for (Tag preventTag: preventTags) { String conditionText = preventTag.getAttributeAsString("condition"); ! if (conditionText != null) { preventClosingConditions.add(conditionText); } --- 116,120 ---- for (Tag preventTag: preventTags) { String conditionText = preventTag.getAttributeAsString("condition"); ! if (conditionText != null) { preventClosingConditions.add(conditionText); } *************** *** 195,199 **** } // end: sfy 1889 ! /** * @return Phase this Private closes --- 195,199 ---- } // end: sfy 1889 ! /** * @return Phase this Private closes *************** *** 242,248 **** /* start sfy 1889 */ public boolean isCloseable() { ! if (preventClosingConditions.isEmpty()) return true; ! if (preventClosingConditions.contains("doesNotClose")) { log.debug("Private Company "+getName()+" does not close (unconditional)."); --- 242,248 ---- /* start sfy 1889 */ public boolean isCloseable() { ! if (preventClosingConditions.isEmpty()) return true; ! if (preventClosingConditions.contains("doesNotClose")) { log.debug("Private Company "+getName()+" does not close (unconditional)."); *************** *** 260,264 **** } /* end sfy 1889 */ ! /** * @param i --- 260,264 ---- } /* end sfy 1889 */ ! /** * @param i |
From: Erik V. <ev...@us...> - 2010-02-05 19:55:20
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5423/rails/game Modified Files: MapHex.java Log Message: Added fixed infoText. To include city name is known. Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** MapHex.java 3 Feb 2010 20:16:40 -0000 1.35 --- MapHex.java 5 Feb 2010 19:55:01 -0000 1.36 *************** *** 12,17 **** import rails.game.move.Moveable; import rails.game.move.TileMove; ! import rails.util.LocalText; ! import rails.util.Tag; /** --- 12,16 ---- import rails.game.move.Moveable; import rails.game.move.TileMove; ! import rails.util.*; /** *************** *** 64,67 **** --- 63,67 ---- protected int[] tileCost; protected String cityName; + protected String infoText; /** Neighbouring hexes <i>to which track may be laid</i>. */ *************** *** 107,111 **** Pattern namePattern = Pattern.compile("(\\D)(\\d+)"); ! name = tag.getAttributeAsString("name"); Matcher m = namePattern.matcher(name); if (!m.matches()) { --- 107,111 ---- Pattern namePattern = Pattern.compile("(\\D)(\\d+)"); ! infoText = name = tag.getAttributeAsString("name"); Matcher m = namePattern.matcher(name); if (!m.matches()) { *************** *** 168,171 **** --- 168,174 ---- // City name cityName = tag.getAttributeAsString("city", ""); + if (Util.hasValue(cityName)) { + infoText += " " + cityName; + } } *************** *** 927,930 **** --- 930,937 ---- } + public String getInfo () { + return infoText; + } + public boolean equals(MapHex hex) { if (hex.getName().equals(getName()) && hex.row == row |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:40
|
Update of /cvsroot/rails/18xx/data/18Kaas In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/data/18Kaas Modified Files: Game.xml Log Message: Removed incorrect 'First' from D-train exchange-related words Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/18Kaas/Game.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Game.xml 23 Jan 2010 23:02:05 -0000 1.11 --- Game.xml 4 Feb 2010 22:22:59 -0000 1.12 *************** *** 60,64 **** <Train name="D" majorStops="99" cost="1100" amount="6" startPhase="D" rustedTrain="4"> ! <ExchangeFirst cost="800"/> </Train> </Component> --- 60,64 ---- <Train name="D" majorStops="99" cost="1100" amount="6" startPhase="D" rustedTrain="4"> ! <Exchange cost="800"/> </Train> </Component> |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:13
|
Update of /cvsroot/rails/18xx/data/1889 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/data/1889 Modified Files: Game.xml Log Message: Removed incorrect 'First' from D-train exchange-related words Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1889/Game.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Game.xml 3 Feb 2010 20:05:42 -0000 1.2 --- Game.xml 4 Feb 2010 22:23:02 -0000 1.3 *************** *** 94,98 **** <Attributes amount="6"/> </IfOption> ! <ExchangeFirst cost="800"/> </Train> </Component> --- 94,98 ---- <Attributes amount="6"/> </IfOption> ! <Exchange cost="800"/> </Train> </Component> |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:11
|
Update of /cvsroot/rails/18xx/data/18AL In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/data/18AL Modified Files: Game.xml Log Message: Removed incorrect 'First' from D-train exchange-related words Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/18AL/Game.xml,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Game.xml 31 Jan 2010 22:16:02 -0000 1.27 --- Game.xml 4 Feb 2010 22:22:56 -0000 1.28 *************** *** 70,74 **** <Reach countTowns="no"/> <Score cities="double"/> ! <ExchangeFirst cost="800"/> </Train> </Component> --- 70,74 ---- <Reach countTowns="no"/> <Score cities="double"/> ! <Exchange cost="800"/> </Train> </Component> |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:10
|
Update of /cvsroot/rails/18xx/data/1856 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/data/1856 Modified Files: Game.xml Log Message: Removed incorrect 'First' from D-train exchange-related words Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1856/Game.xml,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Game.xml 31 Jan 2010 22:15:58 -0000 1.34 --- Game.xml 4 Feb 2010 22:23:01 -0000 1.35 *************** *** 54,58 **** <Train name="D" majorStops="99" cost="1100" amount="-1" startPhase="6" rustedTrain="4"> ! <ExchangeFirst cost="750"/> </Train> </Component> --- 54,58 ---- <Train name="D" majorStops="99" cost="1100" amount="-1" startPhase="6" rustedTrain="4"> ! <Exchange cost="750"/> </Train> </Component> |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:09
|
Update of /cvsroot/rails/18xx/data/1830 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/data/1830 Modified Files: Game.xml Log Message: Removed incorrect 'First' from D-train exchange-related words Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1830/Game.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Game.xml 23 Jan 2010 23:02:06 -0000 1.30 --- Game.xml 4 Feb 2010 22:23:01 -0000 1.31 *************** *** 97,101 **** <Attributes amount="6"/> </IfOption> ! <ExchangeFirst cost="800"/> </Train> </Component> --- 97,101 ---- <Attributes amount="6"/> </IfOption> ! <Exchange cost="800"/> </Train> </Component> |
From: Erik V. <ev...@us...> - 2010-02-04 22:23:09
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10994/rails/game Modified Files: TrainManager.java TrainTypeI.java OperatingRound.java TrainType.java Log Message: Removed incorrect 'First' from D-train exchange-related words Index: TrainTypeI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainTypeI.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TrainTypeI.java 31 Jan 2010 22:22:28 -0000 1.12 --- TrainTypeI.java 4 Feb 2010 22:22:59 -0000 1.13 *************** *** 32,36 **** * @return Returns the firstExchangeCost. */ ! public int getFirstExchangeCost(); /** --- 32,36 ---- * @return Returns the firstExchangeCost. */ ! public int getExchangeCost(); /** Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** OperatingRound.java 3 Feb 2010 20:16:40 -0000 1.96 --- OperatingRound.java 4 Feb 2010 22:23:01 -0000 1.97 *************** *** 2114,2118 **** // Even at train limit, exchange is allowed (per 1856) if (train.canBeExchanged() && hasTrains) { ! cost = train.getType().getFirstExchangeCost(); if (cost <= cash) { List<TrainI> exchangeableTrains = --- 2114,2118 ---- // Even at train limit, exchange is allowed (per 1856) if (train.canBeExchanged() && hasTrains) { ! cost = train.getType().getExchangeCost(); if (cost <= cash) { List<TrainI> exchangeableTrains = Index: TrainType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainType.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** TrainType.java 4 Feb 2010 22:15:56 -0000 1.29 --- TrainType.java 4 Feb 2010 22:23:01 -0000 1.30 *************** *** 41,45 **** protected int cityScoreFactor = 1; ! protected boolean firstCanBeExchanged = false; protected IntegerState numberBoughtFromIPO; --- 41,45 ---- protected int cityScoreFactor = 1; ! protected boolean canBeExchanged = false; protected IntegerState numberBoughtFromIPO; *************** *** 54,58 **** protected int majorStops; protected int minorStops; ! protected int firstExchangeCost; protected String startedPhaseName = null; --- 54,58 ---- protected int majorStops; protected int minorStops; ! protected int exchangeCost; protected String startedPhaseName = null; *************** *** 181,188 **** // Exchangeable ! Tag swapTag = tag.getChild("ExchangeFirst"); if (swapTag != null) { ! firstExchangeCost = swapTag.getAttributeAsInteger("cost", 0); ! firstCanBeExchanged = (firstExchangeCost > 0); } --- 181,188 ---- // Exchangeable ! Tag swapTag = tag.getChild("Exchange"); if (swapTag != null) { ! exchangeCost = swapTag.getAttributeAsInteger("cost", 0); ! canBeExchanged = (exchangeCost > 0); } *************** *** 293,297 **** */ public boolean nextCanBeExchanged() { ! return firstCanBeExchanged/* && numberBoughtFromIPO.intValue() == 0*/; } --- 293,297 ---- */ public boolean nextCanBeExchanged() { ! return canBeExchanged/* && numberBoughtFromIPO.intValue() == 0*/; } *************** *** 307,312 **** * @return Returns the firstExchangeCost. */ ! public int getFirstExchangeCost() { ! return firstExchangeCost; } --- 307,312 ---- * @return Returns the firstExchangeCost. */ ! public int getExchangeCost() { ! return exchangeCost; } Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TrainManager.java 31 Jan 2010 22:22:28 -0000 1.26 --- TrainManager.java 4 Feb 2010 22:22:59 -0000 1.27 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected Map<String, TrainI> trainMap = new HashMap<String, TrainI>(); // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special GameManager.getInstance().setGameParameter(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS, rulesTag.getChild("FaceValueIfDifferentPresidents") != null); } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); for (TrainTypeI type : lTrainTypes) { type.finishConfiguration(gameManager); } // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } public void addTrain (String uniqueID, TrainI train) { trainMap.put(uniqueID, train); } public TrainI getTrainByUniqueId(String id) { return trainMap.get(id); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public String getTrainCostOverview() { StringBuffer b = new StringBuffer(); for (TrainTypeI type : lTrainTypes) { if (b.length() > 1) b.append(" "); b.append(type.getName()).append(":").append(Bank.format(type.getCost())); if (type.getFirstExchangeCost() > 0) { b.append("(").append(Bank.format(type.getFirstExchangeCost())).append(")"); } } return b.toString(); } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected Map<String, TrainI> trainMap = new HashMap<String, TrainI>(); // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special GameManager.getInstance().setGameParameter(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS, rulesTag.getChild("FaceValueIfDifferentPresidents") != null); } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); for (TrainTypeI type : lTrainTypes) { type.finishConfiguration(gameManager); } // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } public void addTrain (String uniqueID, TrainI train) { trainMap.put(uniqueID, train); } public TrainI getTrainByUniqueId(String id) { return trainMap.get(id); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public String getTrainCostOverview() { StringBuffer b = new StringBuffer(); for (TrainTypeI type : lTrainTypes) { if (b.length() > 1) b.append(" "); b.append(type.getName()).append(":").append(Bank.format(type.getCost())); if (type.getExchangeCost() > 0) { b.append("(").append(Bank.format(type.getExchangeCost())).append(")"); } } return b.toString(); } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } } \ No newline at end of file |
From: Erik V. <ev...@us...> - 2010-02-04 22:16:12
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6921/rails/game Modified Files: TrainType.java Log Message: All D-trains can be bought via an exchange, not just the first one. Index: TrainType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainType.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** TrainType.java 31 Jan 2010 22:22:28 -0000 1.28 --- TrainType.java 4 Feb 2010 22:15:56 -0000 1.29 *************** *** 293,297 **** */ public boolean nextCanBeExchanged() { ! return firstCanBeExchanged && numberBoughtFromIPO.intValue() == 0; } --- 293,297 ---- */ public boolean nextCanBeExchanged() { ! return firstCanBeExchanged/* && numberBoughtFromIPO.intValue() == 0*/; } |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx/data/1830 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192/data/1830 Modified Files: CompanyManager.xml Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: CompanyManager.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1830/CompanyManager.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** CompanyManager.xml 3 Feb 2010 20:28:23 -0000 1.32 --- CompanyManager.xml 4 Feb 2010 21:27:59 -0000 1.33 *************** *** 19,27 **** </CompanyType> <Company name="SVNRR" type="Private" basePrice="20" revenue="5" ! longName="Schuylkill Valley Navigation & Railroad Company"> <Blocking hex="G15"/> </Company> <Company name="C&StL" type="Private" basePrice="40" revenue="10" ! longName="Champlain & St.Lawrence"> <Blocking hex="B20"/> <SpecialProperties> --- 19,27 ---- </CompanyType> <Company name="SVNRR" type="Private" basePrice="20" revenue="5" ! longname="Schuylkill Valley Navigation & Railroad Company"> <Blocking hex="G15"/> </Company> <Company name="C&StL" type="Private" basePrice="40" revenue="10" ! longname="Champlain & St.Lawrence"> <Blocking hex="B20"/> <SpecialProperties> *************** *** 32,36 **** </Company> <Company name="D&H" type="Private" basePrice="70" revenue="15" ! longName="Delaware & Hudson"> <Blocking hex="F16"/> <SpecialProperties> --- 32,36 ---- </Company> <Company name="D&H" type="Private" basePrice="70" revenue="15" ! longname="Delaware & Hudson"> <Blocking hex="F16"/> <SpecialProperties> *************** *** 44,48 **** </Company> <Company name="M&H" type="Private" basePrice="110" revenue="20" ! longName="Mohawk & Hudson"> <Blocking hex="D18"/> <SpecialProperties> --- 44,48 ---- </Company> <Company name="M&H" type="Private" basePrice="110" revenue="20" ! longname="Mohawk & Hudson"> <Blocking hex="D18"/> <SpecialProperties> *************** *** 53,62 **** </Company> <Company name="C&A" type="Private" basePrice="160" revenue="25" ! longName="Camden & Amboy"> <Info key="ComesWithCertificate" parm="PRR,10"/> <Blocking hex="H18"/> </Company> <Company name="B&O" type="Private" basePrice="220" revenue="30" ! longName="Baltimore & Ohio"> <Info key="ComesWithPresidency" parm="B&O,20"/> <Blocking hex="I13,I15"/> --- 53,62 ---- </Company> <Company name="C&A" type="Private" basePrice="160" revenue="25" ! longname="Camden & Amboy"> <Info key="ComesWithCertificate" parm="PRR,10"/> <Blocking hex="H18"/> </Company> <Company name="B&O" type="Private" basePrice="220" revenue="30" ! longname="Baltimore & Ohio"> <Info key="ComesWithPresidency" parm="B&O,20"/> <Blocking hex="I13,I15"/> *************** *** 65,91 **** <!-- Note two supported colour specification formats: RGB decimal with commas and RGB hexadecimal without commas --> ! <Company name="B&O" type="Public" tokens="3" fgColour="255,255,255" bgColour="0,0,255"> <FirstTrainCloses type="Private" name="B&O"/> <Home hex="I15"/> </Company> ! <Company name="PRR" type="Public" tokens="4" fgColour="FFFFFF" bgColour="008000"> <Home hex="H12"/> </Company> ! <Company name="NYNH" type="Public" tokens="2" fgColour="000000" bgColour="FF8000"> <Home hex="G19" city="2"/> </Company> ! <Company name="NYC" type="Public" tokens="4" fgColour="FFFFFF" bgColour="000000"> <Home hex="E19"/> </Company> ! <Company name="Erie" type="Public" tokens="3" fgColour="000000" bgColour="FFFF00"> ! <Home hex="E11" city="0"/> </Company> ! <Company name="B&M" type="Public" tokens="2" fgColour="000000" bgColour="60E060"> <Home hex="E23"/> </Company> ! <Company name="C&O" type="Public" tokens="3" fgColour="000000" bgColour="A0E0FF"> <Home hex="F6"/> </Company> ! <Company name="CPR" type="Public" tokens="4" fgColour="FFFFFF" bgColour="FF0000"> <Home hex="A19"/> </Company> --- 65,99 ---- <!-- Note two supported colour specification formats: RGB decimal with commas and RGB hexadecimal without commas --> ! <Company name="B&O" type="Public" tokens="3" fgColour="255,255,255" bgColour="0,0,255" ! longname="Baltimore & Ohio"> <FirstTrainCloses type="Private" name="B&O"/> <Home hex="I15"/> </Company> ! <Company name="PRR" type="Public" tokens="4" fgColour="FFFFFF" bgColour="008000" ! longname="Pennsylvania Railroad"> <Home hex="H12"/> </Company> ! <Company name="NYNH" type="Public" tokens="2" fgColour="000000" bgColour="FF8000" ! longname="New York, New Haven & Hartford"> <Home hex="G19" city="2"/> </Company> ! <Company name="NYC" type="Public" tokens="4" fgColour="FFFFFF" bgColour="000000" ! longname="New York Central"> <Home hex="E19"/> </Company> ! <Company name="Erie" type="Public" tokens="3" fgColour="000000" bgColour="FFFF00" ! longname="Erie Railroad"> ! <Home hex="E11"/> </Company> ! <Company name="B&M" type="Public" tokens="2" fgColour="000000" bgColour="60E060" ! longname="Boston & Maine"> <Home hex="E23"/> </Company> ! <Company name="C&O" type="Public" tokens="3" fgColour="000000" bgColour="A0E0FF" ! longname="Chesapeake & Ohio"> <Home hex="F6"/> </Company> ! <Company name="CPR" type="Public" tokens="4" fgColour="FFFFFF" bgColour="FF0000" ! longname="Canadian Pacific Railroad"> <Home hex="A19"/> </Company> |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192 Modified Files: LocalisedText.properties Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** LocalisedText.properties 3 Feb 2010 20:20:57 -0000 1.105 --- LocalisedText.properties 4 Feb 2010 21:27:59 -0000 1.106 *************** *** 93,96 **** --- 93,97 ---- ComesWithCertificate=Comes with {0} {1}% certificate ComesWithPresidency=Comes with {0} {1}% presidency certificate + Companies=Companies CompanyAlreadyStarted={0} has already been started. CompanyDiscardsTrain={0} discards a {1}-train to Pool *************** *** 244,247 **** --- 245,249 ---- LoadInterrupted=Load interrupted at this point, you can continue play from here LoansNotAllowed={0} may not take any loans + Major=Major MAP=Map MapWindowTitle=Rails: Map *************** *** 256,259 **** --- 258,262 ---- Message=Message MINIMUM_BID=<html>Min.<br>Bid</html> + Minor=Minor MinorCloses=Minor {0} is closed MonetiseTreasuryShares={0} puts 5 shares from Treasury in the Pool and receives {1} from the Bank *************** *** 344,347 **** --- 347,351 ---- PriceIsPaidTo=The price ({0}) is paid to {1} PRINT=Print + Private=Private PrivateBuyingIsNotAllowed=Private buying is not allowed PrivateCloses=Private {0} is closed *************** *** 349,352 **** --- 353,357 ---- PrivateIsAlreadyClosed=Private {0} is already closed PrivateIsNotOwnedByAPlayer=Private {0} is not owned by a player + Public=Public QUIT=Quit REDO=Redo |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192/rails/game Modified Files: Company.java CompanyType.java CompanyManager.java CompanyTypeI.java PublicCompany.java CompanyI.java CompanyManagerI.java PrivateCompany.java Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: CompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CompanyI.java 16 Jan 2010 21:16:14 -0000 1.6 --- CompanyI.java 4 Feb 2010 21:27:58 -0000 1.7 *************** *** 22,26 **** /** * Returns the name of the Company ! * * @return the name of the Company */ --- 22,26 ---- /** * Returns the name of the Company ! * * @return the name of the Company */ *************** *** 30,37 **** public String getInfoText(); ! /** * Returns the CompanyType of the Company ! * * @return the type of the Company */ --- 30,37 ---- public String getInfoText(); ! /** * Returns the CompanyType of the Company ! * * @return the type of the Company */ *************** *** 40,44 **** /** * Returns the type name of the Company ! * * @return type name */ --- 40,44 ---- /** * Returns the type name of the Company ! * * @return type name */ Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CompanyManager.java 31 Jan 2010 22:22:28 -0000 1.21 --- CompanyManager.java 4 Feb 2010 21:27:58 -0000 1.22 *************** *** 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()); protected GameManagerI gameManager; /* * 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 { gameManager = GameManager.getInstance(); /** 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); } } } // 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 --- 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, Map<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, Map<String, CompanyI>>(); /** A list of all company types */ private List<CompanyTypeI> lCompanyTypes = new ArrayList<CompanyTypeI>(); /** 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()); protected GameManagerI gameManager; /* * 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 { gameManager = GameManager.getInstance(); /** 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); lCompanyTypes.add(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>()); (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); } } } // 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 List<CompanyTypeI> getCompanyTypes() { return lCompanyTypes; } 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: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** PublicCompany.java 3 Feb 2010 20:16:40 -0000 1.81 --- PublicCompany.java 4 Feb 2010 21:27:58 -0000 1.82 *************** *** 262,265 **** --- 262,266 ---- longName = tag.getAttributeAsString("longname", name); + infoText = "<html>"+longName; /* Configure public company features */ *************** *** 293,296 **** --- 294,298 ---- homeHexName = homeBaseTag.getAttributeAsString("hex"); homeCityNumber = homeBaseTag.getAttributeAsInteger("city", 1); + infoText += "<br>Home=" + homeHexName; } *************** *** 298,301 **** --- 300,304 ---- if (destinationTag != null) { destinationHexName = destinationTag.getAttributeAsString("hex"); + infoText += " Destination="+destinationHexName; } *************** *** 319,322 **** --- 322,333 ---- } + // Extra info text(usually related to extra-share special properties) + Tag infoTag = tag.getChild("Info"); + if (infoTag != null) { + String infoKey = infoTag.getAttributeAsString("key"); + String[] infoParms = infoTag.getAttributeAsString("parm", "").split(","); + infoText += "<br>"+LocalText.getText(infoKey, (Object[])infoParms); + } + // TODO Normally set in the default train type. May be wrong place. // Ridiculous to reparse with each train type. *************** *** 559,563 **** /** Initialisation, to be called directly after instantiation (cloning) */ @Override ! public void init(String name, CompanyTypeI type) { super.init(name, type); --- 570,574 ---- /** Initialisation, to be called directly after instantiation (cloning) */ @Override ! public void init(String name, CompanyTypeI type) { super.init(name, type); Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** PrivateCompany.java 3 Feb 2010 05:37:54 -0000 1.32 --- PrivateCompany.java 4 Feb 2010 21:27:58 -0000 1.33 *************** *** 44,48 **** /* Configure private company features */ try { ! longName= tag.getAttributeAsString("longName", ""); basePrice = tag.getAttributeAsInteger("basePrice", 0); --- 44,49 ---- /* Configure private company features */ try { ! longName= tag.getAttributeAsString("longname", name); ! infoText = "<html>"+longName; basePrice = tag.getAttributeAsInteger("basePrice", 0); *************** *** 55,58 **** --- 56,60 ---- blockedHexesString = blockedTag.getAttributeAsString("hex"); + infoText += "<br>Blocking "+blockedHexesString; } *************** *** 74,80 **** specialProperties.add(sp); sp.configureFromXML(spTag); } } ! // Extra info text(usually related to extra-share special properties) Tag infoTag = tag.getChild("Info"); --- 76,83 ---- specialProperties.add(sp); sp.configureFromXML(spTag); + infoText += "<br>" + sp.getInfo(); } } ! // Extra info text(usually related to extra-share special properties) Tag infoTag = tag.getChild("Info"); *************** *** 82,86 **** String infoKey = infoTag.getAttributeAsString("key"); String[] infoParms = infoTag.getAttributeAsString("parm", "").split(","); ! infoText = LocalText.getText(infoKey, (Object[])infoParms); } --- 85,89 ---- String infoKey = infoTag.getAttributeAsString("key"); String[] infoParms = infoTag.getAttributeAsString("parm", "").split(","); ! infoText += "<br>"+LocalText.getText(infoKey, (Object[])infoParms); } *************** *** 115,119 **** if (conditionText != null) { preventClosingConditions.add(conditionText); ! } } } --- 118,122 ---- if (conditionText != null) { preventClosingConditions.add(conditionText); ! } } } *************** *** 147,155 **** /** Initialisation, to be called directly after instantiation (cloning) */ @Override ! public void init(String name, CompanyTypeI type) { super.init(name, type); specialProperties = new ArrayList<SpecialPropertyI>(); ! /* start sfy 1889 */ preventClosingConditions = new ArrayList<String>(); --- 150,158 ---- /** Initialisation, to be called directly after instantiation (cloning) */ @Override ! public void init(String name, CompanyTypeI type) { super.init(name, type); specialProperties = new ArrayList<SpecialPropertyI>(); ! /* start sfy 1889 */ preventClosingConditions = new ArrayList<String>(); *************** *** 180,184 **** return revenue; } ! // start: sfy 1889: new method public int getRevenueByPhase(PhaseI phase){ --- 183,187 ---- return revenue; } ! // start: sfy 1889: new method public int getRevenueByPhase(PhaseI phase){ *************** *** 213,220 **** public void setClosed() { ! if (isClosed()) return; if (!isCloseable()) return; /* sfy 1889 */ ! ! super.setClosed(); unblockHexes(); moveTo(GameManager.getInstance().getBank().getScrapHeap()); --- 216,223 ---- public void setClosed() { ! if (isClosed()) return; if (!isCloseable()) return; /* sfy 1889 */ ! ! super.setClosed(); unblockHexes(); moveTo(GameManager.getInstance().getBank().getScrapHeap()); *************** *** 222,226 **** // For 1856: buyable tokens still owned by the private will now ! // become commonly buyable, i.e. owned by GameManager. // (Note: all such tokens will be made buyable from the Bank too, // this is done in OperatingRound_1856). --- 225,229 ---- // For 1856: buyable tokens still owned by the private will now ! // become commonly buyable, i.e. owned by GameManager. // (Note: all such tokens will be made buyable from the Bank too, // this is done in OperatingRound_1856). *************** *** 236,240 **** } } ! /* start sfy 1889 */ public boolean isCloseable() { --- 239,243 ---- } } ! /* start sfy 1889 */ public boolean isCloseable() { Index: CompanyType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyType.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CompanyType.java 31 Oct 2009 17:08:27 -0000 1.10 --- CompanyType.java 4 Feb 2010 21:27:58 -0000 1.11 *************** *** 2,5 **** --- 2,8 ---- package rails.game; + import java.util.ArrayList; + import java.util.List; + import rails.util.LocalText; import rails.util.Tag; *************** *** 23,27 **** private CompanyI dummyCompany; ! /** * The constructor. --- 26,32 ---- private CompanyI dummyCompany; ! ! protected List<CompanyI> companies = new ArrayList<CompanyI>(); ! /** * The constructor. *************** *** 60,68 **** } ! public void finishConfiguration (GameManagerI gameManager) { ! } ! public CompanyI createCompany(String name, Tag tag) throws ConfigurationException { --- 65,73 ---- } ! public void finishConfiguration (GameManagerI gameManager) { ! } ! public CompanyI createCompany(String name, Tag tag) throws ConfigurationException { *************** *** 75,78 **** --- 80,84 ---- newCompany.init(name, this); newCompany.configureFromXML(tag); + companies.add(newCompany); } catch (CloneNotSupportedException e) { DisplayBuffer.add(LocalText.getText("CantCloneCompany", *************** *** 101,105 **** } ! public void setCapitalisation(int mode) { this.capitalisation = mode; } --- 107,115 ---- } ! public List<CompanyI> getCompanies() { ! return companies; ! } ! ! public void setCapitalisation(int mode) { this.capitalisation = mode; } Index: Company.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Company.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Company.java 16 Jan 2010 21:15:58 -0000 1.12 --- Company.java 4 Feb 2010 21:27:58 -0000 1.13 *************** *** 40,44 **** this.type = type; closedObject = new BooleanState(name + "_Closed", false); - } --- 40,43 ---- *************** *** 88,92 **** return longName; } ! public String getInfoText(){ return infoText; --- 87,91 ---- return longName; } ! public String getInfoText(){ return infoText; Index: CompanyTypeI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyTypeI.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CompanyTypeI.java 4 Jun 2008 19:00:30 -0000 1.5 --- CompanyTypeI.java 4 Feb 2010 21:27:58 -0000 1.6 *************** *** 2,5 **** --- 2,7 ---- package rails.game; + import java.util.List; + import rails.util.Tag; *************** *** 40,43 **** --- 42,47 ---- public String getClassName(); + public List<CompanyI> getCompanies(); + public void setCapitalisation(int mode); Index: CompanyManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManagerI.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CompanyManagerI.java 9 Oct 2009 20:20:34 -0000 1.13 --- CompanyManagerI.java 4 Feb 2010 21:27:58 -0000 1.14 *************** *** 56,59 **** --- 56,60 ---- public PublicCompanyI getCompanyByName(String name); + public List<CompanyTypeI> getCompanyTypes(); public void closeAllPrivates(); |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192/rails/ui/swing Modified Files: ORPanel.java Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** ORPanel.java 31 Jan 2010 22:22:34 -0000 1.44 --- ORPanel.java 4 Feb 2010 21:27:59 -0000 1.45 *************** *** 158,162 **** menuBar.add(infoMenu); ! addPrivatesInfo(); addTrainsInfo(); addPhasesInfo(); --- 158,162 ---- menuBar.add(infoMenu); ! addCompanyInfo(); addTrainsInfo(); addPhasesInfo(); *************** *** 469,507 **** } ! protected void addPrivatesInfo () { ! ! List<PrivateCompanyI> privates = orWindow.gameUIManager.getGameManager().getAllPrivateCompanies(); ! if (privates == null || privates.isEmpty()) return; ! privatesInfoMenu = new JMenu(LocalText.getText("PRIVATES")); ! privatesInfoMenu.setEnabled(true); ! infoMenu.add(privatesInfoMenu); ! JMenu item; ! List<SpecialPropertyI> sps; ! StringBuffer b = new StringBuffer("<html>"); ! String info; ! for (PrivateCompanyI p : privates) { ! sps = p.getSpecialProperties(); ! b.setLength(6); ! if (Util.hasValue(p.getLongName())) { ! appendInfoText (b, p.getLongName()); ! } ! info = p.getInfoText(); ! if (Util.hasValue(info)) { ! appendInfoText(b, info); ! } else if (sps == null || sps.isEmpty()) { ! appendInfoText(b, LocalText.getText("NoSpecialProperty")); ! } else { ! for (SpecialPropertyI sp : sps) { ! appendInfoText(b, sp.getInfo()); ! } ! } ! item = new JMenu (p.getName()); ! item.setEnabled(true); ! item.add(new JMenuItem(b.toString())); ! privatesInfoMenu.add(item); ! } } --- 469,494 ---- } ! protected void addCompanyInfo() { ! CompanyManagerI cm = orUIManager.getGameUIManager().getGameManager().getCompanyManager(); ! List<CompanyTypeI> comps = cm.getCompanyTypes(); ! JMenu compMenu, menu, item; ! ! compMenu = new JMenu(LocalText.getText("Companies")); ! compMenu.setEnabled(true); ! infoMenu.add(compMenu); ! for (CompanyTypeI type : comps) { ! menu = new JMenu (LocalText.getText(type.getName())); ! menu.setEnabled(true); ! compMenu.add(menu); ! for (CompanyI comp : type.getCompanies()) { ! item = new JMenu(comp.getName()); ! item.setEnabled(true); ! item.add(new JMenuItem(comp.getInfoText())); ! menu.add(item); ! } ! } } |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx/data/1835 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192/data/1835 Modified Files: CompanyManager.xml Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: CompanyManager.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1835/CompanyManager.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** CompanyManager.xml 31 Jan 2010 22:15:57 -0000 1.23 --- CompanyManager.xml 4 Feb 2010 21:27:59 -0000 1.24 *************** *** 64,68 **** </ClosingConditions> </Company> ! <Company name="LD" longname="Leipzig-Dresdner Bahn" type="Private" basePrice="190" revenue="20"/> <Company name="BB" longname="Braunschweigische Bahn" type="Private" basePrice="130" revenue="25"> <SpecialProperties> --- 64,70 ---- </ClosingConditions> </Company> ! <Company name="LD" longname="Leipzig-Dresdner Bahn" type="Private" basePrice="190" revenue="20"> ! <Info key="ComesWithPresidency" parm="Sax,20"/> ! </Company> <Company name="BB" longname="Braunschweigische Bahn" type="Private" basePrice="130" revenue="25"> <SpecialProperties> *************** *** 81,84 **** --- 83,90 ---- <Company name="M1" longname="Bergisch-Märkische Bahn" type="Minor" price="80" tokens="1"> <Home hex="H2"/> + <!-- The Minor Special Properties may be replaced by some other device, + as Public Companies normally have no special properties. + PLEASE no not use these until further notice. --> + <Info key="SwapPrivateForCertificate" parm="M1,5,Pr"/> <SpecialProperties> <SpecialProperty condition="ifStarted" when="exchangeRound" class="rails.game.special.ExchangeForShare"> *************** *** 89,92 **** --- 95,99 ---- <Company name="M2" longname="Berlin-Potsdamer Bahn" type="Minor" price="170" tokens="1"> <Home hex="E19" city="1"/> + <Info key="SwapPrivateForCertificate" parm="M2,10,Pr"/> <SpecialProperties> <SpecialProperty condition="phase=4" when="exchangeRound" class="rails.game.special.ExchangeForShare"> *************** *** 97,100 **** --- 104,108 ---- <Company name="M3" longname="Magdeburger Bahn" type="Minor" price="80" tokens="1"> <Home hex="F14"/> + <Info key="SwapPrivateForCertificate" parm="M3,5,Pr"/> <SpecialProperties> <SpecialProperty condition="ifStarted" when="exchangeRound" class="rails.game.special.ExchangeForShare"> *************** *** 105,108 **** --- 113,117 ---- <Company name="M4" longname="Köln-Mindener Bahn" type="Minor" price="160" tokens="1"> <Home hex="G5"/> + <Info key="SwapPrivateForCertificate" parm="M4,10,Pr"/> <SpecialProperties> <SpecialProperty condition="ifStarted" when="exchangeRound" class="rails.game.special.ExchangeForShare"> *************** *** 113,116 **** --- 122,126 ---- <Company name="M5" longname="Berlin-Stettiner Bahn" type="Minor" price="80" tokens="1"> <Home hex="E19" city="2"/> + <Info key="SwapPrivateForCertificate" parm="M5,5,Pr"/> <SpecialProperties> <SpecialProperty condition="ifStarted" when="exchangeRound" class="rails.game.special.ExchangeForShare"> *************** *** 121,124 **** --- 131,135 ---- <Company name="M6" longname="Altona-Kiel Bahn" type="Minor" price="80" tokens="1"> <Home hex="C11" city="1"/> + <Info key="SwapPrivateForCertificate" parm="M6,5,Pr"/> <SpecialProperties> <SpecialProperty condition="ifStarted" when="exchangeRound" class="rails.game.special.ExchangeForShare"> |
From: Erik V. <ev...@us...> - 2010-02-04 21:28:07
|
Update of /cvsroot/rails/18xx/rails/game/special In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7192/rails/game/special Modified Files: ExchangeForShare.java Log Message: Info: replaced Privates by Companies. Now covers all (private and public) company types, as defined in the XML. Info display also extended. 1830 and 1835 done, others remain. Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ExchangeForShare.java 7 Oct 2009 19:00:38 -0000 1.15 --- ExchangeForShare.java 4 Feb 2010 21:27:59 -0000 1.16 *************** *** 73,75 **** --- 73,79 ---- publicCompanyName ); } + + public String getInfo() { + return toMenu(); + } } |
From: Jim B. <ji...@ko...> - 2010-02-03 23:37:29
|
The new Info in the Rails 1.1.3 update looks great. However, the first time I tried to save with 1.1.3, no 1.1.2 players could read my game file- so I had to switch back to 1.1.2. Was this happenstance, as to be expected sometimes- or, is there a major file version upgrade implicit in 1.1.3? thanks, - jim On Feb 3, 2010, at 12:17 PM, rai...@li... wrote: > Send Rails-commits mailing list submissions to > rai...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/rails-commits > or, via email, send a message with subject or body 'help' to > rai...@li... > > You can reach the person managing the list at > rai...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Rails-commits digest..." > > > Today's Topics: > > 1. 18xx/data/1889 Game.xml,1.1,1.2 (Erik Vos) > 2. 18xx/data/1856 CompanyManager.xml,1.33,1.34 (Erik Vos) > 3. 18xx/rails/ui/swing/hexmap HexMap.java,1.21,1.22 (Erik Vos) > 4. 18xx/rails/ui/swing ORUIManager.java,1.49,1.50 (Erik Vos) > 5. 18xx/rails/game/action LayToken.java, 1.9, 1.10 > LayBaseToken.java, 1.6, 1.7 (Erik Vos) > 6. 18xx/rails/game MapHex.java, 1.34, 1.35 PublicCompany.java, > 1.80, 1.81 OperatingRound.java, 1.95, 1.96 PublicCompanyI.java, > 1.43, 1.44 (Erik Vos) > 7. 18xx/tools ConvertTilesXML.java, NONE, 1.1 Util.java, NONE, > 1.1 MakeGameTileSets.java, NONE, 1.1 XmlUtils.java, NONE, 1.1 > (Erik Vos) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 03 Feb 2010 20:05:44 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/data/1889 Game.xml,1.1,1.2 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/data/1889 > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32238/data/1889 > > Modified Files: > Game.xml > Log Message: > Fixed money symbol > > Index: Game.xml > =================================================================== > RCS file: /cvsroot/rails/18xx/data/1889/Game.xml,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -C2 -d -r1.1 -r1.2 > *** Game.xml 3 Feb 2010 05:37:54 -0000 1.1 > --- Game.xml 3 Feb 2010 20:05:42 -0000 1.2 > *************** > *** 46,50 **** > <Component name="Bank" class="rails.game.Bank"> > <Bank amount="7000"/> > ! <Money format="¥@"/> > </Component> > <Component name="TileManager" class="rails.game.TileManager" > --- 46,50 ---- > <Component name="Bank" class="rails.game.Bank"> > <Bank amount="7000"/> > ! <Money format="¥@"/> > </Component> > <Component name="TileManager" class="rails.game.TileManager" > > > > > ------------------------------ > > Message: 2 > Date: Wed, 03 Feb 2010 20:16:45 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/data/1856 CompanyManager.xml,1.33,1.34 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/data/1856 > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/data/1856 > > Modified Files: > CompanyManager.xml > Log Message: > Home base on green OO tile can now be chosen in first turn > > Index: CompanyManager.xml > =================================================================== > RCS file: /cvsroot/rails/18xx/data/1856/CompanyManager.xml,v > retrieving revision 1.33 > retrieving revision 1.34 > diff -C2 -d -r1.33 -r1.34 > *** CompanyManager.xml 31 Jan 2010 22:15:58 -0000 1.33 > --- CompanyManager.xml 3 Feb 2010 20:16:40 -0000 1.34 > *************** > *** 113,117 **** > </Company> > <Company name="THB" type="Public" tokens="2" fgColour="000000" bgColour="B0B040"> > ! <Home hex="L15"/> > <Destination hex="J11"/> > </Company> > --- 113,117 ---- > </Company> > <Company name="THB" type="Public" tokens="2" fgColour="000000" bgColour="B0B040"> > ! <Home hex="L15" city="0"/><!-- City to be selected in first turn--> > <Destination hex="J11"/> > </Company> > > > > > ------------------------------ > > Message: 3 > Date: Wed, 03 Feb 2010 20:16:42 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/rails/ui/swing/hexmap > HexMap.java,1.21,1.22 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/rails/ui/swing/hexmap > > Modified Files: > HexMap.java > Log Message: > Home base on green OO tile can now be chosen in first turn > > Index: HexMap.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/HexMap.java,v > retrieving revision 1.21 > retrieving revision 1.22 > diff -C2 -d -r1.21 -r1.22 > *** HexMap.java 31 Jan 2010 22:22:36 -0000 1.21 > --- HexMap.java 3 Feb 2010 20:16:40 -0000 1.22 > *************** > *** 203,206 **** > --- 203,210 ---- > } > > + public void setSelectedHex (GUIHex hex) { > + selectedHex = hex; > + } > + > public boolean isAHexSelected() // Not used > { > > > > > ------------------------------ > > Message: 4 > Date: Wed, 03 Feb 2010 20:16:39 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/rails/ui/swing > ORUIManager.java,1.49,1.50 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/rails/ui/swing > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/rails/ui/swing > > Modified Files: > ORUIManager.java > Log Message: > Home base on green OO tile can now be chosen in first turn > > Index: ORUIManager.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v > retrieving revision 1.49 > retrieving revision 1.50 > diff -C2 -d -r1.49 -r1.50 > *** ORUIManager.java 3 Feb 2010 05:37:55 -0000 1.49 > --- ORUIManager.java 3 Feb 2010 20:16:36 -0000 1.50 > *************** > *** 529,536 **** > for (LayTile action : possibleActions.getType(LayTile.class)) { > if (action.getType() == LayTile.SPECIAL_PROPERTY > ! && !action.getSpecialProperty().requiresConnection() // sfy 1889 > ! && action.getSpecialProperty().getLocations().contains(mapHex) > ! ) > ! { > // log.debug(hex.getName()+" is a special property target"); > return true; > --- 529,533 ---- > for (LayTile action : possibleActions.getType(LayTile.class)) { > if (action.getType() == LayTile.SPECIAL_PROPERTY > ! && action.getSpecialProperty().getLocations().contains(mapHex)) { > // log.debug(hex.getName()+" is a special property target"); > return true; > *************** > *** 631,635 **** > String selected = > (String) JOptionPane.showInputDialog(orWindow, > ! LocalText.getText("SelectStationForToken"), > LocalText.getText("WhichStation"), > JOptionPane.PLAIN_MESSAGE, null, > --- 628,635 ---- > String selected = > (String) JOptionPane.showInputDialog(orWindow, > ! LocalText.getText("SelectStationForToken", > ! action.getPlayerName(), > ! selectedHex.getName(), > ! action.getCompanyName()), > LocalText.getText("WhichStation"), > JOptionPane.PLAIN_MESSAGE, null, > *************** > *** 786,790 **** > Bank.format(bTrain.getPresidentCashToAdd()))); > } > ! > if (bTrain.getExtraMessage() != null) { > b.append(" (").append(bTrain.getExtraMessage()+")"); > --- 786,790 ---- > Bank.format(bTrain.getPresidentCashToAdd()))); > } > ! > if (bTrain.getExtraMessage() != null) { > b.append(" (").append(bTrain.getExtraMessage()+")"); > *************** > *** 810,814 **** > } > setMessage(msgbuf.toString()); > ! > String selectedActionText = > (String) JOptionPane.showInputDialog(orWindow, > --- 810,814 ---- > } > setMessage(msgbuf.toString()); > ! > String selectedActionText = > (String) JOptionPane.showInputDialog(orWindow, > *************** > *** 1119,1122 **** > --- 1119,1131 ---- > orWindow.requestFocus(); > > + // Check first action. > + // If it's to lay a home token, handle that here > + LayBaseToken lbt = possibleActions.getType(LayBaseToken.class).get(0); > + if (lbt.getType() == LayBaseToken.HOME_CITY) { > + map.setSelectedHex(map.getHexByName(lbt.getChosenHex().getName())); > + layBaseToken (lbt); > + return; > + } > + > // Include bonus tokens > List<LayToken> possibleTokenLays = > > > > > ------------------------------ > > Message: 5 > Date: Wed, 03 Feb 2010 20:16:42 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/rails/game/action LayToken.java, 1.9, > 1.10 LayBaseToken.java, 1.6, 1.7 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/rails/game/action > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/rails/game/action > > Modified Files: > LayToken.java LayBaseToken.java > Log Message: > Home base on green OO tile can now be chosen in first turn > > Index: LayBaseToken.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/action/LayBaseToken.java,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -C2 -d -r1.6 -r1.7 > *** LayBaseToken.java 31 Jan 2010 22:22:28 -0000 1.6 > --- LayBaseToken.java 3 Feb 2010 20:16:40 -0000 1.7 > *************** > *** 26,29 **** > --- 26,30 ---- > public final static int LOCATION_SPECIFIC = 1; // Valid hex > public final static int SPECIAL_PROPERTY = 2; // Directed by a special > + public final static int HOME_CITY = 3; // If city on home hex is undefined in 1st turn > // property > > *************** > *** 52,55 **** > --- 53,62 ---- > } > > + public LayBaseToken (MapHex hex) { > + super (hex); > + setChosenHex (hex); > + type = HOME_CITY; > + } > + > public int getChosenStation() { > return chosenStation; > > Index: LayToken.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/action/LayToken.java,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -C2 -d -r1.9 -r1.10 > *** LayToken.java 4 Jun 2008 19:00:29 -0000 1.9 > --- LayToken.java 3 Feb 2010 20:16:38 -0000 1.10 > *************** > *** 1,4 **** > /* $Header$ > ! * > * Created on 14-Sep-2006 > * Change Log: > --- 1,4 ---- > /* $Header$ > ! * > * Created on 14-Sep-2006 > * Change Log: > *************** > *** 6,9 **** > --- 6,10 ---- > package rails.game.action; > > + import java.util.ArrayList; > import java.util.List; > > *************** > *** 56,59 **** > --- 57,66 ---- > } > > + public LayToken (MapHex hex) { > + this.locations = new ArrayList<MapHex>(1); > + locations.add(hex); > + buildLocationNameString(); > + } > + > /** > * @return Returns the chosenHex. > *************** > *** 90,94 **** > * @return Returns the location. > */ > ! public MapHex getLocation() { > if (locations != null) { > return locations.get(0); > --- 97,102 ---- > * @return Returns the location. > */ > ! @Deprecated > ! public MapHex getLocation() { > if (locations != null) { > return locations.get(0); > > > > > ------------------------------ > > Message: 6 > Date: Wed, 03 Feb 2010 20:16:42 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/rails/game MapHex.java, 1.34, 1.35 > PublicCompany.java, 1.80, 1.81 OperatingRound.java, 1.95, 1.96 > PublicCompanyI.java, 1.43, 1.44 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/rails/game > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/rails/game > > Modified Files: > MapHex.java PublicCompany.java OperatingRound.java > PublicCompanyI.java > Log Message: > Home base on green OO tile can now be chosen in first turn > > Index: OperatingRound.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v > retrieving revision 1.95 > retrieving revision 1.96 > diff -C2 -d -r1.95 -r1.96 > *** OperatingRound.java 3 Feb 2010 05:37:54 -0000 1.95 > --- OperatingRound.java 3 Feb 2010 20:16:40 -0000 1.96 > *************** > *** 493,498 **** > > // Checks > ! // Must be correct step > ! if (getStep() != STEP_LAY_TOKEN) { > errMsg = LocalText.getText("WrongActionNoTokenLay"); > break; > --- 493,498 ---- > > // Checks > ! // Must be correct step (exception: home base lay) > ! if (getStep() != STEP_LAY_TOKEN && action.getType() != LayBaseToken.HOME_CITY) { > errMsg = LocalText.getText("WrongActionNoTokenLay"); > break; > *************** > *** 566,569 **** > --- 566,572 ---- > operatingCompany.layBaseToken(hex, cost); > > + // If this is a home base token lay, stop here > + if (action.getType() == LayBaseToken.HOME_CITY) return true; > + > if (cost > 0) { > new CashMove(operatingCompany, bank, cost); > *************** > *** 1926,1939 **** > > int step = getStep(); > > if (step == STEP_LAY_TRACK) { > - setNormalTileLays(); > - setSpecialTileLays(); > - log.debug("Normal tile lays: " + currentNormalTileLays.size()); > - log.debug("Special tile lays: " + currentSpecialTileLays.size()); > > ! possibleActions.addAll(currentNormalTileLays); > ! possibleActions.addAll(currentSpecialTileLays); > ! possibleActions.add(new NullAction(NullAction.SKIP)); > > } else if (step == STEP_LAY_TOKEN) { > --- 1929,1951 ---- > > int step = getStep(); > + boolean forced = false; > > if (step == STEP_LAY_TRACK) { > > ! if (!operatingCompany.hasLaidHomeBaseTokens()) { > ! // This can occur if the home hex has two cities and track, > ! // such as the green OO tile #59 > ! possibleActions.add(new LayBaseToken (operatingCompany.getHomeHex())); > ! forced = true; > ! } else { > ! setNormalTileLays(); > ! setSpecialTileLays(); > ! log.debug("Normal tile lays: " + currentNormalTileLays.size()); > ! log.debug("Special tile lays: " + currentSpecialTileLays.size()); > ! > ! possibleActions.addAll(currentNormalTileLays); > ! possibleActions.addAll(currentSpecialTileLays); > ! possibleActions.add(new NullAction(NullAction.SKIP)); > ! } > > } else if (step == STEP_LAY_TOKEN) { > *************** > *** 1962,1966 **** > // The following additional "common" actions are only available if the > // primary action is not forced. > ! if (step >= 0) { > > setBonusTokenLays(); > --- 1974,1978 ---- > // The following additional "common" actions are only available if the > // primary action is not forced. > ! if (step >= 0 && !forced) { > > setBonusTokenLays(); > *************** > *** 2234,2238 **** > return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); > } > ! > /** > * Can the company buy a train now? > --- 2246,2250 ---- > return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); > } > ! > /** > * Can the company buy a train now? > > Index: MapHex.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v > retrieving revision 1.34 > retrieving revision 1.35 > diff -C2 -d -r1.34 -r1.35 > *** MapHex.java 31 Jan 2010 22:22:28 -0000 1.34 > --- MapHex.java 3 Feb 2010 20:16:40 -0000 1.35 > *************** > *** 846,850 **** > log.error("No cities for home station on hex " + name); > } else { > ! homes.put(company, cities.get(cityNumber - 1)); > } > } > --- 846,850 ---- > log.error("No cities for home station on hex " + name); > } else { > ! homes.put(company, cities.get(Math.max(cityNumber - 1, 0))); > } > } > > Index: PublicCompany.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v > retrieving revision 1.80 > retrieving revision 1.81 > diff -C2 -d -r1.80 -r1.81 > *** PublicCompany.java 2 Feb 2010 20:00:03 -0000 1.80 > --- PublicCompany.java 3 Feb 2010 20:16:40 -0000 1.81 > *************** > *** 800,805 **** > return mayTradeShares; > } > ! > ! /** Stub that allows exclusions such as that 1856 CGR may not buy a 4 */ > public boolean mayBuyTrainType (TrainI train) { > return true; > --- 800,805 ---- > return mayTradeShares; > } > ! > ! /** Stub that allows exclusions such as that 1856 CGR may not buy a 4 */ > public boolean mayBuyTrainType (TrainI train) { > return true; > *************** > *** 829,833 **** > start(startSpace); > } > - > } > > --- 829,832 ---- > *************** > *** 928,932 **** > > } > ! > public ModelObject getClosedModel () { > return closedObject; > --- 927,931 ---- > > } > ! > public ModelObject getClosedModel () { > return closedObject; > *************** > *** 1034,1038 **** > > public void updatePlayersWorth() { > ! > Map<Player, Boolean> done = new HashMap<Player, Boolean>(8); > Player owner; > --- 1033,1037 ---- > > public void updatePlayersWorth() { > ! > Map<Player, Boolean> done = new HashMap<Player, Boolean>(8); > Player owner; > *************** > *** 1673,1676 **** > --- 1672,1676 ---- > } > > + // Return value is not used > public boolean layHomeBaseTokens() { > > *************** > *** 1680,1685 **** > // has a choice, such in 1830 Erie. > if (hasLaidHomeBaseTokens()) return true; > log.debug(name + " lays home base on " + homeHex.getName() + " city " > ! + homeCityNumber); > return homeHex.layBaseToken(this, homeCityNumber); > } > --- 1680,1699 ---- > // has a choice, such in 1830 Erie. > if (hasLaidHomeBaseTokens()) return true; > + > + if (homeCityNumber == 0) { > + // This applies to cases like 1830 Erie and 1856 THB. > + // On a trackless tile it does not matter, but if > + // the tile has track (such as the green OO tile), > + // the player must select a city. > + Map<Integer, List<Track>> tracks > + = homeHex.getCurrentTile().getTracksPerStationMap(); > + if (tracks == null || tracks.isEmpty()) { > + homeCityNumber = 1; > + } else { > + return false; > + } > + } > log.debug(name + " lays home base on " + homeHex.getName() + " city " > ! + homeCityNumber); > return homeHex.layBaseToken(this, homeCityNumber); > } > > Index: PublicCompanyI.java > =================================================================== > RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v > retrieving revision 1.43 > retrieving revision 1.44 > diff -C2 -d -r1.43 -r1.44 > *** PublicCompanyI.java 2 Feb 2010 19:59:43 -0000 1.43 > --- PublicCompanyI.java 3 Feb 2010 20:16:40 -0000 1.44 > *************** > *** 298,301 **** > --- 298,302 ---- > > public boolean layHomeBaseTokens(); > + public boolean hasLaidHomeBaseTokens(); > > public BaseToken getFreeToken(); > *************** > *** 352,356 **** > public int sharesOwnedByPlayers(); > public String getExtraShareMarks (); > ! > public ModelObject getClosedModel (); > > --- 353,357 ---- > public int sharesOwnedByPlayers(); > public String getExtraShareMarks (); > ! > public ModelObject getClosedModel (); > > > > > > ------------------------------ > > Message: 7 > Date: Wed, 03 Feb 2010 20:16:40 +0000 > From: Erik Vos <ev...@us...> > Subject: [Rails-commits] 18xx/tools ConvertTilesXML.java, NONE, 1.1 > Util.java, NONE, 1.1 MakeGameTileSets.java, NONE, 1.1 XmlUtils.java, > NONE, 1.1 > To: rai...@li... > Message-ID: <E1N...@sf...> > > Update of /cvsroot/rails/18xx/tools > In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/tools > > Added Files: > ConvertTilesXML.java Util.java MakeGameTileSets.java > XmlUtils.java > Log Message: > Home base on green OO tile can now be chosen in first turn > > --- NEW FILE: XmlUtils.java --- > /* $Header: /cvsroot/rails/18xx/tools/XmlUtils.java,v 1.1 2010/02/03 20:16:38 evos Exp $*/ > package tools; > > import java.io.IOException; > > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; > > import org.w3c.dom.*; > import org.xml.sax.SAXException; > > import rails.game.ConfigurationException; > > /** > * Booch utility class providing helper functions for working with XML. > */ > public final class XmlUtils { > > /** > * No-args private constructor, to prevent (meaningless) construction of one > * of these. > */ > private XmlUtils() {} > > /** > * Extracts the String value of a given attribute from a NodeNameMap. > * Returns null if no such attribute can be found. See > * extractStringAttribute(NamedNodeMap nnp, String attrName, String > * defaultValue) > * > * @param nnp the NodeNameMap to search for the Attribute > * @param attrName the name of the attribute who's value is desired > * @return the named attribute's value or null if absent. > */ > /** @deprecated */ > public static String extractStringAttribute(NamedNodeMap nnp, > String attrName) { > return extractStringAttribute(nnp, attrName, null); > } > > /** > * Extracts the String value of a given attribute from a NodeNameMap. > * Returns a default value if no such attribute can be found. > * > * @param nnp the NodeNameMap to search for the Attribute > * @param attrName the name of the attribute who's value is desired > * @param defaultValue the value to be returned if the attribute is absent. > * @return the named attribute's value, or the default value if absent. > */ > /** @deprecated */ > public static String extractStringAttribute(NamedNodeMap nnp, > String attrName, String defaultValue) { > > if (nnp == null) return defaultValue; > Node nameAttr = nnp.getNamedItem(attrName); > if (nameAttr == null) return defaultValue; > return nameAttr.getNodeValue(); > } > > /** > * Extracts the integer value of a given attribute from a NodeNameMap. > * Returns zero if no such attribute can be found. > * > * @see > * @param nnp the NodeNameMap to search for the Attribute > * @param attrName the name of the attribute who's value is desired > * @return the named attribute's value, or zero if absent. > */ > /** @deprecated */ > public static int extractIntegerAttribute(NamedNodeMap nnp, String attrName) > throws ConfigurationException { > return extractIntegerAttribute(nnp, attrName, 0); > } > > /** > * Extracts the integer value of a given attribute from a NodeNameMap. > * Returns a default value if no such attribute can be found. > * > * @see > * @param nnp the NodeNameMap to search for the Attribute > * @param attrName the name of the attribute who's value is desired. > * @param defaultValue The value returned if the attribute is absent. > * @return the named attribute's value or the dedault value. > */ > /** @deprecated */ > public static int extractIntegerAttribute(NamedNodeMap nnp, > String attrName, int defaultValue) throws ConfigurationException { > > if (nnp == null) return defaultValue; > Node nameAttr = nnp.getNamedItem(attrName); > if (nameAttr == null) { > return defaultValue; > } > String value = nameAttr.getNodeValue(); > try { > return Integer.parseInt(value); > } catch (Exception e) { > throw new ConfigurationException("Invalid integer value: " + value, > e); > } > } > > /** > * Extracts the boolean value of a given attribute from a NodeNameMap. Any > * string that starts with T or t (for "true") or Y or y (for "yes") is > * considered to represent true, all other values will produce false. > * > * @param nnp The NodeNameMap to search for the Attribute > * @param attrName The name of the attribute who's value is desired > * @return The named attribute's value, or false if absent. > */ > /** @deprecated */ > public static boolean extractBooleanAttribute(NamedNodeMap nnp, > String attrName) throws ConfigurationException { > return extractBooleanAttribute(nnp, attrName, false); > } > > /** > * Extracts the boolean value of a given attribute from a NodeNameMap. > * Returns a default value if no such attribute can be found. Any string > * that starts with T or t (for "true") or Y or y (for "yes") is considered > * to represent true, all other values will produce false. > * > * @param nnp The NodeNameMap to search for the Attribute > * @param attrName The name of the attribute who's value is desired > * @param defaultValue The value returned if the attribute is absent. > * @return The named attribute's value or the default value. > */ > /** @deprecated */ > public static boolean extractBooleanAttribute(NamedNodeMap nnp, > String attrName, boolean defaultValue) > throws ConfigurationException { > > if (nnp == null) return defaultValue; > Node nameAttr = nnp.getNamedItem(attrName); > if (nameAttr == null) { > return defaultValue; > } > String value = nameAttr.getNodeValue(); > return value.matches("^[TtYy].*"); > } > > /** @deprecated */ > public static int[] extractIntegerArrayAttribute(NamedNodeMap nnp, > String attrName) throws ConfigurationException { > > if (nnp == null) return null; > Node nameAttr = nnp.getNamedItem(attrName); > if (nameAttr == null) return new int[0]; > String[] values = nameAttr.getNodeValue().split(","); > int[] result = new int[values.length]; > int i = 0; > try { > for (i = 0; i < values.length; i++) { > result[i] = Integer.parseInt(values[i]); > } > } catch (NumberFormatException e) { > throw new ConfigurationException("Invalid integer '" + values[i] > + "' in attribute '" + attrName > + "'"); > } > return result; > > } > > /** > * Opens and parses an xml file. Searches the root level of the file for an > * element with the supplied name. > * > * @param fileName the name of the file to open > * @param elementName the name of the element to find > * @return the named element in the named file > * @throws ConfigurationException if there is any problem opening and > * parsing the file, or if the file does not contain a top level element > * with the given name. > */ > public static Element findElementInFile(String fileName, String elementName) > throws ConfigurationException { > Document doc = null; > try { > // Step 1: create a DocumentBuilderFactory and setNamespaceAware > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); > dbf.setNamespaceAware(true); > // Step 2: create a DocumentBuilder > DocumentBuilder db = dbf.newDocumentBuilder(); > > // Step 3: parse the input file to get a Document object > doc = db.parse(Util.getStreamForFile(fileName)); > > } catch (ParserConfigurationException e) { > throw new ConfigurationException("Could not read/parse " + fileName > + " to find element " > + elementName, e); > } catch (SAXException e) { > throw new ConfigurationException("Could not read/parse " + fileName > + " to find element " > + elementName, e); > } catch (IOException e) { > throw new ConfigurationException("Could not read/parse " + fileName > + " to find element " > + elementName, e); > } > > if (doc == null) { > throw new ConfigurationException("Cannot find file " + fileName); > } > > // Now find the named Element > NodeList nodeList = doc.getChildNodes(); > for (int iNode = 0; (iNode < nodeList.getLength()); iNode++) { > Node childNode = nodeList.item(iNode); > if ((childNode != null) > && (childNode.getNodeName().equals(elementName)) > && (childNode.getNodeType() == Node.ELEMENT_NODE)) { > return (Element) childNode; > } > } > throw new ConfigurationException("Could not find " + elementName > + " in " + fileName); > } > } > > --- NEW FILE: Util.java --- > /* $Header: /cvsroot/rails/18xx/tools/Util.java,v 1.1 2010/02/03 20:16:38 evos Exp $*/ > package tools; > > import java.io.File; > import java.io.FileInputStream; > import java.io.IOException; > import java.io.InputStream; > > public final class Util { > /** > * No-args private constructor, to prevent (meaningless) construction of one > * of these. > */ > private Util() {} > > public static boolean hasValue(String s) { > return s != null && !s.equals(""); > } > > /** > * Open an input stream from a file, which may exist as a physical file or > * in a JAR file. The name must be valid for both options. > * > * @author Erik Vos > */ > public static InputStream getStreamForFile(String fileName) > throws IOException { > > File file = new File(fileName); > if (file.exists()) { > return new FileInputStream(file); > } else { > return null; > } > } > > } > > --- NEW FILE: ConvertTilesXML.java --- > package tools; > > import java.io.*; > import java.util.*; > import java.util.regex.*; > > import javax.xml.parsers.*; > import javax.xml.transform.*; > import javax.xml.transform.dom.*; > import javax.xml.transform.stream.StreamResult; > > import org.w3c.dom.*; > > import rails.game.ConfigurationException; > import rails.util.Util; > import tools.XmlUtils; > > /** > * Convert an XML tile dictionary, as created by Marco Rocci's Tile Designer, to > * an XML file for use in Rails 18xx. <p> The default names are: > */ > public class ConvertTilesXML { > > private static String inputFilePath = "tiles/TileDictionary.xml"; > > private static String outputFilePath = "tiles/Tiles.xml"; > > private static Map<String, String> colourMap, gaugeMap, sidesMap, cityMap; > private static Map<String, String[]> stationMap; > private static Map<String, String> junctionPosition; > > /** Maps non-edge non-station junctions to tracks ending there. */ > private static Map<String, List<Element>> unresolvedTrack; > /** Maps tracks to edge/station junctions */ > private static Map<Element, String> resolvedTrack; > > private static Pattern namePattern = Pattern.compile("^(\\d+)(/.*)?"); > > Document outputDoc; > Element outputJunction; > String tileNo; > String colour; > > static { > colourMap = new HashMap<String, String>(); > colourMap.put("tlYellow", "yellow"); > colourMap.put("tlGreen", "green"); > colourMap.put("tlBrown", "brown"); > colourMap.put("tlGray", "gray"); > colourMap.put("tlOffMap", "red"); > colourMap.put("tlMapFixed", "fixed"); > colourMap.put("tlMapUpgradableToYellow", "white"); > colourMap.put("tlMapUpgradableToGreen", "yellow"); > colourMap.put("tlMapUpgradableToBrown", "green"); > > stationMap = new HashMap<String, String[]>(); > stationMap.put("jtWhistlestop", new String[] { "Town", "0" }); > stationMap.put("jtCity", new String[] { "City", "1" }); > stationMap.put("jtDoubleCity", new String[] { "City", "2" }); > stationMap.put("jtTripleCity", new String[] { "City", "3" }); > stationMap.put("jtQuadrupleCity", new String[] { "City", "4" }); > stationMap.put("jtNone", new String[] { "", "0" }); > // Note: an additional station type is "Pass". > > gaugeMap = new HashMap<String, String>(); > gaugeMap.put("ctNormal", "normal"); > gaugeMap.put("ctSmall", "narrow"); > gaugeMap.put("ctUniversal", "dual"); > gaugeMap.put("ctTunnel", "normal"); > gaugeMap.put("ctMountain", "normal"); > // 1841 Pass: Station type is changed to Pass. > > sidesMap = new HashMap<String, String>(); > sidesMap.put("tp4SideA", "side0"); > sidesMap.put("tp4SideB", "side1"); > sidesMap.put("tp4SideC", "side2"); > sidesMap.put("tp4SideD", "side3"); > sidesMap.put("tp4SideE", "side4"); > sidesMap.put("tp4SideF", "side5"); > > cityMap = new HashMap<String, String>(); > cityMap.put("tpCenter", "0"); > cityMap.put("tp1SideA", "001"); > cityMap.put("tp1CornerA", "051"); > cityMap.put("tp1SideB", "101"); > cityMap.put("tp1CornerB", "151"); > cityMap.put("tp1SideC", "201"); > cityMap.put("tp1CornerC", "251"); > cityMap.put("tp1SideD", "301"); > cityMap.put("tp1CornerD", "351"); > cityMap.put("tp1SideE", "401"); > cityMap.put("tp1CornerE", "451"); > cityMap.put("tp1SideF", "501"); > cityMap.put("tp1CornerF", "551"); > cityMap.put("tp2SideA", "002"); > cityMap.put("tp2CornerA", "052"); > cityMap.put("tp2SideB", "102"); > cityMap.put("tp2CornerB", "152"); > cityMap.put("tp2SideC", "202"); > cityMap.put("tp2CornerC", "252"); > cityMap.put("tp2SideD", "302"); > cityMap.put("tp2CornerD", "352"); > cityMap.put("tp2SideE", "402"); > cityMap.put("tp2CornerE", "452"); > cityMap.put("tp2SideF", "502"); > cityMap.put("tp2CornerF", "552"); > cityMap.put("tp3SideA", "003"); > cityMap.put("tp3CornerA", "053"); > cityMap.put("tp3SideB", "103"); > cityMap.put("tp3CornerB", "153"); > cityMap.put("tp3SideC", "203"); > cityMap.put("tp3CornerC", "253"); > cityMap.put("tp3SideD", "303"); > cityMap.put("tp3CornerD", "353"); > cityMap.put("tp3SideE", "403"); > cityMap.put("tp3CornerE", "453"); > cityMap.put("tp3SideF", "503"); > cityMap.put("tp3CornerF", "553"); > cityMap.put("tpCurve1RightA", "006"); > cityMap.put("tpCurve2RightA", "007"); > cityMap.put("tpCurve2LeftA", "008"); > cityMap.put("tpCurve1LeftA", "009"); > cityMap.put("tpCurve1RightB", "106"); > cityMap.put("tpCurve2RightB", "107"); > cityMap.put("tpCurve2LeftB", "108"); > cityMap.put("tpCurve1LeftB", "109"); > cityMap.put("tpCurve1RightC", "206"); > cityMap.put("tpCurve2RightC", "207"); > cityMap.put("tpCurve2LeftC", "208"); > cityMap.put("tpCurve1LeftC", "209"); > cityMap.put("tpCurve1RightD", "306"); > cityMap.put("tpCurve2RightD", "307"); > cityMap.put("tpCurve2LeftD", "308"); > cityMap.put("tpCurve1LeftD", "309"); > cityMap.put("tpCurve1RightE", "406"); > cityMap.put("tpCurve2RightE", "407"); > cityMap.put("tpCurve2LeftE", "408"); > cityMap.put("tpCurve1LeftE", "409"); > cityMap.put("tpCurve1RightF", "506"); > cityMap.put("tpCurve2RightF", "507"); > cityMap.put("tpCurve2LeftF", "508"); > cityMap.put("tpCurve1LeftF", "509"); > > } > > public static void main(String[] args) { > > if (args != null) { > if (args.length > 0) inputFilePath = args[0]; > if (args.length > 1) outputFilePath = args[1]; > } > > try { > new ConvertTilesXML(); > } catch (ConfigurationException e) { > e.printStackTrace(); > } > > } > > private ConvertTilesXML() throws ConfigurationException { > > Element inputTopElement = > XmlUtils.findElementInFile(inputFilePath, "tiles"); > > try { > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > DocumentBuilder builder = factory.newDocumentBuilder(); > DOMImplementation impl = builder.getDOMImplementation(); > outputDoc = impl.createDocument(null, "Tiles", null); > > convertXML(inputTopElement, outputDoc); > > TransformerFactory.newInstance().newTransformer().transform( > new DOMSource(outputDoc), > new StreamResult(new FileOutputStream(new File( > outputFilePath)))); > > } catch (Exception e) { > throw new ConfigurationException("Document build error", e); > } > > } > > private void convertXML(Element inputElement, Document outputDoc) > throws ConfigurationException { > > NodeList children = inputElement.getElementsByTagName("tile"); > for (int i = 0; i < children.getLength(); i++) { > Element inputTile = (Element) children.item(i); > Element outputTile = outputDoc.createElement("Tile"); > outputDoc.getDocumentElement().appendChild(outputTile); > convertTile(inputTile, outputTile); > } > > } > > private void convertTile(Element inputTile, Element outputTile) > throws ConfigurationException { > > String id = > inputTile.getElementsByTagName("ID").item(0).getFirstChild().getNodeValue(); > System.out.println(id); > tileNo = id; > outputTile.setAttribute("id", id); > // int intId; > try { > Integer.parseInt(id); > } catch (NumberFormatException e) { > throw new ConfigurationException("Non-numeric ID: " + id, e); > } > > String level = > inputTile.getElementsByTagName("level").item(0).getFirstChild().getNodeValue(); > colour = colourMap.get(level); > if (colour == null) { > throw new ConfigurationException("Unknown level: " + level); > } else { > outputTile.setAttribute("colour", colour); > } > > String name = > inputTile.getElementsByTagName("name").item(0).getFirstChild().getNodeValue(); > Matcher m = namePattern.matcher(name); > if (m.matches()) { > outputTile.setAttribute("name", m.group(1)); > } else > outputTile.setAttribute("name", name); > // The below does not work for "B+" > /* > * if (intId > 0) { throw new ConfigurationException("Tile with ID=" + > * id + " has a name not starting with a number: " + name); } > */ > > /* > * Create map to hold the station 'identifiers', which are referred to > * in the track definitions. > */ > junctionPosition = new HashMap<String, String>(); > outputJunction = null; > > Element junctions = > (Element) inputTile.getElementsByTagName("junctions").item(0); > NodeList children = junctions.getElementsByTagName("junction"); > for (int i = 0; i < children.getLength(); i++) { > Element inputJunction = (Element) children.item(i); > outputJunction = outputDoc.createElement("Station"); > outputTile.appendChild(outputJunction); > > convertJunction(i, inputJunction, outputJunction); > } > > unresolvedTrack = new HashMap<String, List<Element>>(); > resolvedTrack = new HashMap<Element, String>(); > > Element connections = > (Element) inputTile.getElementsByTagName("connections").item(0); > children = connections.getElementsByTagName("connection"); > for (int i = 0; i < children.getLength(); i++) { > Element inputConnection = (Element) children.item(i); > convertConnection(inputConnection, outputTile); > } > > // Iterator it = unresolvedTrack.keySet().iterator(); > String end1, end2; > // while (it.hasNext()) > for (String key : unresolvedTrack.keySet()) { > // String key = (String) it.next(); > List<Element> list = unresolvedTrack.get(key); > Element[] ends = list.toArray(new Element[0]); > if (ends.length <= 1) { > throw new ConfigurationException("Loose end " + ends[0] > + " in tile " + tileNo); > } > for (int i = 1; i < ends.length; i++) { > end1 = resolvedTrack.get(ends[i]); > if (end1 == null) { > throw new ConfigurationException("Loose end " + ends[i] > + " in tile " + tileNo); > } > for (int j = 0; j < i; j++) { > end2 = resolvedTrack.get(ends[j]); > if (end2 == null) { > throw new ConfigurationException("Loose end " + ends[j] > + " in tile " + tileNo); > } > Element outputConnection = outputDoc.createElement("Track"); > outputConnection.setAttribute("gauge", > ends[i].getAttribute("gauge")); > outputConnection.setAttribute("from", end1); > outputConnection.setAttribute("to", end2); > outputTile.appendChild(outputConnection); > > } > } > } > } > > private void convertJunction(int i, Element inputJunction, > Element outputJunction) throws ConfigurationException { > > String cityId = "city" + (i + 1); > outputJunction.setAttribute("id", cityId); > > String type = > inputJunction.getElementsByTagName("junType").item(0).getFirstChild().getNodeValue(); > > String[] station = stationMap.get(type); > if (station == null) { > throw new ConfigurationException("Unknown junction type: " + type); > } else { > station = station.clone(); > } > > /* > * Off-map cities have the special type "OffMapCity" which does not > * allow driving through. Original type "town" indicates that no token > * can be placed. > */ > if (colour.equals("red")) { > if (station[0].equals("Town")) station[1] = "0"; > station[0] = "OffMapCity"; > } > > outputJunction.setAttribute("type", station[0]); > if (!station[1].equals("0")) { > outputJunction.setAttribute("slots", station[1]); > } > > // String[] p = (String[]) ((String[]) stationMap.get(type)).clone(); > if (station == null) { > throw new ConfigurationException("Unknown junction type: " + type); > } > > // Junction revenue > Element revenue = > (Element) inputJunction.getElementsByTagName("revenue").item(0); > if (revenue != null) { > String value = > revenue.getElementsByTagName("value").item(0).getFirstChild().getNodeValue(); > outputJunction.setAttribute("value", value); > } > > // Junction position > String junctionPos = > inputJunction.getElementsByTagName("position").item(0).getFirstChild().getNodeValue(); > junctionPosition.put(junctionPos, cityId); > String jName = cityMap.get(junctionPos); > if (Util.hasValue(jName)) { > outputJunction.setAttribute("position", jName); > } else { > throw new ConfigurationException("Unknown position: " + junctionPos); > } > } > > private void convertConnection(Element inputConnection, Element outputTile) > throws ConfigurationException { > > String type = > inputConnection.getElementsByTagName("conType").item(0).getFirstChild().getNodeValue(); > String gauge = gaugeMap.get(type); > Element outputConnection; > if (gauge == null) { > throw new ConfigurationException("Unknown gauge type: " + type); > } else { > outputConnection = outputDoc.createElement("Track"); > outputConnection.setAttribute("gauge", gauge); > } > > // 1841 special: A pass is not a track type but a station type. > if (type.equals("ctMountain")) > outputJunction.setAttribute("type", "pass"); > > boolean fromOK = > convertTrackEnd(inputConnection, outputConnection, "position1", > "from"); > boolean toOK = > convertTrackEnd(inputConnection, outputConnection, "position2", > "to"); > > if (fromOK && toOK) outputTile.appendChild(outputConnection); > > } > > private boolean convertTrackEnd(Element inputConnection, > Element outputConnection, String inputName, String outputName) > throws ConfigurationException { > > String position = > inputConnection.getElementsByTagName(inputName).item(0).getFirstChild().getNodeValue(); > > String end = sidesMap.get(position); > if (end == null) end = junctionPosition.get(position); > if (end != null) { > outputConnection.setAttribute(outputName, end); > resolvedTrack.put(outputConnection, end); > return true; > } else { > if (!unresolvedTrack.containsKey(position)) { > unresolvedTrack.put(position, new ArrayList<Element>()); > } > unresolvedTrack.get(position).add(outputConnection); > return false; > } > } > > } > > --- NEW FILE: MakeGameTileSets.java --- > package tools; > > import java.io.*; > import java.util.*; > > import javax.xml.parsers.*; > import javax.xml.transform.*; > import javax.xml.transform.dom.*; > import javax.xml.transform.stream.StreamResult; > > import org.w3c.dom.*; > > import rails.game.ConfigurationException; > import tools.XmlUtils; > > /** > * Convert an XML tile dictionary, as created by Marco Rocci's Tile Designer, to > * an XML file for use in Rails 18xx. > */ > public class MakeGameTileSets { > > private static String tilesFilePath = "tiles/Tiles.xml"; > > public static void main(String[] args) { > > try { > if (args.length == 0) { > > System.out.println("Provide rails.game name(s) for which to create" > + " tile sets as argument(s).\nALL implies all games below the data directory."); > > } else if (args[0].equalsIgnoreCase("ALL")) { > > List<String> games = new ArrayList<String>(); > > File gamesDir = new File("data"); > if (gamesDir.exists() && gamesDir.isDirectory()) { > File[] files = gamesDir.listFiles(); > for (int i = 0; i < files.length; i++) { > if (files[i].isDirectory() > && !files[i].getName().equalsIgnoreCase("CVS")) { > games.add(files[i].getName()); > } > } > } > > new MakeGameTileSets(games.toArray(new String[0])); > > } else { > > new MakeGameTileSets(args); > > } > > } catch (ConfigurationException e) { > e.printStackTrace(); > } > > } > > private MakeGameTileSets(String[] games) throws ConfigurationException { > > Element inputTopElement = > XmlUtils.findElementInFile(tilesFilePath, "Tiles"); > > Map<String, Element> tileMap = new HashMap<String, Element>(); > Element tileSpec; > String tileName; > NodeList tList = inputTopElement.getElementsByTagName("Tile"); > for (int i = 0; i < tList.getLength(); i++) { > tileSpec = (Element) tList.item(i); > tileName = tileSpec.getAttribute("id"); > tileMap.put(tileName, tileSpec); > } > > for (int i = 0; i < games.length; i++) { > > makeTileSet(games[i], tileMap); > > } > > } > > private void makeTileSet(String gameName, Map<String, Element> tileMap) > throws ConfigurationException { > > // Open and read the tile set for this rails.game > String tileSetPath = "data/" + gameName + "/TileSet.xml"; > Element tileSet = > XmlUtils.findElementInFile(tileSetPath, "TileManager"); > if (tileSet == null) return; > NodeList tiles = tileSet.getElementsByTagName("Tile"); > Map<String, Object> tilesInSet = new HashMap<String, Object>(); > > // Also open and read the map tiles. > String mapPath = "data/" + gameName + "/Map.xml"; > Element mapHexes = XmlUtils.findElementInFile(mapPath, "Map"); > NodeList hexes = mapHexes.getElementsByTagName("Hex"); > > String tilesPath = "data/" + gameName + "/Tiles.xml"; > Document outputDoc; > String tileName; > > try { > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > DocumentBuilder builder = factory.newDocumentBuilder(); > DOMImplementation impl = builder.getDOMImplementation(); > outputDoc = impl.createDocument(null, "Tiles", null); > > // Scan the TileSet > for (int i = 0; i < tiles.getLength(); i++) { > > tileName = ((Element) tiles.item(i)).getAttribute("id"); > // Save the tile in a Map so that we can check completeness > // later. > tilesInSet.put(tileName, null); > > // Get the Tile specification > Element tileSpec = tileMap.get(tileName); > if (tileSpec != null) { > // Copy it to the subset document > Element copy = > (Element) outputDoc.importNode( > (tileMap.get(tileName)), true); > outputDoc.getDocumentElement().appendChild(copy); > } else { > System.out.println("ERROR: specified " + gameName > + " tile " + tileName > + " not found in Tiles.xml."); > } > } > > // Scan the map, and add any missing tiles, with a warning. > for (int i = 0; i < hexes.getLength(); i++) { > > tileName = ((Element) hexes.item(i)).getAttribute("tile"); > // Does the preprinted tile occur in TileSet? > if (tilesInSet.containsKey(tileName)) continue; > > // No, warn and add it to the tiles document. > System.out.println("WARNING: " + gameName > + " preprinted map tile " + tileName > + " does not occur in TileSet!"); > > // Get the Tile specification > // Element tileSpec = (Element) tileMap.get(tileName); > // Copy it to the subset document > Element copy = > (Element) outputDoc.importNode( > (tileMap.get(tileName)), true); > outputDoc.getDocumentElement().appendChild(copy); > > } > > TransformerFactory.newInstance().newTransformer().transform( > new DOMSource(outputDoc), > new StreamResult(new FileOutputStream(new File(tilesPath)))); > > } catch (Exception e) { > throw new ConfigurationException("Document build error", e); > } > > } > > } > > > > > ------------------------------ > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > > ------------------------------ > > _______________________________________________ > Rails-commits mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-commits > > > End of Rails-commits Digest, Vol 13, Issue 5 > ******************************************** |
From: Erik V. <ev...@us...> - 2010-02-03 20:28:34
|
Update of /cvsroot/rails/18xx/data/1830 In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3132/data/1830 Modified Files: CompanyManager.xml Log Message: Erie start city set to 0 (undefined) Index: CompanyManager.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1830/CompanyManager.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** CompanyManager.xml 31 Jan 2010 22:15:57 -0000 1.31 --- CompanyManager.xml 3 Feb 2010 20:28:23 -0000 1.32 *************** *** 79,83 **** </Company> <Company name="Erie" type="Public" tokens="3" fgColour="000000" bgColour="FFFF00"> ! <Home hex="E11"/> </Company> <Company name="B&M" type="Public" tokens="2" fgColour="000000" bgColour="60E060"> --- 79,83 ---- </Company> <Company name="Erie" type="Public" tokens="3" fgColour="000000" bgColour="FFFF00"> ! <Home hex="E11" city="0"/> </Company> <Company name="B&M" type="Public" tokens="2" fgColour="000000" bgColour="60E060"> |