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...> - 2008-12-02 20:29:20
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1478/rails/ui/swing/hexmap Modified Files: GUIHex.java Log Message: Cleanups Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GUIHex.java 7 Nov 2008 00:52:11 -0000 1.19 --- GUIHex.java 2 Dec 2008 20:29:15 -0000 1.20 *************** *** 359,363 **** for (int i = 0; i < tokens.size(); i++) { PublicCompanyI co = ((BaseToken) tokens.get(i)).getCompany(); ! Point origin = getTokenOrigin2(numTokens, i, 1, 0); drawBaseToken(g2, co, origin); } --- 359,363 ---- for (int i = 0; i < tokens.size(); i++) { PublicCompanyI co = ((BaseToken) tokens.get(i)).getCompany(); ! Point origin = getTokenOrigin(numTokens, i, 1, 0); drawBaseToken(g2, co, origin); } *************** *** 376,380 **** for (int j = 0; j < tokens.size(); j++) { ! origin = getTokenOrigin2(numTokens, j, numStations, i); co = ((BaseToken) tokens.get(j)).getCompany(); drawBaseToken(g2, co, origin); --- 376,380 ---- for (int j = 0; j < tokens.size(); j++) { ! origin = getTokenOrigin(numTokens, j, numStations, i); co = ((BaseToken) tokens.get(j)).getCompany(); drawBaseToken(g2, co, origin); *************** *** 436,579 **** } - /* - * Beware! Here be dragons! And nested switch/case statements! The horror! - * - * NOTE: CurrentFoo starts at 0 TotalFoo starts at 1 - */ - private Point getTokenOrigin(int numTokens, int currentToken, - int numStations, int currentStation) { - Point p = new Point(); - - switch (numStations) { - // Single city, variable number of token spots. - // This is the most common scenario. - case 1: - switch (numTokens) { - // Single dot, basic hex - case 1: - p.x = (center.x - 9); - p.y = (center.y - 9); - return p; - // Two dots, common green hex upgrade - case 2: - // First token - if (currentToken == 0) { - p.x = (center.x - 5); - p.y = (center.y - 9); - return p; - } - // Second Token - else { - p.x = (center.x - 17); - p.y = (center.y - 9); - return p; - } - // Three dots, common brown hex upgrade - case 3: - // First token - if (currentToken == 0) { - p.x = (center.x - 14); - p.y = (center.y - 3); - return p; - } - // Second Token - else if (currentToken == 1) { - p.x = (center.x - 5); - p.y = (center.y - 3); - return p; - } - // Third Token - else { - p.x = (center.x - 9); - p.y = (center.y - 14); - return p; - } - // Four dots, slightly less common brown hex upgrade - case 4: - case 5: - case 6: - default: - return center; - } - // Big Cities, two stations. - // usually only one or two token spots per station - case 2: - // First Station... (left side) - if (currentStation == 0) { - switch (numTokens) { - case 1: - p.x = (center.x - 14); - p.y = (center.y + 3); - return p; - case 2: - // First token - if (currentToken == 0) { - p.x = (center.x - 20); - p.y = (center.y - 3); - return p; - } - // Second Token - else { - p.x = (center.x - 10); - p.y = (center.y + 9); - return p; - } - default: - return center; - } - } - // Second Station... (right side) - else { - switch (numTokens) { - case 1: - p.x = (center.x - 1); - p.y = (center.y - 20); - return p; - case 2: - // First token - if (currentToken == 0) { - p.x = (center.x - 6); - p.y = (center.y - 23); - return p; - } - // Second Token - else { - p.x = (center.x + 6); - p.y = (center.y - 12); - return p; - } - default: - return center; - } - } - case 3: - // TODO: We'll deal with the 3 station scenario later... much later. - - // Known cases: 3 single token stations, - // 2 double token station and a single token station - - // Only do the 3 single token stations case now. - // Coordinates sort of work for 18EU B/V tiles - switch (currentStation) { - case 0: - p.x = center.x - 14; - p.y = center.y + 8; - return p; - case 1: - p.x = center.x - 16; - p.y = center.y - 18; - return p; - case 2: - p.x = center.x + 3; - p.y = center.y - 9; - return p; - default: - return center; - } - default: - return center; - } - } - public void rotateTile() { if (provisionalGUITile != null) { --- 436,439 ---- *************** *** 582,586 **** } ! private Point getTokenOrigin2(int numTokens, int currentToken, int numStations, int stationNumber) { Point p = new Point(center.x - 8, center.y - 8); --- 442,446 ---- } ! private Point getTokenOrigin(int numTokens, int currentToken, int numStations, int stationNumber) { Point p = new Point(center.x - 8, center.y - 8); |
From: Erik V. <ev...@us...> - 2008-12-01 22:16:44
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21590/rails/ui/swing Modified Files: ORWindow.java Log Message: Window now remembers position and height between rounds. Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ORWindow.java 21 Nov 2008 20:41:47 -0000 1.17 --- ORWindow.java 1 Dec 2008 21:31:55 -0000 1.18 *************** *** 31,34 **** --- 31,36 ---- private UpgradesPanel upgradePanel; private MessagePanel messagePanel; + + private Rectangle lastBounds; protected PossibleActions possibleActions = PossibleActions.getInstance(); *************** *** 163,166 **** --- 165,173 ---- orPanel.recreate(or); pack(); + if (lastBounds != null) { + Rectangle newBounds = getBounds(); + lastBounds.x = newBounds.x; + setBounds (lastBounds); + } setVisible(true); requestFocus(); *************** *** 177,180 **** --- 184,188 ---- */ public void finish() { + lastBounds = getBounds(); orPanel.finish(); upgradePanel.finish(); |
From: Erik V. <ev...@us...> - 2008-11-30 21:51:41
|
Update of /cvsroot/rails/18xx/data/1835 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1419/data/1835 Modified Files: TileSet.xml Log Message: Mark initial yellow OO/XX cities to reposition any (home) tokens when upgraded to green (needed for 1835 Badische and 1856 THB) Index: TileSet.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1835/TileSet.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TileSet.xml 6 Mar 2008 21:53:21 -0000 1.7 --- TileSet.xml 30 Nov 2008 21:51:33 -0000 1.8 *************** *** 34,38 **** </Tile> <Tile id="-807"><!--XX--> ! <Upgrade id="210,211,212,213,214,215"/> </Tile> <Tile id="-808"/> --- 34,38 ---- </Tile> <Tile id="-807"><!--XX--> ! <Upgrade id="210,211,212,213,214,215" relayBaseTokens="yes"/> </Tile> <Tile id="-808"/> |
From: Erik V. <ev...@us...> - 2008-11-30 21:51:41
|
Update of /cvsroot/rails/18xx/data/1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1419/data/1856 Modified Files: TileSet.xml Log Message: Mark initial yellow OO/XX cities to reposition any (home) tokens when upgraded to green (needed for 1835 Badische and 1856 THB) Index: TileSet.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1856/TileSet.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TileSet.xml 20 Nov 2008 21:44:46 -0000 1.5 --- TileSet.xml 30 Nov 2008 21:51:33 -0000 1.6 *************** *** 17,21 **** </Tile> <Tile id="-20"><!-- 2 OO cities --> ! <Upgrade id="59"/> </Tile> <Tile id="-21"><!-- Toronto --> --- 17,21 ---- </Tile> <Tile id="-20"><!-- 2 OO cities --> ! <Upgrade id="59" relayBaseTokens="yes"/> </Tile> <Tile id="-21"><!-- Toronto --> |
From: Erik V. <ev...@us...> - 2008-11-30 21:49:11
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv895/rails/ui/swing Modified Files: ORUIManager.java Log Message: Small cleanup Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ORUIManager.java 30 Nov 2008 16:10:35 -0000 1.21 --- ORUIManager.java 30 Nov 2008 21:49:08 -0000 1.22 *************** *** 3,7 **** import java.util.*; - import javax.swing.JComponent; import javax.swing.JOptionPane; --- 3,6 ---- *************** *** 12,16 **** import rails.game.special.*; import rails.ui.swing.elements.CheckBoxDialog; - import rails.ui.swing.elements.RadioButtonDialog; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; --- 11,14 ---- |
From: Mark J S. <kr...@us...> - 2008-11-30 16:10:42
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19297/18xx/rails/ui/swing Modified Files: ORUIManager.java Log Message: Update to only display the Select Station For Token Dialog if there is more than one city where the token can be placed Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ORUIManager.java 29 Nov 2008 20:01:33 -0000 1.20 --- ORUIManager.java 30 Nov 2008 16:10:35 -0000 1.21 *************** *** 618,629 **** return; } ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! station = promptToCityMap.get(selected).getNumber(); } --- 618,634 ---- return; } ! // If more than one City to choose from, ask the player. Otherwise use Element zero (first) for the station. ! if (prompts.size() > 1) { ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! station = promptToCityMap.get(selected).getNumber(); ! } else { ! station = promptToCityMap.get(prompts.toArray() [0]).getNumber(); ! } } *************** *** 682,694 **** continue; } ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(selected)); ! } } } --- 687,703 ---- continue; } ! if (prompts.size () > 1) { ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(selected)); ! } else { ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(prompts.toArray() [0])); ! } ! } } } |
From: Mark J S. <kr...@us...> - 2008-11-29 21:51:03
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32404/18xx/rails/game Modified Files: City.java Log Message: Corrected the hasTokenOf(PublicCompanyI company) to get the Company Name and call hasTokenOf(String companyName). The previous use of the tokens.contains(company) failed since the ArrayList is of TokenI's not PublicCompanyI's. Index: City.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/City.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** City.java 29 Nov 2008 20:01:33 -0000 1.5 --- City.java 29 Nov 2008 21:50:58 -0000 1.6 *************** *** 139,147 **** * @param company * @return true if this City already contains an instance of the specified ! * company's token. */ public boolean hasTokenOf(PublicCompanyI company) { ! if (tokens.contains(company)) return true; ! return false; } --- 139,148 ---- * @param company * @return true if this City already contains an instance of the specified ! * company's token. Do this by calling the hasTokenOf with Company Name. ! * Using a tokens.contains(company) fails since the tokens are a ArrayList ! * of TokenI not a ArrayList of PublicCompanyI. */ public boolean hasTokenOf(PublicCompanyI company) { ! return hasTokenOf (company.getName()); } |
From: Erik V. <ev...@us...> - 2008-11-29 20:01:43
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26165/rails/game Modified Files: TileI.java Tile.java PublicCompany.java OperatingRound.java MapHex.java City.java Log Message: Allow selection of 1830 Erie home base station while upgrading to green. Index: City.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/City.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** City.java 4 Jun 2008 19:00:32 -0000 1.4 --- City.java 29 Nov 2008 20:01:33 -0000 1.5 *************** *** 94,98 **** token.setHolder(this); boolean result = tokens.add(token); - // mapHex.update(); return result; } --- 94,97 ---- *************** *** 146,149 **** --- 145,158 ---- return false; } + + public boolean hasTokenOf (String companyName) { + for (TokenI token : tokens) { + if (token instanceof BaseToken + && ((BaseToken)token).getCompany().getName().equals(companyName)) { + return true; + } + } + return false; + } public void setTokens(ArrayList<TokenI> tokens) { *************** *** 173,177 **** b.append(")"); return b.toString(); - // return "City ID: " + number + ", Hex: " + mapHex.getName(); } } --- 182,185 ---- Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Tile.java 20 Nov 2008 21:49:38 -0000 1.23 --- Tile.java 29 Nov 2008 20:01:33 -0000 1.24 *************** *** 43,46 **** --- 43,51 ---- public static final int UNLIMITED_TILES = -1; + /** + * Flag indicating that player must reposition any basetokens during the upgrade. + */ + boolean relayBaseTokensOnUpgrade = false; + /** Off-board preprinted tiles */ public static final String RED_COLOUR_NAME = "red"; *************** *** 253,257 **** } ! } } --- 258,268 ---- } ! ! // Set reposition base tokens flag ! // (valid for all upgrades although attribute of one) ! relayBaseTokensOnUpgrade = upgradeTag.getAttributeAsBoolean( ! "relayBaseTokens", ! relayBaseTokensOnUpgrade); ! } } *************** *** 380,383 **** --- 391,398 ---- } + public boolean relayBaseTokensOnUpgrade() { + return relayBaseTokensOnUpgrade; + } + public boolean lay(MapHex hex) { *************** *** 474,477 **** --- 489,493 ---- allowedPhases = Arrays.asList(phases.split(",")); } + private void convertHexString() { Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** PublicCompany.java 20 Nov 2008 21:49:38 -0000 1.43 --- PublicCompany.java 29 Nov 2008 20:01:33 -0000 1.44 *************** *** 727,731 **** public void start(StockSpaceI startSpace) { ! log.debug("+++Starting1b "+name); hasStarted.set(true); setParSpace(startSpace); --- 727,731 ---- public void start(StockSpaceI startSpace) { ! hasStarted.set(true); setParSpace(startSpace); Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** OperatingRound.java 20 Nov 2008 21:49:38 -0000 1.44 --- OperatingRound.java 29 Nov 2008 20:01:33 -0000 1.45 *************** *** 374,378 **** hex.getName(), Bank.format(cost) })); } ! hex.upgrade(tile, orientation); // Was a special property used? --- 374,378 ---- hex.getName(), Bank.format(cost) })); } ! hex.upgrade(action); // Was a special property used? Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MapHex.java 26 Nov 2008 22:26:14 -0000 1.20 --- MapHex.java 29 Nov 2008 20:01:33 -0000 1.21 *************** *** 8,11 **** --- 8,12 ---- import org.apache.log4j.Logger; + import rails.game.action.LayTile; import rails.game.model.ModelObject; import rails.game.move.Moveable; *************** *** 362,368 **** * replaceTile(), via a TileMove object. */ ! public void upgrade(TileI newTile, int newRotation) { City newCity; String newTracks; if (currentTile.getNumStations() == newTile.getNumStations()) { --- 363,376 ---- * replaceTile(), via a TileMove object. */ ! public void upgrade(LayTile action) { ! TileI newTile = action.getLaidTile(); ! int newRotation = action.getOrientation(); ! City newCity; String newTracks; + List<City> newCities; + + Map<String, Integer> relaidTokens = action.getRelaidBaseTokens(); + if (relaidTokens == null) relaidTokens = new HashMap<String, Integer>(); if (currentTile.getNumStations() == newTile.getNumStations()) { *************** *** 372,407 **** // may become different from the new tile's // station numbers). // Scan the old cities/stations, // and assign new stations where tracks correspond for (City city : cities) { Station oldStation = city.getRelatedStation(); int[] oldTrackEnds = getTrackEndPoints(currentTile, currentTileRotation, oldStation); ! if (oldTrackEnds.length == 0) { ! // Old tile without any tracks: do not try to match ! // but just assign in sequence. ! // (assuming that we never will have an old tile ! // where some cities have tracks and others haven't). ! Station newStation = ! newTile.getStations().get(city.getNumber() - 1); ! city.setRelatedStation(newStation); ! city.setSlots(newStation.getBaseSlots()); ! log.debug("Assigned " ! + city.getUniqueId() ! + " from " ! + oldStation.getId() ! + " " ! + getConnectionString(currentTile, ! currentTileRotation, ! oldStation.getNumber()) ! + " to " ! + newStation.getId() ! + " " ! + getConnectionString(newTile, newRotation, ! newStation.getNumber())); ! continue; ! } station: for (Station newStation : newTile.getStations()) { int[] newTrackEnds = --- 380,403 ---- // may become different from the new tile's // station numbers). + Map<City, Station> citiesToStations = new HashMap<City, Station>(); + + // Check for manual handling of tokens + for (String compName : relaidTokens.keySet()) { + for (City city : cities) { + if (city.hasTokenOf(compName)) { + citiesToStations.put(city, newTile.getStations().get(relaidTokens.get(compName)-1)); + } + } + } // Scan the old cities/stations, // and assign new stations where tracks correspond for (City city : cities) { + if (citiesToStations.containsKey(city)) continue; Station oldStation = city.getRelatedStation(); int[] oldTrackEnds = getTrackEndPoints(currentTile, currentTileRotation, oldStation); ! if (oldTrackEnds.length == 0) continue; station: for (Station newStation : newTile.getStations()) { int[] newTrackEnds = *************** *** 411,443 **** if (oldTrackEnds[i] == newTrackEnds[j]) { // Match found! ! city.setRelatedStation(newStation); ! city.setSlots(newStation.getBaseSlots()); ! newTracks = ! getConnectionString(newTile, ! newRotation, ! newStation.getNumber()); ! city.setTrackEdges(newTracks); ! log.debug("Assigned " ! + city.getUniqueId() ! + " from " ! + oldStation.getId() ! + " " ! + getConnectionString(currentTile, ! currentTileRotation, ! oldStation.getNumber()) ! + " to " + newStation.getId() + " " ! + newTracks); ! break station; ! } } } - } - } ! new TileMove(this, currentTile, currentTileRotation, cities, ! newTile, newRotation, cities); ! } else { // If the number of stations does change, --- 407,453 ---- if (oldTrackEnds[i] == newTrackEnds[j]) { // Match found! ! citiesToStations.put(city, newStation); ! continue station; } } } } } ! ! // Map any unassigned cities randomly ! city: for (City city : cities) { ! if (citiesToStations.containsKey(city)) continue; ! for (Station newStation : newTile.getStations()) { ! if (citiesToStations.values().contains(newStation)) continue; ! citiesToStations.put(city, newStation); ! continue city; ! } ! } ! ! ! // Assign the new Stations to the existing cities ! for (City city : citiesToStations.keySet()) { ! Station newStation = citiesToStations.get(city); ! Station oldStation = city.getRelatedStation(); ! city.setRelatedStation(newStation); ! city.setSlots(newStation.getBaseSlots()); ! newTracks = ! getConnectionString(newTile, ! newRotation, ! newStation.getNumber()); ! city.setTrackEdges(newTracks); ! log.debug("Assigned " ! + city.getUniqueId() ! + " from " ! + oldStation.getId() ! + " " ! + getConnectionString(currentTile, ! currentTileRotation, ! oldStation.getNumber()) ! + " to " + newStation.getId() + " " ! + newTracks); ! } ! newCities = cities; ! } else { // If the number of stations does change, *************** *** 446,450 **** // Build a map from old to new cities, // so that we can move tokens at the end. ! List<City> newCities = new ArrayList<City>(4); Map<Integer, City> mNewCities = new HashMap<Integer, City>(4); Map<City, City> oldToNewCities = new HashMap<City, City>(); --- 456,460 ---- // Build a map from old to new cities, // so that we can move tokens at the end. ! newCities = new ArrayList<City>(4); Map<Integer, City> mNewCities = new HashMap<Integer, City>(4); Map<City, City> oldToNewCities = new HashMap<City, City>(); *************** *** 468,474 **** + getConnectionString(currentTile, currentTileRotation, oldStation.getNumber())); - // for (City newCity : newCities) { station: for (Station newStation : newTile.getStations()) { - // Station newStation = newCity.getRelatedStation(); int[] newTrackEnds = getTrackEndPoints(newTile, newRotation, newStation); --- 478,482 ---- *************** *** 576,581 **** } - - // Check if there any new stations not corresponding // to an old city. --- 584,587 ---- *************** *** 647,655 **** } - // Replace the tile - new TileMove(this, currentTile, currentTileRotation, cities, - newTile, newRotation, newCities); } /* TODO Further consequences to be processed here, e.g. new routes etc. */ } --- 653,662 ---- } } + // Replace the tile + new TileMove(this, currentTile, currentTileRotation, cities, + newTile, newRotation, newCities); + /* TODO Further consequences to be processed here, e.g. new routes etc. */ } *************** *** 718,722 **** return false; } else { - // new TokenMove (token, company, station); token.moveTo(city); return true; --- 725,728 ---- *************** *** 729,733 **** return false; } else { - // new TokenMove (token, token.getHolder(), this); token.moveTo(this); return true; --- 735,738 ---- *************** *** 804,823 **** } - /** Check if the tile already has a token of a company in one station */ - /* - * public boolean hasTokenOfCompany (PublicCompanyI company, Station - * station) { - * - * for (TokenI token : station.getTokens()) { if - * (((BaseToken)token).getCompany() == company) return true; } return false; } - */ - - /** Check if the tile already has a token of a company in one station */ - /* - * public boolean hasTokenOfCompany (PublicCompanyI company, int station) { - * - * return hasTokenOfCompany (company, cities.get(station).getNumber()); } - */ - public List<TokenI> getTokens(int cityNumber) { if (cities.size() > 0 && mCities.get(cityNumber) != null) { --- 809,812 ---- Index: TileI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TileI.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TileI.java 20 Nov 2008 21:49:38 -0000 1.13 --- TileI.java 29 Nov 2008 20:01:33 -0000 1.14 *************** *** 45,48 **** --- 45,50 ---- public String getUpgradesString(MapHex hex); + public boolean relayBaseTokensOnUpgrade(); + public boolean hasStations(); |
From: Erik V. <ev...@us...> - 2008-11-29 20:01:43
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26165/rails/game/action Modified Files: LayTile.java Log Message: Allow selection of 1830 Erie home base station while upgrading to green. Index: LayTile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/LayTile.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** LayTile.java 4 Jun 2008 19:00:29 -0000 1.12 --- LayTile.java 29 Nov 2008 20:01:33 -0000 1.13 *************** *** 8,15 **** --- 8,19 ---- import java.io.IOException; import java.io.ObjectInputStream; + import java.io.ObjectInputStream.GetField; import java.util.*; + import rails.game.City; + import rails.game.Company; import rails.game.MapHex; import rails.game.MapManager; + import rails.game.PublicCompanyI; import rails.game.TileI; import rails.game.TileManager; *************** *** 51,54 **** --- 55,63 ---- transient private SpecialTileLay specialProperty = null; private int specialPropertyId; + + /** + * Need base tokens be relaid? + */ + private boolean relayBaseTokens = false; /*--- Postconditions ---*/ *************** *** 64,67 **** --- 73,80 ---- /** The tile orientation */ private int orientation; + + /** Any manually assigned base token positions */ + private Map<String, Integer> relaidBaseTokens = null; + private String relaidBaseTokensString = null; public static final long serialVersionUID = 1L; *************** *** 202,205 **** --- 215,241 ---- tileColours = map; } + + + public boolean isRelayBaseTokens() { + return relayBaseTokens; + } + + public void setRelayBaseTokens(boolean relayBaseTokens) { + this.relayBaseTokens = relayBaseTokens; + } + + public void addRelayBaseToken (String companyName, Integer cityNumber) { + if (relaidBaseTokens == null) { + relaidBaseTokens = new HashMap<String, Integer>(); + } + relaidBaseTokens.put(companyName, cityNumber); + relaidBaseTokensString = Util.appendWithDelimiter(relaidBaseTokensString, + Util.appendWithDelimiter(companyName, String.valueOf(cityNumber), ":"), + ","); + } + + public Map<String, Integer> getRelaidBaseTokens() { + return relaidBaseTokens; + } public boolean equals(PossibleAction action) { *************** *** 230,234 **** b.append(" tile=").append(laidTile.getId()).append(" hex=").append( chosenHex.getName()).append(" orientation=").append( ! orientation); } return b.toString(); --- 266,270 ---- b.append(" tile=").append(laidTile.getId()).append(" hex=").append( chosenHex.getName()).append(" orientation=").append( ! orientation).append(" tokens=").append(relaidBaseTokensString); } return b.toString(); *************** *** 239,243 **** ClassNotFoundException { ! in.defaultReadObject(); MapManager mmgr = MapManager.getInstance(); --- 275,291 ---- ClassNotFoundException { ! //in.defaultReadObject(); ! // Custom reading for backwards compatibility ! ObjectInputStream.GetField fields = in.readFields(); ! locationNames = (String) fields.get("locationNames", locationNames); ! tileColours = (Map<String, Integer>) fields.get("tileColours", tileColours); ! tileIds = (int[]) fields.get("tileIds", tileIds); ! specialPropertyId = fields.get("specialPropertyId", specialPropertyId); ! laidTileId = fields.get("laidTileId", laidTileId); ! chosenHexName = (String) fields.get("chosenHexName", chosenHexName); ! orientation = fields.get("orientation", orientation); ! relayBaseTokens = fields.get("relayBaseTokens", relayBaseTokens); ! relaidBaseTokens = (Map<String,Integer>)fields.get("relaidBaseTokens", relaidBaseTokens); ! relaidBaseTokensString = (String) fields.get("relaidBaseTokensString", relaidBaseTokensString); MapManager mmgr = MapManager.getInstance(); *************** *** 265,268 **** --- 313,317 ---- chosenHex = MapManager.getInstance().getHex(chosenHexName); } + } |
From: Erik V. <ev...@us...> - 2008-11-29 20:01:43
|
Update of /cvsroot/rails/18xx/data/1830 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26165/data/1830 Modified Files: TileSet.xml Log Message: Allow selection of 1830 Erie home base station while upgrading to green. Index: TileSet.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1830/TileSet.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TileSet.xml 9 Jul 2006 12:03:32 -0000 1.6 --- TileSet.xml 29 Nov 2008 20:01:33 -0000 1.7 *************** *** 20,24 **** </Tile> <Tile id="-20"><!-- 2 OO cities --> ! <Upgrade id="59"/> </Tile> <Tile id="-21"><!-- New York --> --- 20,24 ---- </Tile> <Tile id="-20"><!-- 2 OO cities --> ! <Upgrade id="59" relayBaseTokens="yes"/> </Tile> <Tile id="-21"><!-- New York --> |
From: Mark J S. <kr...@us...> - 2008-11-28 19:46:24
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6865/18xx/rails/game Modified Files: Bank.java Log Message: Update the LocalText.getText("Bank") to LocalText.getText("BANK") Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Bank.java 20 Nov 2008 21:49:38 -0000 1.8 --- Bank.java 28 Nov 2008 19:46:17 -0000 1.9 *************** *** 243,247 **** public String getName() { ! return LocalText.getText("Bank"); } --- 243,247 ---- public String getName() { ! return LocalText.getText("BANK"); } |
From: Mark J S. <kr...@us...> - 2008-11-28 19:42:05
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6710/18xx/rails/ui/swing Modified Files: GameStatus.java Log Message: Change 'Bank=Bank' to 'BANK=Bank' to match how GameStatus line 471 will now use it. GameStatus.java will also be updated. Index: GameStatus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameStatus.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GameStatus.java 20 Nov 2008 21:49:38 -0000 1.20 --- GameStatus.java 28 Nov 2008 19:41:58 -0000 1.21 *************** *** 469,473 **** // Bank ! addField(new Caption(LocalText.getText("Bank")), bankCashXOffset - 1, bankCashYOffset - 1, 1, 2, WIDE_TOP + WIDE_LEFT); addField(new Caption(LocalText.getText("CASH")), bankCashXOffset, --- 469,473 ---- // Bank ! addField(new Caption(LocalText.getText("BANK")), bankCashXOffset - 1, bankCashYOffset - 1, 1, 2, WIDE_TOP + WIDE_LEFT); addField(new Caption(LocalText.getText("CASH")), bankCashXOffset, |
From: Mark J S. <kr...@us...> - 2008-11-28 19:41:44
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6699/18xx Modified Files: LocalisedText.properties Log Message: Change 'Bank=Bank' to 'BANK=Bank' to match how GameStatus line 471 will now use it. GameStatus.java will also be updated. Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** LocalisedText.properties 20 Nov 2008 21:49:38 -0000 1.60 --- LocalisedText.properties 28 Nov 2008 19:41:34 -0000 1.61 *************** *** 8,12 **** AlreadySoldThisTurn={0} already sold {1} this turn AmountMustBeMultipleOf10=Amount ({0}) must be a multiple of 10 ! Bank=Bank BANK_SHARES=Bank shares BASE_PRICE=<html>Base<br>Price</html> --- 8,12 ---- AlreadySoldThisTurn={0} already sold {1} this turn AmountMustBeMultipleOf10=Amount ({0}) must be a multiple of 10 ! BANK=Bank BANK_SHARES=Bank shares BASE_PRICE=<html>Base<br>Price</html> |
From: Erik V. <ev...@us...> - 2008-11-27 22:20:26
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4564/rails/ui/swing Modified Files: StatusWindow.java Log Message: Added confirmation question on closing StatusWindow Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StatusWindow.java 30 Jun 2008 20:35:29 -0000 1.23 --- StatusWindow.java 27 Nov 2008 22:20:21 -0000 1.24 *************** *** 24,28 **** */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer { private static final long serialVersionUID = 1L; --- 24,28 ---- */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, /*WindowListener,*/ ActionPerformer { private static final long serialVersionUID = 1L; *************** *** 210,214 **** setJMenuBar(menuBar); ! } public StatusWindow() { --- 210,215 ---- setJMenuBar(menuBar); ! ! } public StatusWindow() { *************** *** 263,266 **** --- 264,280 ---- addKeyListener(this); + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE ); + final JFrame frame = this; + addWindowListener(new WindowAdapter () { + public void windowClosing(WindowEvent e) { + if (JOptionPane.showConfirmDialog(frame, "Do you really want to exit the game?", "Select", JOptionPane.OK_CANCEL_OPTION) + == JOptionPane.OK_OPTION) { + frame.dispose(); + System.exit(0); + } + } + }); + + pack(); } *************** *** 623,625 **** --- 637,641 ---- public void keyTyped(KeyEvent e) {} + + } |
From: Erik V. <ev...@us...> - 2008-11-27 22:20:03
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4535/rails/ui/swing Modified Files: ORUIManager.java Log Message: Small cleanup Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ORUIManager.java 21 Nov 2008 20:41:47 -0000 1.18 --- ORUIManager.java 27 Nov 2008 22:19:51 -0000 1.19 *************** *** 417,421 **** List<String> options = new ArrayList<String>(); List<PublicCompanyI> companies = action.getPossibleCompanies(); - String chosenOption; for (PublicCompanyI company : companies) { --- 417,420 ---- |
From: Erik V. <ev...@us...> - 2008-11-26 22:26:25
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19600/rails/game Modified Files: MapHex.java Log Message: Fixed 1851 Louisville green upgrade bug: L&N token not displayed Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MapHex.java 4 Jun 2008 19:00:31 -0000 1.19 --- MapHex.java 26 Nov 2008 22:26:14 -0000 1.20 *************** *** 451,463 **** Map<Station, City> newStationsToCities = new HashMap<Station, City>(); ! // Tentatively number the new cities after the new stations ! // City city; ! // for (Station newStation : newTile.getStations()) { ! // city = new City (this, newStation.getNumber(), newStation); ! // newCities.add(city); ! // } ! // Scan the old cities/stations, // and assign new stations where tracks correspond for (City oldCity : cities) { int cityNumber = oldCity.getNumber(); --- 451,458 ---- Map<Station, City> newStationsToCities = new HashMap<Station, City>(); ! // Scan the old cities/stations, // and assign new stations where tracks correspond + int newCityNumber = 0; for (City oldCity : cities) { int cityNumber = oldCity.getNumber(); *************** *** 491,495 **** if (!newStationsToCities.containsKey(newStation)) { newCity = ! new City(this, cityNumber, newStation); newCities.add(newCity); --- 486,490 ---- if (!newStationsToCities.containsKey(newStation)) { newCity = ! new City(this, ++newCityNumber, newStation); newCities.add(newCity); *************** *** 529,543 **** } } } // Check if there any new stations not corresponding ! // to an old city - create a new city for these stations. for (Station newStation : newTile.getStations()) { if (newStationsToCities.containsKey(newStation)) continue; int cityNumber; for (cityNumber = 1; mNewCities.containsKey(cityNumber); cityNumber++) ; ! newCity = new City(this, cityNumber, newStation); newCities.add(newCity); mNewCities.put(cityNumber, newCity); --- 524,591 ---- } + + } + } + + // If an old city is not yet connected, check if was + // connected to another city it has merged into (1851 Louisville) + for (City oldCity : cities) { + if (oldToNewCities.containsKey(oldCity)) continue; + Station oldStation = oldCity.getRelatedStation(); + int[] oldTrackEnds = + getTrackEndPoints(currentTile, currentTileRotation, + oldStation); + station: for (int i = 0; i < oldTrackEnds.length; i++) { + log.debug("Old track ending at "+oldTrackEnds[i]); + if (oldTrackEnds[i] < 0) { + int oldStationNumber = -oldTrackEnds[i]; + // Find the old city that has this number + for (City oldCity2 : cities) { + log.debug("Old city "+oldCity2.getNumber()+" has station "+oldCity2.getRelatedStation().getNumber()); + log.debug(" and links to new city "+oldToNewCities.get(oldCity2)); + if (oldCity2.getRelatedStation().getNumber() + == oldStationNumber + && oldToNewCities.containsKey(oldCity2)) { + newCity = oldToNewCities.get(oldCity2); + oldToNewCities.put(oldCity, newCity); + log.debug("Assigned from " + + oldCity.getUniqueId() + + " #" + + currentTile.getId() + + "/" + + currentTileRotation + + " " + + oldStation.getId() + + " " + + getConnectionString(currentTile, + currentTileRotation, + oldStation.getNumber()) + + " to " + newCity.getUniqueId() + + " #" + newTile.getId() + "/" + + newRotation + " " + + newCity.getRelatedStation().getId() + " " + + newCity.getTrackEdges()); + break station; + + + } + } + + } } } + + // Check if there any new stations not corresponding ! // to an old city. for (Station newStation : newTile.getStations()) { if (newStationsToCities.containsKey(newStation)) continue; + + // Create a new city for such a station. int cityNumber; for (cityNumber = 1; mNewCities.containsKey(cityNumber); cityNumber++) ; ! newCity = new City(this, ++newCityNumber, newStation); newCities.add(newCity); mNewCities.put(cityNumber, newCity); *************** *** 558,563 **** for (City oldCity : cities) { - // log.debug("Old city "+oldCity.getNumber()+" has - // "+oldCity.getTokens().size()+" tokens"); newCity = oldToNewCities.get(oldCity); if (newCity != null) { --- 606,609 ---- |
From: Erik V. <ev...@us...> - 2008-11-22 17:23:06
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27135/rails/game Modified Files: GameManager.java Log Message: Removed dead code Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** GameManager.java 26 Oct 2008 20:47:37 -0000 1.35 --- GameManager.java 22 Nov 2008 17:22:59 -0000 1.36 *************** *** 55,59 **** protected boolean skipFirstStockRound = false; - //protected boolean companiesCanBuyPrivates = false; protected boolean gameEndsWithBankruptcy = false; protected int gameEndsWhenBankHasLessOrEqual = 0; --- 55,58 ---- *************** *** 543,548 **** // Note: round may have changed! - // log.debug("Calling setPossibleActions for round - // "+getCurrentRound().toString()); possibleActions.clear(); getCurrentRound().setPossibleActions(); --- 542,545 ---- *************** *** 613,618 **** public void finishShareSellingRound() { ! // currentRound = interruptedRound; ! setRound(interruptedRound); ((OperatingRound) getCurrentRound()).resumeTrainBuying(); } --- 610,614 ---- public void finishShareSellingRound() { ! setRound(interruptedRound); ((OperatingRound) getCurrentRound()).resumeTrainBuying(); } *************** *** 816,870 **** } - /* - public static void setCompaniesCanBuyPrivates() { - instance.companiesCanBuyPrivates = true; - } - */ - public String getHelp() { return getCurrentRound().getHelp(); } - /* - public static void setHasAnyParPrice(boolean hasAnyParPrice) { - instance.hasAnyParPrice = hasAnyParPrice; - } - */ - public boolean canAnyCompanyHoldShares() { return canAnyCompanyHoldShares; } - /* - public static void setCanAnyCompanyHoldShares( - boolean canAnyCompanyHoldShares) { - instance.canAnyCompanyHoldShares = canAnyCompanyHoldShares; - } - */ - - /* - public static boolean canAnyCompBuyPrivates() { - return instance.canAnyCompBuyPrivates; - } - */ - - /* - public static void setCanAnyCompBuyPrivates(boolean canAnyCompBuyPrivates) { - instance.canAnyCompanyBuyPrivates = canAnyCompBuyPrivates; - } - */ - - /* - public static boolean doBonusTokensExist() { - return instance.bonusTokensExist; - } - */ - - /* - public static void setBonusTokensExist(boolean bonusTokensExist) { - instance.bonusTokensExist = bonusTokensExist; - } - */ - public String getClassName (Defs.ClassName key) { --- 812,823 ---- |
From: Erik V. <ev...@us...> - 2008-11-21 20:41:57
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5012/rails/ui/swing Modified Files: ORWindow.java ORUIManager.java GameUIManager.java ReportWindow.java Log Message: ReportWindow changes (Jonathan) Index: ReportWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ReportWindow.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ReportWindow.java 18 Nov 2008 22:12:50 -0000 1.6 --- ReportWindow.java 21 Nov 2008 20:41:47 -0000 1.7 *************** *** 16,36 **** private static final long serialVersionUID = 1L; ! private JLabel message; private JScrollPane messageScroller; private JScrollBar vbar; private JPanel messagePanel; ! private static ReportWindow messageWindow; private GameManager gameManager; - private static StringBuffer buffer = new StringBuffer("<html></html>"); - public ReportWindow(GameManager gameManager) { messageWindow = this; this.gameManager = gameManager; ! message = new JLabel(""); message.setBackground(Color.WHITE); message.setOpaque(true); - message.setVerticalAlignment(SwingConstants.TOP); message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); --- 16,35 ---- private static final long serialVersionUID = 1L; ! private JTextArea message; private JScrollPane messageScroller; private JScrollBar vbar; private JPanel messagePanel; ! private ReportWindow messageWindow; private GameManager gameManager; public ReportWindow(GameManager gameManager) { messageWindow = this; this.gameManager = gameManager; ! message = new JTextArea(); ! message.setEditable(false); ! message.setLineWrap(false); message.setBackground(Color.WHITE); message.setOpaque(true); message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); *************** *** 38,42 **** messageScroller = new JScrollPane(message, ! ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); vbar = messageScroller.getVerticalScrollBar(); --- 37,41 ---- messageScroller = new JScrollPane(message, ! ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); vbar = messageScroller.getVerticalScrollBar(); *************** *** 56,65 **** } ! public static void addLog() { String newText = ReportBuffer.get(); if (newText.length() > 0) { ! buffer.insert(buffer.length() - 7, newText.replaceAll("\n", "<br>")); ! ! messageWindow.message.setText(buffer.toString()); SwingUtilities.invokeLater(new Runnable() { public void run() { --- 55,62 ---- } ! public void addLog() { String newText = ReportBuffer.get(); if (newText.length() > 0) { ! message.append(newText); SwingUtilities.invokeLater(new Runnable() { public void run() { Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ORUIManager.java 20 Nov 2008 21:49:38 -0000 1.17 --- ORUIManager.java 21 Nov 2008 20:41:47 -0000 1.18 *************** *** 358,362 **** } ! ReportWindow.addLog(); } --- 358,362 ---- } ! gameUIManager.reportWindow.addLog(); } Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ORWindow.java 30 Jun 2008 20:35:29 -0000 1.16 --- ORWindow.java 21 Nov 2008 20:41:47 -0000 1.17 *************** *** 78,82 **** addWindowListener(this); ! ReportWindow.addLog(); } --- 78,82 ---- addWindowListener(this); ! gameUIManager.reportWindow.addLog(); } Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GameUIManager.java 30 Jun 2008 20:35:29 -0000 1.12 --- GameUIManager.java 21 Nov 2008 20:41:47 -0000 1.13 *************** *** 125,129 **** activeWindow.displayServerMessage(); ! ReportWindow.addLog(); // End of game checks --- 125,129 ---- activeWindow.displayServerMessage(); ! reportWindow.addLog(); // End of game checks |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962/rails/game Modified Files: Portfolio.java Tile.java StockRound.java StartItem.java PublicCompany.java TreasuryShareRound.java Player.java TileI.java StartRound.java PublicCompanyI.java ShareSellingRound.java OperatingRound.java ReportBuffer.java Bank.java Round.java PrivateCompany.java Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Portfolio.java 2 Nov 2008 19:52:48 -0000 1.28 --- Portfolio.java 20 Nov 2008 21:49:38 -0000 1.29 *************** *** 147,195 **** } - public void buyCertificate(PublicCertificateI certificate, Portfolio from, - int price) { - - // Move the certificate - // new CertificateMove (from, this, certificate); - certificate.moveTo(this); - - // Move the money. - if (price != 0) { - /* - * If the company has floated and capitalisation is incremental, the - * money goes to the company, even if the certificates are still in - * the IPO (as in 1835) - */ - PublicCompanyI comp = certificate.getCompany(); - CashHolder recipient; - if (comp.hasFloated() - && from == Bank.getIpo() - && comp.getCapitalisation() == PublicCompanyI.CAPITALISE_INCREMENTAL) { - recipient = comp; - } else { - recipient = from.owner; - } - // Bank.transferCash(owner, recipient, price); - new CashMove(owner, recipient, price); - } - } - - // Sales of stock always go to the Bank pool - // This method should be overridden for 1870 and other games - // that allow price protection. - public static void sellCertificate(PublicCertificateI certificate, - Portfolio from, int price) { - - ReportBuffer.add(LocalText.getText("SellsItemFor", new String[] { - from.getName(), certificate.getName(), Bank.format(price) })); - - // Move the certificate - // new CertificateMove (from, Bank.getPool(), certificate); - certificate.moveTo(Bank.getPool()); - - // Move the money - new CashMove(Bank.getInstance(), from.owner, price); - } - public void transferAssetsFrom(Portfolio otherPortfolio) { --- 147,150 ---- *************** *** 201,246 **** } - public static void transferCertificate(Certificate certificate, - Portfolio from, Portfolio to) { - if (certificate instanceof PublicCertificateI) { - if (from != null) - from.removeCertificate((PublicCertificateI) certificate); - to.addCertificate((PublicCertificateI) certificate); - } else if (certificate instanceof PrivateCompanyI) { - if (from != null) - from.removePrivate((PrivateCompanyI) certificate); - to.addPrivate((PrivateCompanyI) certificate); - } - - /* Update player's worth */ - if (from.owner instanceof Player) { - updatePlayerWorth((Player) from.owner, from, certificate); - } - if (to.owner instanceof Player) { - updatePlayerWorth((Player) to.owner, to, certificate); - } - } - - protected static void updatePlayerWorth(Player player, Portfolio portfolio, - Certificate certificate) { - - PublicCompanyI company; - - /* Update player worth */ - player.getWorthModel().update(); - - /* Make sure that future price changes will update the worth too */ - if (certificate instanceof PublicCertificateI) { - company = ((PublicCertificateI) certificate).getCompany(); - if (portfolio.certPerCompany.containsKey(company.getName())) { - company.getCurrentPriceModel().addDependent( - player.getWorthModel()); - } else { - company.getCurrentPriceModel().removeDependent( - player.getWorthModel()); - } - } - } - public void addPrivate(PrivateCompanyI privateCompany) { privateCompanies.add(privateCompany); --- 156,159 ---- Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TreasuryShareRound.java 2 Nov 2008 19:52:48 -0000 1.7 --- TreasuryShareRound.java 20 Nov 2008 21:49:38 -0000 1.8 *************** *** 370,374 **** for (int i = 0; i < number; i++) { cert2 = from.findCertificate(company, cert.getShares(), false); ! portfolio.buyCertificate(cert2, from, shares * price); } --- 370,375 ---- for (int i = 0; i < number; i++) { cert2 = from.findCertificate(company, cert.getShares(), false); ! //portfolio.buyCertificate(cert2, from, shares * price); ! executeTradeCertificate(cert2, portfolio, shares * price); } *************** *** 493,498 **** // Transfer the sold certificates for (PublicCertificateI cert2 : certsToSell) { ! if (cert2 != null) ! pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); } stockMarket.sell(company, numberSold); --- 494,501 ---- // Transfer the sold certificates for (PublicCertificateI cert2 : certsToSell) { ! if (cert2 != null) { ! //pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); ! executeTradeCertificate (cert2, pool, cert2.getShares() * price); ! } } stockMarket.sell(company, numberSold); Index: StartItem.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartItem.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StartItem.java 2 Nov 2008 19:52:48 -0000 1.12 --- StartItem.java 20 Nov 2008 21:49:38 -0000 1.13 *************** *** 154,159 **** if (pubcert.getPortfolio() == null ! || !pubcert.getPortfolio().getName().equals("Unavailable")) ! unavailable.buyCertificate(pubcert, pubcert.getPortfolio(), 0); } --- 154,159 ---- if (pubcert.getPortfolio() == null ! || pubcert.getPortfolio() != unavailable) ! pubcert.moveTo(unavailable); } *************** *** 170,176 **** // Move the certificate to the "unavailable" pool. PublicCertificateI pubcert2 = (PublicCertificateI) secondary; ! if (!pubcert2.getPortfolio().getName().equals("Unavailable")) ! unavailable.buyCertificate(pubcert2, ! pubcert2.getPortfolio(), 0); } } --- 170,175 ---- // Move the certificate to the "unavailable" pool. PublicCertificateI pubcert2 = (PublicCertificateI) secondary; ! if (pubcert2.getPortfolio() != unavailable) ! pubcert2.moveTo(unavailable); } } Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** PublicCompany.java 15 Nov 2008 13:42:27 -0000 1.42 --- PublicCompany.java 20 Nov 2008 21:49:38 -0000 1.43 *************** *** 290,295 **** if (privateBuyTag != null) { canBuyPrivates = true; - //GameManager.setCanAnyCompBuyPrivates(true); - //GameManager.setCompaniesCanBuyPrivates(); String lower = --- 290,293 ---- *************** *** 344,348 **** canHoldOwnShares = true; treasuryPaysOut = true; - //GameManager.setCanAnyCompanyHoldShares(true); maxPercOfOwnShares = --- 342,345 ---- *************** *** 380,383 **** --- 377,382 ---- } else if (capType.equalsIgnoreCase("incremental")) { setCapitalisation(CAPITALISE_INCREMENTAL); + } else if (capType.equalsIgnoreCase("whenBought")) { + setCapitalisation(CAPITALISE_WHEN_BOUGHT); } else { throw new ConfigurationException( *************** *** 434,439 **** } - //if (hasParPrice) GameManager.setHasAnyParPrice(true); - List<Tag> certificateTags = tag.getChildren("Certificate"); if (certificateTags != null) { --- 433,436 ---- *************** *** 499,503 **** if (buyCostTag != null) { baseTokensBuyCost = ! floatTag.getAttributeAsInteger("initialTokenCost", 0); } --- 496,500 ---- if (buyCostTag != null) { baseTokensBuyCost = ! buyCostTag.getAttributeAsInteger("initialTokenCost", 0); } *************** *** 730,733 **** --- 727,731 ---- public void start(StockSpaceI startSpace) { + log.debug("+++Starting1b "+name); hasStarted.set(true); setParSpace(startSpace); *************** *** 761,775 **** */ public void start() { ! hasStarted.set(true); ! if (hasStockPrice && parPrice.getPrice() != null) { ! // setCurrentPrice (parPrice.getPrice()); ! // The current price is set via the Stock Market ! StockMarket.getInstance().start(this, parPrice.getPrice()); ! } ! ! if (homeBaseTokensLayTime == WHEN_STARTED) { ! layHomeBaseTokens(); } - } --- 759,770 ---- */ public void start() { ! if (hasStockPrice) { ! start (getStartSpace()); ! } else { ! hasStarted.set(true); ! if (homeBaseTokensLayTime == WHEN_STARTED) { ! layHomeBaseTokens(); ! } } } *************** *** 799,827 **** getPresident().getPortfolio().getShareModel(this).update(); - /* - * // In 18EU, before phase 5, cash has already been moved if (moveCash) { - * - * int cash = 0; if (hasStockPrice) { int capFactor = 0; if - * (capitalisation == CAPITALISE_FULL) { capFactor = 100 / shareUnit; } - * else if (capitalisation == CAPITALISE_INCREMENTAL) { // TODO Should - * be: 100% - percentage still in IPO capFactor = - * percentageOwnedByPlayers() / shareUnit; } int price = (hasParPrice ? - * getParPrice() : getCurrentPrice()).getPrice(); cash = capFactor * - * price; } else { cash = fixedPrice; } - * - * if (baseTokensBuyCost > 0) cash -= baseTokensBuyCost; - * - * new CashMove(Bank.getInstance(), this, cash); - * ReportBuffer.add(LocalText.getText("FloatsWithCash", new String[] { - * name, Bank.format(cash) })); - * - * if (capitalisation == CAPITALISE_INCREMENTAL && canHoldOwnShares) { - * List<Certificate> moving = new ArrayList<Certificate>(); for - * (Certificate ipoCert : Bank.getIpo().getCertificatesPerCompany( - * name)) { moving.add(ipoCert); } for (Certificate ipoCert : moving) { - * ipoCert.moveTo(portfolio); } } } else { - * ReportBuffer.add(LocalText.getText("Floats", name)); } - */ - if (sharePriceUpOnFloating) { Game.getStockMarket().moveUp(this); --- 794,797 ---- *************** *** 986,998 **** * @return */ - /* - public static int getNumberOfPublicCompanies() { - return numberOfPublicCompanies; - } - /* - - /** - * @return - */ public int getPublicNumber() { return publicNumber; --- 956,959 ---- *************** *** 1021,1027 **** cert2 = cert.copy(); certificates.add(cert2); - //cert2.setCompany(this); - // TODO Questionable if it should be put in IPO or in - // Unavailable. } } --- 982,985 ---- *************** *** 1047,1051 **** certificates = new ArrayList<PublicCertificateI>(); certificates.add(certificate); - //certificate.setCompany(this); } --- 1005,1008 ---- *************** *** 1130,1148 **** } ! /** ! * Pay out a given amount of revenue (and store it). The amount is ! * distributed to all the certificate holders, or the "beneficiary" if ! * defined (e.g.: BankPool shares may pay to the company). ! * ! * @param The revenue amount. ! */ ! /* ! * public void payOut(int amount) { ! * ! * distributePayout(amount); // Move the token if (hasStockPrice && ! * (!payoutMustExceedPriceToMove || amount >= ! * currentPrice.getPrice().getPrice())) Game.getStockMarket().payOut(this); } /* ! * ! * /** Split a dividend. TODO Optional rounding down the payout * * @param amount --- 1087,1091 ---- } ! /** Split a dividend. TODO Optional rounding down the payout * * @param amount *************** *** 1150,1155 **** public void splitRevenue(int amount) { - // setLastRevenue(amount); - if (amount > 0) { // Withhold half of it --- 1093,1096 ---- *************** *** 1215,1221 **** beneficiary = this; } - // log.debug("Cert "+cert.getName()+"owned by "+holder.getName()+" - // benefits "+beneficiary.getName() - // +" (IPO:"+ipoPaysOut+" Pool:"+poolPaysOut+")"); return beneficiary; } --- 1156,1159 ---- *************** *** 1273,1299 **** } - public static boolean startCompany(String playerName, String companyName, - StockSpace startSpace) { - // TODO: Should probably do error checking in case names aren't found. - Player player = Game.getPlayerManager().getPlayerByName(playerName); - PublicCompany company = - (PublicCompany) Game.getCompanyManager().getPublicCompany( - companyName); - - PublicCertificate cert = - (PublicCertificate) company.certificates.get(0); - - if (player.getCash() >= (startSpace.getPrice() * (cert.getShare() / company.getShareUnit()))) { - company.start(startSpace); - int price = - startSpace.getPrice() - * (cert.getShare() / company.getShareUnit()); - player.buyShare(cert, price); - - return true; - } else - return false; - } - /** * @return Returns the lowerPrivatePriceFactor. --- 1211,1214 ---- *************** *** 1369,1374 **** pres.getPortfolio().swapPresidentCertificate(this, buyer.getPortfolio()); ! ReportBuffer.add(LocalText.getText("PresidencyIsTransferredTo", ! new String[] { name, buyer.getName() })); } } --- 1284,1289 ---- pres.getPortfolio().swapPresidentCertificate(this, buyer.getPortfolio()); ! ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! new String[] { buyer.getName(), name })); } } *************** *** 1394,1399 **** seller.getPortfolio().swapPresidentCertificate(this, player.getPortfolio()); ! ReportBuffer.add(LocalText.getText("PresidencyIsTransferredTo", ! new String[] { name, player.getName() })); } } --- 1309,1314 ---- seller.getPortfolio().swapPresidentCertificate(this, player.getPortfolio()); ! ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! new String[] { player.getName(), name })); } } *************** *** 1401,1415 **** /** - * Only usable if the float percentage is fixed. Games where the percentage - * varies must check this in StockRound and possibly StartRound. - */ - /* - * public boolean checkFlotation(boolean moveCash) { if (hasStarted() && - * !hasFloated() && (Bank.getIpo().getShare(this) + - * portfolio.getShare(this)) <= 100 - floatPerc) { // Float company - * setFloated(moveCash); return true; } else { return false; } } - */ - - /** * Return the unsold share percentage. It is calculated as the sum of the * percentages in IPO and in the company treasury. <p>The latter percentage --- 1316,1319 ---- *************** *** 1449,1457 **** } - /* - * public boolean mayBuyTrains() { - * - * return portfolio.getNumberOfTrains() < getCurrentTrainLimit(); } - */ public int getNumberOfTrains() { return portfolio.getNumberOfTrains(); --- 1353,1356 ---- *************** *** 1607,1614 **** } - /* - * public List<TokenI> getLaidBaseTokens() { return laidBaseTokens; } - */ - public List<TokenI> getTokens() { return allBaseTokens; --- 1506,1509 ---- Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** StartRound.java 2 Nov 2008 19:52:48 -0000 1.20 --- StartRound.java 20 Nov 2008 21:49:38 -0000 1.21 *************** *** 21,25 **** protected int numPlayers; protected String variant; - //protected GameManager gameMgr; protected Player currentPlayer; --- 21,24 ---- *************** *** 74,78 **** auctionItemState.set(null); - //gameMgr = GameManager.getInstance(); gameManager.setRound(this); setCurrentPlayerIndex(gameManager.getPriorityPlayer().getIndex()); --- 73,76 ---- *************** *** 250,254 **** ReportBuffer.add(LocalText.getText("BuysItemFor", new String[] { player.getName(), primary.getName(), Bank.format(price) })); ! player.buy(primary, price); checksOnBuying(primary, sharePrice); if (item.hasSecondary()) { --- 248,253 ---- ReportBuffer.add(LocalText.getText("BuysItemFor", new String[] { player.getName(), primary.getName(), Bank.format(price) })); ! //player.buy(primary, price); ! executeTradeCertificate (primary, player.getPortfolio(), price); checksOnBuying(primary, sharePrice); if (item.hasSecondary()) { *************** *** 256,260 **** ReportBuffer.add(LocalText.getText("ALSO_GETS", new String[] { player.getName(), extra.getName() })); ! player.buy(extra, 0); checksOnBuying(extra, sharePrice); } --- 255,260 ---- ReportBuffer.add(LocalText.getText("ALSO_GETS", new String[] { player.getName(), extra.getName() })); ! //player.buy(extra, 0); ! executeTradeCertificate (extra, player.getPortfolio(), 0); checksOnBuying(extra, sharePrice); } Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Tile.java 15 Nov 2008 21:22:50 -0000 1.22 --- Tile.java 20 Nov 2008 21:49:38 -0000 1.23 *************** *** 30,39 **** private final List<Upgrade> upgrades = new ArrayList<Upgrade>(); // Contains ! // Upgrade ! // instances private String upgradesString = ""; ! private final List[] tracksPerSide = new ArrayList[6]; // Cannot ! // parametrise ! // collection array private Map<Integer, List<Track>> tracksPerStation = null; private final List<Track> tracks = new ArrayList<Track>(); --- 30,37 ---- private final List<Upgrade> upgrades = new ArrayList<Upgrade>(); // Contains ! // Upgrade instances private String upgradesString = ""; ! private final List[] tracksPerSide = new ArrayList[6]; ! // N.B. Cannot parametrise collection array private Map<Integer, List<Track>> tracksPerStation = null; private final List<Track> tracks = new ArrayList<Track>(); *************** *** 138,142 **** } value = stationTag.getAttributeAsInteger("value", 0); - // log.debug("Tile #"+id+" st."+number+" value="+value); slots = stationTag.getAttributeAsInteger("slots", 0); position = stationTag.getAttributeAsInteger("position", 0); --- 136,139 ---- *************** *** 247,250 **** --- 244,256 ---- } + + // Process any phases in which the upgrade is allowed + String phases = upgradeTag.getAttributeAsString("phase"); + if (phases != null) { + for (Upgrade newUpgrade : newUpgrades) { + newUpgrade.setPhases(phases); + } + + } } } *************** *** 325,334 **** * @return A List of valid upgrade TileI objects. */ ! public List<TileI> getUpgrades(MapHex hex) { List<TileI> upgr = new ArrayList<TileI>(); TileI tile; for (Upgrade upgrade : upgrades) { tile = upgrade.getTile(); ! if (hex == null || upgrade.isAllowedForHex(hex)) upgr.add(tile); } return upgr; --- 331,340 ---- * @return A List of valid upgrade TileI objects. */ ! public List<TileI> getUpgrades(MapHex hex, PhaseI phase) { List<TileI> upgr = new ArrayList<TileI>(); TileI tile; for (Upgrade upgrade : upgrades) { tile = upgrade.getTile(); ! if (hex == null || upgrade.isAllowedForHex(hex, phase.getName())) upgr.add(tile); } return upgr; *************** *** 347,351 **** if (phase.isTileColourAllowed(tile.getColourName()) && tile.countFreeTiles() != 0 /* -1 means unlimited */ ! && upgrade.isAllowedForHex(hex)) { valid.add(tile); } --- 353,357 ---- if (phase.isTileColourAllowed(tile.getColourName()) && tile.countFreeTiles() != 0 /* -1 means unlimited */ ! && upgrade.isAllowedForHex(hex, phase.getName())) { valid.add(tile); } *************** *** 421,424 **** --- 427,434 ---- */ List<MapHex> disallowedHexes = null; + /** + * Phases in which the upgrade can be executed. + */ + List<String> allowedPhases = null; /** *************** *** 435,440 **** } ! protected boolean isAllowedForHex(MapHex hex) { if (hexes != null) convertHexString(); --- 445,455 ---- } ! protected boolean isAllowedForHex(MapHex hex, String phaseName) { + if (allowedPhases != null + && !allowedPhases.contains(phaseName)) { + return false; + } + if (hexes != null) convertHexString(); *************** *** 447,451 **** } } ! protected TileI getTile() { return tile; --- 462,466 ---- } } ! protected TileI getTile() { return tile; *************** *** 455,458 **** --- 470,477 ---- this.hexes = hexes; } + + protected void setPhases (String phases) { + allowedPhases = Arrays.asList(phases.split(",")); + } private void convertHexString() { Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Player.java 2 Nov 2008 19:52:48 -0000 1.14 --- Player.java 20 Nov 2008 21:49:38 -0000 1.15 *************** *** 2,6 **** package rails.game; - import java.util.ArrayList; import java.util.List; --- 2,5 ---- *************** *** 46,52 **** private Portfolio portfolio = null; - private ArrayList<PublicCompanyI> companiesSoldThisTurn = - new ArrayList<PublicCompanyI>(); - public static void setLimits(int number, int cash, int certLimit) { if (number > 1 && number <= MAX_PLAYERS) { --- 45,48 ---- *************** *** 107,148 **** } - /** - * @param share - * @throws NullPointerException if company hasn't started yet. UI needs to - * handle this. - */ - public void buyShare(PublicCertificate share, int price) - throws NullPointerException { - if (hasBoughtStockThisTurn) return; - - for (int i = 0; i < companiesSoldThisTurn.size(); i++) { - if (share.company.getName().equalsIgnoreCase( - companiesSoldThisTurn.get(i).toString())) return; - } - - if (portfolio.getCertificates().size() >= playerCertificateLimit) - return; - - try { - // throws nullpointer if company hasn't started yet. - // it's up to the UI to catch this and gracefully start the company. - getPortfolio().buyCertificate(share, share.getPortfolio(), price); - } catch (NullPointerException e) { - throw e; - } - - hasBoughtStockThisTurn = true; - } - - /* - public void buyShare(PublicCertificate share) throws NullPointerException { - try { - buyShare(share, share.getCompany().getCurrentSpace().getPrice()); - } catch (NullPointerException e) { - throw e; - } - } - */ - public boolean isOverLimits() { --- 103,106 ---- *************** *** 218,249 **** /** - * Front-end method for buying any kind of certificate from anyone. - * - * @param cert PrivateCompany or PublicCertificate. - * @param from Portfolio of seller. - * @param price Price. - */ - public void buy(Certificate cert, int price) { - - if (cert instanceof PrivateCompanyI) { - portfolio.buyPrivate((PrivateCompanyI) cert, cert.getPortfolio(), - price); - } else if (cert instanceof PublicCertificateI) { - Portfolio from = cert.getPortfolio(); - portfolio.buyCertificate((PublicCertificateI) cert, from, price); - ((PublicCertificateI) cert).getCompany().checkPresidencyOnBuy(this); - } - } - - /* - public int sellShare(PublicCertificate share) { - Portfolio.sellCertificate(share, portfolio, - share.getCompany().getCurrentSpace().getPrice()); - Game.getStockMarket().sell(share.getCompany(), 1); - return 1; - } - */ - - /** * @return Returns the player's portfolio. */ --- 176,179 ---- Index: Bank.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Bank.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Bank.java 28 Oct 2008 21:01:34 -0000 1.7 --- Bank.java 20 Nov 2008 21:49:38 -0000 1.8 *************** *** 147,151 **** * Put all available certificates in the IPO */ ! public /*static*/ void initCertificates() { // Add privates List<PrivateCompanyI> privates = --- 147,151 ---- * Put all available certificates in the IPO */ ! public void initCertificates() { // Add privates List<PrivateCompanyI> privates = *************** *** 243,247 **** public String getName() { ! return "Bank"; } --- 243,247 ---- public String getName() { ! return LocalText.getText("Bank"); } Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PrivateCompany.java 26 Oct 2008 20:47:37 -0000 1.18 --- PrivateCompany.java 20 Nov 2008 21:49:38 -0000 1.19 *************** *** 9,13 **** import rails.game.move.ObjectMove; import rails.game.special.SpecialPropertyI; - import rails.game.special.SpecialTokenLay; import rails.util.LocalText; import rails.util.Tag; --- 9,12 ---- *************** *** 54,58 **** if (hexes != null && hexes.length > 0) { blockedHexes = new ArrayList<MapHex>(); - // for (int i = 0; i < hexes.length; i++) for (String hexName : hexes) { MapHex hex = MapManager.getInstance().getHex(hexName); --- 53,56 ---- *************** *** 80,91 **** specialProperties.add(sp); sp.configureFromXML(spTag); - - /* - if (sp instanceof SpecialTokenLay - && ((SpecialTokenLay) sp).getToken() instanceof BonusToken) { - GameManager.setBonusTokensExist(true); - } - */ - } } --- 78,81 ---- Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Round.java 2 Nov 2008 19:52:48 -0000 1.11 --- Round.java 20 Nov 2008 21:49:38 -0000 1.12 *************** *** 171,174 **** --- 171,177 ---- // Incremental capitalisation as in 1851 capFactor = (100 - unsoldPercentage) / shareUnit; + } else if (capitalisationMode == PublicCompanyI.CAPITALISE_WHEN_BOUGHT) { + // Cash goes directly to treasury at each buy (as in 1856 before phase 6) + capFactor = 0; } int price = company.getIPOPrice(); *************** *** 178,181 **** --- 181,185 ---- } + // Substract initial token cost (e.g. 1851, 18EU) cash -= company.getBaseTokensBuyCost(); *************** *** 183,189 **** // up) ! new CashMove(Bank.getInstance(), company, cash); ! ReportBuffer.add(LocalText.getText("FloatsWithCash", new String[] { company.getName(), Bank.format(cash) })); if (capitalisationMode == PublicCompanyI.CAPITALISE_INCREMENTAL --- 187,198 ---- // up) ! if (cash > 0) { ! new CashMove(Bank.getInstance(), company, cash); ! ReportBuffer.add(LocalText.getText("FloatsWithCash", new String[] { company.getName(), Bank.format(cash) })); + } else { + ReportBuffer.add(LocalText.getText("Floats", + company.getName())); + } if (capitalisationMode == PublicCompanyI.CAPITALISE_INCREMENTAL *************** *** 205,207 **** --- 214,239 ---- } + protected void executeTradeCertificate(Certificate cert, Portfolio newHolder, int price) { + + Portfolio oldHolder = (Portfolio) cert.getHolder(); + cert.moveTo(newHolder); + + if (price != 0) { + new CashMove(newHolder.getOwner(), oldHolder.getOwner(), price); + } + + } + + /** + * Who receives the cash when a certificate is bought. + * Normally this is owner of the previously holding portfolio. + * This method must be called <i>before</i> transferring the certificate. + * @param cert + * @param newHolder + * @return + */ + protected CashHolder getSharePriceRecipient (Certificate cert, int price) { + return ((Portfolio)cert.getHolder()).getOwner(); + } + } Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PublicCompanyI.java 15 Nov 2008 13:42:27 -0000 1.24 --- PublicCompanyI.java 20 Nov 2008 21:49:38 -0000 1.25 *************** *** 15,18 **** --- 15,20 ---- public static final int CAPITALISE_INCREMENTAL = 1; + + public static final int CAPITALISE_WHEN_BOUGHT = 2; public void init2() throws ConfigurationException; Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ShareSellingRound.java 2 Nov 2008 19:52:48 -0000 1.14 --- ShareSellingRound.java 20 Nov 2008 21:49:38 -0000 1.15 *************** *** 319,323 **** if (presCert != null && dumpedPlayer != null && presSharesToSell > 0) { ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { ! dumpedPlayer.getName(), companyName })); // First swap the certificates Portfolio dumpedPortfolio = dumpedPlayer.getPortfolio(); --- 319,323 ---- if (presCert != null && dumpedPlayer != null && presSharesToSell > 0) { ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { ! dumpedPlayer.getName(), companyName})); // First swap the certificates Portfolio dumpedPortfolio = dumpedPlayer.getPortfolio(); *************** *** 331,336 **** // Transfer the sold certificates for (PublicCertificateI cert2 : certsToSell) { ! if (cert2 != null) ! pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); } stockMarket.sell(company, numberSold); --- 331,338 ---- // Transfer the sold certificates for (PublicCertificateI cert2 : certsToSell) { ! if (cert2 != null) { ! //pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); ! executeTradeCertificate (cert2, pool, cert2.getShares() * price); ! } } stockMarket.sell(company, numberSold); *************** *** 346,350 **** ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { otherPlayer.getName(), ! company.getName() })); break; } --- 348,353 ---- ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { otherPlayer.getName(), ! company.getName() ! })); break; } Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** OperatingRound.java 15 Nov 2008 13:43:38 -0000 1.43 --- OperatingRound.java 20 Nov 2008 21:49:38 -0000 1.44 *************** *** 45,50 **** new HashMap<String, Integer>(); - // protected Map<MapHex, SpecialPropertyI> specialPropertyPerHex - // = new HashMap<MapHex, SpecialPropertyI>(); protected List<LayBaseToken> currentNormalTokenLays = new ArrayList<LayBaseToken>(); --- 45,48 ---- *************** *** 76,83 **** static protected int numberOfPlayers = 0; - // static protected int relativeORNumber = 0; - - // static protected int cumulativeORNumber = 0; - /* Constants */ public static final int SPLIT_NOT_ALLOWED = 0; --- 74,77 ---- *************** *** 122,138 **** */ public OperatingRound() { - // relativeORNumber++; - // cumulativeORNumber++; - // thisOrNumber = getCompositeORNumber(); - } public void start(boolean operate, String orNumber) { - //if (operatingCompanyIndexObject == null) { - // operatingCompanyIndexObject = - // new IntegerState("OperatingCompanyIndex", 0); - //} - if (players == null) { players = gameManager.getPlayers(); --- 116,123 ---- *************** *** 169,210 **** } - /*----- General methods -----*/ - /** - * Return the operating round (OR) number in the format sr.or, where sr is - * the last stock round number and or is the relative OR number. - * - * @return Composite SR/OR number. - */ - // public String getCompositeORNumber() { - // return StockRound.getLastStockRoundNumber() + "." + relativeORNumber; - // } - /** - * Get the relative OR number. This number restarts at 1 after each stock - * round. - * - * @return Relative OR number - */ - // public int getRelativeORNumber() { - // return relativeORNumber; - // } - /** - * Get the cumulative OR number. This number never restarts. - * - * @return Cumulative OR number. - */ - // public int getCumulativeORNumber() { - // return cumulativeORNumber; - // } - // public static int getLastORNumber() { - // return cumulativeORNumber; - // } - /** - * //@deprecated Currently needed, but will be removed in a later stage. - */ - // @Deprecated - // public static void resetRelativeORNumber() { - // relativeORNumber = 0; - // } /*----- METHODS THAT PROCESS PLAYER ACTIONS -----*/ --- 154,158 ---- *************** *** 256,259 **** --- 204,211 ---- result = buyPrivate((BuyPrivate) selectedAction); + + } else if (selectedAction instanceof ReachDestinations) { + + result = reachDestinations ((ReachDestinations) selectedAction); } else if (selectedAction instanceof NullAction) { *************** *** 321,325 **** if (tile == null) break; - //if (!tile.isLayableNow()) { if (!currentPhase.isTileColourAllowed(tile.getColourName())) { errMsg = --- 273,276 ---- *************** *** 409,414 **** if (tile != null) { ! if (cost > 0) // Bank.transferCash((CashHolder) operatingCompany, ! // null, cost); new CashMove(operatingCompany, null, cost); operatingCompany.layTile(hex, tile, orientation, cost); --- 360,364 ---- if (tile != null) { ! if (cost > 0) new CashMove(operatingCompany, null, cost); operatingCompany.layTile(hex, tile, orientation, cost); *************** *** 447,452 **** && currentSpecialTileLays.isEmpty()) { nextStep(); - } else { - // setPossibleActions("layTile"); } --- 397,400 ---- *************** *** 464,468 **** protected boolean checkNormalTileLay(TileI tile, boolean update) { - // if (currentNormalTileLays.isEmpty()) return false; if (tileLaysPerColour.isEmpty()) return false; String colour = tile.getColourName(); --- 412,415 ---- *************** *** 557,562 **** // Does the company have the money? if (cost > operatingCompany.getCash()) { ! errMsg = LocalText.getText("NotEnoughMoney", companyName); ! break; } break; --- 504,513 ---- // Does the company have the money? if (cost > operatingCompany.getCash()) { ! errMsg = LocalText.getText("NotEnoughMoney", new String[] { ! companyName, ! Bank.format(operatingCompany.getCash()), ! Bank.format(cost) ! }); ! break; } break; *************** *** 610,615 **** && currentSpecialTokenLays.isEmpty()) { nextStep(); - } else { - // setPossibleActions("layBaseToken"); } --- 561,564 ---- *************** *** 893,898 **** } - // if (step >= steps.length) { - // done(); if (step == STEP_FINAL) { finishTurn(); --- 842,845 ---- *************** *** 985,991 **** * normal tile lays are also (still) allowed */ - // for (MapHex hex : stl.getLocations()) { - // specialPropertyPerHex.put(hex, stl); - // } currentSpecialTileLays.add(new LayTile(stl)); } --- 932,935 ---- *************** *** 1015,1020 **** /* Special-property tile lays */ currentSpecialTokenLays.clear(); ! // specialPropertyPerHex.clear(); ! /* * In 1835, this only applies to major companies. TODO: For now, --- 959,963 ---- /* Special-property tile lays */ currentSpecialTokenLays.clear(); ! /* * In 1835, this only applies to major companies. TODO: For now, *************** *** 1031,1035 **** * normal tile lays are also (still) allowed */ - // specialPropertyPerHex.put(stl.getLocation(), stl); currentSpecialTokenLays.add(new LayBaseToken(stl)); } --- 974,977 ---- *************** *** 1219,1224 **** presidentCash = action.getPresidentCashToAdd(); if (currentPlayer.getCash() >= presidentCash) { - // new CashMove(currentPlayer, operatingCompany, - // presidentCash); actualPresidentCash = presidentCash; } else { --- 1161,1164 ---- *************** *** 1236,1242 **** break; } else if (currentPlayer.getCash() >= presidentCash) { ! // new CashMove(currentPlayer, operatingCompany, ! // presidentCash); ! actualPresidentCash = presidentCash; } else { presidentMustSellShares = true; --- 1176,1180 ---- break; } else if (currentPlayer.getCash() >= presidentCash) { ! actualPresidentCash = presidentCash; } else { presidentMustSellShares = true; *************** *** 1327,1331 **** } - // setPossibleActions("buyTrain"); return true; } --- 1265,1268 ---- *************** *** 1518,1521 **** --- 1455,1490 ---- } + + public boolean reachDestinations (ReachDestinations action) { + + List<PublicCompanyI> destinedCompanies + = action.getReachedCompanies(); + if (destinedCompanies != null) { + for (PublicCompanyI company : destinedCompanies) { + if (company.hasDestination() + && !company.hasReachedDestination()) { + if (!MoveSet.isOpen()) MoveSet.start(true); + company.setReachedDestination(true); + ReportBuffer.add(LocalText.getText("DestinationReached", new String[] { + company.getName(), + company.getDestinationHex().getName() + })); + // Process any consequences of reaching a destination + // (default none) + reachDestination (company); + } + } + } + return true; + } + + /** Stub for applying any follow-up actions when + * a company reaches it destinations. + * Default version: no actions. + * @param company + */ + protected void reachDestination (PublicCompanyI company) { + + } /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ *************** *** 1575,1580 **** public boolean setPossibleActions() { - // log.debug("Called from ", new Exception("HERE")); - operatingCompanyIndex = operatingCompanyIndexObject.intValue(); operatingCompany = operatingCompanyArray[operatingCompanyIndex]; --- 1544,1547 ---- *************** *** 1595,1598 **** --- 1562,1566 ---- possibleActions.addAll(currentSpecialTileLays); possibleActions.add(new NullAction(NullAction.SKIP)); + } else if (step == STEP_LAY_TOKEN) { setNormalTokenLays(); *************** *** 1629,1632 **** --- 1597,1602 ---- setBonusTokenLays(); + + setDestinationActions(); setGameSpecificPossibleActions(); *************** *** 1686,1690 **** int cost; List<TrainI> trains; ! // TrainI train; boolean hasTrains = operatingCompany.getPortfolio().getNumberOfTrains() > 0; --- 1656,1660 ---- int cost; List<TrainI> trains; ! boolean hasTrains = operatingCompany.getPortfolio().getNumberOfTrains() > 0; *************** *** 1859,1862 **** --- 1829,1842 ---- } } + + /** + * This is currently a stub, as it is unclear if there is a common + * rule for setting destination reaching options. + * See OperatingRound_1856 for a first implementation + * of such rules. + */ + protected void setDestinationActions () { + + } /* TODO This is just a start of a possible approach to a Help system */ Index: ReportBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ReportBuffer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReportBuffer.java 4 Jun 2008 19:00:30 -0000 1.3 --- ReportBuffer.java 20 Nov 2008 21:49:38 -0000 1.4 *************** *** 4,8 **** --- 4,10 ---- import java.io.*; import java.text.*; + import java.util.ArrayList; import java.util.Date; + import java.util.List; import org.apache.log4j.Logger; *************** *** 99,102 **** --- 101,118 ---- } } + + /* 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(); + } } Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** StockRound.java 2 Nov 2008 19:52:48 -0000 1.31 --- StockRound.java 20 Nov 2008 21:49:38 -0000 1.32 *************** *** 4,7 **** --- 4,8 ---- import rails.game.action.*; + import rails.game.move.CashMove; import rails.game.move.DoubleMapChange; import rails.game.move.MoveSet; *************** *** 19,26 **** /* Transient memory (per round only) */ ! protected /*static*/ int numberOfPlayers; protected Player currentPlayer; - // protected PublicCompanyI companyBoughtThisTurn = null; protected State companyBoughtThisTurnWrapper = new State("CompanyBoughtThisTurn", PublicCompany.class); --- 20,26 ---- /* Transient memory (per round only) */ ! protected int numberOfPlayers; protected Player currentPlayer; protected State companyBoughtThisTurnWrapper = new State("CompanyBoughtThisTurn", PublicCompany.class); *************** *** 30,39 **** protected BooleanState hasActed = new BooleanState("HasActed", false); // Is - // set - // true - // on - // any - // player - // action protected IntegerState numPasses = new IntegerState("StockRoundPasses"); --- 30,33 ---- *************** *** 54,65 **** /* Permanent memory */ - //static IntegerState stockRoundNumber = - // new IntegerState("StockRoundNumber", 0); static protected StockMarketI stockMarket; static protected Portfolio ipo; static protected Portfolio pool; static protected Portfolio unavailable; - //static protected CompanyManagerI companyMgr; - //static protected GameManager gameMgr; /* Rules */ --- 48,55 ---- *************** *** 73,88 **** if (numberOfPlayers == 0) numberOfPlayers = gameManager.getPlayers().size(); - //if (gameMgr == null) gameMgr = GameManager.getInstance(); if (stockMarket == null) stockMarket = StockMarket.getInstance(); if (ipo == null) ipo = Bank.getIpo(); if (pool == null) pool = Bank.getPool(); if (unavailable == null) unavailable = Bank.getUnavailable(); - //if (companyMgr == null) companyMgr = Game.getCompanyManager(); gameManager.setRound(this); sequenceRule = gameManager.getStockRoundSequenceRule(); - //stockRoundNumber.add(1); - ReportBuffer.add("\n" + LocalText.getText("StartStockRound") + getStockRoundNumber()); --- 63,74 ---- *************** *** 101,105 **** } - @Override public boolean setPossibleActions() { --- 87,90 ---- *************** *** 174,178 **** price = comp.getIPOPrice(); if (price <= playerCash) { ! possibleActions.add(new BuyCertificate(cert, from, price)); } } else if (!comp.hasStarted()) { --- 159,164 ---- price = comp.getIPOPrice(); if (price <= playerCash) { ! possibleActions.add(new BuyCertificate(cert, from, ! price)); } } else if (!comp.hasStarted()) { *************** *** 180,185 **** price = comp.getIPOPrice() * cert.getShares(); if (price <= playerCash) { ! possibleActions.add(new StartCompany(cert, ! price)); } } else { --- 166,170 ---- price = comp.getIPOPrice() * cert.getShares(); if (price <= playerCash) { ! possibleActions.add(new StartCompany(cert, price)); } } else { *************** *** 199,203 **** } } ! } } --- 184,188 ---- } } ! } } *************** *** 267,272 **** if (company.getMarketPrice() <= playerCash) { possibleActions.add(new BuyCertificate(cert, ! company.getPortfolio(), ! company.getMarketPrice())); } } --- 252,256 ---- if (company.getMarketPrice() <= playerCash) { possibleActions.add(new BuyCertificate(cert, ! company.getPortfolio(), company.getMarketPrice())); } } *************** *** 414,423 **** } else if (action instanceof BuyCertificate) { - // BuyCertificate buyAction = (BuyCertificate) action; - // result = buyShare (playerName, - // buyAction.getCertificate().getPortfolio(), - // buyAction.getCertificate().getCompany().getName(), - // buyAction.getCertificate().getShares(), - // 1); result = buyShares(playerName, (BuyCertificate) action); --- 398,401 ---- *************** *** 430,434 **** result = useSpecialProperty((UseSpecialProperty) action); ! } else if ((result = processGameSpecificAction(action))) { } else { --- 408,412 ---- result = useSpecialProperty((UseSpecialProperty) action); ! } else if (!!(result = processGameSpecificAction(action))) { } else { *************** *** 546,553 **** // All is OK, now start the company company.start(startSpace); // Transfer the President's certificate ! currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! company.getIPOPrice()); // If more than one certificate is bought at the same time, transfer --- 524,533 ---- // All is OK, now start the company company.start(startSpace); + + CashHolder priceRecipient = getSharePriceRecipient (cert, price); // Transfer the President's certificate ! executeTradeCertificate(cert, currentPlayer.getPortfolio(), ! price * cert.getShares(), priceRecipient); // If more than one certificate is bought at the same time, transfer *************** *** 555,560 **** for (int i = 1; i < numberOfCertsToBuy; i++) { cert = ipo.findCertificate(company, false); ! currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! company.getIPOPrice()); } --- 535,540 ---- for (int i = 1; i < numberOfCertsToBuy; i++) { cert = ipo.findCertificate(company, false); ! executeTradeCertificate(cert, currentPlayer.getPortfolio(), ! company.getIPOPrice(), priceRecipient); } *************** *** 562,570 **** playerName, companyName, Bank.format(price), Bank.format(shares * price), String.valueOf(shares), ! String.valueOf(cert.getShare()), LocalText.getText("BANK") })); checkFlotation(company); - // companyBoughtThisTurn = company; companyBoughtThisTurnWrapper.set(company); hasActed.set(true); --- 542,551 ---- playerName, companyName, Bank.format(price), Bank.format(shares * price), String.valueOf(shares), ! String.valueOf(cert.getShare()), ! priceRecipient.getName()})); ! ReportBuffer.getAllWaiting(); checkFlotation(company); companyBoughtThisTurnWrapper.set(company); hasActed.set(true); *************** *** 598,601 **** --- 579,583 ---- String errMsg = null; int price = 0; + int cash = 0; PublicCompanyI company = null; *************** *** 627,634 **** } ! // The company must have started before ! //if (!company.hasStarted()) { ! // The above is not true for 1835 Pr (for instance) ! // New rule: the presidents share may not be in IPO if (company.getPresidentsShare().getHolder() == ipo) { errMsg = LocalText.getText("NotYetStarted", companyName); --- 609,613 ---- } ! // The presidents share may not be in IPO if (company.getPresidentsShare().getHolder() == ipo) { errMsg = LocalText.getText("NotYetStarted", companyName); *************** *** 689,695 **** price = currentSpace.getPrice(); // Check if the Player has the money. ! if (currentPlayer.getCash() < shares * price) { errMsg = LocalText.getText("NoMoney"); break; --- 668,675 ---- price = currentSpace.getPrice(); + cash = shares * price; // Check if the Player has the money. ! if (currentPlayer.getCash() < cash) { errMsg = LocalText.getText("NoMoney"); break; *************** *** 709,716 **** MoveSet.start(true); if (number == 1) { ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", new String[] { playerName, String.valueOf(shareUnit), companyName, ! from.getName(), Bank.format(shares * price) })); } else { ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", new String[] { --- 689,698 ---- MoveSet.start(true); + CashHolder priceRecipient = getSharePriceRecipient (cert, cash); + if (number == 1) { ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", new String[] { playerName, String.valueOf(shareUnit), companyName, ! from.getName(), Bank.format(cash) })); } else { ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", new String[] { *************** *** 718,723 **** String.valueOf(shareUnit), String.valueOf(number * shareUnit), companyName, ! from.getName(), Bank.format(shares * price) })); } PublicCertificateI cert2; --- 700,706 ---- String.valueOf(shareUnit), String.valueOf(number * shareUnit), companyName, ! from.getName(), Bank.format(cash) })); } + ReportBuffer.getAllWaiting(); PublicCertificateI cert2; *************** *** 728,732 **** + "% share in " + from.getName()); } ! currentPlayer.buy(cert2, price * shares); } --- 711,724 ---- + "% share in " + from.getName()); } ! executeTradeCertificate(cert2, currentPlayer.getPortfolio(), ! cash, priceRecipient); ! } ! ! if (priceRecipient != from.getOwner()) { ! ReportBuffer.add(LocalText.getText("PriceIsPaidTo", ! new String[] { ! Bank.format(price * shares), ! priceRecipient.getName() ! })); } *************** *** 735,741 **** setPriority(); // Check if the company has floated if (!company.hasFloated()) checkFlotation(company); ! // Check for any game-specific consequences // (such as making another company available in the IPO) --- 727,736 ---- setPriority(); + // Check if presidency has changed + company.checkPresidencyOnBuy(currentPlayer); + // Check if the company has floated if (!company.hasFloated()) checkFlotation(company); ! // Check for any game-specific consequences // (such as making another company available in the IPO) *************** *** 744,760 **** return true; } ! /** Stub, may be overridden in subclasses */ protected void gameSpecificChecks(Portfolio boughtFrom, PublicCompanyI company) { } ! ! /** Make the cerificates of one company available for buying * by putting these in the IPO. * @param company The company to be released. */ ! protected void releaseCompanyShares (PublicCompanyI company) { ! for (PublicCertificateI cert : company.getCertificates()) { if (cert.getHolder().e... [truncated message content] |
From: Erik V. <ev...@us...> - 2008-11-20 21:49:49
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962/rails/game/special Modified Files: ExchangeForShare.java Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExchangeForShare.java 4 Jun 2008 19:00:38 -0000 1.7 --- ExchangeForShare.java 20 Nov 2008 21:49:38 -0000 1.8 *************** *** 89,93 **** false) : Bank.getPool().findCertificate(publicCompany, false); ! player.buy(cert, 0); ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", new String[] { player.getName(), privateCompany.getName(), --- 89,94 ---- false) : Bank.getPool().findCertificate(publicCompany, false); ! //player.buy(cert, 0); ! cert.moveTo(player.getPortfolio()); ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", new String[] { player.getName(), privateCompany.getName(), |
From: Erik V. <ev...@us...> - 2008-11-20 21:49:49
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962 Modified Files: LocalisedText.properties Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** LocalisedText.properties 15 Nov 2008 13:45:00 -0000 1.59 --- LocalisedText.properties 20 Nov 2008 21:49:38 -0000 1.60 *************** *** 8,12 **** AlreadySoldThisTurn={0} already sold {1} this turn AmountMustBeMultipleOf10=Amount ({0}) must be a multiple of 10 ! BANK=Bank BANK_SHARES=Bank shares BASE_PRICE=<html>Base<br>Price</html> --- 8,12 ---- AlreadySoldThisTurn={0} already sold {1} this turn AmountMustBeMultipleOf10=Amount ({0}) must be a multiple of 10 ! Bank=Bank BANK_SHARES=Bank shares BASE_PRICE=<html>Base<br>Price</html> *************** *** 98,101 **** --- 98,104 ---- CREDITS=Credits DestinationReachedByToken={0} gains {1} by laying a token on its destination {2} + DestinationReached={0} has reached its destination hex {1} + DestinationsReached=Destinations reached + DestinationsReachedPrompt=Select companies that have reached their destinations DiscardTrain=Discard {0}-train DoesNotExist=Item does not exist *************** *** 146,149 **** --- 149,153 ---- HasPriority={0} has the Priority Deal HIDE_OPTIONS=Hide Options + HoldMoneyInEscrow=The price ({0}) is paid to the Bank which holds it in escrow for {1} HOW_MANY_SHARES=How many shares? INFO=Game Notes *************** *** 185,189 **** MINIMUM_BID=<html>Min.<br>Bid</html> MinorCloses=Minor {0} is closed ! MonetiseTreasuryShares={0} puts 5 shares from Treasury in the Pool and receives {1} from the Bank MOVE=Move MODERATOR=Moderator --- 189,194 ---- MINIMUM_BID=<html>Min.<br>Bid</html> MinorCloses=Minor {0} is closed ! MonetiseTreasuryShares={0} puts 5 shares from Treasury in the Pool and receives {1} from the Bank ! PaysTo={0} pays {1} to {2} MOVE=Move MODERATOR=Moderator *************** *** 246,253 **** PoolOverHoldLimit=Pool would get over its share holding limit PoolWouldGetOverLimit=The Pool would get over its share holding limit of {0} - PresidencyIsTransferredTo=Presidency of {0} is transferred to {1}. PresidentMayNotAddMoreThan=The president may not add more than {0} PriceAboveUpperLimit=Price ({0}) is above the maximum buy price ({1}) of {2} PriceBelowLowerLimit=Price ({0}) is below the minimum buy price ({1}) of {2} PrivateBuyingIsNotAllowed=Private buying is not allowed PrivateCloses=Private {0} is closed --- 251,258 ---- PoolOverHoldLimit=Pool would get over its share holding limit PoolWouldGetOverLimit=The Pool would get over its share holding limit of {0} PresidentMayNotAddMoreThan=The president may not add more than {0} PriceAboveUpperLimit=Price ({0}) is above the maximum buy price ({1}) of {2} PriceBelowLowerLimit=Price ({0}) is below the minimum buy price ({1}) of {2} + PriceIsPaidTo=The price ({0}) is paid to {1} PrivateBuyingIsNotAllowed=Private buying is not allowed PrivateCloses=Private {0} is closed *************** *** 257,260 **** --- 262,266 ---- QUIT=Quit REDO=Redo + ReleasedFromEscrow={0} receives {1} released from bank escrow RemainingTiles=Remaining tiles REPORT=Report Window |
From: Erik V. <ev...@us...> - 2008-11-20 21:49:48
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962/rails/game/action Added Files: ReachDestinations.java Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups --- NEW FILE: ReachDestinations.java --- package rails.game.action; import java.io.IOException; import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.List; import rails.game.CompanyManagerI; import rails.game.Game; import rails.game.MapHex; import rails.game.MapManager; import rails.game.PublicCompanyI; /** This class is needed until we have a means to determine reaching * destinations automatically. * @author Erik * */ public class ReachDestinations extends PossibleORAction { // Server-side settings transient protected List<PublicCompanyI> possibleCompanies; protected String possibleCompanyNames = ""; // Client-side settings transient protected List<PublicCompanyI> reachedCompanies; protected String reachedCompanyNames = ""; 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(","); b.append (company.getName()); } possibleCompanyNames = b.toString(); } /** Required for deserialization */ public ReachDestinations() {} public List<PublicCompanyI> getPossibleCompanies() { return possibleCompanies; } public String getPossibleCompanyNames () { return possibleCompanyNames; } public void addReachedCompany (PublicCompanyI company) { if (reachedCompanies == null) reachedCompanies = new ArrayList<PublicCompanyI>(); reachedCompanies.add (company); if (reachedCompanyNames.length() > 0) { reachedCompanyNames += ","; } reachedCompanyNames += company.getName(); } public List<PublicCompanyI> getReachedCompanies() { return reachedCompanies; } @Override public boolean equals(PossibleAction pa) { if (!(pa instanceof ReachDestinations)) return false; ReachDestinations rd = (ReachDestinations) pa; return possibleCompanyNames.equals(rd.getPossibleCompanyNames()); } @Override public String toString() { StringBuffer text = new StringBuffer(); text.append("ReachDestinations: ").append(possibleCompanyNames); if (reachedCompanyNames.length() > 0) { text.append(" reached="+reachedCompanyNames); } return text.toString(); } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); CompanyManagerI cmgr = Game.getCompanyManager(); MapManager mmgr = MapManager.getInstance(); possibleCompanies = new ArrayList<PublicCompanyI>(); for (String cname : possibleCompanyNames.split(",")) { possibleCompanies.add(cmgr.getCompanyByName(cname)); } reachedCompanies = new ArrayList<PublicCompanyI>(); for (String cname : reachedCompanyNames.split(",")) { reachedCompanies.add(cmgr.getCompanyByName(cname)); } } } |
From: Erik V. <ev...@us...> - 2008-11-20 21:49:47
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962/rails/ui/swing Modified Files: ORPanel.java ORUIManager.java GameStatus.java Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ORUIManager.java 12 Oct 2008 14:36:44 -0000 1.16 --- ORUIManager.java 20 Nov 2008 21:49:38 -0000 1.17 *************** *** 3,6 **** --- 3,7 ---- import java.util.*; + import javax.swing.JComponent; import javax.swing.JOptionPane; *************** *** 10,13 **** --- 11,16 ---- import rails.game.action.*; import rails.game.special.*; + import rails.ui.swing.elements.CheckBoxDialog; + import rails.ui.swing.elements.RadioButtonDialog; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; *************** *** 336,339 **** --- 339,346 ---- orWindow.process(actions.get(0)); + + } else if (actionType == ReachDestinations.class) { + + reachDestinations ((ReachDestinations) actions.get(0)); } *************** *** 404,407 **** --- 411,443 ---- } + + protected void reachDestinations (ReachDestinations action) { + + int index; + List<String> options = new ArrayList<String>(); + List<PublicCompanyI> companies = action.getPossibleCompanies(); + String chosenOption; + + for (PublicCompanyI company : companies) { + options.add(company.getName()); + } + + if (options.size() > 0) { + boolean[] destined = + new CheckBoxDialog(orPanel, + LocalText.getText("DestinationsReached"), + LocalText.getText("DestinationsReachedPrompt"), + options.toArray(new String[0])) + .getSelectedOptions(); + for (index=0; index < options.size(); index++) { + if (destined[index]) { + action.addReachedCompany(companies.get(index)); + } + } + if (orWindow.process(action)) { + updateMessage(); + } + } + } public void hexClicked(GUIHex clickedHex, GUIHex selectedHex) { *************** *** 1087,1090 **** --- 1123,1131 ---- } } + + if (possibleActions.contains(ReachDestinations.class)) { + orPanel.addSpecialAction(possibleActions.getType(ReachDestinations.class).get(0), + LocalText.getText("DestinationsReached")); + } checkForGameSpecificActions(); Index: GameStatus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameStatus.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GameStatus.java 30 Oct 2008 21:48:20 -0000 1.19 --- GameStatus.java 20 Nov 2008 21:49:38 -0000 1.20 *************** *** 172,176 **** players = gameUIManager.getPlayers().toArray(new Player[0]); np = gameUIManager.getNumberOfPlayers(); - //cm = Game.getCompanyManager(); companies = gameUIManager.getAllPublicCompanies().toArray(new PublicCompanyI[0]); nc = companies.length; --- 172,175 ---- *************** *** 470,474 **** // Bank ! addField(new Caption(LocalText.getText("BANK")), bankCashXOffset - 1, bankCashYOffset - 1, 1, 2, WIDE_TOP + WIDE_LEFT); addField(new Caption(LocalText.getText("CASH")), bankCashXOffset, --- 469,473 ---- // Bank ! addField(new Caption(LocalText.getText("Bank")), bankCashXOffset - 1, bankCashYOffset - 1, 1, 2, WIDE_TOP + WIDE_LEFT); addField(new Caption(LocalText.getText("CASH")), bankCashXOffset, *************** *** 777,784 **** if (buyableCerts != null) { for (BuyCertificate bCert : buyableCerts) { - // tCert = (TradeableCertificate) it.next(); cert = bCert.getCertificate(); index = cert.getCompany().getPublicNumber(); - // holder = cert.getPortfolio(); holder = bCert.getFromPortfolio(); if (holder == ipo) { --- 776,781 ---- Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ORPanel.java 12 Oct 2008 14:36:44 -0000 1.26 --- ORPanel.java 20 Nov 2008 21:49:38 -0000 1.27 *************** *** 172,176 **** public void recreate(OperatingRound or) { ! log.debug("ORPanel.recreate() called"/* , new Exception("TRACE") */); companies = (or).getOperatingCompanies(); --- 172,176 ---- public void recreate(OperatingRound or) { ! log.debug("ORPanel.recreate() called"); companies = (or).getOperatingCompanies(); *************** *** 508,514 **** trainCaption.setHighlight(false); if (privatesCanBeBought) privatesCaption.setHighlight(false); - // if (orCompIndex >= 0) - // president[orCompIndex].setHighlight(false); - // } for (int i = 0; i < president.length; i++) { president[i].setHighlight(false); --- 508,511 ---- |
From: Erik V. <ev...@us...> - 2008-11-20 21:49:45
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18962/rails/game/specific/_1856 Modified Files: StockRound_1856.java OperatingRound_1856.java Added Files: PublicCompany_1856.java Log Message: Implemented 1856 capitalisation rules. Implemented temporary procedure for destination reaching (checkboxes in OR) Cleanups Index: StockRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/StockRound_1856.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StockRound_1856.java 5 Nov 2008 22:44:26 -0000 1.2 --- StockRound_1856.java 20 Nov 2008 21:49:38 -0000 1.3 *************** *** 1,8 **** package rails.game.specific._1856; import rails.game.PublicCompanyI; import rails.game.StockRound; ! import rails.game.TrainI; ! import rails.game.TrainManager; public class StockRound_1856 extends StockRound { --- 1,14 ---- package rails.game.specific._1856; + import rails.game.Bank; + import rails.game.CashHolder; + import rails.game.Certificate; + import rails.game.Portfolio; + import rails.game.PublicCertificateI; import rails.game.PublicCompanyI; + import rails.game.ReportBuffer; import rails.game.StockRound; ! import rails.game.move.CashMove; ! import rails.util.LocalText; public class StockRound_1856 extends StockRound { *************** *** 19,40 **** int unsoldPercentage = company.getUnsoldPercentage(); ! TrainI nextAvailableTrain = TrainManager.get().getAvailableNewTrains().get(0); ! int trainNumber; ! try { ! trainNumber = Integer.parseInt(nextAvailableTrain.getName()); ! } catch (NumberFormatException e) { ! trainNumber = 6; // Diesel! ! } ! int floatPercentage = 10 * trainNumber; log.debug ("Floatpercentage is "+floatPercentage); - //int floatPercentage = Math.min(60, (Integer)getCurrentPhase().getParameter("floatPercentage")); - if (unsoldPercentage <= 100 - floatPercentage) { ! // Company floats ! floatCompany(company); } } } --- 25,85 ---- int unsoldPercentage = company.getUnsoldPercentage(); ! PublicCompany_1856 comp = (PublicCompany_1856) company; ! int trainNumberAtStart = comp.getTrainNumberAvailableAtStart(); ! int floatPercentage = 10 * trainNumberAtStart; log.debug ("Floatpercentage is "+floatPercentage); if (unsoldPercentage <= 100 - floatPercentage) { ! // Company floats. ! // In 1856 this does not mean that the company will operate, ! // only that it will be added to the list of companies ! // being considered for an OR turn. ! // See OperatingRound_1856 for the actual check. ! if (!company.hasFloated()) { ! floatCompany(company); ! } } } + protected CashHolder getSharePriceRecipient(Certificate cert, int price) { + + CashHolder recipient; + Portfolio oldHolder = (Portfolio) cert.getHolder(); + + if (price != 0 + && cert instanceof PublicCertificateI + && oldHolder == Bank.getIpo()) { + + PublicCompany_1856 comp = (PublicCompany_1856)((PublicCertificateI) cert).getCompany(); + + switch (comp.getTrainNumberAvailableAtStart()) { + case 2: + case 3: + case 4: + // Note, that the share has not yet been moved + if (comp.getUnsoldPercentage() <= 50 + && !comp.hasReachedDestination()) { + recipient = oldHolder.getOwner(); // i.e. the Bank + comp.addMoneyInEscrow(price); + ReportBuffer.addWaiting(LocalText.getText("HoldMoneyInEscrow", new String[] { + Bank.format(comp.getMoneyInEscrow()), + comp.getName() + })); + break; + } + // fall through + case 5: + recipient = ((PublicCertificateI)cert).getCompany(); + break; + case 6: + default: + recipient = oldHolder.getOwner(); + } + } else { + recipient = oldHolder.getOwner(); + } + return recipient; + } + } Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OperatingRound_1856.java 15 Nov 2008 13:44:25 -0000 1.1 --- OperatingRound_1856.java 20 Nov 2008 21:49:38 -0000 1.2 *************** *** 1,8 **** --- 1,16 ---- package rails.game.specific._1856; + import java.util.ArrayList; + import java.util.List; + + import rails.game.Bank; import rails.game.DisplayBuffer; import rails.game.OperatingRound; + import rails.game.PublicCompanyI; + import rails.game.ReportBuffer; import rails.game.TrainI; import rails.game.TrainManager; + import rails.game.action.ReachDestinations; + import rails.game.move.CashMove; import rails.game.state.IntegerState; import rails.util.LocalText; *************** *** 70,72 **** --- 78,109 ---- } + protected void setDestinationActions() { + + List<PublicCompanyI> possibleDestinations = new ArrayList<PublicCompanyI>(); + for (PublicCompanyI comp : operatingCompanyArray) { + if (comp.hasDestination() + && ((PublicCompany_1856)comp).getTrainNumberAvailableAtStart() < 5 + && !comp.hasReachedDestination()) { + possibleDestinations.add (comp); + } + } + if (possibleDestinations.size() > 0) { + possibleActions.add(new ReachDestinations (possibleDestinations)); + } + } + + protected void reachDestination (PublicCompanyI company) { + + PublicCompany_1856 comp = (PublicCompany_1856) company; + int cashInEscrow = comp.getMoneyInEscrow(); + if (cashInEscrow > 0) { + new CashMove (null, company, cashInEscrow); + ReportBuffer.add(LocalText.getText("ReleasedFromEscrow", new String[] { + company.getName(), + Bank.format(cashInEscrow) + })); + } + + } + } --- NEW FILE: PublicCompany_1856.java --- package rails.game.specific._1856; import rails.game.PublicCompany; import rails.game.StockSpaceI; import rails.game.TrainI; import rails.game.TrainManager; import rails.game.state.IntegerState; public class PublicCompany_1856 extends PublicCompany { private IntegerState trainNumberAvailableAtStart; private IntegerState moneyInEscrow; public void start(StockSpaceI startSpace) { super.start(startSpace); TrainI nextAvailableTrain = TrainManager.get().getAvailableNewTrains().get(0); int trainNumber; try { trainNumber = Integer.parseInt(nextAvailableTrain.getName()); } catch (NumberFormatException e) { trainNumber = 6; // Diesel! } trainNumberAvailableAtStart = new IntegerState (name+"_trainAtStart"); trainNumberAvailableAtStart.set(trainNumber); if (trainNumber == 6) { this.capitalisation = CAPITALISE_FULL; } moneyInEscrow = new IntegerState (name+"_moneyInEscrow", 0); } public int getTrainNumberAvailableAtStart () { return trainNumberAvailableAtStart.intValue(); } public void setMoneyInEscrow (int amount) { moneyInEscrow.set(amount); } public void addMoneyInEscrow (int amount) { moneyInEscrow.add(amount); } public int getMoneyInEscrow () { return moneyInEscrow.intValue(); } } |
From: Erik V. <ev...@us...> - 2008-11-20 21:46:17
|
Update of /cvsroot/rails/18xx/data/1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv18598/data/1856 Modified Files: CompanyManager.xml Log Message: New (initial) capitalisation type. Index: CompanyManager.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1856/CompanyManager.xml,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** CompanyManager.xml 3 Nov 2008 15:55:00 -0000 1.22 --- CompanyManager.xml 20 Nov 2008 21:44:26 -0000 1.23 *************** *** 3,7 **** <CompanyType name="Private" class="rails.game.PrivateCompany"> </CompanyType> ! <CompanyType name="Public" class="rails.game.PublicCompany"> <CanBuyPrivates lowerPriceFactor="0.5" upperPriceFactor="2.0"/> <PoolPaysOut/> --- 3,7 ---- <CompanyType name="Private" class="rails.game.PrivateCompany"> </CompanyType> ! <CompanyType name="Public" class="rails.game.specific._1856.PublicCompany_1856"> <CanBuyPrivates lowerPriceFactor="0.5" upperPriceFactor="2.0"/> <PoolPaysOut/> *************** *** 9,13 **** <Certificate type="President" shares="2"/> <Certificate shares="1" number="8"/> ! <Capitalisation type="incremental"/> <BaseTokens> <LayCost method="sequence" cost="0,40,100"/> --- 9,13 ---- <Certificate type="President" shares="2"/> <Certificate shares="1" number="8"/> ! <Capitalisation type="whenBought"/> <BaseTokens> <LayCost method="sequence" cost="0,40,100"/> |