From: Erik V. <ev...@us...> - 2009-01-11 17:24:57
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543/rails/game/specific/_1856 Modified Files: OperatingRound_1856.java Log Message: Basic loans taking and specific rules for 1856. Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OperatingRound_1856.java 23 Dec 2008 20:00:20 -0000 1.3 --- OperatingRound_1856.java 11 Jan 2009 17:24:46 -0000 1.4 *************** *** 13,16 **** --- 13,17 ---- import rails.game.TrainManager; import rails.game.action.ReachDestinations; + import rails.game.action.TakeLoans; import rails.game.move.CashMove; import rails.game.state.IntegerState; *************** *** 18,24 **** public class OperatingRound_1856 extends OperatingRound { ! public OperatingRound_1856 (GameManagerI gameManager) { super (gameManager); } --- 19,26 ---- public class OperatingRound_1856 extends OperatingRound { ! public OperatingRound_1856 (GameManagerI gameManager) { super (gameManager); + } *************** *** 68,76 **** if (soldPercentage < floatPercentage) { ! DisplayBuffer.add(LocalText.getText("MayNotYetOperate", new String[] { operatingCompany.getName(), String.valueOf(soldPercentage), String.valueOf(floatPercentage) ! })); // Company may not yet operate continue; --- 70,78 ---- if (soldPercentage < floatPercentage) { ! DisplayBuffer.add(LocalText.getText("MayNotYetOperate", operatingCompany.getName(), String.valueOf(soldPercentage), String.valueOf(floatPercentage) ! )); // Company may not yet operate continue; *************** *** 104,114 **** if (cashInEscrow > 0) { new CashMove (null, company, cashInEscrow); ! ReportBuffer.add(LocalText.getText("ReleasedFromEscrow", new String[] { company.getName(), Bank.format(cashInEscrow) ! })); } } } --- 106,174 ---- if (cashInEscrow > 0) { new CashMove (null, company, cashInEscrow); ! ReportBuffer.add(LocalText.getText("ReleasedFromEscrow", company.getName(), Bank.format(cashInEscrow) ! )); } } + + protected void setGameSpecificPossibleActions() { + + // Take a loan + if ((loansThisRound == null + || !loansThisRound.containsKey(operatingCompany) + || loansThisRound.get(operatingCompany) == 0) + && gameManager.getCurrentPhase().getIndex() + <= gameManager.getPhaseManager().getPhaseByName("4").getIndex() + && operatingCompany.getCurrentNumberOfLoans() + < operatingCompany.sharesOwnedByPlayers()) { + possibleActions.add(new TakeLoans(operatingCompany, + 1, operatingCompany.getValuePerLoan())); + } + } + + protected String validateTakeLoans (TakeLoans action) { + + String errMsg = super.validateTakeLoans(action); + + if (errMsg == null) { + + while (true) { + // Still allowed in current phase? + if (gameManager.getCurrentPhase().getIndex() + > gameManager.getPhaseManager().getPhaseByName("4").getIndex()) { + errMsg = LocalText.getText("WrongPhase", + gameManager.getCurrentPhase().getName()); + break; + } + // Exceeds number of shares in player hands? + int newLoans = operatingCompany.getCurrentNumberOfLoans() + + action.getNumberTaken(); + int maxLoans = operatingCompany.sharesOwnedByPlayers(); + if (newLoans > maxLoans) { + errMsg = LocalText.getText("WouldExceedSharesAtPlayers", + newLoans, maxLoans); + break; + } + break; + } + } + return errMsg; + } + protected int calculateLoanAmount (int numberOfLoans) { + + int amount = super.calculateLoanAmount(numberOfLoans); + + // Deduct interest immediately? + if (stepObject.intValue() > STEP_PAYOUT) { + int interest = numberOfLoans + * operatingCompany.getValuePerLoan() + * operatingCompany.getLoanInterestPct() / 100; + amount -= interest; + } + + return amount; + } } |