From: Erik V. <ev...@us...> - 2009-11-17 19:31:39
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6307/rails/game Modified Files: StartRound_1830.java StartItem.java Player.java OperatingRound.java Tile.java Game.java Log Message: Fixed various bugs Index: StartItem.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartItem.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** StartItem.java 25 Sep 2009 19:13:01 -0000 1.18 --- StartItem.java 17 Nov 2009 19:31:24 -0000 1.19 *************** *** 282,287 **** bids[index].set(amount); - // Take care for negative values, meaning "has passed" - // (used in 18EU) if (amount > 0) { lastBidderIndex.set(index); --- 282,285 ---- *************** *** 292,295 **** --- 290,297 ---- bids[index].resetOption(MoneyModel.SUPPRESS_ZERO); bids[index].update(); + } else { + // Passed + bids[index].set(0); + bids[index].update(); } Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Player.java 12 Sep 2009 09:40:56 -0000 1.21 --- Player.java 17 Nov 2009 19:31:25 -0000 1.22 *************** *** 13,17 **** public static int MIN_PLAYERS = 2; ! private String name = ""; --- 13,17 ---- public static int MIN_PLAYERS = 2; ! private String name = ""; *************** *** 85,89 **** for (PublicCertificateI cert : portfolio.getCertificates()) { ! worth += cert.getCompany().getGameEndPrice(); } for (PrivateCompanyI priv : portfolio.getPrivateCompanies()) { --- 85,89 ---- for (PublicCertificateI cert : portfolio.getCertificates()) { ! worth += cert.getCompany().getGameEndPrice() * cert.getShares(); } for (PrivateCompanyI priv : portfolio.getPrivateCompanies()) { Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Game.java 14 Nov 2009 20:21:51 -0000 1.37 --- Game.java 17 Nov 2009 19:31:26 -0000 1.38 *************** *** 58,63 **** } ! public void start() { gameManager.startGame(gameOptions); } --- 58,71 ---- } ! public String start() { ! ! if (players.size() < playerManager.minPlayers ! || players.size() > playerManager.maxPlayers) { ! return name+" is not configured to be played with "+players.size()+" players\n" ! + "Please enter a valid number of players, or add a <Players> entry to data/"+name+"/Game.xml"; ! } ! gameManager.startGame(gameOptions); + return null; } *************** *** 231,235 **** log.debug("Number of loaded actions: " + executedActions.size()); ! game.start(); log.debug("Starting to execute loaded actions"); --- 239,247 ---- log.debug("Number of loaded actions: " + executedActions.size()); ! String startError = game.start(); ! if (startError != null) { ! DisplayBuffer.add(startError); ! return null; ! } log.debug("Starting to execute loaded actions"); Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** OperatingRound.java 7 Nov 2009 12:09:55 -0000 1.76 --- OperatingRound.java 17 Nov 2009 19:31:25 -0000 1.77 *************** *** 548,552 **** cost = operatingCompany.getBaseTokenLayCost(); if (stl != null && stl.isFree()) cost = 0; ! // Does the company have the money? if (cost > operatingCompany.getCash()) { --- 548,552 ---- cost = operatingCompany.getBaseTokenLayCost(); if (stl != null && stl.isFree()) cost = 0; ! // Does the company have the money? if (cost > operatingCompany.getCash()) { *************** *** 1307,1311 **** // Does the company have room for another train? int trainLimit = operatingCompany.getCurrentTrainLimit(); ! if (!canBuyTrain()) { errMsg = LocalText.getText("WouldExceedTrainLimit", --- 1307,1311 ---- // Does the company have room for another train? int trainLimit = operatingCompany.getCurrentTrainLimit(); ! if (!isBelowTrainLimit() && !action.isForcedExchange()) { errMsg = LocalText.getText("WouldExceedTrainLimit", *************** *** 2058,2062 **** boolean atTrainLimit = operatingCompany.getNumberOfTrains() >= operatingCompany.getCurrentTrainLimit(); ! boolean canBuyTrainNow = canBuyTrain(); boolean presidentMayHelp = !hasTrains && operatingCompany.mustOwnATrain(); TrainI cheapestTrain = null; --- 2058,2062 ---- boolean atTrainLimit = operatingCompany.getNumberOfTrains() >= operatingCompany.getCurrentTrainLimit(); ! boolean canBuyTrainNow = isBelowTrainLimit(); boolean presidentMayHelp = !hasTrains && operatingCompany.mustOwnATrain(); TrainI cheapestTrain = null; *************** *** 2096,2103 **** if (atTrainLimit) action.setForcedExchange(true); possibleActions.add(action); } } ! if (!canBuyTrainNow) return; // Can a special property be used? --- 2096,2104 ---- if (atTrainLimit) action.setForcedExchange(true); possibleActions.add(action); + canBuyTrainNow = true; } } ! if (!canBuyTrainNow) continue; // Can a special property be used? *************** *** 2209,2213 **** * @return */ ! protected boolean canBuyTrain() { return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); } --- 2210,2214 ---- * @return */ ! protected boolean isBelowTrainLimit() { return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); } Index: StartRound_1830.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1830.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** StartRound_1830.java 7 Oct 2009 21:03:36 -0000 1.22 --- StartRound_1830.java 17 Nov 2009 19:31:21 -0000 1.23 *************** *** 306,309 **** --- 306,310 ---- } else { // More than one left: find next bidder + auctionItem.setBid(-1, player); setNextBiddingPlayer(auctionItem, getCurrentPlayerIndex()); Index: Tile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Tile.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Tile.java 31 Oct 2009 17:08:26 -0000 1.30 --- Tile.java 17 Nov 2009 19:31:26 -0000 1.31 *************** *** 270,278 **** } ! public void finishConfiguration (TileManager tileManager) throws ConfigurationException { ! for (Upgrade upgrade : upgrades) { ! TileI tile = tileManager.getTile(upgrade.getTileId()); if (tile != null) { --- 270,278 ---- } ! public void finishConfiguration (TileManager tileManager) throws ConfigurationException { ! for (Upgrade upgrade : upgrades) { ! TileI tile = tileManager.getTile(upgrade.getTileId()); if (tile != null) { *************** *** 284,288 **** } } ! /** * @return Returns the colour. --- 284,288 ---- } } ! /** * @return Returns the colour. *************** *** 372,377 **** } public String getUpgradesString(MapHex hex) { ! return upgradesString; } --- 372,388 ---- } + /** Get a delimited list of all possible upgrades, regardless current phase */ public String getUpgradesString(MapHex hex) { ! StringBuffer b = new StringBuffer(); ! TileI tile; ! for (Upgrade upgrade : upgrades) { ! tile = upgrade.getTile(); ! if (upgrade.isAllowedForHex(hex)) { ! if (b.length() > 0) b.append(","); ! b.append(tile.getExternalId()); ! } ! } ! ! return b.toString(); } *************** *** 451,455 **** protected class Upgrade { ! /** The upgrade tile id */ int tileId; --- 462,466 ---- protected class Upgrade { ! /** The upgrade tile id */ int tileId; *************** *** 501,504 **** --- 512,528 ---- } + protected boolean isAllowedForHex(MapHex hex) { + + if (hexes != null) convertHexString(hex.getMapManager()); + + if (allowedHexes != null) { + return allowedHexes.contains(hex); + } else if (disallowedHexes != null) { + return !disallowedHexes.contains(hex); + } else { + return true; + } + } + public void setTile(TileI tile) { this.tile = tile; |