From: Erik V. <ev...@us...> - 2010-02-03 20:17:40
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1357/rails/game Modified Files: MapHex.java PublicCompany.java OperatingRound.java PublicCompanyI.java Log Message: Home base on green OO tile can now be chosen in first turn Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** OperatingRound.java 3 Feb 2010 05:37:54 -0000 1.95 --- OperatingRound.java 3 Feb 2010 20:16:40 -0000 1.96 *************** *** 493,498 **** // Checks ! // Must be correct step ! if (getStep() != STEP_LAY_TOKEN) { errMsg = LocalText.getText("WrongActionNoTokenLay"); break; --- 493,498 ---- // Checks ! // Must be correct step (exception: home base lay) ! if (getStep() != STEP_LAY_TOKEN && action.getType() != LayBaseToken.HOME_CITY) { errMsg = LocalText.getText("WrongActionNoTokenLay"); break; *************** *** 566,569 **** --- 566,572 ---- operatingCompany.layBaseToken(hex, cost); + // If this is a home base token lay, stop here + if (action.getType() == LayBaseToken.HOME_CITY) return true; + if (cost > 0) { new CashMove(operatingCompany, bank, cost); *************** *** 1926,1939 **** int step = getStep(); if (step == STEP_LAY_TRACK) { - setNormalTileLays(); - setSpecialTileLays(); - log.debug("Normal tile lays: " + currentNormalTileLays.size()); - log.debug("Special tile lays: " + currentSpecialTileLays.size()); ! possibleActions.addAll(currentNormalTileLays); ! possibleActions.addAll(currentSpecialTileLays); ! possibleActions.add(new NullAction(NullAction.SKIP)); } else if (step == STEP_LAY_TOKEN) { --- 1929,1951 ---- int step = getStep(); + boolean forced = false; if (step == STEP_LAY_TRACK) { ! if (!operatingCompany.hasLaidHomeBaseTokens()) { ! // This can occur if the home hex has two cities and track, ! // such as the green OO tile #59 ! possibleActions.add(new LayBaseToken (operatingCompany.getHomeHex())); ! forced = true; ! } else { ! setNormalTileLays(); ! setSpecialTileLays(); ! log.debug("Normal tile lays: " + currentNormalTileLays.size()); ! log.debug("Special tile lays: " + currentSpecialTileLays.size()); ! ! possibleActions.addAll(currentNormalTileLays); ! possibleActions.addAll(currentSpecialTileLays); ! possibleActions.add(new NullAction(NullAction.SKIP)); ! } } else if (step == STEP_LAY_TOKEN) { *************** *** 1962,1966 **** // The following additional "common" actions are only available if the // primary action is not forced. ! if (step >= 0) { setBonusTokenLays(); --- 1974,1978 ---- // The following additional "common" actions are only available if the // primary action is not forced. ! if (step >= 0 && !forced) { setBonusTokenLays(); *************** *** 2234,2238 **** return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); } ! /** * Can the company buy a train now? --- 2246,2250 ---- return operatingCompany.getNumberOfTrains() < operatingCompany.getCurrentTrainLimit(); } ! /** * Can the company buy a train now? Index: MapHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapHex.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** MapHex.java 31 Jan 2010 22:22:28 -0000 1.34 --- MapHex.java 3 Feb 2010 20:16:40 -0000 1.35 *************** *** 846,850 **** log.error("No cities for home station on hex " + name); } else { ! homes.put(company, cities.get(cityNumber - 1)); } } --- 846,850 ---- log.error("No cities for home station on hex " + name); } else { ! homes.put(company, cities.get(Math.max(cityNumber - 1, 0))); } } Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** PublicCompany.java 2 Feb 2010 20:00:03 -0000 1.80 --- PublicCompany.java 3 Feb 2010 20:16:40 -0000 1.81 *************** *** 800,805 **** return mayTradeShares; } ! ! /** Stub that allows exclusions such as that 1856 CGR may not buy a 4 */ public boolean mayBuyTrainType (TrainI train) { return true; --- 800,805 ---- return mayTradeShares; } ! ! /** Stub that allows exclusions such as that 1856 CGR may not buy a 4 */ public boolean mayBuyTrainType (TrainI train) { return true; *************** *** 829,833 **** start(startSpace); } - } --- 829,832 ---- *************** *** 928,932 **** } ! public ModelObject getClosedModel () { return closedObject; --- 927,931 ---- } ! public ModelObject getClosedModel () { return closedObject; *************** *** 1034,1038 **** public void updatePlayersWorth() { ! Map<Player, Boolean> done = new HashMap<Player, Boolean>(8); Player owner; --- 1033,1037 ---- public void updatePlayersWorth() { ! Map<Player, Boolean> done = new HashMap<Player, Boolean>(8); Player owner; *************** *** 1673,1676 **** --- 1672,1676 ---- } + // Return value is not used public boolean layHomeBaseTokens() { *************** *** 1680,1685 **** // has a choice, such in 1830 Erie. if (hasLaidHomeBaseTokens()) return true; log.debug(name + " lays home base on " + homeHex.getName() + " city " ! + homeCityNumber); return homeHex.layBaseToken(this, homeCityNumber); } --- 1680,1699 ---- // has a choice, such in 1830 Erie. if (hasLaidHomeBaseTokens()) return true; + + if (homeCityNumber == 0) { + // This applies to cases like 1830 Erie and 1856 THB. + // On a trackless tile it does not matter, but if + // the tile has track (such as the green OO tile), + // the player must select a city. + Map<Integer, List<Track>> tracks + = homeHex.getCurrentTile().getTracksPerStationMap(); + if (tracks == null || tracks.isEmpty()) { + homeCityNumber = 1; + } else { + return false; + } + } log.debug(name + " lays home base on " + homeHex.getName() + " city " ! + homeCityNumber); return homeHex.layBaseToken(this, homeCityNumber); } Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** PublicCompanyI.java 2 Feb 2010 19:59:43 -0000 1.43 --- PublicCompanyI.java 3 Feb 2010 20:16:40 -0000 1.44 *************** *** 298,301 **** --- 298,302 ---- public boolean layHomeBaseTokens(); + public boolean hasLaidHomeBaseTokens(); public BaseToken getFreeToken(); *************** *** 352,356 **** public int sharesOwnedByPlayers(); public String getExtraShareMarks (); ! public ModelObject getClosedModel (); --- 353,357 ---- public int sharesOwnedByPlayers(); public String getExtraShareMarks (); ! public ModelObject getClosedModel (); |