You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: Erik V. <ev...@us...> - 2009-10-30 22:44:37
|
Update of /cvsroot/rails/18xx/rails/util In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/util Modified Files: Tag.java Log Message: More rationalising of static method usage Index: Tag.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/Tag.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Tag.java 30 Aug 2009 18:13:48 -0000 1.10 --- Tag.java 30 Oct 2009 21:53:04 -0000 1.11 *************** *** 11,15 **** import org.xml.sax.SAXException; ! import rails.game.*; /** --- 11,16 ---- import org.xml.sax.SAXException; ! import rails.game.ConfigurationException; ! import rails.game.GameOption; /** *************** *** 31,34 **** --- 32,38 ---- private boolean parsing = false; + /** A reference to the current game chosen options */ + private Map<String, String> gameOptions = null; + protected static Logger log = Logger.getLogger(Tag.class.getPackage().getName()); *************** *** 38,41 **** --- 42,54 ---- } + public Tag (Element element, Map<String, String> gameOptions) { + this (element); + this.gameOptions = gameOptions; + } + + public void setGameOptions (Map<String, String> gameOptions) { + this.gameOptions = gameOptions; + } + public Map<String, List<Tag>> getChildren() throws ConfigurationException { *************** *** 79,85 **** } } ! public boolean hasChild (String tagName) throws ConfigurationException { ! return getChildren ("AllowsMultipleBasesOfOneCompany") != null; } --- 92,98 ---- } } ! public boolean hasChild (String tagName) throws ConfigurationException { ! return getChildren ("AllowsMultipleBasesOfOneCompany") != null; } *************** *** 140,144 **** if (!parsed) parse(element); ! String value = attributes.get(name); if (value == null) return defaultValue; --- 153,157 ---- if (!parsed) parse(element); ! String value = attributes.get(name); if (value == null) return defaultValue; *************** *** 279,291 **** // Check if the option has been chosen; if not, skip the // rest ! String optionValue = Game.getGameOption(name); if (optionValue == null) { ! // throw new ConfigurationException ("GameOption ! // "+name+"="+value+" but no assigned value found"); ! log.warn("GameOption " + name + "=" + value + " but no assigned value found"); // Take the default value ! optionValue = GameOption.getByName(name).getDefaultValue(); } if (optionValue.equalsIgnoreCase(value)) { --- 292,308 ---- // Check if the option has been chosen; if not, skip the // rest ! if (gameOptions == null) { ! throw new ConfigurationException ( ! "No GameOptions available in tag "+element.getNodeName()); ! } ! ! String optionValue = gameOptions.get(name); if (optionValue == null) { ! log.warn("GameOption " + name + "=" + value + " but no assigned value found"); // Take the default value ! optionValue = GameOption.getByName(name).getDefaultValue(); + } if (optionValue.equalsIgnoreCase(value)) { *************** *** 296,300 **** children.put(childTagName, new ArrayList<Tag>()); } ! children.get(childTagName).add(new Tag(childElement)); } } else if (childNode.getNodeType() == Node.TEXT_NODE) { --- 313,317 ---- children.put(childTagName, new ArrayList<Tag>()); } ! children.get(childTagName).add(new Tag(childElement, gameOptions)); } } else if (childNode.getNodeType() == Node.TEXT_NODE) { |
From: Erik V. <ev...@us...> - 2009-10-30 21:53:18
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/game/action Modified Files: LayBaseToken.java LayTile.java LayBonusToken.java PossibleAction.java Log Message: More rationalising of static method usage Index: PossibleAction.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/PossibleAction.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PossibleAction.java 29 Oct 2009 19:41:30 -0000 1.13 --- PossibleAction.java 30 Oct 2009 21:53:04 -0000 1.14 *************** *** 24,27 **** --- 24,28 ---- protected String playerName; protected int playerIndex; + transient protected GameManagerI gameManager; protected boolean acted = false; *************** *** 37,41 **** public PossibleAction() { ! Player player = GameManager.getInstance().getCurrentPlayer(); if (player != null) { playerName = player.getName(); --- 38,43 ---- public PossibleAction() { ! gameManager = GameManager.getInstance(); ! Player player = gameManager.getCurrentPlayer(); if (player != null) { playerName = player.getName(); *************** *** 84,87 **** --- 86,91 ---- ClassNotFoundException { in.defaultReadObject(); + gameManager = GameManager.getInstance(); + } } Index: LayBaseToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/LayBaseToken.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LayBaseToken.java 4 Jun 2008 19:00:29 -0000 1.4 --- LayBaseToken.java 30 Oct 2009 21:53:04 -0000 1.5 *************** *** 1,4 **** /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: *************** *** 64,68 **** } ! public boolean equals(PossibleAction action) { if (!(action instanceof LayBaseToken)) return false; LayBaseToken a = (LayBaseToken) action; --- 64,69 ---- } ! @Override ! public boolean equals(PossibleAction action) { if (!(action instanceof LayBaseToken)) return false; LayBaseToken a = (LayBaseToken) action; *************** *** 73,77 **** } ! public String toString() { StringBuffer b = new StringBuffer("LayBaseToken "); if (chosenHex == null) { --- 74,79 ---- } ! @Override ! public String toString() { StringBuffer b = new StringBuffer("LayBaseToken "); if (chosenHex == null) { *************** *** 91,95 **** in.defaultReadObject(); ! MapManager mmgr = MapManager.getInstance(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { --- 93,97 ---- in.defaultReadObject(); ! MapManager mmgr = gameManager.getMapManager(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { *************** *** 104,108 **** } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = MapManager.getInstance().getHex(chosenHexName); } } --- 106,110 ---- } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = mmgr.getHex(chosenHexName); } } Index: LayTile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/LayTile.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** LayTile.java 11 Dec 2008 20:12:07 -0000 1.16 --- LayTile.java 30 Oct 2009 21:53:04 -0000 1.17 *************** *** 273,277 **** relaidBaseTokensString = (String) fields.get("relaidBaseTokensString", relaidBaseTokensString); ! MapManager mmgr = MapManager.getInstance(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { --- 273,278 ---- relaidBaseTokensString = (String) fields.get("relaidBaseTokensString", relaidBaseTokensString); ! MapManager mmgr = gameManager.getMapManager(); ! TileManager tmgr = gameManager.getTileManager(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { *************** *** 284,288 **** tiles = new ArrayList<TileI>(); for (int i = 0; i < tileIds.length; i++) { ! tiles.add(TileManager.get().getTile(tileIds[i])); } } --- 285,289 ---- tiles = new ArrayList<TileI>(); for (int i = 0; i < tileIds.length; i++) { ! tiles.add(tmgr.getTile(tileIds[i])); } } *************** *** 292,299 **** } if (laidTileId != 0) { ! laidTile = TileManager.get().getTile(laidTileId); } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = MapManager.getInstance().getHex(chosenHexName); } --- 293,300 ---- } if (laidTileId != 0) { ! laidTile = tmgr.getTile(laidTileId); } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = mmgr.getHex(chosenHexName); } Index: LayBonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/LayBonusToken.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LayBonusToken.java 4 Jun 2008 19:00:30 -0000 1.6 --- LayBonusToken.java 30 Oct 2009 21:53:04 -0000 1.7 *************** *** 1,4 **** /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: *************** *** 10,17 **** import java.util.ArrayList; ! import rails.game.BonusToken; ! import rails.game.MapHex; ! import rails.game.MapManager; ! import rails.game.Token; import rails.game.special.SpecialProperty; import rails.game.special.SpecialTokenLay; --- 10,14 ---- import java.util.ArrayList; ! import rails.game.*; import rails.game.special.SpecialProperty; import rails.game.special.SpecialTokenLay; *************** *** 42,46 **** } ! public boolean equals(PossibleAction action) { if (!(action instanceof LayBonusToken)) return false; LayBonusToken a = (LayBonusToken) action; --- 39,44 ---- } ! @Override ! public boolean equals(PossibleAction action) { if (!(action instanceof LayBonusToken)) return false; LayBonusToken a = (LayBonusToken) action; *************** *** 49,53 **** } ! public String toString() { StringBuffer b = new StringBuffer("LayBonusToken "); if (chosenHex == null) { --- 47,52 ---- } ! @Override ! public String toString() { StringBuffer b = new StringBuffer("LayBonusToken "); if (chosenHex == null) { *************** *** 66,70 **** in.defaultReadObject(); ! MapManager mmgr = MapManager.getInstance(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { --- 65,69 ---- in.defaultReadObject(); ! MapManager mmgr = gameManager.getMapManager(); locations = new ArrayList<MapHex>(); if (Util.hasValue(locationNames)) { *************** *** 82,86 **** } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = MapManager.getInstance().getHex(chosenHexName); } } --- 81,85 ---- } if (chosenHexName != null && chosenHexName.length() > 0) { ! chosenHex = mmgr.getHex(chosenHexName); } } |
From: Erik V. <ev...@us...> - 2009-10-30 21:53:12
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11565/rails/game/special Modified Files: SpecialTileLay.java SpecialProperty.java Log Message: More rationalising of static method usage Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SpecialProperty.java 9 Oct 2009 20:20:34 -0000 1.16 --- SpecialProperty.java 30 Oct 2009 21:53:04 -0000 1.17 *************** *** 5,11 **** import java.util.Map; ! import rails.game.ConfigurationException; ! import rails.game.GameManager; ! import rails.game.PrivateCompanyI; import rails.game.move.MoveableHolderI; import rails.game.move.ObjectMove; --- 5,9 ---- import java.util.Map; ! import rails.game.*; import rails.game.move.MoveableHolderI; import rails.game.move.ObjectMove; *************** *** 31,34 **** --- 29,35 ---- protected int uniqueId; + /** To give subclasses access to the various 'managers' */ + protected GameManagerI gameManager; + protected static Map<Integer, SpecialPropertyI> spMap = new HashMap<Integer, SpecialPropertyI>(); *************** *** 38,41 **** --- 39,43 ---- uniqueId = ++lastIndex; spMap.put(uniqueId, this); + gameManager = GameManager.getInstance(); } *************** *** 57,62 **** transferText = tag.getAttributeAsString("transfer", ""); } ! ! public void finishConfiguration (GameManager gameManager) {} public int getUniqueId() { --- 59,67 ---- transferText = tag.getAttributeAsString("transfer", ""); } ! ! public void finishConfiguration (GameManager gameManager) ! throws ConfigurationException { ! ! } public int getUniqueId() { Index: SpecialTileLay.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialTileLay.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SpecialTileLay.java 4 Jun 2008 19:00:38 -0000 1.6 --- SpecialTileLay.java 30 Oct 2009 21:53:04 -0000 1.7 *************** *** 19,23 **** boolean free = false; ! public void configureFromXML(Tag tag) throws ConfigurationException { super.configureFromXML(tag); --- 19,24 ---- boolean free = false; ! @Override ! public void configureFromXML(Tag tag) throws ConfigurationException { super.configureFromXML(tag); *************** *** 30,35 **** if (!Util.hasValue(locationCodes)) throw new ConfigurationException("SpecialTileLay: location missing"); ! MapManager mmgr = MapManager.getInstance(); MapHex hex; locations = new ArrayList<MapHex>(); for (String hexName : locationCodes.split(",")) { --- 31,56 ---- if (!Util.hasValue(locationCodes)) throw new ConfigurationException("SpecialTileLay: location missing"); ! ! tileNumber = tileLayTag.getAttributeAsInteger("tile", 0); ! ! name = tileLayTag.getAttributeAsString("name"); ! ! extra = tileLayTag.getAttributeAsBoolean("extra", extra); ! free = tileLayTag.getAttributeAsBoolean("free", free); ! closingValue = ! tileLayTag.getAttributeAsInteger("closingValue", closingValue); ! } ! ! public void finishConfiguration (GameManagerI gameManager) ! throws ConfigurationException { ! ! TileManager tmgr = gameManager.getTileManager(); ! MapManager mmgr = gameManager.getMapManager(); MapHex hex; + + if (tileNumber > 0) { + tile = tmgr.getTile(tileNumber); + } + locations = new ArrayList<MapHex>(); for (String hexName : locationCodes.split(",")) { *************** *** 41,55 **** } - tileNumber = tileLayTag.getAttributeAsInteger("tile", 0); - if (tileNumber > 0) { - tile = TileManager.get().getTile(tileNumber); - } - - name = tileLayTag.getAttributeAsString("name"); - - extra = tileLayTag.getAttributeAsBoolean("extra", extra); - free = tileLayTag.getAttributeAsBoolean("free", free); - closingValue = - tileLayTag.getAttributeAsInteger("closingValue", closingValue); } --- 62,65 ---- *************** *** 67,71 **** /** @deprecated */ ! public MapHex getLocation() { if (locations != null) { return locations.get(0); --- 77,82 ---- /** @deprecated */ ! @Deprecated ! public MapHex getLocation() { if (locations != null) { return locations.get(0); *************** *** 95,99 **** } ! public String toString() { return "SpecialTileLay comp=" + privateCompany.getName() + " hex=" + locationCodes + " extra=" + extra + " cost=" + free; --- 106,111 ---- } ! @Override ! public String toString() { return "SpecialTileLay comp=" + privateCompany.getName() + " hex=" + locationCodes + " extra=" + extra + " cost=" + free; |
From: Erik V. <ev...@us...> - 2009-10-29 19:42:07
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6460/rails/ui/swing/hexmap Modified Files: GUIHex.java Log Message: More rationalising of static method usage Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** GUIHex.java 8 Sep 2009 21:48:57 -0000 1.21 --- GUIHex.java 29 Oct 2009 19:41:27 -0000 1.22 *************** *** 317,321 **** if (getHexModel().isBlocked()) { List<PrivateCompanyI> privates = ! Game.getCompanyManager().getAllPrivateCompanies(); for (PrivateCompanyI p : privates) { List<MapHex> blocked = p.getBlockedHexes(); --- 317,321 ---- if (getHexModel().isBlocked()) { List<PrivateCompanyI> privates = ! GameManager.getInstance().getCompanyManager().getAllPrivateCompanies(); for (PrivateCompanyI p : privates) { List<MapHex> blocked = p.getBlockedHexes(); |
From: Erik V. <ev...@us...> - 2009-10-29 19:41:40
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6460/rails/game/action Modified Files: SellShares.java ReachDestinations.java PossibleORAction.java MergeCompanies.java SetDividend.java TakeLoans.java BuyBonusToken.java RepayLoans.java BuyPrivate.java PossibleAction.java Log Message: More rationalising of static method usage Index: PossibleAction.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/PossibleAction.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PossibleAction.java 30 Jun 2008 20:35:30 -0000 1.12 --- PossibleAction.java 29 Oct 2009 19:41:30 -0000 1.13 *************** *** 1,4 **** /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: *************** *** 6,17 **** package rails.game.action; ! import java.io.IOException; ! import java.io.ObjectInputStream; ! import java.io.Serializable; import org.apache.log4j.Logger; ! import rails.game.GameManager; ! import rails.game.Player; /** --- 6,14 ---- package rails.game.action; ! import java.io.*; import org.apache.log4j.Logger; ! import rails.game.*; /** *************** *** 19,23 **** * action (such as laying a tile or dropping a token on a specific hex, buying a * train etc.). ! * * @author Erik Vos */ --- 16,20 ---- * action (such as laying a tile or dropping a token on a specific hex, buying a * train etc.). ! * * @author Erik Vos */ *************** *** 36,40 **** /** ! * */ public PossibleAction() { --- 33,37 ---- /** ! * */ public PossibleAction() { *************** *** 59,63 **** * the player who was <b>allowed</b> to do the action, which is the one set * in the constructor). ! * * @param playerName */ --- 56,60 ---- * the player who was <b>allowed</b> to do the action, which is the one set * in the constructor). ! * * @param playerName */ *************** *** 76,79 **** --- 73,84 ---- public abstract boolean equals(PossibleAction pa); + protected GameManagerI getGameManager() { + return GameManager.getInstance(); + } + + protected CompanyManagerI getCompanyManager () { + return getGameManager().getCompanyManager(); + } + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { Index: SellShares.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/SellShares.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SellShares.java 4 Jun 2008 19:00:29 -0000 1.5 --- SellShares.java 29 Oct 2009 19:41:29 -0000 1.6 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Sep-2006 * Change Log: *************** *** 10,14 **** import rails.game.Bank; - import rails.game.Game; import rails.game.PublicCompanyI; import rails.util.Util; --- 10,13 ---- *************** *** 34,38 **** /** ! * */ public SellShares(String companyName, int shareUnits, int maximumNumber, --- 33,37 ---- /** ! * */ public SellShares(String companyName, int shareUnits, int maximumNumber, *************** *** 43,47 **** this.maximumNumber = maximumNumber; ! company = Game.getCompanyManager().getPublicCompany(companyName); shareUnit = company.getShareUnit(); share = shareUnits * shareUnit; --- 42,46 ---- this.maximumNumber = maximumNumber; ! company = getCompanyManager().getPublicCompany(companyName); shareUnit = company.getShareUnit(); share = shareUnits * shareUnit; *************** *** 70,74 **** public PublicCompanyI getCompany() { ! return Game.getCompanyManager().getPublicCompany(companyName); } --- 69,73 ---- public PublicCompanyI getCompany() { ! return getCompanyManager().getPublicCompany(companyName); } *************** *** 93,97 **** } ! public boolean equals(PossibleAction action) { if (!(action instanceof SellShares)) return false; SellShares a = (SellShares) action; --- 92,97 ---- } ! @Override ! public boolean equals(PossibleAction action) { if (!(action instanceof SellShares)) return false; SellShares a = (SellShares) action; *************** *** 102,106 **** } ! public String toString() { return "SellShares: " + (numberSold > 0 ? numberSold : "max " + maximumNumber) --- 102,107 ---- } ! @Override ! public String toString() { return "SellShares: " + (numberSold > 0 ? numberSold : "max " + maximumNumber) *************** *** 116,120 **** if (Util.hasValue(companyName)) ! company = Game.getCompanyManager().getPublicCompany(companyName); } } --- 117,121 ---- if (Util.hasValue(companyName)) ! company = getCompanyManager().getPublicCompany(companyName); } } Index: TakeLoans.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/TakeLoans.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TakeLoans.java 11 Jan 2009 17:24:46 -0000 1.1 --- TakeLoans.java 29 Oct 2009 19:41:29 -0000 1.2 *************** *** 9,13 **** import java.io.ObjectInputStream; - import rails.game.Game; import rails.game.PublicCompanyI; --- 9,12 ---- *************** *** 95,99 **** company = ! Game.getCompanyManager().getPublicCompany(companyName); } --- 94,98 ---- company = ! getCompanyManager().getPublicCompany(companyName); } Index: BuyBonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/BuyBonusToken.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BuyBonusToken.java 23 Sep 2009 21:38:58 -0000 1.1 --- BuyBonusToken.java 29 Oct 2009 19:41:30 -0000 1.2 *************** *** 116,125 **** privateCompany = ! Game.getCompanyManager().getPrivateCompany(privateCompanyName); if (sellerName.equalsIgnoreCase("Bank")) { seller = Bank.getInstance(); } else if (sellerName != null) { seller = ! Game.getCompanyManager().getPublicCompany(sellerName); } if (specialPropertyId > 0) { --- 116,125 ---- privateCompany = ! getCompanyManager().getPrivateCompany(privateCompanyName); if (sellerName.equalsIgnoreCase("Bank")) { seller = Bank.getInstance(); } else if (sellerName != null) { seller = ! getCompanyManager().getPublicCompany(sellerName); } if (specialPropertyId > 0) { Index: RepayLoans.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/RepayLoans.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RepayLoans.java 4 May 2009 20:29:15 -0000 1.4 --- RepayLoans.java 29 Oct 2009 19:41:30 -0000 1.5 *************** *** 9,13 **** import java.io.ObjectInputStream; - import rails.game.Game; import rails.game.PublicCompanyI; --- 9,12 ---- *************** *** 109,113 **** company = ! Game.getCompanyManager().getPublicCompany(companyName); } --- 108,112 ---- company = ! getCompanyManager().getPublicCompany(companyName); } Index: BuyPrivate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/BuyPrivate.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BuyPrivate.java 4 Jun 2008 19:00:29 -0000 1.5 --- BuyPrivate.java 29 Oct 2009 19:41:30 -0000 1.6 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Sep-2006 * Change Log: *************** *** 9,13 **** import java.io.ObjectInputStream; - import rails.game.Game; import rails.game.PrivateCompanyI; --- 9,12 ---- *************** *** 29,33 **** /** ! * */ public BuyPrivate(PrivateCompanyI privateCompany, int minimumPrice, --- 28,32 ---- /** ! * */ public BuyPrivate(PrivateCompanyI privateCompany, int minimumPrice, *************** *** 69,73 **** } ! public boolean equals(PossibleAction action) { if (!(action instanceof BuyPrivate)) return false; BuyPrivate a = (BuyPrivate) action; --- 68,73 ---- } ! @Override ! public boolean equals(PossibleAction action) { if (!(action instanceof BuyPrivate)) return false; BuyPrivate a = (BuyPrivate) action; *************** *** 77,81 **** } ! public String toString() { return "BuyPrivate " + privateCompany.getName() + " holder=" + privateCompany.getPortfolio().getName(); --- 77,82 ---- } ! @Override ! public String toString() { return "BuyPrivate " + privateCompany.getName() + " holder=" + privateCompany.getPortfolio().getName(); *************** *** 89,93 **** privateCompany = ! Game.getCompanyManager().getPrivateCompany(privateCompanyName); } --- 90,94 ---- privateCompany = ! getCompanyManager().getPrivateCompany(privateCompanyName); } Index: SetDividend.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/SetDividend.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SetDividend.java 14 Jan 2009 20:45:07 -0000 1.5 --- SetDividend.java 29 Oct 2009 19:41:29 -0000 1.6 *************** *** 6,10 **** import rails.game.Bank; - import rails.game.Game; import rails.util.Util; --- 6,9 ---- *************** *** 201,205 **** if (Util.hasValue(companyName)) { ! company = Game.getCompanyManager().getPublicCompany(companyName); } } --- 200,204 ---- if (Util.hasValue(companyName)) { ! company = getCompanyManager().getPublicCompany(companyName); } } Index: MergeCompanies.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/MergeCompanies.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MergeCompanies.java 24 Dec 2008 22:02:20 -0000 1.5 --- MergeCompanies.java 29 Oct 2009 19:41:29 -0000 1.6 *************** *** 53,57 **** && (!hex.hasTokenOfCompany(target) || hex.getCurrentTile().allowsMultipleBasesOfOneCompany() ! && hex.getCityOfBaseToken(mergingCompany) != hex.getCityOfBaseToken(target))); } --- 53,57 ---- && (!hex.hasTokenOfCompany(target) || hex.getCurrentTile().allowsMultipleBasesOfOneCompany() ! && hex.getCityOfBaseToken(mergingCompany) != hex.getCityOfBaseToken(target))); } *************** *** 126,130 **** replaceToken = fields.get("replaceToken", replaceToken); ! CompanyManagerI cmgr = Game.getCompanyManager(); mergingCompany = cmgr.getCompanyByName(mergingCompanyName); --- 126,130 ---- replaceToken = fields.get("replaceToken", replaceToken); ! CompanyManagerI cmgr = getCompanyManager(); mergingCompany = cmgr.getCompanyByName(mergingCompanyName); Index: PossibleORAction.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/PossibleORAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PossibleORAction.java 4 Jun 2008 19:00:29 -0000 1.3 --- PossibleORAction.java 29 Oct 2009 19:41:29 -0000 1.4 *************** *** 1,4 **** /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 14-Sep-2006 * Change Log: *************** *** 9,17 **** import java.io.ObjectInputStream; ! import rails.game.Game; ! import rails.game.GameManager; ! import rails.game.OperatingRound; ! import rails.game.PublicCompanyI; ! import rails.game.RoundI; import rails.util.Util; --- 9,13 ---- import java.io.ObjectInputStream; ! import rails.game.*; import rails.util.Util; *************** *** 20,24 **** * action (such as laying a tile or dropping a token on a specific hex, buying a * train etc.). ! * * @author Erik Vos */ --- 16,20 ---- * action (such as laying a tile or dropping a token on a specific hex, buying a * train etc.). ! * * @author Erik Vos */ *************** *** 30,34 **** /** ! * */ public PossibleORAction() { --- 26,30 ---- /** ! * */ public PossibleORAction() { *************** *** 63,67 **** if (Util.hasValue(companyName)) ! company = Game.getCompanyManager().getPublicCompany(companyName); } } --- 59,63 ---- if (Util.hasValue(companyName)) ! company = getCompanyManager().getPublicCompany(companyName); } } Index: ReachDestinations.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/ReachDestinations.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReachDestinations.java 2 Dec 2008 20:29:15 -0000 1.2 --- ReachDestinations.java 29 Oct 2009 19:41:29 -0000 1.3 *************** *** 7,11 **** import rails.game.CompanyManagerI; - import rails.game.Game; import rails.game.PublicCompanyI; --- 7,10 ---- *************** *** 26,33 **** public static final long serialVersionUID = 1L; ! public ReachDestinations (List<PublicCompanyI> companies) { possibleCompanies = companies; ! StringBuffer b = new StringBuffer(); for (PublicCompanyI company : companies) { if (b.length() > 0) b.append(","); --- 25,32 ---- public static final long serialVersionUID = 1L; ! public ReachDestinations (List<PublicCompanyI> companies) { possibleCompanies = companies; ! StringBuffer b = new StringBuffer(); for (PublicCompanyI company : companies) { if (b.length() > 0) b.append(","); *************** *** 36,40 **** possibleCompanyNames = b.toString(); } ! /** Required for deserialization */ public ReachDestinations() {} --- 35,39 ---- possibleCompanyNames = b.toString(); } ! /** Required for deserialization */ public ReachDestinations() {} *************** *** 43,53 **** return possibleCompanies; } ! public String getPossibleCompanyNames () { return possibleCompanyNames; } ! public void addReachedCompany (PublicCompanyI company) { ! if (reachedCompanies == null) reachedCompanies = new ArrayList<PublicCompanyI>(); reachedCompanies.add (company); --- 42,52 ---- return possibleCompanies; } ! public String getPossibleCompanyNames () { return possibleCompanyNames; } ! public void addReachedCompany (PublicCompanyI company) { ! if (reachedCompanies == null) reachedCompanies = new ArrayList<PublicCompanyI>(); reachedCompanies.add (company); *************** *** 61,66 **** return reachedCompanies; } ! ! @Override --- 60,65 ---- return reachedCompanies; } ! ! @Override *************** *** 86,90 **** in.defaultReadObject(); ! CompanyManagerI cmgr = Game.getCompanyManager(); possibleCompanies = new ArrayList<PublicCompanyI>(); --- 85,89 ---- in.defaultReadObject(); ! CompanyManagerI cmgr = getCompanyManager(); possibleCompanies = new ArrayList<PublicCompanyI>(); |
From: Erik V. <ev...@us...> - 2009-10-29 19:41:40
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6460/rails/game/specific/_18EU Modified Files: FinalMinorExchangeRound.java StartCompany_18EU.java Log Message: More rationalising of static method usage Index: FinalMinorExchangeRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/FinalMinorExchangeRound.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FinalMinorExchangeRound.java 7 Oct 2009 19:00:38 -0000 1.8 --- FinalMinorExchangeRound.java 29 Oct 2009 19:41:30 -0000 1.9 *************** *** 96,100 **** moveStack.start(false); ! for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { if (comp.getTypeName().equals("Minor")) { if (!comp.isClosed()) { --- 96,100 ---- moveStack.start(false); ! for (PublicCompanyI comp : companyManager.getAllPublicCompanies()) { if (comp.getTypeName().equals("Minor")) { if (!comp.isClosed()) { Index: StartCompany_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartCompany_18EU.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StartCompany_18EU.java 3 Oct 2009 14:02:28 -0000 1.6 --- StartCompany_18EU.java 29 Oct 2009 19:41:30 -0000 1.7 *************** *** 111,115 **** in.defaultReadObject(); ! CompanyManagerI cmgr = Game.getCompanyManager(); if (minorsToMergeNames != null) { minorsToMerge = new ArrayList<PublicCompanyI>(); --- 111,115 ---- in.defaultReadObject(); ! CompanyManagerI cmgr = getCompanyManager(); if (minorsToMergeNames != null) { minorsToMerge = new ArrayList<PublicCompanyI>(); *************** *** 121,130 **** chosenMinor = cmgr.getPublicCompany(chosenMinorName); } ! MapManager mapManager = MapManager.getInstance(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); for (String cityName : availableHomeStationNames.split(",")) { ! String[] parts = parseStationName (cityName); MapHex hex = mapManager.getHex(parts[0]); availableHomeStations.add (hex.getCity(Integer.parseInt(parts[1]))); --- 121,130 ---- chosenMinor = cmgr.getPublicCompany(chosenMinorName); } ! MapManager mapManager = MapManager.getInstance(); if (availableHomeStationNames != null) { availableHomeStations = new ArrayList<City>(); for (String cityName : availableHomeStationNames.split(",")) { ! String[] parts = parseStationName (cityName); MapHex hex = mapManager.getHex(parts[0]); availableHomeStations.add (hex.getCity(Integer.parseInt(parts[1]))); *************** *** 132,143 **** } if (selectedHomeStationName != null) { ! String[] parts = parseStationName (selectedHomeStationName); MapHex hex = mapManager.getHex(parts[0]); selectedHomeStation = hex.getCity(Integer.parseInt(parts[1])); } } ! private String[] parseStationName (String name) { ! if (name.contains(" on ")) { // Old style --- 132,143 ---- } if (selectedHomeStationName != null) { ! String[] parts = parseStationName (selectedHomeStationName); MapHex hex = mapManager.getHex(parts[0]); selectedHomeStation = hex.getCity(Integer.parseInt(parts[1])); } } ! private String[] parseStationName (String name) { ! if (name.contains(" on ")) { // Old style |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6460/rails/game Modified Files: StartRound.java StockRound.java StockMarket.java GameManagerI.java Game.java ComponentManager.java GameManager.java Log Message: More rationalising of static method usage Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** StartRound.java 7 Oct 2009 21:03:36 -0000 1.28 --- StartRound.java 29 Oct 2009 19:41:28 -0000 1.29 *************** *** 55,59 **** public void start() { ! this.variant = Game.getGameOption(GameManager.VARIANT_KEY); if (variant == null) variant = ""; numPlayers = gameManager.getNumberOfPlayers(); --- 55,59 ---- public void start() { ! this.variant = gameManager.getGameOption(GameManager.VARIANT_KEY); if (variant == null) variant = ""; numPlayers = gameManager.getNumberOfPlayers(); Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** GameManager.java 9 Oct 2009 22:29:01 -0000 1.62 --- GameManager.java 29 Oct 2009 19:41:29 -0000 1.63 *************** *** 52,55 **** --- 52,57 ---- protected Bank bank; + protected Map<String, String> gameOptions; + protected List<Player> players; protected List<String> playerNames; *************** *** 400,405 **** } ! public void startGame() { setGameParameters(); --- 402,408 ---- } ! public void startGame(Map<String,String> gameOptions) { + this.gameOptions = gameOptions; setGameParameters(); *************** *** 1032,1035 **** --- 1035,1042 ---- } + public String getGameOption (String key) { + return gameOptions.get(key); + } + // TODO Should be removed public void initialiseNewPhase(PhaseI phase) { Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Game.java 9 Oct 2009 22:29:01 -0000 1.32 --- Game.java 29 Oct 2009 19:41:29 -0000 1.33 *************** *** 69,73 **** public void start() { ! gameManager.startGame(); } --- 69,73 ---- public void start() { ! gameManager.startGame(gameOptions); } *************** *** 89,93 **** } ! ComponentManager.configureInstance(name, componentManagerTag); componentManager = ComponentManager.getInstance(); --- 89,93 ---- } ! ComponentManager.configureInstance(name, componentManagerTag, gameOptions); componentManager = ComponentManager.getInstance(); *************** *** 170,174 **** playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); --- 170,174 ---- playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, tileManager, bank); *************** *** 255,265 **** * @return The company manager */ - public static CompanyManagerI getCompanyManager() { - return instance.companyManager; - } - - /** - * @return The company manager - */ public static StockMarketI getStockMarket() { return instance.stockMarket; --- 255,258 ---- Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** StockMarket.java 9 Oct 2009 20:20:34 -0000 1.19 --- StockMarket.java 29 Oct 2009 19:41:28 -0000 1.20 *************** *** 146,150 **** public void finishConfiguration (GameManager gameManager) { ! for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { if (!comp.hasStarted() && comp.getStartSpace() != null) { comp.getStartSpace().addFixedStartPrice(comp); --- 146,150 ---- public void finishConfiguration (GameManager gameManager) { ! for (PublicCompanyI comp : GameManager.getInstance().getCompanyManager().getAllPublicCompanies()) { if (!comp.hasStarted() && comp.getStartSpace() != null) { comp.getStartSpace().addFixedStartPrice(comp); Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** StockRound.java 7 Oct 2009 19:00:38 -0000 1.46 --- StockRound.java 29 Oct 2009 19:41:28 -0000 1.47 *************** *** 1247,1251 **** // Over the hold limit of any company? ! for (PublicCompanyI company : Game.getCompanyManager().getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() && !mayPlayerBuyCompanyShare(player, company, 0)) return true; --- 1247,1251 ---- // Over the hold limit of any company? ! for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() && !mayPlayerBuyCompanyShare(player, company, 0)) return true; Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ComponentManager.java 15 Jan 2009 20:53:28 -0000 1.12 --- ComponentManager.java 29 Oct 2009 19:41:29 -0000 1.13 *************** *** 35,38 **** --- 35,40 ---- private List<Tag> componentTags; + private Map<String, String> gameOptions; + protected static Logger log = Logger.getLogger(ComponentManager.class.getPackage().getName()); *************** *** 47,51 **** } ! public static synchronized void configureInstance(String gameName, Tag tag) throws ConfigurationException { if (instance != null) { --- 49,54 ---- } ! public static synchronized void configureInstance(String gameName, Tag tag, ! Map<String, String> gameOptions) throws ConfigurationException { if (instance != null) { *************** *** 53,62 **** LocalText.getText("ComponentManagerNotReconfigured")); } ! new ComponentManager(gameName, tag); } ! private ComponentManager(String gameName, Tag tag) throws ConfigurationException { instance = this; ComponentManager.gameName = gameName; --- 56,67 ---- LocalText.getText("ComponentManagerNotReconfigured")); } ! new ComponentManager(gameName, tag, gameOptions); } ! private ComponentManager(String gameName, Tag tag, Map<String, String> gameOptions) throws ConfigurationException { + instance = this; + this.gameOptions = gameOptions; ComponentManager.gameName = gameName; *************** *** 82,86 **** } ! private static void configureComponent(Tag componentTag) throws ConfigurationException { --- 87,91 ---- } ! private void configureComponent(Tag componentTag) throws ConfigurationException { Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GameManagerI.java 9 Oct 2009 22:29:01 -0000 1.18 --- GameManagerI.java 29 Oct 2009 19:41:28 -0000 1.19 *************** *** 2,5 **** --- 2,6 ---- import java.util.List; + import java.util.Map; import rails.common.Defs; *************** *** 19,23 **** TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, TileManager tileManager, Bank bank); ! public abstract void startGame(); public abstract CompanyManagerI getCompanyManager(); --- 20,24 ---- TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, TileManager tileManager, Bank bank); ! public abstract void startGame(Map<String, String> gameOptions); public abstract CompanyManagerI getCompanyManager(); *************** *** 152,155 **** --- 153,158 ---- public Bank getBank (); + public String getGameOption (String key); + public int getPlayerCertificateLimit(); public void setPlayerCertificateLimit(int newLimit); |
From: Erik V. <ev...@us...> - 2009-10-29 19:41:04
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6274 Modified Files: LocalisedText.properties Log Message: Added message for payouts Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** LocalisedText.properties 6 Oct 2009 18:34:04 -0000 1.78 --- LocalisedText.properties 29 Oct 2009 19:40:53 -0000 1.79 *************** *** 228,231 **** --- 228,232 ---- MoreLoansNotAllowed={0} would exceed loans limit of {1} PaysTo={0} pays {1} to {2} + Payout={0} receives {1} for {2} {3}% shares MOVE=Move MODERATOR=Moderator |
From: Erik V. <ev...@us...> - 2009-10-29 19:40:50
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6135/rails/game Modified Files: PublicCompany.java Log Message: Payments are rounded up Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** PublicCompany.java 9 Oct 2009 20:20:34 -0000 1.68 --- PublicCompany.java 29 Oct 2009 19:40:31 -0000 1.69 *************** *** 22,26 **** */ public class PublicCompany extends Company implements PublicCompanyI { ! protected static final int DEFAULT_SHARE_UNIT = 10; --- 22,26 ---- */ public class PublicCompany extends Company implements PublicCompanyI { ! protected static final int DEFAULT_SHARE_UNIT = 10; *************** *** 1215,1235 **** int part; ! Map<CashHolder, Integer> split = new HashMap<CashHolder, Integer>(); for (PublicCertificateI cert : certificates) { CashHolder recipient = getBeneficiary(cert); ! part = amount * cert.getShares() * shareUnit.intValue() / 100; ! // For reporting, we want to add up the amounts per recipient ! if (split.containsKey(recipient)) { ! part += (split.get(recipient)).intValue(); } - split.put(recipient, new Integer(part)); } ! // Report and add the cash ! for (CashHolder recipient : split.keySet()) { if (recipient instanceof Bank) continue; ! part = (split.get(recipient)).intValue(); ! ReportBuffer.add(recipient.getName() + " receives " ! + Bank.format(part)); new CashMove(bank, recipient, part); } --- 1215,1246 ---- int part; ! int shares; ! Map<CashHolder, Integer> sharesPerRecipient = new HashMap<CashHolder, Integer>(); + // Changed to accomodate the CGR 5% share roundup rule. + // For now it is assumed, that actual payouts are always rounded up + // (the withheld half of split revenues is not handled here, see splitRevenue()). + + // First count the shares per recipient for (PublicCertificateI cert : certificates) { CashHolder recipient = getBeneficiary(cert); ! if (!sharesPerRecipient.containsKey(recipient)) { ! sharesPerRecipient.put(recipient, cert.getShares()); ! } else { ! sharesPerRecipient.put(recipient, ! sharesPerRecipient.get(recipient) + cert.getShares()); } } ! ! // Calculate, round up, report and add the cash ! for (CashHolder recipient : sharesPerRecipient.keySet()) { if (recipient instanceof Bank) continue; ! shares = (sharesPerRecipient.get(recipient)); ! part = (int) Math.ceil(amount * shares * shareUnit.intValue() / 100.0); ! ReportBuffer.add(LocalText.getText("Payout", ! recipient.getName(), ! Bank.format(part), ! shares, ! shareUnit.intValue())); new CashMove(bank, recipient, part); } *************** *** 1237,1241 **** // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove || amount >= currentPrice.getPrice().getPrice())) { stockMarket.payOut(this); --- 1248,1252 ---- // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove || amount >= currentPrice.getPrice().getPrice())) { stockMarket.payOut(this); |
From: Erik V. <ev...@us...> - 2009-10-10 15:26:07
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4315/rails/game Modified Files: ConfigurableComponentI.java Train.java TrainManager.java TrainI.java TrainTypeI.java TrainType.java Log Message: TrainManager - removed static instance variable. Index: TrainTypeI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainTypeI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TrainTypeI.java 25 Sep 2009 19:13:01 -0000 1.9 --- TrainTypeI.java 10 Oct 2009 15:25:49 -0000 1.10 *************** *** 2,6 **** package rails.game; ! public interface TrainTypeI { /** --- 2,7 ---- package rails.game; ! public interface TrainTypeI ! extends ConfigurableComponentI, Cloneable { /** *************** *** 104,107 **** --- 105,110 ---- public TrainI cloneTrain(); + + public int getIndex(); } Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** TrainManager.java 9 Oct 2009 20:20:34 -0000 1.20 --- TrainManager.java 10 Oct 2009 15:25:49 -0000 1.21 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes private static TrainManager instance = null; protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { instance = this; // Nothing to do here, everything happens when configured. newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManager gameManager) { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : instance.getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManager gameManager) throws ConfigurationException { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); for (TrainTypeI type : lTrainTypes) { type.finishConfiguration(gameManager); } // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : GameManager.getInstance().getTrainManager().getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file Index: ConfigurableComponentI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ConfigurableComponentI.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConfigurableComponentI.java 9 Oct 2009 20:20:34 -0000 1.5 --- ConfigurableComponentI.java 10 Oct 2009 15:25:49 -0000 1.6 *************** *** 5,9 **** /** ! * Interaface for rails.game components which can be configured from an XML * element. */ --- 5,9 ---- /** ! * Interface for rails.game components which can be configured from an XML * element. */ Index: Train.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Train.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Train.java 25 Sep 2009 19:13:01 -0000 1.13 --- Train.java 10 Oct 2009 15:25:49 -0000 1.14 *************** *** 47,51 **** this.townCountIndicator = type.getTownCountIndicator(); - unavailable.addTrain(this); uniqueId = type.getName() + "_" + index; trainMap.put(uniqueId, this); --- 47,50 ---- *************** *** 155,158 **** return getName(); } ! } --- 154,157 ---- return getName(); } ! } Index: TrainI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainI.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TrainI.java 4 Jun 2008 19:00:32 -0000 1.7 --- TrainI.java 10 Oct 2009 15:25:49 -0000 1.8 *************** *** 5,8 **** --- 5,9 ---- public interface TrainI extends Moveable { + public void init(TrainTypeI type, int index); Index: TrainType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainType.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** TrainType.java 9 Oct 2009 20:20:34 -0000 1.23 --- TrainType.java 10 Oct 2009 15:25:49 -0000 1.24 *************** *** 12,16 **** import rails.util.Tag; ! public class TrainType implements TrainTypeI, ConfigurableComponentI, Cloneable { public final static int TOWN_COUNT_MAJOR = 2; --- 12,17 ---- import rails.util.Tag; ! public class TrainType ! implements TrainTypeI { public final static int TOWN_COUNT_MAJOR = 2; *************** *** 24,27 **** --- 25,31 ---- protected int amount; protected boolean infiniteAmount = false; + + /** Index: used for sorting trains lists in configured order. */ + protected int index; private String reachBasis = "stops"; *************** *** 217,221 **** } ! public void finishConfiguration (GameManager gameManager) {} protected TrainI createTrain () throws ConfigurationException { --- 221,233 ---- } ! public void finishConfiguration (GameManager gameManager) { ! index = gameManager.getTrainManager().getTrainTypes().indexOf(this); ! ! Portfolio unavailable = gameManager.getBank().getUnavailable(); ! ! for (TrainI train : trains) { ! unavailable.addTrain(train); ! } ! } protected TrainI createTrain () throws ConfigurationException { *************** *** 450,453 **** return clone; } ! } --- 462,469 ---- return clone; } ! ! public int getIndex() { ! return index; ! } ! } |
From: Erik V. <ev...@us...> - 2009-10-09 22:29:16
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21628/rails/game Modified Files: Game.java MapManager.java MapHex.java GameManagerI.java GameManager.java Log Message: MapManager & TrainManager config. updates Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MapHex.java 9 Oct 2009 20:20:34 -0000 1.26 --- MapHex.java 9 Oct 2009 22:29:01 -0000 1.27 *************** *** 162,177 **** currentTileRotation = tag.getAttributeAsInteger("orientation", 0); - currentTile = TileManager.get().getTile(preprintedTileId); impassable = tag.getAttributeAsString("impassable"); tileCost = tag.getAttributeAsIntegerArray("cost", new int[0]); // We need completely new objects, not just references to the Tile's // stations. cities = new ArrayList<City>(4); mCities = new HashMap<Integer, City>(4); ! // for (int i = 0; i < currentTile.getStations().size(); i++) ! for (Station s : currentTile.getStations()) { // sid, type, value, slots - // Station s = currentTile.getStations().get(i); City c = new City(this, s.getNumber(), s); cities.add(c); --- 162,185 ---- currentTileRotation = tag.getAttributeAsInteger("orientation", 0); impassable = tag.getAttributeAsString("impassable"); tileCost = tag.getAttributeAsIntegerArray("cost", new int[0]); + // Off-board revenue values + offBoardValues = tag.getAttributeAsIntegerArray("value", null); + + // City name + cityName = tag.getAttributeAsString("city", ""); + + } + + public void finishConfiguration (GameManager gameManager) { + + currentTile = gameManager.getTileManager().getTile(preprintedTileId); // We need completely new objects, not just references to the Tile's // stations. cities = new ArrayList<City>(4); mCities = new HashMap<Integer, City>(4); ! for (Station s : currentTile.getStations()) { // sid, type, value, slots City c = new City(this, s.getNumber(), s); cities.add(c); *************** *** 179,192 **** } - // Off-board revenue values - offBoardValues = tag.getAttributeAsIntegerArray("value", null); - - // City name - cityName = tag.getAttributeAsString("city", ""); - } - public void finishConfiguration (GameManager gameManager) {} - public boolean isNeighbour(MapHex neighbour, int direction) { /* --- 187,192 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** GameManager.java 9 Oct 2009 20:20:34 -0000 1.61 --- GameManager.java 9 Oct 2009 22:29:01 -0000 1.62 *************** *** 49,52 **** --- 49,53 ---- protected StockMarketI stockMarket; protected MapManager mapManager; + protected TileManager tileManager; protected Bank bank; *************** *** 381,384 **** --- 382,386 ---- StockMarketI stockMarket, MapManager mapManager, + TileManager tileManager, Bank bank) { this.playerManager = playerManager; *************** *** 388,391 **** --- 390,394 ---- this.stockMarket = stockMarket; this.mapManager = mapManager; + this.tileManager = tileManager; this.bank = bank; *************** *** 1021,1024 **** --- 1024,1031 ---- } + public TileManager getTileManager() { + return tileManager; + } + public Bank getBank () { return bank; Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MapManager.java 9 Oct 2009 20:20:34 -0000 1.9 --- MapManager.java 9 Oct 2009 22:29:01 -0000 1.10 *************** *** 22,25 **** --- 22,26 ---- protected static MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); + protected int maxX, maxY; protected static final int[] xDeltaNS = new int[] { 0, -1, -1, 0, +1, +1 }; *************** *** 78,83 **** List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! int maxX = 0; ! int maxY = 0; for (Tag hexTag : hexTags) { hex = new MapHex(this); --- 79,84 ---- List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! maxX = 0; ! maxY = 0; for (Tag hexTag : hexTags) { hex = new MapHex(this); *************** *** 94,97 **** --- 95,110 ---- hexes[hex.getX()][hex.getY()] = hex; } + } + + public void finishConfiguration (GameManager gameManager) { + + MapHex hex; + int i, j, k, dx, dy; + MapHex nb; + + for (String hexName : mHexes.keySet()) { + hex = mHexes.get(hexName); + hex.finishConfiguration(gameManager); + } // Initialise the neighbours *************** *** 100,108 **** * preprinted tiles. */ - int i, j, k, dx, dy; - MapHex nb; for (i = 0; i <= maxX; i++) { for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { --- 113,120 ---- * preprinted tiles. */ for (i = 0; i <= maxX; i++) { for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; + for (k = 0; k < 6; k++) { if (tileOrientation == MapHex.EW) { *************** *** 126,133 **** } } - } - - public void finishConfiguration (GameManager gameManager) { - MapHex hex; for (PublicCompanyI company : gameManager.getCompanyManager().getAllPublicCompanies()) { --- 138,141 ---- Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Game.java 9 Oct 2009 20:20:34 -0000 1.31 --- Game.java 9 Oct 2009 22:29:01 -0000 1.32 *************** *** 28,31 **** --- 28,32 ---- protected StockMarketI stockMarket; protected MapManager mapManager; + protected TileManager tileManager; protected Bank bank; // protected ArrayList companyList; *************** *** 155,158 **** --- 156,167 ---- } + tileManager = + (TileManager) componentManager.findComponent("TileManager"); + if (tileManager == null) { + throw new ConfigurationException( + "No TileManager XML element found in file " + + GAME_XML_FILE); + } + /* * Initialisations that involve relations between components can *************** *** 161,165 **** playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, bank); companyManager.finishConfiguration(gameManager); --- 170,175 ---- playerManager.setPlayers(players, bank); gameManager.init(playerManager, companyManager, ! phaseManager, trainManager, stockMarket, mapManager, ! tileManager, bank); companyManager.finishConfiguration(gameManager); Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GameManagerI.java 9 Oct 2009 20:20:34 -0000 1.17 --- GameManagerI.java 9 Oct 2009 22:29:01 -0000 1.18 *************** *** 9,13 **** import rails.game.move.MoveableHolderI; import rails.game.special.SpecialPropertyI; - import rails.util.Tag; public interface GameManagerI extends MoveableHolderI, ConfigurableComponentI { --- 9,12 ---- *************** *** 19,23 **** CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, ! MapManager mapManager, Bank bank); public abstract void startGame(); --- 18,22 ---- CompanyManagerI companyManager, PhaseManager phaseManager, TrainManager trainManager, StockMarketI stockMarket, ! MapManager mapManager, TileManager tileManager, Bank bank); public abstract void startGame(); |
From: Erik V. <ev...@us...> - 2009-10-09 20:20:50
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3137/rails/ui/swing Modified Files: StartRoundWindow.java Log Message: Extended ConfiguableComponentI interface to include final (post XML-parsing) initialisation. Used it to remove several more static methods & calls. Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** StartRoundWindow.java 15 Jan 2009 20:53:28 -0000 1.30 --- StartRoundWindow.java 9 Oct 2009 20:20:34 -0000 1.31 *************** *** 158,162 **** gbc = new GridBagConstraints(); ! players = Game.getPlayerManager().getPlayers().toArray(new Player[0]); np = GameManager.getInstance().getNumberOfPlayers(); packet = round.getStartPacket(); --- 158,162 ---- gbc = new GridBagConstraints(); ! players = gameUIManager.getGameManager().getPlayers().toArray(new Player[0]); np = GameManager.getInstance().getNumberOfPlayers(); packet = round.getStartPacket(); |
From: Erik V. <ev...@us...> - 2009-10-09 20:20:49
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3137/rails/game/specific/_18EU Modified Files: StockRound_18EU.java Log Message: Extended ConfiguableComponentI interface to include final (post XML-parsing) initialisation. Used it to remove several more static methods & calls. Index: StockRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StockRound_18EU.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** StockRound_18EU.java 7 Oct 2009 19:00:39 -0000 1.25 --- StockRound_18EU.java 9 Oct 2009 20:20:34 -0000 1.26 *************** *** 89,94 **** } else { freeStations = new ArrayList<City>(); ! MapManager map = ! (MapManager) Game.getComponentManager().findComponent("Map"); for (City city : map.getCurrentStations()) { if (city.getSlots() > city.getTokens().size()) { --- 89,93 ---- } else { freeStations = new ArrayList<City>(); ! MapManager map = gameManager.getMapManager(); for (City city : map.getCurrentStations()) { if (city.getSlots() > city.getTokens().size()) { |
From: Erik V. <ev...@us...> - 2009-10-09 20:20:49
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3137/rails/game/specific/_1856 Modified Files: PublicCompany_CGR.java Log Message: Extended ConfiguableComponentI interface to include final (post XML-parsing) initialisation. Used it to remove several more static methods & calls. Index: PublicCompany_CGR.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/PublicCompany_CGR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PublicCompany_CGR.java 6 Oct 2009 18:34:03 -0000 1.4 --- PublicCompany_CGR.java 9 Oct 2009 20:20:34 -0000 1.5 *************** *** 93,97 **** if (amount > 0) new CashMove(bank, this, amount); if (hasStockPrice && !runsWithBorrowedTrain()) { ! Game.getStockMarket().withhold(this); } } --- 93,97 ---- if (amount > 0) new CashMove(bank, this, amount); if (hasStockPrice && !runsWithBorrowedTrain()) { ! stockMarket.withhold(this); } } |
From: Erik V. <ev...@us...> - 2009-10-09 20:20:49
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3137/rails/game/special Modified Files: SpecialProperty.java Log Message: Extended ConfiguableComponentI interface to include final (post XML-parsing) initialisation. Used it to remove several more static methods & calls. Index: SpecialProperty.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/SpecialProperty.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SpecialProperty.java 3 Oct 2009 14:00:07 -0000 1.15 --- SpecialProperty.java 9 Oct 2009 20:20:34 -0000 1.16 *************** *** 6,9 **** --- 6,10 ---- import rails.game.ConfigurationException; + import rails.game.GameManager; import rails.game.PrivateCompanyI; import rails.game.move.MoveableHolderI; *************** *** 56,59 **** --- 57,62 ---- transferText = tag.getAttributeAsString("transfer", ""); } + + public void finishConfiguration (GameManager gameManager) {} public int getUniqueId() { |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3137/rails/game Modified Files: StockMarket.java PhaseManager.java MapHex.java TileManager.java TrainType.java Game.java PlayerManager.java ConfigurableComponentI.java PublicCompany.java TrainManager.java GameManager.java Phase.java CompanyManagerI.java PublicCompanyI.java StockMarketI.java CompanyManager.java CompanyType.java Bank.java GameManagerI.java MapManager.java PrivateCompany.java Log Message: Extended ConfiguableComponentI interface to include final (post XML-parsing) initialisation. Used it to remove several more static methods & calls. Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Bank.java 3 Oct 2009 14:00:36 -0000 1.13 --- Bank.java 9 Oct 2009 20:20:34 -0000 1.14 *************** *** 96,118 **** DEFAULT_BANK_AMOUNT)); } - ReportBuffer.add(LocalText.getText("BankSizeIs", - format(money.getCash()))); } ! /** ! * @param percentage of a company allowed to be in the Bank pool. ! */ ! public void setPoolShareLimit(int percentage) { ! poolShareLimit = percentage; ! } - /** - * Put all available certificates in the IPO - */ - public void initCertificates() { // Add privates List<PrivateCompanyI> privates = ! Game.getCompanyManager().getAllPrivateCompanies(); for (PrivateCompanyI priv : privates) { ipo.addPrivate(priv); --- 96,110 ---- DEFAULT_BANK_AMOUNT)); } } ! public void finishConfiguration (GameManager gameManager) { ! ! ReportBuffer.add(LocalText.getText("BankSizeIs", ! format(money.getCash()))); // Add privates List<PrivateCompanyI> privates = ! gameManager.getCompanyManager().getAllPrivateCompanies(); for (PrivateCompanyI priv : privates) { ipo.addPrivate(priv); *************** *** 121,125 **** // Add public companies List<PublicCompanyI> companies = ! Game.getCompanyManager().getAllPublicCompanies(); for (PublicCompanyI comp : companies) { for (PublicCertificateI cert : comp.getCertificates()) { --- 113,117 ---- // Add public companies List<PublicCompanyI> companies = ! gameManager.getCompanyManager().getAllPublicCompanies(); for (PublicCompanyI comp : companies) { for (PublicCertificateI cert : comp.getCertificates()) { *************** *** 131,134 **** --- 123,133 ---- } } + } + + /** + * @param percentage of a company allowed to be in the Bank pool. + */ + public void setPoolShareLimit(int percentage) { + poolShareLimit = percentage; } Index: StockMarketI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarketI.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StockMarketI.java 4 May 2009 20:29:14 -0000 1.8 --- StockMarketI.java 9 Oct 2009 20:20:34 -0000 1.9 *************** *** 4,8 **** import java.util.List; ! public interface StockMarketI { /** --- 4,8 ---- import java.util.List; ! public interface StockMarketI extends ConfigurableComponentI { /** *************** *** 12,17 **** static final String COMPONENT_NAME = "StockMarket"; - public void init(); - public StockSpaceI[][] getStockChart(); --- 12,15 ---- Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CompanyManager.java 11 Sep 2009 19:27:23 -0000 1.15 --- CompanyManager.java 9 Oct 2009 20:20:34 -0000 1.16 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void initCompanies(GameManagerI gameManager, List<Player> players ) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.init2(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ private List<StartPacket> startPackets = new ArrayList<StartPacket>(); /** A map of all start packets, keyed by name. Default name is "Initial" */ private Map<String, StartPacket> startPacketMap = new HashMap<String, StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name", StartPacket.DEFAULT_NAME); String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); startPacketMap.put(name, sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void finishConfiguration (GameManager gameManager) throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.finishConfiguration(gameManager); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } public StartPacket getStartPacket (int index) { return startPackets.get(index); } public StartPacket getStartPacket (String name) { return startPacketMap.get(name); } } \ No newline at end of file Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** PublicCompany.java 9 Oct 2009 19:03:49 -0000 1.67 --- PublicCompany.java 9 Oct 2009 20:20:34 -0000 1.68 *************** *** 22,25 **** --- 22,26 ---- */ public class PublicCompany extends Company implements PublicCompanyI { + protected static final int DEFAULT_SHARE_UNIT = 10; *************** *** 626,630 **** * Final initialisation, after all XML has been processed. */ ! public void init2(GameManagerI gameManager) throws ConfigurationException { --- 627,631 ---- * Final initialisation, after all XML has been processed. */ ! public void finishConfiguration(GameManager gameManager) throws ConfigurationException { *************** *** 684,687 **** --- 685,695 ---- } } + + if (Util.hasValue(privateToCloseOnFirstTrainName)) { + privateToCloseOnFirstTrain = + gameManager.getCompanyManager().getPrivateCompany( + privateToCloseOnFirstTrainName); + } + } *************** *** 805,816 **** stockMarket.start(this, startSpace); ! /* Final initialisations */ ! if (Util.hasValue(privateToCloseOnFirstTrainName)) { ! privateToCloseOnFirstTrain = ! Game.getCompanyManager().getPrivateCompany( ! privateToCloseOnFirstTrainName); ! } ! ! if (homeBaseTokensLayTime == WHEN_STARTED) { layHomeBaseTokens(); } --- 813,817 ---- stockMarket.start(this, startSpace); ! if (homeBaseTokensLayTime == WHEN_STARTED) { layHomeBaseTokens(); } *************** *** 867,871 **** if (sharePriceUpOnFloating) { ! Game.getStockMarket().moveUp(this); } --- 868,872 ---- if (sharePriceUpOnFloating) { ! stockMarket.moveUp(this); } *************** *** 1236,1241 **** // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove || amount >= currentPrice.getPrice().getPrice())) { ! Game.getStockMarket().payOut(this); } --- 1237,1243 ---- // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove ! || amount >= currentPrice.getPrice().getPrice())) { ! stockMarket.payOut(this); } *************** *** 1263,1267 **** if (amount > 0) new CashMove(bank, this, amount); // Move the token ! if (hasStockPrice) Game.getStockMarket().withhold(this); } --- 1265,1269 ---- if (amount > 0) new CashMove(bank, this, amount); // Move the token ! if (hasStockPrice) stockMarket.withhold(this); } Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TileManager.java 9 Oct 2009 19:03:49 -0000 1.9 --- TileManager.java 9 Oct 2009 20:20:34 -0000 1.10 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; protected Map<Integer, TileI> tileMap = new HashMap<Integer, TileI>(); protected List<Integer> tileIds = new ArrayList<Integer>(); private static List<String> directories = new ArrayList<String>(); /** * No-args constructor. */ public TileManager() { instance = this; } public static TileManager get() { return instance; } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tileSetTop) throws ConfigurationException { /* * Note: prefix se is used for elements from TileSet.xml, prefix te for * elements from Tiles.xml. */ String tileDefFileName = tileSetTop.getAttributeAsString("tiles"); if (tileDefFileName == null) throw new ConfigurationException(LocalText.getText("NoTilesXML")); directories.add("data/" + ComponentManager.getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; protected Map<Integer, TileI> tileMap = new HashMap<Integer, TileI>(); protected List<Integer> tileIds = new ArrayList<Integer>(); private static List<String> directories = new ArrayList<String>(); /** * No-args constructor. */ public TileManager() { instance = this; } public static TileManager get() { return instance; } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tileSetTop) throws ConfigurationException { /* * Note: prefix se is used for elements from TileSet.xml, prefix te for * elements from Tiles.xml. */ String tileDefFileName = tileSetTop.getAttributeAsString("tiles"); if (tileDefFileName == null) throw new ConfigurationException(LocalText.getText("NoTilesXML")); directories.add("data/" + ComponentManager.getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public void finishConfiguration (GameManager gameManager) {} public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TrainManager.java 9 Oct 2009 19:03:49 -0000 1.19 --- TrainManager.java 9 Oct 2009 20:20:34 -0000 1.20 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes private static TrainManager instance = null; protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { instance = this; // Nothing to do here, everything happens when configured. newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void init (GameManagerI gameManager) { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : instance.getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes private static TrainManager instance = null; protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { instance = this; // Nothing to do here, everything happens when configured. newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void finishConfiguration (GameManager gameManager) { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : instance.getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PrivateCompany.java 25 Sep 2009 19:13:01 -0000 1.22 --- PrivateCompany.java 9 Oct 2009 20:20:34 -0000 1.23 *************** *** 111,114 **** --- 111,116 ---- } + public void finishConfiguration (GameManager gameManager) {} + /** Initialisation, to be called directly after instantiation (cloning) */ @Override Index: PlayerManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PlayerManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PlayerManager.java 25 Sep 2009 19:13:01 -0000 1.10 --- PlayerManager.java 9 Oct 2009 20:20:34 -0000 1.11 *************** *** 45,49 **** } ! public void setPlayers (List<String> playerNames, Bank bank) { Player player; --- 45,51 ---- } ! public void finishConfiguration (GameManager gameManager) {} ! ! public void setPlayers (List<String> playerNames, Bank bank) { Player player; Index: CompanyType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CompanyType.java 24 Jan 2009 15:10:28 -0000 1.8 --- CompanyType.java 9 Oct 2009 20:20:34 -0000 1.9 *************** *** 61,65 **** } ! public CompanyI createCompany(String name, Tag tag) throws ConfigurationException { CompanyI newCompany = null; --- 61,69 ---- } ! public void finishConfiguration (GameManager gameManager) { ! ! } ! ! public CompanyI createCompany(String name, Tag tag) throws ConfigurationException { CompanyI newCompany = null; Index: ConfigurableComponentI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ConfigurableComponentI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConfigurableComponentI.java 4 Jun 2008 19:00:31 -0000 1.4 --- ConfigurableComponentI.java 9 Oct 2009 20:20:34 -0000 1.5 *************** *** 14,21 **** * element. * ! * @param el the XML element containing the configuration * @throws ConfigurationException */ void configureFromXML(Tag tag) throws ConfigurationException; } --- 14,37 ---- * element. * ! * @param element the XML element containing the configuration * @throws ConfigurationException */ void configureFromXML(Tag tag) throws ConfigurationException; + + /** + * This method is intended to be called for each configurable + * component, to perforn any initialisation activities that + * require any other components to be initialised first. + * This includes creating any required relationships to other + * configured components and objects. + * <p>This method should be called where necessary after all + * XML file parsing has completed, so that all objects that + * need to be related to do exist. + * @param parent The 'parent' configurable component is passed to allow + * the 'child' to access any other object without the need to resort to + * static calls where possible. + */ + void finishConfiguration (GameManager parent) + throws ConfigurationException; } Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** GameManager.java 9 Oct 2009 19:03:49 -0000 1.60 --- GameManager.java 9 Oct 2009 20:20:34 -0000 1.61 *************** *** 354,357 **** --- 354,359 ---- } + public void finishConfiguration (GameManager gameManager) {} + /** Check if a classname can be instantiated. * Throws a ConfiguratioNException if not. Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MapManager.java 3 Oct 2009 14:02:28 -0000 1.8 --- MapManager.java 9 Oct 2009 20:20:34 -0000 1.9 *************** *** 128,131 **** --- 128,144 ---- } + public void finishConfiguration (GameManager gameManager) { + MapHex hex; + + for (PublicCompanyI company : gameManager.getCompanyManager().getAllPublicCompanies()) { + if ((hex = company.getHomeHex()) != null) { + hex.addHome(company, company.getHomeCityNumber()); + } + if ((hex = company.getDestinationHex()) != null) { + hex.addDestination(company); + } + } + } + /** * @return an instance of the MapManager *************** *** 174,196 **** } - /** - * Necessary mechanism for delaying assignment of companyDestination until - * after all of the proper elements of the XML have been loaded. - * - * Called by Game.initialise() - */ - protected static void assignHomesAndDestinations() { - MapHex hex; - - for (PublicCompanyI company : Game.getCompanyManager().getAllPublicCompanies()) { - if ((hex = company.getHomeHex()) != null) { - hex.addHome(company, company.getHomeCityNumber()); - } - if ((hex = company.getDestinationHex()) != null) { - hex.addDestination(company); - } - } - } - public List<City> getCurrentStations() { List<City> stations = new ArrayList<City>(); --- 187,190 ---- Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Game.java 9 Oct 2009 19:03:49 -0000 1.30 --- Game.java 9 Oct 2009 20:20:34 -0000 1.31 *************** *** 21,25 **** /** The component Manager */ protected ComponentManager componentManager; ! protected GameManagerI gameManager; protected CompanyManagerI companyManager; protected PlayerManager playerManager; --- 21,25 ---- /** The component Manager */ protected ComponentManager componentManager; ! protected GameManager gameManager; protected CompanyManagerI companyManager; protected PlayerManager playerManager; *************** *** 124,128 **** } gameManager = ! (GameManagerI) componentManager.findComponent("GameManager"); if (gameManager == null) { throw new ConfigurationException( --- 124,128 ---- } gameManager = ! (GameManager) componentManager.findComponent("GameManager"); if (gameManager == null) { throw new ConfigurationException( *************** *** 163,173 **** phaseManager, trainManager, stockMarket, mapManager, bank); ! companyManager.initCompanies(gameManager, playerManager.getPlayers()); ! trainManager.init(gameManager); ! phaseManager.init(gameManager); ! bank.initCertificates(); //StartPacket.init(); //companyManager.initCompanies(gameManager); ! stockMarket.init(); } catch (Exception e) { String message = --- 163,174 ---- p... [truncated message content] |
From: Erik V. <ev...@us...> - 2009-10-09 19:04:03
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv28916/rails/game/specific/_18EU Modified Files: OperatingRound_18EU.java Log Message: Removed some not really necessary interfaces. Index: OperatingRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OperatingRound_18EU.java 25 Sep 2009 19:13:01 -0000 1.7 --- OperatingRound_18EU.java 9 Oct 2009 19:03:49 -0000 1.8 *************** *** 15,19 **** */ public class OperatingRound_18EU extends OperatingRound { ! protected TrainTypeI pullmannType; --- 15,19 ---- */ public class OperatingRound_18EU extends OperatingRound { ! protected TrainTypeI pullmannType; *************** *** 23,27 **** protected State playerToStartExchangeRound = new State("PlayerToStartExchangeRound", Player.class); ! public OperatingRound_18EU (GameManagerI gameManager) { super (gameManager); --- 23,27 ---- protected State playerToStartExchangeRound = new State("PlayerToStartExchangeRound", Player.class); ! public OperatingRound_18EU (GameManagerI gameManager) { super (gameManager); *************** *** 44,48 **** if (operatingCompany == null) return; ! TrainManagerI trainMgr = gameManager.getTrainManager(); int cash = operatingCompany.getCash(); --- 44,48 ---- if (operatingCompany == null) return; ! TrainManager trainMgr = gameManager.getTrainManager(); int cash = operatingCompany.getCash(); |
From: Erik V. <ev...@us...> - 2009-10-09 19:03:59
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv28916/rails/game Modified Files: Game.java PublicCompany.java TrainManager.java OperatingRound.java TileManager.java GameManagerI.java GameManager.java Removed Files: PhaseManagerI.java TileManagerI.java TrainManagerI.java Log Message: Removed some not really necessary interfaces. --- PhaseManagerI.java DELETED --- Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** PublicCompany.java 7 Oct 2009 21:03:36 -0000 1.66 --- PublicCompany.java 9 Oct 2009 19:03:49 -0000 1.67 *************** *** 8,12 **** import rails.game.model.*; import rails.game.move.*; ! import rails.game.special.*; import rails.game.state.*; import rails.util.*; --- 8,13 ---- import rails.game.model.*; import rails.game.move.*; ! import rails.game.special.SellBonusToken; ! import rails.game.special.SpecialPropertyI; import rails.game.state.*; import rails.util.*; *************** *** 874,878 **** if (initialTrain != null) { ! TrainManagerI trainManager = gameManager.getTrainManager(); TrainTypeI type = trainManager.getTypeByName(initialTrain); TrainI train = bank.getIpo().getTrainOfType(type); --- 875,879 ---- if (initialTrain != null) { ! TrainManager trainManager = gameManager.getTrainManager(); TrainTypeI type = trainManager.getTypeByName(initialTrain); TrainI train = bank.getIpo().getTrainOfType(type); Index: TileManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TileManager.java 4 Jun 2008 19:00:30 -0000 1.8 --- TileManager.java 9 Oct 2009 19:03:49 -0000 1.9 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.*; public class TileManager implements TileManagerI, ConfigurableComponentI { protected static TileManagerI instance = null; protected Map<Integer, TileI> tileMap = new HashMap<Integer, TileI>(); protected List<Integer> tileIds = new ArrayList<Integer>(); private static List<String> directories = new ArrayList<String>(); /** * No-args constructor. */ public TileManager() { instance = this; } public static TileManagerI get() { return instance; } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tileSetTop) throws ConfigurationException { /* * Note: prefix se is used for elements from TileSet.xml, prefix te for * elements from Tiles.xml. */ String tileDefFileName = tileSetTop.getAttributeAsString("tiles"); if (tileDefFileName == null) throw new ConfigurationException(LocalText.getText("NoTilesXML")); directories.add("data/" + ComponentManager.getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.util.LocalText; import rails.util.Tag; public class TileManager implements ConfigurableComponentI { protected static TileManager instance = null; protected Map<Integer, TileI> tileMap = new HashMap<Integer, TileI>(); protected List<Integer> tileIds = new ArrayList<Integer>(); private static List<String> directories = new ArrayList<String>(); /** * No-args constructor. */ public TileManager() { instance = this; } public static TileManager get() { return instance; } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tileSetTop) throws ConfigurationException { /* * Note: prefix se is used for elements from TileSet.xml, prefix te for * elements from Tiles.xml. */ String tileDefFileName = tileSetTop.getAttributeAsString("tiles"); if (tileDefFileName == null) throw new ConfigurationException(LocalText.getText("NoTilesXML")); directories.add("data/" + ComponentManager.getGameName()); Tag tileDefTop = Tag.findTopTagInFile(tileDefFileName, directories, "Tiles"); if (tileDefTop == null) throw new ConfigurationException(LocalText.getText("NoTilesTag")); List<Tag> tileSetList = tileSetTop.getChildren("Tile"); List<Tag> tileDefList = tileDefTop.getChildren("Tile"); /* * The XML files TileSet.xml and Tiles.xml are read side by side, as * each one configures different tile aspects. The reason for having two * XML files is, that Tiles.xml defines per-tile aspects that are the * same for all games (such as the colour, tracks and stations; this * file is an automatically generated subset of the generic file * tiles/Tiles.xml), whereas TileSet.xml specifies the aspects that are * (or can be) specific to each rails.game (such as the possible * upgrades). <p>TileSet.xml is leading. */ int tileId; TileI tile; // Creates maps to the tile definitions in both files. Map<Integer, Tag> tileSetMap = new HashMap<Integer, Tag>(); Map<Integer, Tag> tileDefMap = new HashMap<Integer, Tag>(); for (Tag tileSetTag : tileSetList) { tileId = tileSetTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTilesetID", String.valueOf(tileId))); } tileSetMap.put(tileId, tileSetTag); tileIds.add(tileId); } for (Tag tileDefTag : tileDefList) { tileId = tileDefTag.getAttributeAsInteger("id"); /* * Check for duplicates (this also covers missing tile ids, as this * returns 0, and we always have a tile numbered 0! */ if (tileDefMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "DuplicateTileID", String.valueOf(tileId))); } else if (!tileSetMap.containsKey(tileId)) { throw new ConfigurationException(LocalText.getText( "TileMissingInTileSet", String.valueOf(tileId))); } tileDefMap.put(tileId, tileDefTag); } // Create the Tile objects (must be done before further parsing) for (Integer id : tileSetMap.keySet()) { tile = new Tile(id); tileMap.put(id, tile); } // Finally, parse the <Tile> subtags for (Integer id : tileMap.keySet()) { tile = tileMap.get(id); tile.configureFromXML(tileSetMap.get(id), tileDefMap.get(id)); } } public TileI getTile(int id) { return tileMap.get(id); } /** Get the tile IDs in the XML definition sequence */ public List<Integer> getTileIds() { return tileIds; } } \ No newline at end of file Index: TrainManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** TrainManager.java 25 Sep 2009 19:13:01 -0000 1.18 --- TrainManager.java 9 Oct 2009 19:03:49 -0000 1.19 *************** *** 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 TrainManagerI, ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes private static TrainManagerI instance = null; protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { instance = this; // Nothing to do here, everything happens when configured. newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void init (GameManagerI gameManager) { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : instance.getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import rails.game.state.IntegerState; import rails.util.LocalText; import rails.util.Tag; public class TrainManager implements ConfigurableComponentI { // Static attributes protected List<TrainTypeI> lTrainTypes = new ArrayList<TrainTypeI>(); protected Map<String, TrainTypeI> mTrainTypes = new HashMap<String, TrainTypeI>(); protected boolean buyAtFaceValueBetweenDifferentPresidents = false; // Dynamic attributes protected Portfolio unavailable = null; protected IntegerState newTypeIndex; protected boolean trainsHaveRusted = false; protected boolean phaseHasChanged = false; protected boolean trainAvailabilityChanged = false; protected List<PublicCompanyI> companiesWithExcessTrains; protected GameManagerI gameManager = null; protected Bank bank = null; // Non-game attributes private static TrainManager instance = null; protected Portfolio ipo = null; /** * No-args constructor. */ public TrainManager() { instance = this; // Nothing to do here, everything happens when configured. newTypeIndex = new IntegerState("NewTrainTypeIndex", 0); } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { TrainType defaultType = null; TrainType newType; Tag defaultsTag = tag.getChild("Defaults"); if (defaultsTag != null) { defaultType = new TrainType(false); defaultType.configureFromXML(defaultsTag); } List<Tag> typeTags = tag.getChildren("Train"); for (Tag typeTag : typeTags) { if (defaultType != null) { newType = (TrainType) defaultType.clone(); if (newType == null) { throw new ConfigurationException("Cannot clone traintype " + defaultType.getName()); } } else { newType = new TrainType(true); } lTrainTypes.add(newType); newType.configureFromXML(typeTag); mTrainTypes.put(newType.getName(), newType); } // Special train buying rules Tag rulesTag = tag.getChild("TrainBuyingRules"); if (rulesTag != null) { // A 1851 special buyAtFaceValueBetweenDifferentPresidents = rulesTag.getChild("FaceValueIfDifferentPresidents") != null; } // Finish initialisation of the train types for (TrainTypeI type : lTrainTypes) { if (type.getReleasedTrainTypeName() != null) { type.setReleasedTrainType(mTrainTypes.get(type.getReleasedTrainTypeName())); } if (type.getRustedTrainTypeName() != null) { type.setRustedTrainType(mTrainTypes.get(type.getRustedTrainTypeName())); mTrainTypes.get(type.getRustedTrainTypeName()).setPermanent(false); } } } public void init (GameManagerI gameManager) { this.gameManager = gameManager; bank = gameManager.getBank(); ipo = bank.getIpo(); unavailable = bank.getUnavailable(); // By default, set the first train type to "available". newTypeIndex.set(0); lTrainTypes.get(newTypeIndex.intValue()).setAvailable(bank); } /** * Make an abbreviated list of trains, like "2(6) 3(5)" etc, to show in the * IPO. * * @param holder The Portfolio for which this list will be made (always * IPO). */ public static String makeAbbreviatedList(Portfolio holder) { StringBuffer b = new StringBuffer(); TrainI[] trains; for (TrainTypeI type : instance.getTrainTypes()) { trains = holder.getTrainsPerType(type); if (trains.length > 0) { if (b.length() > 0) b.append(" "); b.append(type.getName()).append("("); if (type.hasInfiniteAmount()) { b.append("+"); } else { b.append(trains.length); } b.append(")"); } } return b.toString(); } /** * Make a full list of trains, like "2 2 3 3", to show in any field * describing train possessions, except the IPO. * * @param holder The Portfolio for which this list will be made. */ public static String makeFullList(Portfolio holder) { List<TrainI> trains = holder.getTrainList(); if (trains == null || trains.size() == 0) return ""; return makeFullList(trains); } public static String makeFullList(List<TrainI> trains) { StringBuffer b = new StringBuffer(); for (TrainI train : trains) { if (b.length() > 0) b.append(" "); if (train.isObsolete()) b.append("("); b.append(train.toDisplay()); if (train.isObsolete()) b.append(")"); } return b.toString(); } /** * This method handles any consequences of new train buying (from the IPO), * such as rusting and phase changes. It must be called <b>after</b> the * train has been transferred. * */ public void checkTrainAvailability(TrainI train, Portfolio from) { trainsHaveRusted = false; phaseHasChanged = false; if (from != ipo) return; TrainTypeI boughtType, nextType; boughtType = train.getType(); if (boughtType == (lTrainTypes.get(newTypeIndex.intValue())) && ipo.getTrainOfType(boughtType) == null) { // Last train bought, make a new type available. newTypeIndex.add(1); nextType = (lTrainTypes.get(newTypeIndex.intValue())); if (nextType != null) { if (!nextType.isAvailable()) nextType.setAvailable(bank); trainAvailabilityChanged = true; ReportBuffer.add("All " + boughtType.getName() + "-trains are sold out, " + nextType.getName() + "-trains now available"); } } if (boughtType.getNumberBoughtFromIPO() == 1) { // First train of a new type bought ReportBuffer.add(LocalText.getText("FirstTrainBought", boughtType.getName())); String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { gameManager.getPhaseManager().setPhase(newPhase); phaseHasChanged = true; } TrainTypeI rustedType = boughtType.getRustedTrainType(); if (rustedType != null && !rustedType.hasRusted()) { rustedType.setRusted(train.getHolder()); // Or obsolete, // where applicable ReportBuffer.add(LocalText.getText("TrainsRusted", rustedType.getName())); trainsHaveRusted = true; trainAvailabilityChanged = true; } TrainTypeI releasedType = boughtType.getReleasedTrainType(); if (releasedType != null) { if (!releasedType.isAvailable()) releasedType.setAvailable(bank); ReportBuffer.add(LocalText.getText("TrainsAvailable", releasedType.getName())); trainAvailabilityChanged = true; } } } public List<TrainI> getAvailableNewTrains() { List<TrainI> availableTrains = new ArrayList<TrainI>(); TrainI train; for (TrainTypeI type : lTrainTypes) { if (type.isAvailable()) { train = ipo.getTrainOfType(type); if (train != null) { availableTrains.add(train); } } } return availableTrains; } public TrainTypeI getTypeByName(String name) { return mTrainTypes.get(name); } public List<TrainTypeI> getTrainTypes() { return lTrainTypes; } public boolean hasAvailabilityChanged() { return trainAvailabilityChanged; } public void resetAvailabilityChanged() { trainAvailabilityChanged = false; } public boolean hasPhaseChanged() { return phaseHasChanged; } public boolean buyAtFaceValueBetweenDifferentPresidents() { return buyAtFaceValueBetweenDifferentPresidents; } } \ No newline at end of file Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** GameManager.java 8 Oct 2009 21:14:15 -0000 1.59 --- GameManager.java 9 Oct 2009 19:03:49 -0000 1.60 *************** *** 46,50 **** protected CompanyManagerI companyManager; protected PhaseManager phaseManager; ! protected TrainManagerI trainManager; protected StockMarketI stockMarket; protected MapManager mapManager; --- 46,50 ---- protected CompanyManagerI companyManager; protected PhaseManager phaseManager; ! protected TrainManager trainManager; protected StockMarketI stockMarket; protected MapManager mapManager; *************** *** 376,380 **** CompanyManagerI companyManager, PhaseManager phaseManager, ! TrainManagerI trainManager, StockMarketI stockMarket, MapManager mapManager, --- 376,380 ---- CompanyManagerI companyManager, PhaseManager phaseManager, ! TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, *************** *** 1007,1011 **** } ! public TrainManagerI getTrainManager () { return trainManager; } --- 1007,1011 ---- } ! public TrainManager getTrainManager () { return trainManager; } --- TileManagerI.java DELETED --- Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Game.java 3 Oct 2009 14:02:28 -0000 1.29 --- Game.java 9 Oct 2009 19:03:49 -0000 1.30 *************** *** 25,29 **** protected PlayerManager playerManager; protected PhaseManager phaseManager; ! protected TrainManagerI trainManager; protected StockMarketI stockMarket; protected MapManager mapManager; --- 25,29 ---- protected PlayerManager playerManager; protected PhaseManager phaseManager; ! protected TrainManager trainManager; protected StockMarketI stockMarket; protected MapManager mapManager; Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** OperatingRound.java 7 Oct 2009 21:03:36 -0000 1.72 --- OperatingRound.java 9 Oct 2009 19:03:49 -0000 1.73 *************** *** 111,115 **** protected boolean doneAllowed = false; ! protected TrainManagerI trainManager = gameManager.getTrainManager(); public static String[] stepNames = --- 111,115 ---- protected boolean doneAllowed = false; ! protected TrainManager trainManager = gameManager.getTrainManager(); public static String[] stepNames = *************** *** 2047,2051 **** if (operatingCompany == null) return; ! TrainManagerI trainMgr = gameManager.getTrainManager(); int cash = operatingCompany.getCash(); --- 2047,2051 ---- if (operatingCompany == null) return; ! TrainManager trainMgr = gameManager.getTrainManager(); int cash = operatingCompany.getCash(); --- TrainManagerI.java DELETED --- Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** GameManagerI.java 8 Oct 2009 21:14:15 -0000 1.15 --- GameManagerI.java 9 Oct 2009 19:03:49 -0000 1.16 *************** *** 21,25 **** public abstract void init(PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, ! TrainManagerI trainManager, StockMarketI stockMarket, MapManager mapManager, Bank bank); public abstract void startGame(); --- 21,25 ---- public abstract void init(PlayerManager playerManager, CompanyManagerI companyManager, PhaseManager phaseManager, ! TrainManager trainManager, StockMarketI stockMarket, MapManager mapManager, Bank bank); public abstract void startGame(); *************** *** 150,154 **** public void initialiseNewPhase(PhaseI phase); ! public abstract TrainManagerI getTrainManager (); public PlayerManager getPlayerManager(); public StockMarketI getStockMarket(); --- 150,154 ---- public void initialiseNewPhase(PhaseI phase); ! public abstract TrainManager getTrainManager (); public PlayerManager getPlayerManager(); public StockMarketI getStockMarket(); |
From: Erik V. <ev...@us...> - 2009-10-09 19:03:59
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv28916/rails/ui/swing Modified Files: RemainingTilesWindow.java Log Message: Removed some not really necessary interfaces. Index: RemainingTilesWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/RemainingTilesWindow.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RemainingTilesWindow.java 4 Jun 2008 19:00:33 -0000 1.4 --- RemainingTilesWindow.java 9 Oct 2009 19:03:49 -0000 1.5 *************** *** 2,17 **** package rails.ui.swing; ! import rails.game.*; ! import rails.game.model.ModelObject; ! import rails.ui.swing.elements.Field; ! import rails.ui.swing.hexmap.GUIHex; ! import rails.util.LocalText; ! ! import java.util.ArrayList; ! import java.util.List; ! ! import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import javax.swing.*; --- 2,11 ---- package rails.ui.swing; ! import java.awt.GridLayout; ! import java.awt.Image; import java.awt.event.*; import java.awt.image.BufferedImage; + import java.util.ArrayList; + import java.util.List; import javax.swing.*; *************** *** 19,22 **** --- 13,23 ---- import org.apache.log4j.Logger; + import rails.game.TileI; + import rails.game.TileManager; + import rails.game.model.ModelObject; + import rails.ui.swing.elements.Field; + import rails.ui.swing.hexmap.GUIHex; + import rails.util.LocalText; + /** * This Window displays the available operations that may be performed during an *************** *** 57,61 **** private void init() { ! TileManagerI tmgr = TileManager.get(); TileI tile; Field label; --- 58,62 ---- private void init() { ! TileManager tmgr = TileManager.get(); TileI tile; Field label; *************** *** 129,133 **** /** * Round-end settings ! * */ public void finish() {} --- 130,134 ---- /** * Round-end settings ! * */ public void finish() {} |
From: Erik V. <ev...@us...> - 2009-10-08 21:14:28
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv25800/rails/game Modified Files: ReportBuffer.java GameManagerI.java GameManager.java DisplayBuffer.java Log Message: ReportBuffer and DisplayBuffer made instantiatable Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** GameManager.java 7 Oct 2009 21:03:36 -0000 1.58 --- GameManager.java 8 Oct 2009 21:14:15 -0000 1.59 *************** *** 125,129 **** * All other objects will access it via NDC. */ ! protected static final String GM_KEY = "GM-1"; /** --- 125,130 ---- * All other objects will access it via NDC. */ ! protected static final String GM_KEY = "01"; ! protected static final String GM_NAME = "GameManager"; /** *************** *** 132,136 **** --- 133,148 ---- protected MoveStack moveStack = new MoveStack(); + /** + * The DisplayBuffer instance collects messages to be displayed in the UI. + */ + protected DisplayBuffer displayBuffer; + + /** + * The ReportBuffer collectes messages to be shown in the Game Report. + */ + protected ReportBuffer reportBuffer; + protected String name; + protected String key; protected StartPacket startPacket; *************** *** 163,167 **** --- 175,185 ---- */ public GameManager() { + name = GM_NAME; + key = GM_KEY; + NDC.clear(); + NDC.push (GM_KEY); gameManagerMap.put(GM_KEY, this); + displayBuffer = new DisplayBuffer(); + reportBuffer = new ReportBuffer(); } *************** *** 379,385 **** public void startGame() { - NDC.clear(); - NDC.push (GM_KEY); - setGameParameters(); --- 397,400 ---- *************** *** 704,710 **** public void processOnReload(List<PossibleAction> actions) throws Exception { - NDC.clear(); - NDC.push (GM_KEY); - for (PossibleAction action : actions) { --- 719,722 ---- *************** *** 1165,1170 **** } public String getName () { ! return "GameManager"; } --- 1177,1190 ---- } + /** + * Get name of the GM instance. Currently, the name is fixed, + * but that will change whenever a multi-game server will be implemented. + */ public String getName () { ! return name; ! } ! ! public String getKey () { ! return key; } *************** *** 1173,1175 **** --- 1193,1202 ---- } + public DisplayBuffer getDisplayBuffer() { + return displayBuffer; + } + + public ReportBuffer getReportBuffer() { + return reportBuffer; + } } Index: ReportBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ReportBuffer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReportBuffer.java 20 Nov 2008 21:49:38 -0000 1.4 --- ReportBuffer.java 8 Oct 2009 21:14:14 -0000 1.5 *************** *** 3,14 **** import java.io.*; ! import java.text.*; ! import java.util.ArrayList; ! import java.util.Date; ! import java.util.List; import org.apache.log4j.Logger; ! import rails.util.*; /** --- 3,14 ---- import java.io.*; ! import java.text.DateFormat; ! import java.text.SimpleDateFormat; ! import java.util.*; import org.apache.log4j.Logger; ! import rails.util.Config; ! import rails.util.Util; /** *************** *** 17,26 **** */ public final class ReportBuffer { - protected static Logger log = - Logger.getLogger(ReportBuffer.class.getPackage().getName()); protected static String reportDirectory = null; ! protected static String reportPathname = null; ! protected static PrintWriter report = null; protected static boolean wantReport = false; static { --- 17,30 ---- */ public final class ReportBuffer { protected static String reportDirectory = null; ! protected String reportPathname = null; ! protected PrintWriter report = null; protected static boolean wantReport = false; + protected static List<String> initialQueue = new ArrayList<String>(); + + private static final String DEFAULT_DTS_PATTERN = "yyyyMMdd_HHmm"; + private static final String DEFAULT_REPORT_EXTENSION = "txt"; + protected static Logger log = + Logger.getLogger(ReportBuffer.class.getPackage().getName()); static { *************** *** 29,34 **** } ! /** This class is not instantiated */ ! private ReportBuffer() {} /** --- 33,44 ---- } ! public ReportBuffer() { ! if (!initialQueue.isEmpty()) { ! for (String s : initialQueue) { ! addMessage (s); ! } ! initialQueue.clear(); ! } ! } /** *************** *** 37,44 **** * rails.game report. */ ! private static StringBuffer reportBuffer = new StringBuffer(); /** Add a message to the log buffer (and display it on the console) */ public static void add(String message) { if (Util.hasValue(message)) { reportBuffer.append(message).append("\n"); --- 47,66 ---- * rails.game report. */ ! private StringBuffer reportBuffer = new StringBuffer(); /** Add a message to the log buffer (and display it on the console) */ public static void add(String message) { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) instance = gm.getReportBuffer(); + if (gm == null || instance == null) { + // Queue in a static buffer until the instance is created + initialQueue.add(message); + } else { + instance.addMessage(message); + } + } + + private void addMessage (String message) { if (Util.hasValue(message)) { reportBuffer.append(message).append("\n"); *************** *** 52,61 **** /** Get the current log buffer, and clear it */ public static String get() { ! String result = reportBuffer.toString(); ! reportBuffer = new StringBuffer(); return result; } ! private static void writeToReport(String message) { /* Get out if we don't want a report */ --- 74,88 ---- /** Get the current log buffer, and clear it */ public static String get() { ! ReportBuffer instance = getInstance(); ! String result = instance.reportBuffer.toString(); ! instance.reportBuffer = new StringBuffer(); return result; } ! private static ReportBuffer getInstance() { ! return GameManager.getInstance().getReportBuffer(); ! } ! ! private void writeToReport(String message) { /* Get out if we don't want a report */ *************** *** 70,74 **** } ! private static void openReportFile() { /* Get any configured date/time pattern, or else set the default */ --- 97,101 ---- } ! private void openReportFile() { /* Get any configured date/time pattern, or else set the default */ *************** *** 76,80 **** Config.get("report.filename.date_time_pattern"); if (!Util.hasValue(reportFilenamePattern)) { ! reportFilenamePattern = "yyyyMMdd_HHmm"; } /* Get any configured extension, or else set the default */ --- 103,107 ---- Config.get("report.filename.date_time_pattern"); if (!Util.hasValue(reportFilenamePattern)) { ! reportFilenamePattern = ReportBuffer.DEFAULT_DTS_PATTERN; } /* Get any configured extension, or else set the default */ *************** *** 82,86 **** Config.get("report.filename.extension"); if (!Util.hasValue(reportFilenameExtension)) { ! reportFilenameExtension = "txt"; } /* Create a date formatter */ --- 109,113 ---- Config.get("report.filename.extension"); if (!Util.hasValue(reportFilenameExtension)) { ! reportFilenameExtension = ReportBuffer.DEFAULT_REPORT_EXTENSION; } /* Create a date formatter */ *************** *** 89,92 **** --- 116,120 ---- reportPathname = reportDirectory + "/" + Game.getName() + "_" + + GameManager.getInstance().getKey() + "_" + dateFormat.format(new Date()) + "." + reportFilenameExtension; *************** *** 101,117 **** } } ! /* A stack for messages that must "wait" for other messages */ ! private static List<String> waitQueue = new ArrayList<String> (); public static void addWaiting (String string) { ! waitQueue.add (string); } ! public static void getAllWaiting () { ! for (String message : waitQueue) { ! ReportBuffer.add (message); } ! waitQueue.clear(); } --- 129,146 ---- } } ! /* A stack for messages that must "wait" for other messages */ ! private List<String> waitQueue = new ArrayList<String> (); public static void addWaiting (String string) { ! getInstance().waitQueue.add (string); } ! public static void getAllWaiting () { ! ReportBuffer instance = getInstance(); ! for (String message : instance.waitQueue) { ! instance.addMessage (message); } ! instance.waitQueue.clear(); } Index: DisplayBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/DisplayBuffer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DisplayBuffer.java 6 Sep 2009 12:26:11 -0000 1.7 --- DisplayBuffer.java 8 Oct 2009 21:14:15 -0000 1.8 *************** *** 7,11 **** import org.apache.log4j.Logger; ! import rails.util.*; /** --- 7,11 ---- import org.apache.log4j.Logger; ! import rails.util.Util; /** *************** *** 15,23 **** public final class DisplayBuffer { protected static Logger log = Logger.getLogger(DisplayBuffer.class.getPackage().getName()); ! /** This class is not instantiated */ ! private DisplayBuffer() {} /** --- 15,34 ---- public final class DisplayBuffer { + /** List to catch messages before the buffer is instantiated, + * based on the supposition that never 2 games will be initialised simultaneously... + */ + protected static List<String> initialQueue = new ArrayList<String>(); + protected static Logger log = Logger.getLogger(DisplayBuffer.class.getPackage().getName()); ! public DisplayBuffer() { ! if (!initialQueue.isEmpty()) { ! for (String s : initialQueue) { ! addMessage (s, true); ! } ! initialQueue.clear(); ! } ! } /** *************** *** 26,32 **** * interest to players. */ ! private static List<String> displayBuffer = new ArrayList<String>(); ! ! private static boolean autoDisplay = true; /** --- 37,43 ---- * interest to players. */ ! private List<String> displayBuffer = new ArrayList<String>(); ! ! private boolean autoDisplay = true; /** *************** *** 35,55 **** */ public static void add(String message) { ! add (message, true); } ! ! public static void add (String message, boolean autoDisplay) { ! DisplayBuffer.autoDisplay = autoDisplay; if (Util.hasValue(message)) { ! displayBuffer.add(message); ! /* Also log the message */ ! //log.info("To display: " + message); } } /** Get the current message buffer, and clear it */ public static String[] get() { ! if (displayBuffer.size() > 0) { ! String[] message = (String[]) displayBuffer.toArray(new String[0]); ! displayBuffer.clear(); return message; } else { --- 46,86 ---- */ public static void add(String message) { ! add (message, true); } ! ! public static void add(String message, boolean autoDisplay) { ! GameManagerI gm = GameManager.getInstance(); ! DisplayBuffer instance = null; ! if (gm != null) instance = gm.getDisplayBuffer(); ! if (gm == null || instance == null) { ! // Queue in a static buffer until the instance is created ! initialQueue.add(message); ! } else { ! instance.addMessage(message, autoDisplay); ! } ! } ! ! private void addMessage (String message, boolean autoDisplay) { ! DisplayBuffer instance = getInstance(); ! instance.autoDisplay = autoDisplay; if (Util.hasValue(message)) { ! instance.displayBuffer.add(message); ! /* Also log the message (don't remove this, ! * otherwise the message will not be logged during a reload, ! * which may hinder troubleshooting) */ ! log.debug("To display: " + message); } } + private static DisplayBuffer getInstance() { + return GameManager.getInstance().getDisplayBuffer(); + } + /** Get the current message buffer, and clear it */ public static String[] get() { ! DisplayBuffer instance = getInstance(); ! if (instance.displayBuffer.size() > 0) { ! String[] message = instance.displayBuffer.toArray(new String[0]); ! instance.displayBuffer.clear(); return message; } else { *************** *** 57,71 **** } } ! public static int getSize() { ! return displayBuffer.size(); } ! public static boolean getAutoDisplay () { ! return autoDisplay; } public static void clear() { ! displayBuffer.clear(); } --- 88,102 ---- } } ! public static int getSize() { ! return getInstance().displayBuffer.size(); } ! public static boolean getAutoDisplay () { ! return getInstance().autoDisplay; } public static void clear() { ! getInstance().displayBuffer.clear(); } Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GameManagerI.java 7 Oct 2009 19:00:38 -0000 1.14 --- GameManagerI.java 8 Oct 2009 21:14:15 -0000 1.15 *************** *** 180,184 **** --- 180,187 ---- Class<T> clazz, boolean includeExercised); + public String getKey (); public MoveStack getMoveStack (); + public DisplayBuffer getDisplayBuffer(); + public ReportBuffer getReportBuffer(); } \ No newline at end of file |
From: Erik V. <ev...@us...> - 2009-10-07 21:03:51
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18129/rails/game Modified Files: StartRound_1830.java StartRound.java PublicCompany.java OperatingRound.java GameManager.java Log Message: Dead code removal Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** OperatingRound.java 7 Oct 2009 19:00:38 -0000 1.71 --- OperatingRound.java 7 Oct 2009 21:03:36 -0000 1.72 *************** *** 138,142 **** for (PrivateCompanyI priv : companyManager.getAllPrivateCompanies()) { if (!priv.isClosed()) { - //priv.payOut(); if (((Portfolio)priv.getHolder()).getOwner().getClass() != Bank.class) { CashHolder recipient = ((Portfolio)priv.getHolder()).getOwner(); --- 138,141 ---- *************** *** 177,181 **** ReportBuffer.add(text); DisplayBuffer.add(text); - //gameManager.nextRound(this); finishRound(); } --- 176,179 ---- *************** *** 963,976 **** if (step == STEP_CALC_REVENUE) { - //if (operatingCompany.getPortfolio().getNumberOfTrains() == 0) { if (!operatingCompany.canRunTrains()) { // No trains, then the revenue is zero. - /* - operatingCompany.setLastRevenue(0); - operatingCompany.setLastRevenueAllocation(SetDividend.UNKNOWN); - ReportBuffer.add(LocalText.getText("CompanyRevenue", - new String[] { operatingCompany.getName(), - Bank.format(0) })); - */ executeSetRevenueAndDividend ( new SetDividend (0, false, new int[] {SetDividend.WITHHOLD})); --- 961,966 ---- *************** *** 1274,1278 **** // OR done. Inform GameManager. ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); - //gameManager.nextRound(this); finishRound(); } --- 1264,1267 ---- Index: StartRound_1830.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1830.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** StartRound_1830.java 7 Oct 2009 19:00:38 -0000 1.21 --- StartRound_1830.java 7 Oct 2009 21:03:36 -0000 1.22 *************** *** 97,101 **** item.setStatus(StartItem.AUCTIONED); auctionItemState.set(item); - // numBidders = item.getBidders(); } if (currentPlayer.getFreeCash() --- 97,100 ---- *************** *** 290,294 **** numPasses.add(1); - if (auctionItem != null) { --- 289,292 ---- Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** PublicCompany.java 7 Oct 2009 19:00:38 -0000 1.65 --- PublicCompany.java 7 Oct 2009 21:03:36 -0000 1.66 *************** *** 1482,1486 **** int price) { - //portfolio.buyPrivate(privateCompany, from, price); if (from != bank.getIpo()) { // The initial buy is reported from StartRound. This message should also --- 1482,1485 ---- *************** *** 1711,1716 **** if (object instanceof TokenI) { return addToken((TokenI) object); - } else if (object instanceof LocatedBonus) { - return addBonus ((Bonus) object); } else { return false; --- 1710,1713 ---- *************** *** 1721,1727 **** if (object instanceof BaseToken) { return removeToken((TokenI) object); - } else if (object instanceof Bonus) { - removeBonus((Bonus) object); - return true; } else { return false; --- 1718,1721 ---- Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** StartRound.java 7 Oct 2009 19:00:38 -0000 1.27 --- StartRound.java 7 Oct 2009 21:03:36 -0000 1.28 *************** *** 145,149 **** * ultimately be possible. */ - //gameManager.nextRound(this); finishRound(); } --- 145,148 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** GameManager.java 7 Oct 2009 19:00:38 -0000 1.57 --- GameManager.java 7 Oct 2009 21:03:36 -0000 1.58 *************** *** 92,104 **** protected EnumMap<Defs.Parm, Boolean> gameParameters = new EnumMap<Defs.Parm, Boolean>(Defs.Parm.class); - //protected boolean hasAnyParPrice = false; - //protected boolean canAnyCompanyBuyPrivates = false; - //protected boolean canAnyCompanyHoldShares = false; - //protected boolean bonusTokensExist = false; - //protected boolean hasAnyCompanyLoans = false; protected int stockRoundSequenceRule = StockRound.SELL_BUY_SELL; - //protected static GameManager instance; /** * Map of GameManager instances. --- 92,98 ---- *************** *** 169,179 **** */ public GameManager() { - //instance = this; gameManagerMap.put(GM_KEY, this); } - /* (non-Javadoc) - * @see rails.game.GameManagerI#configureFromXML(rails.util.Tag) - */ public void configureFromXML(Tag tag) throws ConfigurationException { /* Get the rails.game name as configured */ --- 163,169 ---- *************** *** 412,422 **** for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { - //hasAnyParPrice = hasAnyParPrice || company.hasParPrice(); if (company.hasParPrice()) gameParameters.put(Defs.Parm.HAS_ANY_PAR_PRICE, true); - //canAnyCompanyBuyPrivates = canAnyCompanyBuyPrivates || company.canBuyPrivates(); if (company.canBuyPrivates()) gameParameters.put(Defs.Parm.CAN_ANY_COMPANY_BUY_PRIVATES, true); - //canAnyCompanyHoldShares = canAnyCompanyHoldShares || company.canHoldOwnShares(); if (company.canHoldOwnShares()) gameParameters.put(Defs.Parm.CAN_ANY_COMPANY_HOLD_OWN_SHARES, true); - //hasAnyCompanyLoans = hasAnyCompanyLoans || company.getMaxNumberOfLoans() != 0; if (company.getMaxNumberOfLoans() != 0) gameParameters.put(Defs.Parm.HAS_ANY_COMPANY_LOANS, true); } --- 402,408 ---- *************** *** 426,430 **** if (sp instanceof SpecialTokenLay && ((SpecialTokenLay)sp).getToken() instanceof BonusToken) { - //bonusTokensExist = true; gameParameters.put(Defs.Parm.DO_BONUS_TOKENS_EXIST, true); break loop; --- 412,415 ---- |
From: Erik V. <ev...@us...> - 2009-10-07 21:03:50
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1851 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18129/rails/game/specific/_1851 Modified Files: StartRound_1851.java Log Message: Dead code removal Index: StartRound_1851.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1851/StartRound_1851.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StartRound_1851.java 19 Jul 2009 19:24:21 -0000 1.8 --- StartRound_1851.java 7 Oct 2009 21:03:36 -0000 1.9 *************** *** 37,41 **** * ultimately be possible. */ - //gameManager.nextRound(this); finishRound(); } --- 37,40 ---- |
From: Erik V. <ev...@us...> - 2009-10-07 21:03:46
|
Update of /cvsroot/rails/18xx/data/1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18129/data/1856 Modified Files: Game.xml Log Message: Dead code removal Index: Game.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1856/Game.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Game.xml 3 Sep 2009 21:36:54 -0000 1.25 --- Game.xml 7 Oct 2009 21:03:36 -0000 1.26 *************** *** 6,10 **** sequence="SellBuyOrBuySell"/> <OperatingRound class="rails.game.specific._1856.OperatingRound_1856"/> - <GameUIManager class="rails.game.specific._1856.GameUIManager_1856"/> <StatusWindow class="rails.ui.swing.gamespecific._1856.StatusWindow_1856"/> <PlayerShareLimit percentage="60"/> --- 6,9 ---- |
From: Erik V. <ev...@us...> - 2009-10-07 21:03:46
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18129/rails/game/specific/_18EU Modified Files: StartRound_18EU.java Log Message: Dead code removal Index: StartRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartRound_18EU.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StartRound_18EU.java 7 Oct 2009 19:00:39 -0000 1.8 --- StartRound_18EU.java 7 Oct 2009 21:03:36 -0000 1.9 *************** *** 309,315 **** Bank.format(currentBuyPrice.intValue()) )); setStep(BUY_STEP); ! //if (auctionedItem.getStatus() != StartItem.BUYABLE) { ! // auctionedItem.setStatus(StartItem.BUYABLE); ! //} if (currentBuyPrice.intValue() == 0) { // Forced buy --- 309,313 ---- Bank.format(currentBuyPrice.intValue()) )); setStep(BUY_STEP); ! if (currentBuyPrice.intValue() == 0) { // Forced buy |
From: Erik V. <ev...@us...> - 2009-10-07 21:03:46
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18129/rails/game/specific/_1856 Modified Files: CGRFormationRound.java StockRound_1856.java Removed Files: GameUIManager_1856.java Log Message: Dead code removal Index: StockRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/StockRound_1856.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** StockRound_1856.java 6 Oct 2009 18:34:03 -0000 1.10 --- StockRound_1856.java 7 Oct 2009 21:03:36 -0000 1.11 *************** *** 140,144 **** cgr.getName(), cgr.getShareUnit())); - //log.debug("MustBuyExtraShareMessageAdded", new Exception("HERE")); if (lowestPrice > cash) { gameManager.startShareSellingRound(currentPlayer, --- 140,143 ---- --- GameUIManager_1856.java DELETED --- Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CGRFormationRound.java 7 Oct 2009 19:00:38 -0000 1.20 --- CGRFormationRound.java 7 Oct 2009 21:03:36 -0000 1.21 *************** *** 48,52 **** public Class<? extends RoundI> getRoundTypeForUI () { return StockRound.class; - //return OperatingRound.class; } --- 48,51 ---- *************** *** 441,445 **** totalPrice += price; if (price < lowestPrice) lowestPrice = price; - //comp.setClosed(); } if (numberMerged >= 3) { --- 440,443 ---- *************** *** 631,635 **** if (hex.layBaseToken(cgr, city.getNumber())) { cgr.layBaseToken(hex, 0); - //log.debug("CGR exchanges a token at "+hex.getName()+" "+hex.getCityName()); } else { log.error("Error in laying CGR token on "+hex.getName()+" "+hex.getCityName()); --- 629,632 ---- *************** *** 662,666 **** setStep (STEP_EXCHANGE_TOKENS); } else { - //gameManager.nextRound(this); finishRound(); } --- 659,662 ---- *************** *** 681,685 **** if (checkForTrainsToDiscard()) return true; - //gameManager.nextRound(this); finishRound(); } --- 677,680 ---- |