From: Erik V. <ev...@us...> - 2009-02-04 20:36:52
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4948/rails/game Modified Files: RoundI.java OperatingRound.java DisplayBuffer.java Round.java GameManager.java Log Message: CGR Formation round phase 1: repaying loans. Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** OperatingRound.java 24 Jan 2009 15:10:27 -0000 1.54 --- OperatingRound.java 4 Feb 2009 20:36:39 -0000 1.55 *************** *** 107,111 **** protected boolean doneAllowed = false; ! protected TrainManagerI trainManager = gameManager.getTrainManager(); --- 107,111 ---- protected boolean doneAllowed = false; ! protected TrainManagerI trainManager = gameManager.getTrainManager(); *************** *** 127,130 **** --- 127,132 ---- numberOfPlayers = players.size(); } + + operatingCompanyArray = super.getOperatingCompanies(); } *************** *** 151,155 **** if (operate) { ! operatingCompanyArray = super.getOperatingCompanies(); if (operatingCompanyArray.length > 0) { --- 153,164 ---- if (operate) { ! ! ! StringBuffer msg = new StringBuffer(); ! for (PublicCompanyI company : operatingCompanyArray) { ! msg.append(",").append(company.getName()); ! } ! msg.deleteCharAt(0); ! log.info("Initial operating sequence is "+msg.toString()); if (operatingCompanyArray.length > 0) { *************** *** 908,912 **** continue; } ! if (step == STEP_TRADE_SHARES) { --- 917,921 ---- continue; } ! if (step == STEP_TRADE_SHARES) { *************** *** 1387,1390 **** --- 1396,1400 ---- executeRepayLoans ((RepayLoans) savedAction); } + savedAction = null; } *************** *** 1702,1706 **** int repayment = action.getNumberRepaid() * operatingCompany.getValuePerLoan(); ! if (repayment > operatingCompany.getCash()) { // President must contribute int remainder = repayment - operatingCompany.getCash(); --- 1712,1716 ---- int repayment = action.getNumberRepaid() * operatingCompany.getValuePerLoan(); ! if (repayment > 0 && repayment > operatingCompany.getCash()) { // President must contribute int remainder = repayment - operatingCompany.getCash(); *************** *** 1722,1726 **** MoveSet.start(true); ! executeRepayLoans (action); return true; --- 1732,1736 ---- MoveSet.start(true); ! if (repayment > 0) executeRepayLoans (action); return true; *************** *** 1865,1868 **** --- 1875,1882 ---- } else if (step == STEP_BUY_TRAIN) { setBuyableTrains(); + if (!operatingCompany.mustOwnATrain() + || operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + doneAllowed = true; + } } else if (step == STEP_DISCARD_TRAINS) { setTrainsToDiscard(); Index: DisplayBuffer.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/DisplayBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DisplayBuffer.java 4 Jun 2008 19:00:31 -0000 1.5 --- DisplayBuffer.java 4 Feb 2009 20:36:39 -0000 1.6 *************** *** 27,30 **** --- 27,32 ---- */ private static List<String> displayBuffer = new ArrayList<String>(); + + private static boolean autoDisplay = true; /** *************** *** 33,40 **** */ public static void add(String message) { if (Util.hasValue(message)) { displayBuffer.add(message); /* Also log the message */ ! log.info("Displayed: " + message); } } --- 35,47 ---- */ public static void add(String message) { + add (message, true); + } + + public static void add (String message, boolean autoDisplay) { + DisplayBuffer.autoDisplay = autoDisplay; if (Util.hasValue(message)) { displayBuffer.add(message); /* Also log the message */ ! log.info("To display: " + message); } } *************** *** 50,53 **** --- 57,68 ---- } } + + public static int getSize() { + return displayBuffer.size(); + } + + public static boolean getAutoDisplay () { + return autoDisplay; + } public static void clear() { Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Round.java 15 Jan 2009 20:53:28 -0000 1.15 --- Round.java 4 Feb 2009 20:36:39 -0000 1.16 *************** *** 80,83 **** --- 80,93 ---- } + /** Allows round instances to tell the UI what type of window to raise. + * Normally the type corresponds to the round type (e.g. OperatingRound + * needs ORWindow), but sometimes deviations occur (such as the + * CGRFormationRound, which isn't a StockRound type but needs StatusWindow). + * @return + */ + public Class<? extends RoundI> getRoundTypeForUI () { + return this.getClass(); + } + /* * (non-Javadoc) *************** *** 140,143 **** --- 150,154 ---- operatingCompanies.put(new Integer(key), company); } + return operatingCompanies.values().toArray(new PublicCompanyI[0]); } Index: RoundI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/RoundI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RoundI.java 23 Dec 2008 19:55:29 -0000 1.9 --- RoundI.java 4 Feb 2009 20:36:39 -0000 1.10 *************** *** 12,20 **** /** * Get the player that has the next turn. ! * * @return Player object. */ public Player getCurrentPlayer(); public String getHelp(); --- 12,22 ---- /** * Get the player that has the next turn. ! * * @return Player object. */ public Player getCurrentPlayer(); + public Class<? extends RoundI> getRoundTypeForUI (); + public String getHelp(); Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** GameManager.java 24 Jan 2009 15:10:29 -0000 1.43 --- GameManager.java 4 Feb 2009 20:36:39 -0000 1.44 *************** *** 40,43 **** --- 40,44 ---- protected String gameStatusClassName = Defs.getDefaultClassName(Defs.ClassName.GAME_STATUS); protected String statusWindowClassName = Defs.getDefaultClassName(Defs.ClassName.STATUS_WINDOW); + protected String orWindowClassName = Defs.getDefaultClassName(Defs.ClassName.OR_WINDOW); protected PlayerManager playerManager; *************** *** 249,253 **** if (orMgrTag != null) { orUIManagerClassName = ! orMgrTag.getAttributeAsString("class", "ORUIManager"); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (orUIManagerClassName); --- 250,254 ---- if (orMgrTag != null) { orUIManagerClassName = ! orMgrTag.getAttributeAsString("class", orUIManagerClassName); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (orUIManagerClassName); *************** *** 258,262 **** if (gameStatusTag != null) { gameStatusClassName = ! gameStatusTag.getAttributeAsString("class", "GameStatus"); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (gameStatusClassName); --- 259,263 ---- if (gameStatusTag != null) { gameStatusClassName = ! gameStatusTag.getAttributeAsString("class", gameStatusClassName); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (gameStatusClassName); *************** *** 268,275 **** statusWindowClassName = statusWindowTag.getAttributeAsString("class", ! "StatusWindow"); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (statusWindowClassName); } } --- 269,286 ---- statusWindowClassName = statusWindowTag.getAttributeAsString("class", ! statusWindowClassName); // Check instantiatability (not sure if this belongs here) canClassBeInstantiated (statusWindowClassName); } + + // ORWindow class + Tag orWindowTag = tag.getChild("ORWindow"); + if (orWindowTag != null) { + orWindowClassName = + orWindowTag.getAttributeAsString("class", + orWindowClassName); + // Check instantiatability (not sure if this belongs here) + canClassBeInstantiated (orWindowClassName); + } } *************** *** 360,364 **** * @see rails.game.GameManagerI#setRound(rails.game.RoundI) */ ! private void setRound(RoundI round) { currentRound.set(round); } --- 371,375 ---- * @see rails.game.GameManagerI#setRound(rails.game.RoundI) */ ! protected void setRound(RoundI round) { currentRound.set(round); } *************** *** 616,620 **** for (PossibleAction action : actions) { ! // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (!possibleActions.contains(action.getClass()) --- 627,631 ---- for (PossibleAction action : actions) { ! // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (!possibleActions.contains(action.getClass()) *************** *** 625,629 **** getCurrentRound().setPossibleActions(); } ! try { log.debug("Action: " + action); --- 636,640 ---- getCurrentRound().setPossibleActions(); } ! try { log.debug("Action: " + action); *************** *** 882,886 **** return phaseManager; } ! public TrainManagerI getTrainManager () { return trainManager; --- 893,897 ---- return phaseManager; } ! public TrainManagerI getTrainManager () { return trainManager; *************** *** 919,922 **** --- 930,934 ---- switch (key) { + case OR_UI_MANAGER: return orUIManagerClassName; |