From: Erik V. <ev...@us...> - 2010-03-12 20:29:06
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv630/rails/game Modified Files: StockRound.java GameManager.java GameDef.java Log Message: 1856: disallow selling share bought in the same SR turn Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** GameManager.java 12 Mar 2010 17:18:47 -0000 1.89 --- GameManager.java 12 Mar 2010 20:28:27 -0000 1.90 *************** *** 81,86 **** protected EnumMap<GameDef.Parm, Object> gameParameters = new EnumMap<GameDef.Parm, Object>(GameDef.Parm.class); ! ! // protected EnumSet<CorrectionType> activeCorrections // = EnumSet.noneOf(CorrectionType.class); --- 81,86 ---- protected EnumMap<GameDef.Parm, Object> gameParameters = new EnumMap<GameDef.Parm, Object>(GameDef.Parm.class); ! ! // protected EnumSet<CorrectionType> activeCorrections // = EnumSet.noneOf(CorrectionType.class); *************** *** 160,164 **** */ protected List<String> nextPlayerMessages = new ArrayList<String>(); ! /** * The ReportBuffer collectes messages to be shown in the Game Report. --- 160,164 ---- */ protected List<String> nextPlayerMessages = new ArrayList<String>(); ! /** * The ReportBuffer collectes messages to be shown in the Game Report. *************** *** 231,235 **** throw new ConfigurationException("GameOption without name"); if (gameOptions.containsKey(optionName)) continue; ! // Include missing option option = new GameOption(optionName); --- 231,235 ---- throw new ConfigurationException("GameOption without name"); if (gameOptions.containsKey(optionName)) continue; ! // Include missing option option = new GameOption(optionName); *************** *** 247,255 **** if (optionDefault != null) option.setDefaultValue(optionDefault); ! gameOptions.put(optionName, optionDefault); } } ! Tag gameParmTag = tag.getChild("GameParameters"); --- 247,255 ---- if (optionDefault != null) option.setDefaultValue(optionDefault); ! gameOptions.put(optionName, optionDefault); } } ! Tag gameParmTag = tag.getChild("GameParameters"); *************** *** 293,296 **** --- 293,298 ---- } else if (ruleTagName.equals("NoSaleIfNotOperated")) { setGameParameter(GameDef.Parm.NO_SALE_IF_NOT_OPERATED, true); + } else if (ruleTagName.equals("NoSaleOfJustBoughtShare")) { + setGameParameter(GameDef.Parm.NO_SALE_OF_JUST_BOUGHT_CERT, true); } *************** *** 500,507 **** } ! if (GameOption.convertValueToBoolean(getGameOption("NoMapMode"))) guiParameters.put(GuiDef.Parm.NO_MAP_MODE, true); ! } --- 502,509 ---- } ! if (GameOption.convertValueToBoolean(getGameOption("NoMapMode"))) guiParameters.put(GuiDef.Parm.NO_MAP_MODE, true); ! } *************** *** 804,809 **** } ! ! // logging of game actions activated for (PossibleAction pa : possibleActions.getList()) { log.debug(((Player) currentPlayer.getObject()).getName() + " may: " --- 806,811 ---- } ! ! // logging of game actions activated for (PossibleAction pa : possibleActions.getList()) { log.debug(((Player) currentPlayer.getObject()).getName() + " may: " *************** *** 814,818 **** } ! /** * Adds all Game actions --- 816,820 ---- } ! /** * Adds all Game actions *************** *** 827,831 **** possibleActions.clear(); } ! } // if (!activeCorrections.isEmpty()) { --- 829,833 ---- possibleActions.clear(); } ! } // if (!activeCorrections.isEmpty()) { *************** *** 834,838 **** // // and set GuiHints for corrections - removed // } ! // CorrectionMode Actions // EnumSet<CorrectionType> possibleCorrections = EnumSet.allOf(CorrectionType.class); --- 836,840 ---- // // and set GuiHints for corrections - removed // } ! // CorrectionMode Actions // EnumSet<CorrectionType> possibleCorrections = EnumSet.allOf(CorrectionType.class); *************** *** 840,844 **** // possibleActions.add( // new CorrectionModeAction(ct, activeCorrections.contains(ct))); ! // Correction Actions for (CorrectionType ct:EnumSet.allOf(CorrectionType.class)) { --- 842,846 ---- // possibleActions.add( // new CorrectionModeAction(ct, activeCorrections.contains(ct))); ! // Correction Actions for (CorrectionType ct:EnumSet.allOf(CorrectionType.class)) { *************** *** 847,855 **** } } ! private boolean processCorrectionActions(PossibleAction a){ boolean result = false; ! // if (a instanceof CorrectionModeAction) { // CorrectionModeAction cma = (CorrectionModeAction)a; --- 849,857 ---- } } ! private boolean processCorrectionActions(PossibleAction a){ boolean result = false; ! // if (a instanceof CorrectionModeAction) { // CorrectionModeAction cma = (CorrectionModeAction)a; *************** *** 874,878 **** // result = true; // } ! if (a instanceof CorrectionAction) { CorrectionAction ca= (CorrectionAction)a; --- 876,880 ---- // result = true; // } ! if (a instanceof CorrectionAction) { CorrectionAction ca= (CorrectionAction)a; *************** *** 881,885 **** result = cm.executeCorrection(ca); } ! return result; } --- 883,887 ---- result = cm.executeCorrection(ca); } ! return result; } *************** *** 916,920 **** getCurrentRound().setPossibleActions(); setCorrectionActions(); ! } catch (Exception e) { log.debug("Error while reprocessing " + action.toString(), e); --- 918,922 ---- getCurrentRound().setPossibleActions(); setCorrectionActions(); ! } catch (Exception e) { log.debug("Error while reprocessing " + action.toString(), e); *************** *** 926,930 **** } ! // DisplayBuffer.clear(); // previous line removed to allow display of nextPlayerMessages guiHints.clearVisibilityHints(); --- 928,932 ---- } ! // DisplayBuffer.clear(); // previous line removed to allow display of nextPlayerMessages guiHints.clearVisibilityHints(); *************** *** 1409,1415 **** return displayBuffer; } ! public void addToNextPlayerMessages(String s, boolean undoable) { ! if (undoable) new AddToList<String>(nextPlayerMessages, s, "nextPlayerMessages"); else --- 1411,1417 ---- return displayBuffer; } ! public void addToNextPlayerMessages(String s, boolean undoable) { ! if (undoable) new AddToList<String>(nextPlayerMessages, s, "nextPlayerMessages"); else *************** *** 1420,1424 **** return reportBuffer; } ! public GuiHints getUIHints() { return guiHints; --- 1422,1426 ---- return reportBuffer; } ! public GuiHints getUIHints() { return guiHints; Index: GameDef.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameDef.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GameDef.java 17 Feb 2010 22:11:49 -0000 1.5 --- GameDef.java 12 Mar 2010 20:28:27 -0000 1.6 *************** *** 18,22 **** TREASURY_SHARE_LIMIT(50), FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS(false), ! SKIP_FIRST_STOCK_ROUND(false); private Object defaultValue; --- 18,23 ---- TREASURY_SHARE_LIMIT(50), FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS(false), ! SKIP_FIRST_STOCK_ROUND(false), ! NO_SALE_OF_JUST_BOUGHT_CERT(false); private Object defaultValue; *************** *** 35,39 **** */ public enum OrStep { ! /* In-sequence steps */ INITIAL, --- 36,40 ---- */ public enum OrStep { ! /* In-sequence steps */ INITIAL, *************** *** 46,53 **** REPAY_LOANS, FINAL, ! /* Out-of-sequence steps*/ DISCARD_TRAINS; ! } --- 47,54 ---- REPAY_LOANS, FINAL, ! /* Out-of-sequence steps*/ DISCARD_TRAINS; ! } Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** StockRound.java 4 Mar 2010 22:55:35 -0000 1.68 --- StockRound.java 12 Mar 2010 20:28:27 -0000 1.69 *************** *** 401,404 **** --- 401,405 ---- price /= company.getShareUnitsForSharePrice(); + /* Allow for different share units (as in 1835) */ for (int i = 1; i <= 4; i++) { number = shareCountPerUnit[i]; *************** *** 407,411 **** Math.min(number, maxShareToSell / (i * company.getShareUnit())); ! if (number == 0) continue; possibleActions.add(new SellShares(compName, i, number, price)); --- 408,419 ---- Math.min(number, maxShareToSell / (i * company.getShareUnit())); ! ! /* In some games (1856), a just bought share may not be sold */ ! // This code ignores the possibility of different share units ! if ((Boolean)gameManager.getGameParameter(GameDef.Parm.NO_SALE_OF_JUST_BOUGHT_CERT) ! && company.equals(companyBoughtThisTurnWrapper.getObject())) { ! number--; ! } ! if (number <= 0) continue; possibleActions.add(new SellShares(compName, i, number, price)); |