From: Erik V. <ev...@us...> - 2009-01-24 15:09:27
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8115/rails/game/specific/_1856 Modified Files: OperatingRound_1856.java Log Message: Preparations for final loan repayment Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OperatingRound_1856.java 21 Jan 2009 20:18:24 -0000 1.6 --- OperatingRound_1856.java 24 Jan 2009 15:09:14 -0000 1.7 *************** *** 7,14 **** --- 7,19 ---- import rails.game.action.*; import rails.game.move.CashMove; + import rails.game.state.BooleanState; import rails.game.state.IntegerState; import rails.util.LocalText; public class OperatingRound_1856 extends OperatingRound { + + BooleanState finalLoanRepaymentPending + = new BooleanState ("LoanRepaymentPending", false); + Player playerToStartLoanRepayment = null; public static final int STEP_REPAY_LOANS = 6; *************** *** 64,68 **** = 100 - operatingCompany.getUnsoldPercentage(); ! TrainI nextAvailableTrain = TrainManager.get().getAvailableNewTrains().get(0); int trainNumber; try { --- 69,73 ---- = 100 - operatingCompany.getUnsoldPercentage(); ! TrainI nextAvailableTrain = gameManager.getTrainManager().getAvailableNewTrains().get(0); int trainNumber; try { *************** *** 324,327 **** --- 329,350 ---- } } + + public boolean buyTrain(BuyTrain action) { + + PhaseI prePhase = currentPhase; + + boolean result = super.buyTrain(action); + + PhaseI postPhase = currentPhase; + + if (postPhase != prePhase && postPhase.getName().equals("5")) { + finalLoanRepaymentPending.set(true); + playerToStartLoanRepayment + = gameManager.getPlayerByIndex(action.getPlayerIndex()); + } + + return result; + } + @Override *************** *** 402,405 **** --- 425,451 ---- } + + protected void finishTurn() { + + operatingCompany.setOperated(true); + + // Check if any privates must be closed + // (now only applies to 1856 W&SR) + for (PrivateCompanyI priv : operatingCompany.getPortfolio().getPrivateCompanies()) { + priv.checkClosingIfExercised(true); + } + + if (finalLoanRepaymentPending.booleanValue()) { + // Must start final loan repayment and CGR formation + // TODO + } + + if (setNextOperatingCompany(false)) { + setStep(STEP_INITIAL); + } else { + finishOR(); + } + } + } |