You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: Erik V. <ev...@us...> - 2009-01-21 20:18:34
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26428/rails/game Modified Files: OperatingRound.java GameManager.java Log Message: Added 1856 loan repayment step at end of OR. Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** OperatingRound.java 15 Jan 2009 20:53:28 -0000 1.52 --- OperatingRound.java 21 Jan 2009 20:18:23 -0000 1.53 *************** *** 97,101 **** public static final int STEP_TRADE_SHARES = 5; ! public static final int STEP_FINAL = 6; protected static int[] steps = --- 97,101 ---- public static final int STEP_TRADE_SHARES = 5; ! public static int STEP_FINAL = 6; protected static int[] steps = *************** *** 106,110 **** public static final int STEP_DISCARD_TRAINS = -2; ! public static final String[] stepNames = new String[] { "LayTrack", "LayToken", "EnterRevenue", "Payout", "BuyTrain", "TradeShares", "Final" }; --- 106,112 ---- public static final int STEP_DISCARD_TRAINS = -2; ! protected boolean doneAllowed = false; ! ! public static String[] stepNames = new String[] { "LayTrack", "LayToken", "EnterRevenue", "Payout", "BuyTrain", "TradeShares", "Final" }; *************** *** 225,228 **** --- 227,234 ---- result = takeLoans((TakeLoans) selectedAction); + } else if (selectedAction instanceof RepayLoans) { + + result = repayLoans((RepayLoans) selectedAction); + } else if (selectedAction instanceof NullAction) { *************** *** 794,797 **** --- 800,809 ---- operatingCompany.setLastRevenueAllocation(revenueAllocation); + if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { + DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", + operatingCompany.getName(), + Bank.format(0) )); + } + // Pay any debts from treasury, revenue and/or president's cash // The remaining dividend may be less that the original income *************** *** 894,898 **** continue; } ! if (step == STEP_TRADE_SHARES) { --- 906,910 ---- continue; } ! if (step == STEP_TRADE_SHARES) { *************** *** 907,910 **** --- 919,924 ---- } + if (!gameSpecificNextStep (step)) continue; + // No reason found to skip this step break; *************** *** 919,922 **** --- 933,941 ---- } + /** Stub, can be overridden in subclasses to check for extra steps */ + protected boolean gameSpecificNextStep (int step) { + return true; + } + protected void initTurn() { setCurrentPlayer(operatingCompany.getPresident()); *************** *** 1088,1113 **** String errMsg = null; ! int step = getStep(); ! ! if (step == STEP_BUY_TRAIN) { ! ! if (operatingCompany.getPortfolio().getNumberOfTrains() == 0 ! && operatingCompany.mustOwnATrain()) { ! // FIXME: Need to check for valid route before throwing an ! // error. ! errMsg = ! LocalText.getText("CompanyMustOwnATrain", ! operatingCompany.getName()); ! setStep(STEP_BUY_TRAIN); ! DisplayBuffer.add(errMsg); ! return false; ! } ! ! } else { ! ! errMsg = LocalText.getText("InvalidDoneAction"); DisplayBuffer.add(errMsg); return false; - } --- 1107,1120 ---- String errMsg = null; ! if (operatingCompany.getPortfolio().getNumberOfTrains() == 0 ! && operatingCompany.mustOwnATrain()) { ! // FIXME: Need to check for valid route before throwing an ! // error. ! errMsg = ! LocalText.getText("CompanyMustOwnATrain", ! operatingCompany.getName()); ! setStep(STEP_BUY_TRAIN); DisplayBuffer.add(errMsg); return false; } *************** *** 1375,1378 **** --- 1382,1387 ---- } else if (savedAction instanceof SetDividend) { executeSetRevenueAndDividend ((SetDividend) savedAction); + } else if (savedAction instanceof RepayLoans) { + executeRepayLoans ((RepayLoans) savedAction); } } *************** *** 1570,1582 **** } - /** Stub for applying any follow-up actions when - * a company reaches it destinations. - * Default version: no actions. - * @param company - */ - protected void reachDestination (PublicCompanyI company) { - - } - protected boolean takeLoans (TakeLoans action) { --- 1579,1582 ---- *************** *** 1587,1591 **** action.getCompanyName(), action.getNumberTaken(), ! action.getPrice(), errMsg)); --- 1587,1591 ---- action.getCompanyName(), action.getNumberTaken(), ! Bank.format(action.getPrice()), errMsg)); *************** *** 1676,1679 **** --- 1676,1773 ---- } + /** Stub for applying any follow-up actions when + * a company reaches it destinations. + * Default version: no actions. + * @param company + */ + protected void reachDestination (PublicCompanyI company) { + + } + + protected boolean repayLoans (RepayLoans action) { + + String errMsg = validateRepayLoans (action); + + if (errMsg != null) { + DisplayBuffer.add(LocalText.getText("CannotRepayLoans", + action.getCompanyName(), + action.getNumberRepaid(), + Bank.format(action.getPrice()), + errMsg)); + + return false; + } + + int repayment = action.getNumberRepaid() * operatingCompany.getValuePerLoan(); + if (repayment > operatingCompany.getCash()) { + // President must contribute + int remainder = repayment - operatingCompany.getCash(); + Player president = operatingCompany.getPresident(); + int presCash = president.getCash(); + if (remainder > presCash) { + // Start a share selling round + cashToBeRaisedByPresident = remainder - presCash; + log.info("A share selling round must be started as the president cannot pay $" + + remainder + " loan repayment"); + log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); + savedAction = action; + gameManager.startShareSellingRound(this, operatingCompany, + cashToBeRaisedByPresident); + return true; + } + } + + MoveSet.start(true); + + executeRepayLoans (action); + + return true; + } + + protected String validateRepayLoans (RepayLoans action) { + + String errMsg = null; + + return errMsg; + } + + protected void executeRepayLoans (RepayLoans action) { + + int number = action.getNumberRepaid(); + int payment; + int remainder = 0; + + operatingCompany.addLoans(-number); + int amount = payment = number * operatingCompany.getValuePerLoan(); + if (amount > operatingCompany.getCash()) { + // By now the president must have enough cash + payment = operatingCompany.getCash(); + remainder = amount - payment; + if (payment > 0) { + new CashMove (operatingCompany, null, payment); + } + ReportBuffer.add (LocalText.getText("CompanyRepaysLoans", + operatingCompany.getName(), + Bank.format(payment), + Bank.format(amount), + number, + Bank.format(operatingCompany.getValuePerLoan()))); + } + if (remainder > 0) { + Player president = operatingCompany.getPresident(); + if (president.getCash() >= remainder) { + payment = remainder; + new CashMove (president, null, payment); + ReportBuffer.add (LocalText.getText("CompanyRepaysLoansWithPresCash", + operatingCompany.getName(), + Bank.format(payment), + Bank.format(amount), + number, + Bank.format(operatingCompany.getValuePerLoan()), + president.getName())); + } + } + } + protected int calculateLoanAmount (int numberOfLoans) { return numberOfLoans * operatingCompany.getValuePerLoan(); *************** *** 1742,1745 **** --- 1836,1840 ---- possibleActions.clear(); selectedAction = null; + doneAllowed = false; int step = getStep(); *************** *** 1800,1805 **** } ! if (getStep() >= STEP_BUY_TRAIN ! && (!operatingCompany.mustOwnATrain() || operatingCompany.getPortfolio().getNumberOfTrains() > 0)) { possibleActions.add(new NullAction(NullAction.DONE)); } --- 1895,1899 ---- } ! if (doneAllowed) { possibleActions.add(new NullAction(NullAction.DONE)); } *************** *** 1990,1993 **** --- 2084,2092 ---- } } + + if (!operatingCompany.mustOwnATrain() + || operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + doneAllowed = true; + } } *************** *** 2040,2054 **** } - public void repayLoans (int number) { - operatingCompany.addLoans(-number); - int amount = number * operatingCompany.getValuePerLoan(); - new CashMove (operatingCompany, null, amount); - DisplayBuffer.add(LocalText.getText("CompanyRepaysLoan", - operatingCompany.getName(), - number, - Bank.format(operatingCompany.getValuePerLoan()), - Bank.format(amount))); - } - public void payLoanInterest () { int amount = operatingCompany.getCurrentLoanValue() --- 2139,2142 ---- Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** GameManager.java 15 Jan 2009 20:53:28 -0000 1.41 --- GameManager.java 21 Jan 2009 20:18:24 -0000 1.42 *************** *** 613,616 **** --- 613,626 ---- for (PossibleAction action : actions) { + + // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED + if (!possibleActions.contains(action.getClass()) + && possibleActions.contains(RepayLoans.class)) { + // Insert "Done" + log.debug("Action DONE inserted"); + getCurrentRound().process(new NullAction (NullAction.DONE)); + getCurrentRound().setPossibleActions(); + } + try { log.debug("Action: " + action); |
From: Erik V. <ev...@us...> - 2009-01-21 20:18:34
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26428 Modified Files: LocalisedText.properties Log Message: Added 1856 loan repayment step at end of OR. Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** LocalisedText.properties 14 Jan 2009 20:45:07 -0000 1.66 --- LocalisedText.properties 21 Jan 2009 20:18:23 -0000 1.67 *************** *** 61,64 **** --- 61,65 ---- CannotPayOutRevenue={0} cannot pay out revenue of {1}: {2} CannotProcessRevenue=Cannot process revenue {0} of {1}: {2}. + CannotRepayLoans={0} cannot repay {1} loan(s) of {2}: {3} CannotSplitRevenue={0} cannot split revenue of {1}: {2} CannotSwapPrivateForCertificate={0} cannot swap private {1} for a {2}% share of {3}: {3}. *************** *** 87,91 **** CompanyPaysLoanInterest={0} pays {1} as {2}% interest over {3} loans of {4} CompanyPaysOutFull={0} pays out full dividend of {1} ! CompanyRepaysLoan={0} repays {1} loan(s) of {2} for {3} CompanyRevenue={0} earns {1} CompanySplits={0} splits dividend of {1} --- 88,93 ---- CompanyPaysLoanInterest={0} pays {1} as {2}% interest over {3} loans of {4} CompanyPaysOutFull={0} pays out full dividend of {1} ! CompanyRepaysLoans={0} pays {1} (of {2}) to repay {3} loan(s) of {4} from its treasury ! CompanyRepaysLoansWithPresCash={0} pays {1} (of {2}) to repay {3} loan(s) of {4} from {5}'s personal cash CompanyRevenue={0} earns {1} CompanySplits={0} splits dividend of {1} *************** *** 208,211 **** --- 210,214 ---- MOVE=Move MODERATOR=Moderator + MustRepayLoans={0} must repay {1} loans of {2} for {3} NamesTrain={0} names {1}-train as {2} NegativeAmountNotAllowed=Negative amount {0} not allowed *************** *** 282,285 **** --- 285,289 ---- RemainingTiles=Remaining tiles RepayLoans=Repay loan(s) + RepayLoan=Repay {0} loan(s) of {1} for {2} REPORT=Report Window REVENUE=Revenue *************** *** 289,293 **** --- 293,299 ---- SAVE=Save SaveFailed=Save failed, reason: {0} + Select=Select SelectCompanyToMergeMinorInto=Select major company to merge minor {0} into + SelectLoansToRepay=Select number of loans to repay SelectMinorToMerge=Select the minor to merge to start company {0} SelectNoBid=Select, No Bid |
From: Erik V. <ev...@us...> - 2009-01-21 20:18:33
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26428/rails/game/action Modified Files: RepayLoans.java Log Message: Added 1856 loan repayment step at end of OR. Index: RepayLoans.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/RepayLoans.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RepayLoans.java 11 Jan 2009 17:24:46 -0000 1.1 --- RepayLoans.java 21 Jan 2009 20:18:24 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- transient private PublicCompanyI company; private String companyName; + private int minNumber; private int maxNumber; private int price; *************** *** 31,43 **** * */ ! public RepayLoans(PublicCompanyI company, int maxNumber, int price) { this.company = company; this.companyName = company.getName(); this.maxNumber = maxNumber; this.price = price; } /** * @return Returns the minimumPrice. --- 32,49 ---- * */ ! public RepayLoans(PublicCompanyI company, int minNumber, int maxNumber, int price) { this.company = company; this.companyName = company.getName(); + this.minNumber = minNumber; this.maxNumber = maxNumber; this.price = price; } + public int getMinNumber() { + return minNumber; + } + /** * @return Returns the minimumPrice. *************** *** 63,66 **** --- 69,76 ---- } + public int getNumberRepaid() { + return numberRepaid; + } + @Override public boolean equals(PossibleAction action) { *************** *** 68,71 **** --- 78,82 ---- RepayLoans a = (RepayLoans) action; return a.company == company + && a.minNumber == minNumber && a.maxNumber == maxNumber && a.price == price; *************** *** 76,79 **** --- 87,91 ---- StringBuffer b = new StringBuffer(); b.append ("RepayLoans ").append(company.getName()) + .append(" minNumber=").append(minNumber) .append(" maxNumber=").append(maxNumber) .append(" value=").append(price); |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:44
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18AL In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/specific/_18AL Modified Files: OperatingRound_18AL.java Log Message: Fixed code to remove compiler warnings Index: OperatingRound_18AL.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18AL/OperatingRound_18AL.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OperatingRound_18AL.java 23 Dec 2008 20:00:20 -0000 1.4 --- OperatingRound_18AL.java 15 Jan 2009 20:53:28 -0000 1.5 *************** *** 4,18 **** import java.util.List; ! import rails.game.Bank; ! import rails.game.GameManagerI; ! import rails.game.MapHex; ! import rails.game.OperatingRound; ! import rails.game.ReportBuffer; ! import rails.game.TrainI; import rails.game.action.LayBaseToken; import rails.game.action.PossibleAction; import rails.game.move.CashMove; import rails.game.move.MoveSet; - import rails.game.specific._18AL.AssignNamedTrains; import rails.util.LocalText; --- 4,12 ---- import java.util.List; ! import rails.game.*; import rails.game.action.LayBaseToken; import rails.game.action.PossibleAction; import rails.game.move.CashMove; import rails.game.move.MoveSet; import rails.util.LocalText; *************** *** 72,78 **** if (newToken != null) { ReportBuffer.add(LocalText.getText("NamesTrain", ! new String[] { operatingCompany.getName(), ! trains.get(i).getName(), ! newToken.getLongName() })); } } --- 66,72 ---- if (newToken != null) { ReportBuffer.add(LocalText.getText("NamesTrain", ! operatingCompany.getName(), ! trains.get(i).getName(), ! newToken.getLongName() )); } } *************** *** 93,98 **** new CashMove(Bank.getInstance(), operatingCompany, payout); ReportBuffer.add(LocalText.getText("DestinationReachedByToken", ! new String[] { operatingCompany.getName(), ! Bank.format(payout), hex.getName() })); } return true; --- 87,93 ---- new CashMove(Bank.getInstance(), operatingCompany, payout); ReportBuffer.add(LocalText.getText("DestinationReachedByToken", ! operatingCompany.getName(), ! Bank.format(payout), ! hex.getName() )); } return true; |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:44
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/specific/_1856 Modified Files: StockRound_1856.java Log Message: Fixed code to remove compiler warnings Index: StockRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/StockRound_1856.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StockRound_1856.java 23 Dec 2008 20:00:03 -0000 1.7 --- StockRound_1856.java 15 Jan 2009 20:53:28 -0000 1.8 *************** *** 67,74 **** recipient = oldHolder.getOwner(); // i.e. the Bank comp.addMoneyInEscrow(price); ! ReportBuffer.addWaiting(LocalText.getText("HoldMoneyInEscrow", new String[] { Bank.format(comp.getMoneyInEscrow()), ! comp.getName() ! })); break; } --- 67,73 ---- recipient = oldHolder.getOwner(); // i.e. the Bank comp.addMoneyInEscrow(price); ! ReportBuffer.addWaiting(LocalText.getText("HoldMoneyInEscrow", Bank.format(comp.getMoneyInEscrow()), ! comp.getName() )); break; } |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:44
|
Update of /cvsroot/rails/18xx/rails/game/specific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/specific/_18EU Modified Files: FinalMinorExchangeRound.java StartRound_18EU.java StockRound_18EU.java Log Message: Fixed code to remove compiler warnings Index: StockRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StockRound_18EU.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** StockRound_18EU.java 23 Dec 2008 20:00:03 -0000 1.19 --- StockRound_18EU.java 15 Jan 2009 20:53:28 -0000 1.20 *************** *** 326,331 **** if ((startSpace = stockMarket.getStartSpace(price)) == null) { errMsg = ! LocalText.getText("InvalidStartPrice", new String[] { ! Bank.format(price), company.getName() }); break; } --- 326,332 ---- if ((startSpace = stockMarket.getStartSpace(price)) == null) { errMsg = ! LocalText.getText("InvalidStartPrice", ! Bank.format(price), ! company.getName() ); break; } *************** *** 344,349 **** minor.getName()) == null) { errMsg = ! LocalText.getText("PlayerDoesNotOwn", new String[] { ! currentPlayer.getName(), minor.getName() }); break; } --- 345,351 ---- minor.getName()) == null) { errMsg = ! LocalText.getText("PlayerDoesNotOwn", ! currentPlayer.getName(), ! minor.getName() ); break; } *************** *** 353,359 **** if (selectedHomeCity.getSlots() <= selectedHomeCity.getTokens().size()) { errMsg = ! LocalText.getText("InvalidHomeBase", new String[] { selectedHomeCity.toString(), ! company.getName() }); break; } --- 355,361 ---- if (selectedHomeCity.getSlots() <= selectedHomeCity.getTokens().size()) { errMsg = ! LocalText.getText("InvalidHomeBase", selectedHomeCity.toString(), ! company.getName() ); break; } *************** *** 366,371 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantStart", new String[] { ! playerName, companyName, Bank.format(price), errMsg })); return false; } --- 368,376 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantStart", ! playerName, ! companyName, ! Bank.format(price), ! errMsg )); return false; } *************** *** 387,394 **** company.start(startSpace); ! ReportBuffer.add(LocalText.getText("START_COMPANY_LOG", new String[] { ! playerName, companyName, Bank.format(price), ! Bank.format(shares * price), String.valueOf(shares), ! String.valueOf(cert.getShare()), company.getName() })); // Transfer the President's certificate --- 392,403 ---- company.start(startSpace); ! ReportBuffer.add(LocalText.getText("START_COMPANY_LOG", ! playerName, ! companyName, ! Bank.format(price), ! Bank.format(shares * price), ! shares, ! cert.getShare(), ! company.getName() )); // Transfer the President's certificate *************** *** 406,421 **** company.transferAssetsFrom(minor); minor.setClosed(); ! ReportBuffer.add(LocalText.getText("MERGE_MINOR_LOG", new String[] { ! currentPlayer.getName(), minor.getName(), ! company.getName(), Bank.format(minorCash), ! String.valueOf(minorTrains) })); ReportBuffer.add(LocalText.getText("GetShareForMinor", ! new String[] { currentPlayer.getName(), ! String.valueOf(cert2.getShare()), ! company.getName(), minor.getName() })); } else { ReportBuffer.add(LocalText.getText("SelectedHomeBase", ! new String[] { company.getName(), homeHex.getName(), ! selectedHomeCity.toString() })); } --- 415,434 ---- company.transferAssetsFrom(minor); minor.setClosed(); ! ReportBuffer.add(LocalText.getText("MERGE_MINOR_LOG", ! currentPlayer.getName(), ! minor.getName(), ! company.getName(), ! Bank.format(minorCash), ! minorTrains )); ReportBuffer.add(LocalText.getText("GetShareForMinor", ! currentPlayer.getName(), ! cert2.getShare(), ! company.getName(), ! minor.getName() )); } else { ReportBuffer.add(LocalText.getText("SelectedHomeBase", ! company.getName(), ! homeHex.getName(), ! selectedHomeCity.toString() )); } *************** *** 424,437 **** company.getPortfolio()); ! ReportBuffer.add(LocalText.getText("SharesPutInTreasury", new String[] { ! String.valueOf(company.getPortfolio().getShare(company)), ! company.getName() })); // TODO must get this amount from XML int tokensCost = 100; new CashMove(company, null, tokensCost); ! ReportBuffer.add(LocalText.getText("PaysForTokens", new String[] { ! company.getName(), Bank.format(100), ! String.valueOf(company.getNumberOfBaseTokens()) })); companyBoughtThisTurnWrapper.set(company); --- 437,451 ---- company.getPortfolio()); ! ReportBuffer.add(LocalText.getText("SharesPutInTreasury", ! company.getPortfolio().getShare(company), ! company.getName() )); // TODO must get this amount from XML int tokensCost = 100; new CashMove(company, null, tokensCost); ! ReportBuffer.add(LocalText.getText("PaysForTokens", ! company.getName(), ! Bank.format(100), ! company.getNumberOfBaseTokens() )); companyBoughtThisTurnWrapper.set(company); *************** *** 524,541 **** if (cert != null) { ! ReportBuffer.add(LocalText.getText("MERGE_MINOR_LOG", new String[] { ! currentPlayer.getName(), minor.getName(), major.getName(), ! Bank.format(minorCash), String.valueOf(minorTrains) })); ReportBuffer.add(LocalText.getText("GetShareForMinor", ! new String[] { currentPlayer.getName(), ! String.valueOf(cert.getShare()), major.getName(), ! cert.getPortfolio().getName(), minor.getName() })); cert.moveTo(currentPlayer.getPortfolio()); ReportBuffer.add(LocalText.getText("MinorCloses", minor.getName())); checkFlotation(major); } else { ! ReportBuffer.add(LocalText.getText("CLOSE_MINOR_LOG", new String[] { ! currentPlayer.getName(), minor.getName(), ! Bank.format(minorCash), String.valueOf(minorTrains) })); } hasActed.set(true); --- 538,562 ---- if (cert != null) { ! ReportBuffer.add(LocalText.getText("MERGE_MINOR_LOG", ! currentPlayer.getName(), ! minor.getName(), ! major.getName(), ! Bank.format(minorCash), ! minorTrains )); ReportBuffer.add(LocalText.getText("GetShareForMinor", ! currentPlayer.getName(), ! cert.getShare(), ! major.getName(), ! cert.getPortfolio().getName(), ! minor.getName() )); cert.moveTo(currentPlayer.getPortfolio()); ReportBuffer.add(LocalText.getText("MinorCloses", minor.getName())); checkFlotation(major); } else { ! ReportBuffer.add(LocalText.getText("CLOSE_MINOR_LOG", ! currentPlayer.getName(), ! minor.getName(), ! Bank.format(minorCash), ! minorTrains )); } hasActed.set(true); *************** *** 566,570 **** new CashMove(null, company, cash); ReportBuffer.add(LocalText.getText("MonetiseTreasuryShares", ! new String[] { company.getName(), Bank.format(cash) })); } --- 587,592 ---- new CashMove(null, company, cash); ReportBuffer.add(LocalText.getText("MonetiseTreasuryShares", ! company.getName(), ! Bank.format(cash) )); } *************** *** 598,603 **** errMsg = LocalText.getText("CompanyDoesNotOwnTrain", ! new String[] { company.getName(), ! train.getName() }); break; } --- 620,625 ---- errMsg = LocalText.getText("CompanyDoesNotOwnTrain", ! company.getName(), ! train.getName() ); break; } *************** *** 607,611 **** if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotDiscardTrain", ! new String[] { companyName, train.getName(), errMsg })); return false; } --- 629,635 ---- if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotDiscardTrain", ! companyName, ! train.getName(), ! errMsg )); return false; } *************** *** 618,622 **** Bank.getPool().buyTrain(train, 0); ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", ! new String[] { companyName, train.getName() })); finishTurn(); --- 642,647 ---- Bank.getPool().buyTrain(train, 0); ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", ! companyName, ! train.getName() )); finishTurn(); Index: StartRound_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/StartRound_18EU.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StartRound_18EU.java 8 Jan 2009 19:59:39 -0000 1.6 --- StartRound_18EU.java 15 Jan 2009 20:53:28 -0000 1.7 *************** *** 138,143 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuyItem", new String[] { ! playerName, item.getName(), errMsg })); return false; } --- 138,145 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuyItem", ! playerName, ! item.getName(), ! errMsg )); return false; } *************** *** 184,189 **** && !item.equals(auctionedItem)) { errMsg = ! LocalText.getText("WrongStartItem", new String[] { ! item.getName(), auctionedItem.getName() }); break; } --- 186,192 ---- && !item.equals(auctionedItem)) { errMsg = ! LocalText.getText("WrongStartItem", ! item.getName(), ! auctionedItem.getName() ); break; } *************** *** 199,208 **** // Bid must be a multiple of the modulus if (bidAmount % startPacket.getModulus() != 0) { ! errMsg = ! LocalText.getText( "BidMustBeMultipleOf", ! new String[] { ! String.valueOf(bidAmount), ! String.valueOf(startPacket.getMinimumIncrement()) }); break; } --- 202,209 ---- // Bid must be a multiple of the modulus if (bidAmount % startPacket.getModulus() != 0) { ! errMsg = LocalText.getText( "BidMustBeMultipleOf", ! bidAmount, ! startPacket.getMinimumIncrement() ); break; } *************** *** 221,226 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidBid", new String[] { ! playerName, item.getName(), errMsg })); return false; } --- 222,229 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidBid", ! playerName, ! item.getName(), ! errMsg )); return false; } *************** *** 241,246 **** } ! ReportBuffer.add(LocalText.getText("SELECT_ITEM", new String[] { ! playerName, item.getName() })); } --- 244,250 ---- } ! ReportBuffer.add(LocalText.getText("SELECT_ITEM", ! playerName, ! item.getName() )); } *************** *** 250,255 **** setStep(BID_STEP); ! ReportBuffer.add(LocalText.getText("BID_ITEM", new String[] { ! playerName, Bank.format(bidAmount), item.getName() })); } --- 254,261 ---- setStep(BID_STEP); ! ReportBuffer.add(LocalText.getText("BID_ITEM", ! playerName, ! Bank.format(bidAmount), ! item.getName() )); } *************** *** 301,306 **** auctionedItem.setMinimumBid(currentBuyPrice.intValue()); ReportBuffer.add(LocalText.getText("ITEM_PRICE_REDUCED", ! new String[] { auctionedItem.getName(), ! Bank.format(currentBuyPrice.intValue()) })); setStep(BUY_STEP); //if (auctionedItem.getStatus() != StartItem.BUYABLE) { --- 307,312 ---- auctionedItem.setMinimumBid(currentBuyPrice.intValue()); ReportBuffer.add(LocalText.getText("ITEM_PRICE_REDUCED", ! auctionedItem.getName(), ! Bank.format(currentBuyPrice.intValue()) )); setStep(BUY_STEP); //if (auctionedItem.getStatus() != StartItem.BUYABLE) { Index: FinalMinorExchangeRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_18EU/FinalMinorExchangeRound.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FinalMinorExchangeRound.java 23 Dec 2008 20:02:18 -0000 1.6 --- FinalMinorExchangeRound.java 15 Jan 2009 20:53:28 -0000 1.7 *************** *** 21,25 **** super (aGameManager); } ! public void start(Player playerToStartFMERound) { ReportBuffer.add("\n" --- 21,25 ---- super (aGameManager); } ! public void start(Player playerToStartFMERound) { ReportBuffer.add("\n" *************** *** 29,33 **** initPlayer(); ReportBuffer.add(LocalText.getText("HasFirstTurn", ! new String[] { playerToStartFMERound.getName() })); } --- 29,33 ---- initPlayer(); ReportBuffer.add(LocalText.getText("HasFirstTurn", ! playerToStartFMERound.getName() )); } |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:44
|
Update of /cvsroot/rails/18xx/rails/util In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/util Modified Files: ResourceLoader.java Log Message: Fixed code to remove compiler warnings Index: ResourceLoader.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/ResourceLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ResourceLoader.java 4 Jun 2008 19:00:39 -0000 1.4 --- ResourceLoader.java 15 Jan 2009 20:53:28 -0000 1.5 *************** *** 2,13 **** package rails.util; ! import javax.swing.text.*; ! import javax.swing.text.html.*; ! import java.awt.*; ! import java.net.*; import java.io.*; import java.util.*; ! import java.util.List; ! import java.lang.reflect.*; import org.apache.log4j.Logger; --- 2,14 ---- package rails.util; ! import java.awt.Font; import java.io.*; + import java.lang.reflect.Constructor; + import java.net.Socket; import java.util.*; ! ! import javax.swing.text.*; ! import javax.swing.text.html.HTMLDocument; ! import javax.swing.text.html.HTMLEditorKit; import org.apache.log4j.Logger; *************** *** 16,20 **** * Class ResourceLoader is an utility class to load a resource from a filename * and a list of directory. ! * * @version $Id$ * @author Romain Dolbeau --- 17,21 ---- * Class ResourceLoader is an utility class to load a resource from a filename * and a list of directory. ! * * @version $Id$ * @author Romain Dolbeau *************** *** 27,36 **** * Class ColossusClassLoader allows for class loading outside the CLASSPATH, * i.e. from the various variant directories. ! * * @version $Id$ * @author Romain Dolbeau */ private static class RailsClassLoader extends ClassLoader { ! List directories = null; protected static Logger log = --- 28,37 ---- * Class ColossusClassLoader allows for class loading outside the CLASSPATH, * i.e. from the various variant directories. ! * * @version $Id$ * @author Romain Dolbeau */ private static class RailsClassLoader extends ClassLoader { ! List<String> directories = null; protected static Logger log = *************** *** 45,48 **** --- 46,50 ---- } + @Override public Class<?> findClass(String className) throws ClassNotFoundException { *************** *** 72,76 **** } ! void setDirectories(List d) { directories = d; } --- 74,78 ---- } ! void setDirectories(List<String> d) { directories = d; } *************** *** 109,113 **** /** * Give the String to mark directories. ! * * @return The String to mark directories. */ --- 111,115 ---- /** * Give the String to mark directories. ! * * @return The String to mark directories. */ *************** *** 125,129 **** * Return the first InputStream from file of name filename in the list of * directories, tell the getInputStream not to complain if not found. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). --- 127,131 ---- * Return the first InputStream from file of name filename in the list of * directories, tell the getInputStream not to complain if not found. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). *************** *** 131,135 **** */ public static InputStream getInputStreamIgnoreFail(String filename, ! List directories) { return getInputStream(filename, directories, server != null, false, true); --- 133,137 ---- */ public static InputStream getInputStreamIgnoreFail(String filename, ! List<String> directories) { return getInputStream(filename, directories, server != null, false, true); *************** *** 139,148 **** * Return the first InputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The InputStream, or null if it was not found. */ ! public static InputStream getInputStream(String filename, List directories) { return getInputStream(filename, directories, server != null, false, false); --- 141,150 ---- * Return the first InputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The InputStream, or null if it was not found. */ ! public static InputStream getInputStream(String filename, List<String> directories) { return getInputStream(filename, directories, server != null, false, false); *************** *** 152,156 **** * Return the first InputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). --- 154,158 ---- * Return the first InputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). *************** *** 161,165 **** * @return The InputStream, or null if it was not found. */ ! public static InputStream getInputStream(String filename, List directories, boolean remote, boolean cachedOnly, boolean ignoreFail) { String mapKey = getMapKey(filename, directories); --- 163,167 ---- * @return The InputStream, or null if it was not found. */ ! public static InputStream getInputStream(String filename, List<String> directories, boolean remote, boolean cachedOnly, boolean ignoreFail) { String mapKey = getMapKey(filename, directories); *************** *** 178,182 **** synchronized (fileCache) { InputStream stream = null; ! java.util.Iterator it = directories.iterator(); while (it.hasNext() && (stream == null)) { Object o = it.next(); --- 180,184 ---- synchronized (fileCache) { InputStream stream = null; ! java.util.Iterator<String> it = directories.iterator(); while (it.hasNext() && (stream == null)) { Object o = it.next(); *************** *** 251,257 **** } out.print(filename); ! java.util.Iterator it = directories.iterator(); while (it.hasNext()) { ! out.print(sep + (String) it.next()); } out.println(); --- 253,259 ---- } out.print(filename); ! java.util.Iterator<String> it = directories.iterator(); while (it.hasNext()) { ! out.print(sep + it.next()); } out.println(); *************** *** 277,281 **** /** * Return the content of the specified file as an array of byte. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). --- 279,283 ---- /** * Return the content of the specified file as an array of byte. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). *************** *** 285,289 **** * it fails. */ ! public static byte[] getBytesFromFile(String filename, List directories, boolean cachedOnly, boolean ignoreFail) { InputStream is = --- 287,291 ---- * it fails. */ ! public static byte[] getBytesFromFile(String filename, List<String> directories, boolean cachedOnly, boolean ignoreFail) { InputStream is = *************** *** 305,309 **** /** * Return the content of the specified InputStream as an array of byte. ! * * @param InputStream The InputStream to use. * @return An array of byte representing the content of the InputStream, or --- 307,311 ---- /** * Return the content of the specified InputStream as an array of byte. ! * * @param InputStream The InputStream to use. * @return An array of byte representing the content of the InputStream, or *************** *** 335,339 **** /** * Return the content of the specified byte array as an InputStream. ! * * @param data The byte array to convert. * @return An InputStream whose content is the data byte array. --- 337,341 ---- /** * Return the content of the specified byte array as an InputStream. ! * * @param data The byte array to convert. * @return An InputStream whose content is the data byte array. *************** *** 351,362 **** * Return the first OutputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The OutputStream, or null if it was not found. */ ! public static OutputStream getOutputStream(String filename, List directories) { OutputStream stream = null; ! java.util.Iterator it = directories.iterator(); while (it.hasNext() && (stream == null)) { Object o = it.next(); --- 353,364 ---- * Return the first OutputStream from file of name filename in the list of * directories. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The OutputStream, or null if it was not found. */ ! public static OutputStream getOutputStream(String filename, List<String> directories) { OutputStream stream = null; ! java.util.Iterator<String> it = directories.iterator(); while (it.hasNext() && (stream == null)) { Object o = it.next(); *************** *** 382,391 **** * String describing the content type of the Document. This can currently * load HTML and pure text. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The Document, or null if it was not found. */ ! public static Document getDocument(String filename, List directories) { InputStream htmlIS = getInputStreamIgnoreFail(filename + ".html", directories); --- 384,393 ---- * String describing the content type of the Document. This can currently * load HTML and pure text. ! * * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @return The Document, or null if it was not found. */ ! public static Document getDocument(String filename, List<String> directories) { InputStream htmlIS = getInputStreamIgnoreFail(filename + ".html", directories); *************** *** 440,444 **** /** * Return the key to use in the image and file caches. ! * * @param filename Name of the file. * @param directories List of directories. --- 442,446 ---- /** * Return the key to use in the image and file caches. ! * * @param filename Name of the file. * @param directories List of directories. *************** *** 446,450 **** * specified file from the specified list of directories. */ ! private static String getMapKey(String filename, List directories) { String[] filenames = new String[1]; filenames[0] = filename; --- 448,452 ---- * specified file from the specified list of directories. */ ! private static String getMapKey(String filename, List<String> directories) { String[] filenames = new String[1]; filenames[0] = filename; *************** *** 454,458 **** /** * Return the key to use in the image cache. ! * * @param filenames Array of name of files. * @param directories List of directories. --- 456,460 ---- /** * Return the key to use in the image cache. ! * * @param filenames Array of name of files. * @param directories List of directories. *************** *** 460,464 **** * specified array of name of files from the specified list of directories. */ ! private static String getMapKey(String[] filenames, List directories) { StringBuffer buf = new StringBuffer(filenames[0]); for (int i = 1; i < filenames.length; i++) { --- 462,466 ---- * specified array of name of files from the specified list of directories. */ ! private static String getMapKey(String[] filenames, List<String> directories) { StringBuffer buf = new StringBuffer(filenames[0]); for (int i = 1; i < filenames.length; i++) { *************** *** 466,470 **** buf.append(filenames[i]); } ! Iterator it = directories.iterator(); while (it.hasNext()) { Object o = it.next(); --- 468,472 ---- buf.append(filenames[i]); } ! Iterator<String> it = directories.iterator(); while (it.hasNext()) { Object o = it.next(); *************** *** 479,483 **** /** * Fix a filename by replacing space with underscore. ! * * @param filename Filename to fix. * @return The fixed filename. --- 481,485 ---- /** * Fix a filename by replacing space with underscore. ! * * @param filename Filename to fix. * @return The fixed filename. *************** *** 489,498 **** /** * Create an instance of the class whose name is in parameter. ! * * @param className The name of the class to use. * @param directories List of directories to search (in order). * @return A new object, instance from the given class. */ ! public static Object getNewObject(String className, List directories) { return getNewObject(className, directories, null); } --- 491,500 ---- /** * Create an instance of the class whose name is in parameter. ! * * @param className The name of the class to use. * @param directories List of directories to search (in order). * @return A new object, instance from the given class. */ ! public static Object getNewObject(String className, List<String> directories) { return getNewObject(className, directories, null); } *************** *** 501,511 **** * Create an instance of the class whose name is in parameter, using * parameters. ! * * If no parameters are given, the default constructor is used. ! * * @TODO this is full of catch(Exception) blocks, which all return null. * Esp. returning null seems a rather bad idea, since it will most likely * turn out to be NPEs somewhere later. ! * * @param className The name of the class to use, must not be null. * @param directories List of directories to search (in order), must not be --- 503,513 ---- * Create an instance of the class whose name is in parameter, using * parameters. ! * * If no parameters are given, the default constructor is used. ! * * @TODO this is full of catch(Exception) blocks, which all return null. * Esp. returning null seems a rather bad idea, since it will most likely * turn out to be NPEs somewhere later. ! * * @param className The name of the class to use, must not be null. * @param directories List of directories to search (in order), must not be *************** *** 516,522 **** * instantiation failed. */ ! public static Object getNewObject(String className, List directories, Object[] parameter) { ! Class theClass = null; cl.setDirectories(directories); try { --- 518,524 ---- * instantiation failed. */ ! public static Object getNewObject(String className, List<String> directories, Object[] parameter) { ! Class<?> theClass = null; cl.setDirectories(directories); try { *************** *** 528,537 **** } if (parameter != null) { ! Class[] paramClasses = new Class[parameter.length]; for (int i = 0; i < parameter.length; i++) { paramClasses[i] = parameter[i].getClass(); } try { ! Constructor c = theClass.getConstructor(paramClasses); return c.newInstance(parameter); } catch (Exception e) { --- 530,539 ---- } if (parameter != null) { ! Class<?>[] paramClasses = new Class[parameter.length]; for (int i = 0; i < parameter.length; i++) { paramClasses[i] = parameter[i].getClass(); } try { ! Constructor<?> c = theClass.getConstructor(paramClasses); return c.newInstance(parameter); } catch (Exception e) { *************** *** 554,563 **** * Force adding the given data as belonging to the given filename in the * file cache. ! * * @param filename Name of the Image file to add. * @param directories List of directories to search (in order). * @param data File content to add. */ ! public static void putIntoFileCache(String filename, List directories, byte[] data) { String mapKey = getMapKey(filename, directories); --- 556,565 ---- * Force adding the given data as belonging to the given filename in the * file cache. ! * * @param filename Name of the Image file to add. * @param directories List of directories to search (in order). * @param data File content to add. */ ! public static void putIntoFileCache(String filename, List<String> directories, byte[] data) { String mapKey = getMapKey(filename, directories); *************** *** 568,572 **** * Force adding the given data as belonging to the given key in the file * cache. ! * * @see #getMapKey(String, List) * @see #getMapKey(String[], List) --- 570,574 ---- * Force adding the given data as belonging to the given key in the file * cache. ! * * @see #getMapKey(String, List) * @see #getMapKey(String[], List) |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:41
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/ui/swing Modified Files: ImageLoader.java ORUIManager.java StartRoundWindow.java GameStatus.java ORWindow.java Log Message: Fixed code to remove compiler warnings Index: ImageLoader.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ImageLoader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ImageLoader.java 4 Jun 2008 19:00:33 -0000 1.11 --- ImageLoader.java 15 Jan 2009 20:53:28 -0000 1.12 *************** *** 2,18 **** package rails.ui.swing; ! import java.awt.image.*; ! import java.io.*; import java.util.*; import javax.imageio.ImageIO; - import rails.ui.swing.hexmap.GUIHex; - import rails.util.*; - import org.apache.batik.transcoder.*; import org.apache.batik.transcoder.image.ImageTranscoder; ! import org.apache.log4j.*; /** --- 2,17 ---- package rails.ui.swing; ! import java.awt.image.BufferedImage; ! import java.io.InputStream; import java.util.*; import javax.imageio.ImageIO; import org.apache.batik.transcoder.*; import org.apache.batik.transcoder.image.ImageTranscoder; + import org.apache.log4j.Logger; ! import rails.ui.swing.hexmap.GUIHex; ! import rails.util.*; /** *************** *** 30,34 **** private static String tileRootDir = Config.get("tile.root_directory"); private static String preference = Config.get("tile.format_preference"); ! private static ArrayList<String> directories = new ArrayList<String>(); static { --- 29,33 ---- private static String tileRootDir = Config.get("tile.root_directory"); private static String preference = Config.get("tile.format_preference"); ! private static List<String> directories = new ArrayList<String>(); static { *************** *** 50,57 **** --- 49,58 ---- private BufferedImage image; + @Override public BufferedImage createImage(int width, int height) { return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); } + @Override public void writeImage(BufferedImage image, TranscoderOutput output) throws TranscoderException { *************** *** 140,144 **** if (!tileMap.containsKey(Integer.toString(tileID))) loadTile(tileID); ! return (BufferedImage) tileMap.get(Integer.toString(tileID)); } --- 141,145 ---- if (!tileMap.containsKey(Integer.toString(tileID))) loadTile(tileID); ! return tileMap.get(Integer.toString(tileID)); } Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** StartRoundWindow.java 8 Jan 2009 19:59:39 -0000 1.29 --- StartRoundWindow.java 15 Jan 2009 20:53:28 -0000 1.30 *************** *** 594,600 **** StockSpace sp = (StockSpace) JOptionPane.showInputDialog(this, ! LocalText.getText("WHICH_START_PRICE", new String[] { activeItem.getPlayerName(), ! compName}), LocalText.getText("WHICH_PRICE"), JOptionPane.QUESTION_MESSAGE, null, options, --- 594,600 ---- StockSpace sp = (StockSpace) JOptionPane.showInputDialog(this, ! LocalText.getText("WHICH_START_PRICE", activeItem.getPlayerName(), ! compName), LocalText.getText("WHICH_PRICE"), JOptionPane.QUESTION_MESSAGE, null, options, Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ORUIManager.java 14 Jan 2009 20:45:07 -0000 1.24 --- ORUIManager.java 15 Jan 2009 20:53:28 -0000 1.25 *************** *** 237,243 **** if (specialTiles.length() > 1) { extraMessage += ! LocalText.getText("SpecialTile", new String[] { specialTiles.toString(), ! extraTileMessage.toString() }); } else if (extraTileMessage.length() > 1) { extraMessage += --- 237,243 ---- if (specialTiles.length() > 1) { extraMessage += ! LocalText.getText("SpecialTile", specialTiles.toString(), ! extraTileMessage.toString() ); } else if (extraTileMessage.length() > 1) { extraMessage += *************** *** 341,347 **** reachDestinations ((ReachDestinations) actions.get(0)); ! } else if (actionType == TakeLoans.class) { ! takeLoans ((TakeLoans)actions.get(0)); } --- 341,347 ---- reachDestinations ((ReachDestinations) actions.get(0)); ! } else if (actionType == TakeLoans.class) { ! takeLoans ((TakeLoans)actions.get(0)); } *************** *** 605,617 **** for (City city : stations) { if (city.hasTokenSlotsLeft()) { ! prompt = ! LocalText.getText( ! "SelectStationForTokenOption", ! new String[] { ! String.valueOf(city.getNumber()), ! ((MapHex) selectedHex.getModel()).getConnectionString( ! selectedHex.getCurrentTile(), ! ((MapHex) selectedHex.getModel()).getCurrentTileRotation(), ! city.getNumber()) }); prompts.add(prompt); promptToCityMap.put(prompt, city); --- 605,615 ---- for (City city : stations) { if (city.hasTokenSlotsLeft()) { ! prompt = LocalText.getText( ! "SelectStationForTokenOption", ! city.getNumber(), ! ((MapHex) selectedHex.getModel()).getConnectionString( ! selectedHex.getCurrentTile(), ! ((MapHex) selectedHex.getModel()).getCurrentTileRotation(), ! city.getNumber())) ; prompts.add(prompt); promptToCityMap.put(prompt, city); *************** *** 674,686 **** for (Station newStation : newTile.getStations()) { if (newStation.getBaseSlots() > 0) { ! prompt = ! LocalText.getText( ! "SelectStationForTokenOption", ! new String[] { ! String.valueOf(newStation.getNumber()), ! hex.getConnectionString( ! newTile, ! action.getOrientation(), ! newStation.getNumber()) }); prompts.add(prompt); promptToCityMap.put(prompt, newStation.getNumber()); --- 672,681 ---- for (Station newStation : newTile.getStations()) { if (newStation.getBaseSlots() > 0) { ! prompt = LocalText.getText("SelectStationForTokenOption", ! newStation.getNumber(), ! hex.getConnectionString( ! newTile, ! action.getOrientation(), ! newStation.getNumber()) ); prompts.add(prompt); promptToCityMap.put(prompt, newStation.getNumber()); *************** *** 757,762 **** b = new StringBuffer(); ! b.append(LocalText.getText("BUY_TRAIN_FROM", new String[] { ! train.getName(), from.getName() })); if (bTrain.isForExchange()) { b.append(" (").append(LocalText.getText("EXCHANGED")).append( --- 752,758 ---- b = new StringBuffer(); ! b.append(LocalText.getText("BUY_TRAIN_FROM", ! train.getName(), ! from.getName() )); if (bTrain.isForExchange()) { b.append(" (").append(LocalText.getText("EXCHANGED")).append( *************** *** 820,827 **** if (price == 0 && seller.getOwner() instanceof PublicCompanyI) { ! prompt = ! LocalText.getText("WHICH_TRAIN_PRICE", ! new String[] { orComp.getName(), train.getName(), ! seller.getName() }); String response; for (;;) { --- 816,823 ---- if (price == 0 && seller.getOwner() instanceof PublicCompanyI) { ! prompt = LocalText.getText("WHICH_TRAIN_PRICE", ! orComp.getName(), ! train.getName(), ! seller.getName() ); String response; for (;;) { *************** *** 913,918 **** (String) JOptionPane.showInputDialog(orWindow, LocalText.getText("HAS_TOO_MANY_TRAINS", ! new String[] { playerName, ! c.getName() }), LocalText.getText("WhichTrainToDiscard"), JOptionPane.QUESTION_MESSAGE, null, --- 909,914 ---- (String) JOptionPane.showInputDialog(orWindow, LocalText.getText("HAS_TOO_MANY_TRAINS", ! playerName, ! c.getName() ), LocalText.getText("WhichTrainToDiscard"), JOptionPane.QUESTION_MESSAGE, null, *************** *** 949,959 **** for (BuyPrivate action : privates) { ! privatesForSale.add(LocalText.getText( ! "BuyPrivatePrompt", ! new String[] { ! action.getPrivateCompany().getName(), ! action.getPrivateCompany().getPortfolio().getName(), ! Bank.format(action.getMinimumPrice()), ! Bank.format(action.getMaximumPrice()) })); } --- 945,953 ---- for (BuyPrivate action : privates) { ! privatesForSale.add(LocalText.getText("BuyPrivatePrompt", ! action.getPrivateCompany().getName(), ! action.getPrivateCompany().getPortfolio().getName(), ! Bank.format(action.getMinimumPrice()), ! Bank.format(action.getMaximumPrice()) )); } *************** *** 973,979 **** JOptionPane.showInputDialog(orWindow, LocalText.getText("WHICH_PRIVATE_PRICE", ! new String[] { chosenOption, ! Bank.format(minPrice), ! Bank.format(maxPrice) }), LocalText.getText("WHICH_PRICE"), JOptionPane.QUESTION_MESSAGE); --- 967,973 ---- JOptionPane.showInputDialog(orWindow, LocalText.getText("WHICH_PRIVATE_PRICE", ! chosenOption, ! Bank.format(minPrice), ! Bank.format(maxPrice) ), LocalText.getText("WHICH_PRICE"), JOptionPane.QUESTION_MESSAGE); *************** *** 1038,1045 **** if (action.getMaxNumber() == 1) { ! String message = LocalText.getText("PleaseConfirm"); ! String prompt = LocalText.getText("TakeLoanPrompt", ! action.getCompanyName(), Bank.format(action.getPrice())); if (JOptionPane.showConfirmDialog(orWindow, prompt, --- 1032,1039 ---- if (action.getMaxNumber() == 1) { ! String message = LocalText.getText("PleaseConfirm"); ! String prompt = LocalText.getText("TakeLoanPrompt", ! action.getCompanyName(), Bank.format(action.getPrice())); if (JOptionPane.showConfirmDialog(orWindow, prompt, *************** *** 1143,1147 **** orPanel.initRevenueEntryStep(orCompIndex, action); ! String message = LocalText.getText("EnterRevenue"); if (action.getRequiredCash() > 0) { --- 1137,1141 ---- orPanel.initRevenueEntryStep(orCompIndex, action); ! String message = LocalText.getText("EnterRevenue"); if (action.getRequiredCash() > 0) { *************** *** 1166,1172 **** // discardTrain(); ! } else if (possibleActions.contains(TakeLoans.class)) { ! orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); --- 1160,1166 ---- // discardTrain(); ! } else if (possibleActions.contains(TakeLoans.class)) { ! orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); *************** *** 1229,1234 **** BonusToken token = (BonusToken) stl.getToken(); String text = ! LocalText.getText("LayBonusToken", new String[] { ! token.toString(), stl.getLocationCodeString() }); orPanel.addSpecialAction(btAction, text); } --- 1223,1229 ---- BonusToken token = (BonusToken) stl.getToken(); String text = ! LocalText.getText("LayBonusToken", ! token.toString(), ! stl.getLocationCodeString() ); orPanel.addSpecialAction(btAction, text); } Index: GameStatus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameStatus.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GameStatus.java 11 Jan 2009 17:24:46 -0000 1.22 --- GameStatus.java 15 Jan 2009 20:53:28 -0000 1.23 *************** *** 559,567 **** for (int i = 1; i <= sale.getMaximumNumber(); i++) { options.add(LocalText.getText("SellShares", ! new String[] { ! String.valueOf(i * sale.getShare()), ! sale.getCompanyName(), ! Bank.format(i * sale.getShareUnits() ! * sale.getPrice()) })); sellActions.add(sale); sellAmounts.add(i); --- 559,566 ---- for (int i = 1; i <= sale.getMaximumNumber(); i++) { options.add(LocalText.getText("SellShares", ! (i * sale.getShare()), ! sale.getCompanyName(), ! Bank.format(i * sale.getShareUnits() ! * sale.getPrice()) )); sellActions.add(sale); sellAmounts.add(i); *************** *** 620,628 **** for (int i = 0; i < startPrices.length; i++) { options.add(LocalText.getText("StartCompany", ! new String[] { ! Bank.format(startPrices[i]), ! String.valueOf(cert.getShare()), ! Bank.format(cert.getShares() ! * startPrices[i]) })); buyActions.add(buy); buyAmounts.add(startPrices[i]); --- 619,626 ---- for (int i = 0; i < startPrices.length; i++) { options.add(LocalText.getText("StartCompany", ! Bank.format(startPrices[i]), ! cert.getShare(), ! Bank.format(cert.getShares() ! * startPrices[i]) )); buyActions.add(buy); buyAmounts.add(startPrices[i]); *************** *** 630,637 **** } else { startPrices = new int[] {((StartCompany) buy).getPrice()}; ! options.add(LocalText.getText("StartCompanyFixed", new String[]{ companyName, ! String.valueOf(cert.getShare()), ! Bank.format(startPrices[0])})); buyActions.add(buy); buyAmounts.add(startPrices[0]); --- 628,635 ---- } else { startPrices = new int[] {((StartCompany) buy).getPrice()}; ! options.add(LocalText.getText("StartCompanyFixed", companyName, ! cert.getShare(), ! Bank.format(startPrices[0]) )); buyActions.add(buy); buyAmounts.add(startPrices[0]); *************** *** 641,661 **** options.add(LocalText.getText("BuyCertificate", ! new String[] { ! String.valueOf(cert.getShare()), ! cert.getCompany().getName(), ! cert.getPortfolio().getName(), ! Bank.format(cert.getShares() ! * buy.getPrice()) })); buyActions.add(buy); buyAmounts.add(1); for (int i = 2; i <= buy.getMaximumNumber(); i++) { options.add(LocalText.getText("BuyCertificates", ! new String[] { ! String.valueOf(i), ! String.valueOf(cert.getShare()), ! cert.getCompany().getName(), ! cert.getPortfolio().getName(), ! Bank.format(i * cert.getShares() ! * buy.getPrice()) })); buyActions.add(buy); buyAmounts.add(i); --- 639,657 ---- options.add(LocalText.getText("BuyCertificate", ! cert.getShare(), ! cert.getCompany().getName(), ! cert.getPortfolio().getName(), ! Bank.format(cert.getShares() ! * buy.getPrice()) )); buyActions.add(buy); buyAmounts.add(1); for (int i = 2; i <= buy.getMaximumNumber(); i++) { options.add(LocalText.getText("BuyCertificates", ! i, ! cert.getShare(), ! cert.getCompany().getName(), ! cert.getPortfolio().getName(), ! Bank.format(i * cert.getShares() ! * buy.getPrice()) )); buyActions.add(buy); buyAmounts.add(i); *************** *** 669,675 **** new RadioButtonDialog(this, LocalText.getText("PleaseSelect"), ! LocalText.getText("WHICH_START_PRICE", new String[] { playerName, ! companyName}), options.toArray(new String[0]), -1).getSelectedOption(); } else { --- 665,671 ---- new RadioButtonDialog(this, LocalText.getText("PleaseSelect"), ! LocalText.getText("WHICH_START_PRICE", playerName, ! companyName), options.toArray(new String[0]), -1).getSelectedOption(); } else { Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ORWindow.java 3 Jan 2009 22:51:16 -0000 1.21 --- ORWindow.java 15 Jan 2009 20:53:28 -0000 1.22 *************** *** 15,21 **** import rails.common.Defs; ! import rails.game.DisplayBuffer; ! import rails.game.GameManager; ! import rails.game.OperatingRound; import rails.game.action.*; import rails.util.LocalText; --- 15,19 ---- import rails.common.Defs; ! import rails.game.*; import rails.game.action.*; import rails.util.LocalText; *************** *** 159,168 **** String compositeORNumber = gameManager.getCompositeORNumber (); String numORs = gameManager.getNumOfORs (); ! orPanel.recreate(or); setTitle(LocalText.getText("MapWindowORTitle", ! new String [] {compositeORNumber, numORs} )); ! // gameManager.getCompositeORNumber(), ! // gameManager.getNumOfORs ()})); pack(); if (lastBounds != null) { --- 157,165 ---- String compositeORNumber = gameManager.getCompositeORNumber (); String numORs = gameManager.getNumOfORs (); ! orPanel.recreate(or); setTitle(LocalText.getText("MapWindowORTitle", ! compositeORNumber, ! numORs )); pack(); if (lastBounds != null) { |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:39
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1835 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/specific/_1835 Modified Files: StockRound_1835.java Log Message: Fixed code to remove compiler warnings Index: StockRound_1835.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1835/StockRound_1835.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StockRound_1835.java 23 Dec 2008 20:00:03 -0000 1.3 --- StockRound_1835.java 15 Jan 2009 20:53:28 -0000 1.4 *************** *** 9,13 **** public class StockRound_1835 extends StockRound { ! /** * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize --- 9,13 ---- public class StockRound_1835 extends StockRound { ! /** * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize *************** *** 19,51 **** super (aGameManager); } ! /** * The company release rules for 1835. ! * * For now these rules are hardcoded (which makes this code vulnerablt ! * to company name changes!). It did not seem worthwhile to * invent come complex XML for the unique 1835 rules on this matter. ! * * @param boughtfrom The portfolio from which a certificate has been bought. * @param company The company of which a share has been traded. */ protected void gameSpecificChecks (Portfolio boughtFrom, PublicCompanyI company) { ! if (boughtFrom != ipo) return; ! String name = company.getName(); int sharesInIPO = ipo.getShare(company); ! // Check for group releases if (sharesInIPO == 0) { ! if (name.equals("Sax") && ipo.getShare(companyManager.getCompanyByName("Bay")) == 0 ! || name.equals("Bay") && ipo.getShare(companyManager.getCompanyByName("Sax")) == 0) { // Group 1 sold out: release Badische releaseCompanyShares (companyManager.getCompanyByName("Bad")); ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"All", "Bad"})); } else if (name.equals("Bad") || name.equals("Wrt") || name.equals("Hes")) { if (ipo.getShare(companyManager.getCompanyByName("Bad")) == 0 --- 19,52 ---- super (aGameManager); } ! /** * The company release rules for 1835. ! * * For now these rules are hardcoded (which makes this code vulnerablt ! * to company name changes!). It did not seem worthwhile to * invent come complex XML for the unique 1835 rules on this matter. ! * * @param boughtfrom The portfolio from which a certificate has been bought. * @param company The company of which a share has been traded. */ + @Override protected void gameSpecificChecks (Portfolio boughtFrom, PublicCompanyI company) { ! if (boughtFrom != ipo) return; ! String name = company.getName(); int sharesInIPO = ipo.getShare(company); ! // Check for group releases if (sharesInIPO == 0) { ! if (name.equals("Sax") && ipo.getShare(companyManager.getCompanyByName("Bay")) == 0 ! || name.equals("Bay") && ipo.getShare(companyManager.getCompanyByName("Sax")) == 0) { // Group 1 sold out: release Badische releaseCompanyShares (companyManager.getCompanyByName("Bad")); ReportBuffer.add (LocalText.getText("SharesReleased", ! "All", "Bad")); } else if (name.equals("Bad") || name.equals("Wrt") || name.equals("Hes")) { if (ipo.getShare(companyManager.getCompanyByName("Bad")) == 0 *************** *** 55,63 **** releaseCompanyShares (companyManager.getCompanyByName("MS")); ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"All", "MS"})); } } } ! // Check for releases within group /* We leave out the Bayern/Sachsen connection, as the latter --- 56,64 ---- releaseCompanyShares (companyManager.getCompanyByName("MS")); ReportBuffer.add (LocalText.getText("SharesReleased", ! "All", "MS")); } } } ! // Check for releases within group /* We leave out the Bayern/Sachsen connection, as the latter *************** *** 68,73 **** releaseCompanyShares (companyManager.getCompanyByName("Wrt")); ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"All", "Wrt"})); ! } else if (sharesInIPO == 80) { // President sold: release four 10% Prussian shares for (int i=0; i<4; i++) { --- 69,74 ---- releaseCompanyShares (companyManager.getCompanyByName("Wrt")); ReportBuffer.add (LocalText.getText("SharesReleased", ! "All", "Wrt")); ! } else if (sharesInIPO == 80) { // President sold: release four 10% Prussian shares for (int i=0; i<4; i++) { *************** *** 75,79 **** } ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"4 10%", "Pr"})); } } else if (name.equals("Wrt")) { //Wurttembergische --- 76,80 ---- } ReportBuffer.add (LocalText.getText("SharesReleased", ! "4 10%", "Pr")); } } else if (name.equals("Wrt")) { //Wurttembergische *************** *** 81,85 **** releaseCompanyShares (companyManager.getCompanyByName("Hes")); ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"All", "Hes"})); } } else if (name.equals("MS")) { // Mecklenburg/Schwerin --- 82,86 ---- releaseCompanyShares (companyManager.getCompanyByName("Hes")); ReportBuffer.add (LocalText.getText("SharesReleased", ! "All", "Hes")); } } else if (name.equals("MS")) { // Mecklenburg/Schwerin *************** *** 87,91 **** releaseCompanyShares (companyManager.getCompanyByName("Old")); ReportBuffer.add (LocalText.getText("SharesReleased", ! new String[] {"All", "Old"})); } } --- 88,92 ---- releaseCompanyShares (companyManager.getCompanyByName("Old")); ReportBuffer.add (LocalText.getText("SharesReleased", ! "All", "Old")); } } |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:39
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/move Modified Files: MapChange.java Log Message: Fixed code to remove compiler warnings Index: MapChange.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/MapChange.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MapChange.java 11 Jan 2009 17:24:46 -0000 1.1 --- MapChange.java 15 Jan 2009 20:53:28 -0000 1.2 *************** *** 1,4 **** /* $Header$ ! * * Created on 19-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 19-Jul-2006 * Change Log: *************** *** 6,10 **** package rails.game.move; - import java.util.HashMap; import java.util.Map; --- 6,9 ---- *************** *** 12,16 **** * This Move class handles adding an entry to a 2-D Map (a Map of Maps, or a * matrix). An Undo will remove the second key, but not the first key. ! * * @author Erik Vos */ --- 11,15 ---- * This Move class handles adding an entry to a 2-D Map (a Map of Maps, or a * matrix). An Undo will remove the second key, but not the first key. ! * * @author Erik Vos */ *************** *** 34,37 **** --- 33,37 ---- } + @Override public boolean execute() { *************** *** 41,44 **** --- 41,45 ---- } + @Override public boolean undo() { |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:39
|
Update of /cvsroot/rails/18xx/test In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/test Modified Files: SVGOffscreenLoader.java Log Message: Fixed code to remove compiler warnings Index: SVGOffscreenLoader.java =================================================================== RCS file: /cvsroot/rails/18xx/test/SVGOffscreenLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SVGOffscreenLoader.java 4 Jun 2008 19:00:39 -0000 1.4 --- SVGOffscreenLoader.java 15 Jan 2009 20:53:28 -0000 1.5 *************** *** 1,32 **** package test; - import java.awt.geom.AffineTransform; import java.awt.Rectangle; ! import java.io.File; ! import java.io.OutputStream; ! import java.io.IOException; ! import java.io.FileOutputStream; import java.util.List; import org.apache.batik.ext.awt.image.codec.PNGEncodeParam; import org.apache.batik.ext.awt.image.codec.PNGImageEncoder; ! ! import org.apache.batik.dom.svg.SAXSVGDocumentFactory; ! import org.apache.batik.bridge.BridgeContext; ! import org.apache.batik.bridge.BridgeException; ! import org.apache.batik.bridge.GVTBuilder; ! import org.apache.batik.bridge.UpdateManager; ! import org.apache.batik.bridge.UpdateManagerAdapter; ! import org.apache.batik.bridge.UpdateManagerEvent; ! import org.apache.batik.bridge.UserAgentAdapter; import org.apache.batik.util.RunnableQueue; import org.apache.batik.util.XMLResourceDescriptor; - import org.apache.batik.gvt.CanvasGraphicsNode; - import org.apache.batik.gvt.CompositeGraphicsNode; - import org.apache.batik.gvt.GraphicsNode; - import org.apache.batik.gvt.renderer.ConcreteImageRendererFactory; - import org.apache.batik.gvt.renderer.ImageRenderer; - import org.apache.batik.gvt.renderer.ImageRendererFactory; - import org.w3c.dom.Document; import org.w3c.dom.Element; --- 1,17 ---- package test; import java.awt.Rectangle; ! import java.awt.geom.AffineTransform; ! import java.io.*; import java.util.List; + import org.apache.batik.bridge.*; + import org.apache.batik.dom.svg.SAXSVGDocumentFactory; import org.apache.batik.ext.awt.image.codec.PNGEncodeParam; import org.apache.batik.ext.awt.image.codec.PNGImageEncoder; ! import org.apache.batik.gvt.*; ! import org.apache.batik.gvt.renderer.*; import org.apache.batik.util.RunnableQueue; import org.apache.batik.util.XMLResourceDescriptor; import org.w3c.dom.Document; import org.w3c.dom.Element; *************** *** 108,115 **** --- 93,102 ---- manager.addUpdateManagerListener(new UpdateManagerAdapter() { + @Override public void updateCompleted(UpdateManagerEvent e) { render(e.getImage()); } + @Override public void managerSuspended(UpdateManagerEvent e) { // Make sure pending updates are completed. *************** *** 124,128 **** if (!(gn instanceof CompositeGraphicsNode)) return null; CompositeGraphicsNode cgn = (CompositeGraphicsNode) gn; ! List children = cgn.getChildren(); if (children.size() == 0) return null; gn = (GraphicsNode) children.get(0); --- 111,115 ---- if (!(gn instanceof CompositeGraphicsNode)) return null; CompositeGraphicsNode cgn = (CompositeGraphicsNode) gn; ! List<?> children = cgn.getChildren(); if (children.size() == 0) return null; gn = (GraphicsNode) children.get(0); |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:39
|
Update of /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18EU In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/ui/swing/gamespecific/_18EU Modified Files: StatusWindow_18EU.java GameStatus_18EU.java Log Message: Fixed code to remove compiler warnings Index: StatusWindow_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18EU/StatusWindow_18EU.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StatusWindow_18EU.java 30 Jun 2008 20:35:29 -0000 1.4 --- StatusWindow_18EU.java 15 Jan 2009 20:53:28 -0000 1.5 *************** *** 7,11 **** import javax.swing.JOptionPane; ! import rails.game.*; import rails.game.action.DiscardTrain; import rails.game.action.PossibleAction; --- 7,12 ---- import javax.swing.JOptionPane; ! import rails.game.PublicCompanyI; ! import rails.game.TrainI; import rails.game.action.DiscardTrain; import rails.game.action.PossibleAction; *************** *** 68,72 **** LocalText.getText( "HAS_TOO_MANY_TRAINS", ! new String[] { playerName, c.getName() }), LocalText.getText("WhichTrainToDiscard"), JOptionPane.QUESTION_MESSAGE, null, options, --- 69,74 ---- LocalText.getText( "HAS_TOO_MANY_TRAINS", ! playerName, ! c.getName() ), LocalText.getText("WhichTrainToDiscard"), JOptionPane.QUESTION_MESSAGE, null, options, Index: GameStatus_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GameStatus_18EU.java 24 Dec 2008 14:55:11 -0000 1.6 --- GameStatus_18EU.java 15 Jan 2009 20:53:28 -0000 1.7 *************** *** 85,91 **** boolean replaceToken = JOptionPane.showConfirmDialog(this, LocalText.getText( ! "WantToReplaceToken", new String[] { ! minor.getName(), // ! major.getName() }), LocalText.getText("PleaseSelect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; --- 85,91 ---- boolean replaceToken = JOptionPane.showConfirmDialog(this, LocalText.getText( ! "WantToReplaceToken", ! minor.getName(), ! major.getName() ), LocalText.getText("PleaseSelect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; *************** *** 95,125 **** } - // TODO MOVE THIS TO A LATER STEP - MAY BE ANOTHER PLAYER!!! - /* - * List<TrainI> trains = action.getMinorTrains(); - * trains.addAll(action.getMajorTrains().get(choice)); int - * trainLimit = action.getMajorTrainLimit(); List<TrainI> - * discardedTrains = new ArrayList<TrainI>(); - * - * while (trains.size() > trainLimit) { - * - * List<String> trainOptions = new ArrayList<String>(trains.size()); - * options = new String[trains.size()]; - * - * for (int j=0; j<options.length; j++) { options[j] = - * LocalText.getText("N_Train", trains.get(j).getName()); - * trainOptions.add(options[j]); } String discardedTrainName = - * (String) JOptionPane.showInputDialog (this, - * LocalText.getText("HasTooManyTrains", new String[] { - * major.getName(), String.valueOf(trains.size()), - * String.valueOf(trainLimit) }), - * LocalText.getText("WhichTrainToDiscard"), - * JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if - * (discardedTrainName != null) { TrainI train = - * trains.get(trainOptions.indexOf(discardedTrainName)); - * discardedTrains.add(train); trains.remove(train); } } if - * (!discardedTrains.isEmpty()) { - * action.setDiscardedTrains(discardedTrains); } - */ } return chosenAction; --- 95,98 ---- *************** *** 146,152 **** LocalText.getText( "MergeMinorConfirm", ! new String[] { ! minor.getName(), ! action.getCertificate().getCompany().getName() }), LocalText.getText("PleaseConfirm"), JOptionPane.OK_CANCEL_OPTION, --- 119,124 ---- LocalText.getText( "MergeMinorConfirm", ! minor.getName(), ! action.getCertificate().getCompany().getName() ), LocalText.getText("PleaseConfirm"), JOptionPane.OK_CANCEL_OPTION, |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game Modified Files: Portfolio.java Tile.java StockRound.java StockMarket.java PublicCertificate.java MapHex.java StartRound_1830.java PublicCompany.java TreasuryShareRound.java Player.java GameManager.java StartRound.java StartRound_1835.java ShareSellingRound.java OperatingRound.java CompanyManager.java CompanyType.java ComponentManager.java Round.java PrivateCompany.java PrivateCompanyI.java GameOption.java Log Message: Fixed code to remove compiler warnings Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** PublicCompany.java 11 Jan 2009 17:24:46 -0000 1.46 --- PublicCompany.java 15 Jan 2009 20:53:28 -0000 1.47 *************** *** 1309,1313 **** buyer.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! new String[] { buyer.getName(), name })); } } --- 1309,1314 ---- buyer.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! buyer.getName(), ! name )); } } *************** *** 1334,1338 **** player.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! new String[] { player.getName(), name })); } } --- 1335,1340 ---- player.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! player.getName(), ! name )); } } Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StartRound.java 8 Jan 2009 19:59:39 -0000 1.23 --- StartRound.java 15 Jan 2009 20:53:28 -0000 1.24 *************** *** 209,214 **** errMsg = LocalText.getText("InvalidStartPrice", ! new String[] { Bank.format(sharePrice), ! shareCompName }); break; } --- 209,214 ---- errMsg = LocalText.getText("InvalidStartPrice", ! Bank.format(sharePrice), ! shareCompName ); break; } *************** *** 218,223 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuyItem", new String[] { ! playerName, item.getName(), errMsg })); return false; } --- 218,225 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuyItem", ! playerName, ! item.getName(), ! errMsg )); return false; } *************** *** 248,261 **** int sharePrice) { Certificate primary = item.getPrimary(); ! ReportBuffer.add(LocalText.getText("BuysItemFor", new String[] { ! player.getName(), primary.getName(), Bank.format(price) })); ! //player.buy(primary, price); executeTradeCertificate (primary, player.getPortfolio(), price); checksOnBuying(primary, sharePrice); if (item.hasSecondary()) { Certificate extra = item.getSecondary(); ! ReportBuffer.add(LocalText.getText("ALSO_GETS", new String[] { ! player.getName(), extra.getName() })); ! //player.buy(extra, 0); executeTradeCertificate (extra, player.getPortfolio(), 0); checksOnBuying(extra, sharePrice); --- 250,264 ---- int sharePrice) { Certificate primary = item.getPrimary(); ! ReportBuffer.add(LocalText.getText("BuysItemFor", ! player.getName(), ! primary.getName(), ! Bank.format(price) )); executeTradeCertificate (primary, player.getPortfolio(), price); checksOnBuying(primary, sharePrice); if (item.hasSecondary()) { Certificate extra = item.getSecondary(); ! ReportBuffer.add(LocalText.getText("ALSO_GETS", ! player.getName(), ! extra.getName() )); executeTradeCertificate (extra, player.getPortfolio(), 0); checksOnBuying(extra, sharePrice); Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Player.java 20 Nov 2008 21:49:38 -0000 1.15 --- Player.java 15 Jan 2009 20:53:28 -0000 1.16 *************** *** 55,59 **** * Initialises each Player's parameters which depend on the number of * players. To be called when all Players have been added. ! * */ public static void initPlayers(List<Player> players) { --- 55,59 ---- * Initialises each Player's parameters which depend on the number of * players. To be called when all Players have been added. ! * */ public static void initPlayers(List<Player> players) { *************** *** 66,71 **** player.index = index++; Bank.transferCash(null, player, startCash); ! ReportBuffer.add(LocalText.getText("PlayerIs", new String[] { ! String.valueOf(index), player.getName() })); } ReportBuffer.add(LocalText.getText("PlayerCash", Bank.format(startCash))); --- 66,72 ---- player.index = index++; Bank.transferCash(null, player, startCash); ! ReportBuffer.add(LocalText.getText("PlayerIs", ! index, ! player.getName() )); } ReportBuffer.add(LocalText.getText("PlayerCash", Bank.format(startCash))); *************** *** 120,124 **** /** * Check if a player may buy the given number of certificates. ! * * @param number Number of certificates to buy (usually 1 but not always * so). --- 121,125 ---- /** * Check if a player may buy the given number of certificates. ! * * @param number Number of certificates to buy (usually 1 but not always * so). *************** *** 137,141 **** * company, given the "hold limit" per company, that is the percentage of * shares of one company that a player may hold (typically 60%). ! * * @param company The company from which to buy * @param number The number of shares (usually 1 but not always so). --- 138,142 ---- * company, given the "hold limit" per company, that is the percentage of * shares of one company that a player may hold (typically 60%). ! * * @param company The company from which to buy * @param number The number of shares (usually 1 but not always so). *************** *** 155,159 **** * may hold (typically 60%). <p>If no hold limit applies, it is taken to be * 100%. ! * * @param company The company from which to buy * @param number The share unit (typically 10%). --- 156,160 ---- * may hold (typically 60%). <p>If no hold limit applies, it is taken to be * 100%. ! * * @param company The company from which to buy * @param number The share unit (typically 10%). *************** *** 211,215 **** /** * Get the player's total worth. ! * * @return Total worth */ --- 212,216 ---- /** * Get the player's total worth. ! * * @return Total worth */ *************** *** 256,260 **** /** * Block cash allocated by a bid. ! * * @param amount Amount of cash to be blocked. * @return false if the amount was not available. --- 257,261 ---- /** * Block cash allocated by a bid. ! * * @param amount Amount of cash to be blocked. * @return false if the amount was not available. *************** *** 272,276 **** /** * Unblock cash. ! * * @param amount Amount to be unblocked. * @return false if the given amount was not blocked. --- 273,277 ---- /** * Unblock cash. ! * * @param amount Amount to be unblocked. * @return false if the given amount was not blocked. *************** *** 288,292 **** /** * Return the unblocked cash (available for bidding) ! * * @return */ --- 289,293 ---- /** * Return the unblocked cash (available for bidding) ! * * @return */ Index: CompanyType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CompanyType.java 4 Jun 2008 19:00:30 -0000 1.6 --- CompanyType.java 15 Jan 2009 20:53:28 -0000 1.7 *************** *** 26,30 **** /** * The constructor. ! * * @param name Company type name ("Private", "Public", "Minor" etc.). * @param className Name of the class that will instantiate this type of --- 26,30 ---- /** * The constructor. ! * * @param name Company type name ("Private", "Public", "Minor" etc.). * @param className Name of the class that will instantiate this type of *************** *** 73,77 **** } catch (CloneNotSupportedException e) { DisplayBuffer.add(LocalText.getText("CantCloneCompany", ! new String[] { name, this.name })); } return newCompany; --- 73,77 ---- } catch (CloneNotSupportedException e) { DisplayBuffer.add(LocalText.getText("CantCloneCompany", ! name, this.name )); } return newCompany; *************** *** 81,85 **** /** * Get the company type name ! * * @return The name of this company type. */ --- 81,85 ---- /** * Get the company type name ! * * @return The name of this company type. */ *************** *** 90,94 **** /** * Get the name of the class that will implement this type of company. ! * * @return The full class name. */ --- 90,94 ---- /** * Get the name of the class that will implement this type of company. ! * * @return The full class name. */ Index: GameOption.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameOption.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GameOption.java 4 Jun 2008 19:00:31 -0000 1.6 --- GameOption.java 15 Jan 2009 20:53:28 -0000 1.7 *************** *** 2,9 **** package rails.game; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.List; ! import java.util.Map; import rails.util.LocalText; --- 2,6 ---- package rails.game; ! import java.util.*; import rails.util.LocalText; *************** *** 43,47 **** public String getLocalisedName() { ! return LocalText.getText(name, parm); } --- 40,44 ---- public String getLocalisedName() { ! return LocalText.getText(name, (Object[]) parm); } Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** StockMarket.java 2 Nov 2008 20:04:26 -0000 1.13 --- StockMarket.java 15 Jan 2009 20:53:28 -0000 1.14 *************** *** 2,11 **** package rails.game; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.List; import rails.game.move.PriceTokenMove; ! import rails.util.*; public class StockMarket implements StockMarketI, ConfigurableComponentI { --- 2,10 ---- package rails.game; ! import java.util.*; import rails.game.move.PriceTokenMove; ! import rails.util.LocalText; ! import rails.util.Tag; public class StockMarket implements StockMarketI, ConfigurableComponentI { *************** *** 105,109 **** spaceTag.getAttributeAsString(StockSpaceI.TYPE_TAG); if (typeName != null ! && (type = (StockSpaceTypeI) stockSpaceTypes.get(typeName)) == null) { throw new ConfigurationException(LocalText.getText( "StockSpaceTypeUndefined", type)); --- 104,108 ---- spaceTag.getAttributeAsString(StockSpaceI.TYPE_TAG); if (typeName != null ! && (type = stockSpaceTypes.get(typeName)) == null) { throw new ConfigurationException(LocalText.getText( "StockSpaceTypeUndefined", type)); *************** *** 120,124 **** row = Integer.parseInt(name.substring(1)); ! col = (int) (name.toUpperCase().charAt(0) - '@'); if (row > numRows) numRows = row; if (col > numCols) numCols = col; --- 119,123 ---- row = Integer.parseInt(name.substring(1)); ! col = (name.toUpperCase().charAt(0) - '@'); if (row > numRows) numRows = row; if (col > numCols) numCols = col; *************** *** 138,142 **** startPrices = new int[startSpaces.size()]; for (int i = 0; i < startPrices.length; i++) { ! startPrices[i] = ((StockSpaceI) startSpaces.get(i)).getPrice(); } --- 137,141 ---- startPrices = new int[startSpaces.size()]; for (int i = 0; i < startPrices.length; i++) { ! startPrices[i] = (startSpaces.get(i)).getPrice(); } *************** *** 290,302 **** // To be written to a log file in the future. if (from != null && from == to) { ! ReportBuffer.add(LocalText.getText("PRICE_STAYS_LOG", new String[] { ! company.getName(), Bank.format(from.getPrice()), ! from.getName() })); return; } else if (from == null && to != null) {} else if (from != null && to != null) { ! ReportBuffer.add(LocalText.getText("PRICE_MOVES_LOG", new String[] { ! company.getName(), Bank.format(from.getPrice()), ! from.getName(), Bank.format(to.getPrice()), to.getName() })); /* Check for rails.game closure */ --- 289,305 ---- // To be written to a log file in the future. if (from != null && from == to) { ! ReportBuffer.add(LocalText.getText("PRICE_STAYS_LOG", ! company.getName(), ! Bank.format(from.getPrice()), ! from.getName() )); return; } else if (from == null && to != null) {} else if (from != null && to != null) { ! ReportBuffer.add(LocalText.getText("PRICE_MOVES_LOG", ! company.getName(), ! Bank.format(from.getPrice()), ! from.getName(), ! Bank.format(to.getPrice()), ! to.getName() )); /* Check for rails.game closure */ *************** *** 328,332 **** /** * Return start prices as an int array. Note: this array is NOT sorted. ! * * @return */ --- 331,335 ---- /** * Return start prices as an int array. Note: this array is NOT sorted. ! * * @return */ Index: StartRound_1830.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound_1830.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** StartRound_1830.java 8 Jan 2009 19:59:39 -0000 1.17 --- StartRound_1830.java 15 Jan 2009 20:53:28 -0000 1.18 *************** *** 188,193 **** } if (!validItem) { ! errMsg = ! LocalText.getText("ActionNotAllowed", bidItem.toString()); break; --- 188,192 ---- } if (!validItem) { ! errMsg = LocalText.getText("ActionNotAllowed", bidItem.toString()); break; *************** *** 203,208 **** // Bid must be at least 5 above last bid if (bidAmount < item.getMinimumBid()) { ! errMsg = ! LocalText.getText("BidTooLow", "" + item.getMinimumBid()); break; --- 202,206 ---- // Bid must be at least 5 above last bid if (bidAmount < item.getMinimumBid()) { ! errMsg = LocalText.getText("BidTooLow", "" + item.getMinimumBid()); break; *************** *** 211,220 **** // Bid must be a multiple of the modulus if (bidAmount % startPacket.getModulus() != 0) { ! errMsg = ! LocalText.getText( ! "BidMustBeMultipleOf", ! new String[] { ! String.valueOf(bidAmount), ! String.valueOf(startPacket.getMinimumIncrement()) }); break; } --- 209,215 ---- // Bid must be a multiple of the modulus if (bidAmount % startPacket.getModulus() != 0) { ! errMsg = LocalText.getText("BidMustBeMultipleOf", ! bidAmount, ! startPacket.getMinimumIncrement()); break; } *************** *** 224,229 **** int available = player.getFreeCash() + previousBid; if (bidAmount > available) { ! errMsg = ! LocalText.getText("BidTooHigh", Bank.format(available)); break; } --- 219,223 ---- int available = player.getFreeCash() + previousBid; if (bidAmount > available) { ! errMsg = LocalText.getText("BidTooHigh", Bank.format(available)); break; } *************** *** 233,238 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidBid", new String[] { ! playerName, item.getName(), errMsg })); return false; } --- 227,234 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidBid", ! playerName, ! item.getName(), ! errMsg )); return false; } *************** *** 243,249 **** if (previousBid > 0) player.unblockCash(previousBid); player.blockCash(bidAmount); ! ReportBuffer.add(LocalText.getText("BID_ITEM_LOG", new String[] { ! playerName, Bank.format(bidAmount), item.getName(), ! Bank.format(player.getFreeCash()) })); if (bidItem.getStatus() != StartItem.AUCTIONED) { --- 239,247 ---- if (previousBid > 0) player.unblockCash(previousBid); player.blockCash(bidAmount); ! ReportBuffer.add(LocalText.getText("BID_ITEM_LOG", ! playerName, ! Bank.format(bidAmount), ! item.getName(), ! Bank.format(player.getFreeCash()) )); if (bidItem.getStatus() != StartItem.AUCTIONED) { *************** *** 282,287 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidPass", new String[] { ! playerName, errMsg })); return false; } --- 280,286 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("InvalidPass", ! playerName, ! errMsg )); return false; } *************** *** 325,331 **** ReportBuffer.add(LocalText.getText( "ITEM_PRICE_REDUCED", - new String[] { startPacket.getFirstItem().getName(), ! Bank.format(startPacket.getFirstItem().getBasePrice()) })); numPasses.set(0); if (startPacket.getFirstItem().getBasePrice() == 0) { --- 324,329 ---- ReportBuffer.add(LocalText.getText( "ITEM_PRICE_REDUCED", startPacket.getFirstItem().getName(), ! Bank.format(startPacket.getFirstItem().getBasePrice()) )); numPasses.set(0); if (startPacket.getFirstItem().getBasePrice() == 0) { Index: ComponentManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ComponentManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ComponentManager.java 4 Jun 2008 19:00:31 -0000 1.11 --- ComponentManager.java 15 Jan 2009 20:53:28 -0000 1.12 *************** *** 142,147 **** // Add it to the map of known components. instance.mComponentMap.put(name, component); ! log.debug(LocalText.getText("ComponentInitAs", new String[] { name, ! clazz })); } --- 142,146 ---- // Add it to the map of known components. instance.mComponentMap.put(name, component); ! log.debug(LocalText.getText("ComponentInitAs", name, clazz )); } *************** *** 149,153 **** /** * Returns the configured parameter with the given name. ! * * @param componentName the of the component sought. * @return the component sought, or null if it has not been configured. --- 148,152 ---- /** * Returns the configured parameter with the given name. ! * * @param componentName the of the component sought. * @return the component sought, or null if it has not been configured. Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CompanyManager.java 3 Dec 2008 20:15:15 -0000 1.12 --- CompanyManager.java 15 Jan 2009 20:53:28 -0000 1.13 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ // TODO Currently not used (but some newer games have more than one) private List<StartPacket> startPackets = new ArrayList<StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", new String[] { name, type })); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name"); if (name == null) name = "Initial"; String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void initCompanies() throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.init2(); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ // TODO Currently not used (but some newer games have more than one) private List<StartPacket> startPackets = new ArrayList<StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", name, type )); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name"); if (name == null) name = "Initial"; String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void initCompanies() throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.init2(); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } } \ No newline at end of file Index: PrivateCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PrivateCompany.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PrivateCompany.java 20 Nov 2008 21:49:38 -0000 1.19 --- PrivateCompany.java 15 Jan 2009 20:53:28 -0000 1.20 *************** *** 2,15 **** package rails.game; ! import java.util.*; ! import rails.game.move.CashMove; ! import rails.game.move.Moveable; ! import rails.game.move.MoveableHolderI; ! import rails.game.move.ObjectMove; import rails.game.special.SpecialPropertyI; ! import rails.util.LocalText; ! import rails.util.Tag; ! import rails.util.Util; public class PrivateCompany extends Company implements PrivateCompanyI { --- 2,11 ---- package rails.game; ! import java.util.ArrayList; ! import java.util.List; ! import rails.game.move.*; import rails.game.special.SpecialPropertyI; ! import rails.util.*; public class PrivateCompany extends Company implements PrivateCompanyI { *************** *** 22,26 **** protected List<SpecialPropertyI> specialProperties = null; protected String auctionType; ! // Closing conditions protected int closingPhase; --- 18,22 ---- protected List<SpecialPropertyI> specialProperties = null; protected String auctionType; ! // Closing conditions protected int closingPhase; *************** *** 80,84 **** } } ! // Closing conditions // Currently only used to handle closure following laying --- 76,80 ---- } } ! // Closing conditions // Currently only used to handle closure following laying *************** *** 86,96 **** // Other cases are currently handled elsewhere. Tag closureTag = tag.getChild("ClosingConditions"); ! if (closureTag != null) { Tag spTag = closureTag.getChild("SpecialProperties"); ! if (spTag != null) { ! String ifAttribute = spTag.getAttributeAsString("condition"); if (ifAttribute != null) { --- 82,92 ---- // Other cases are currently handled elsewhere. Tag closureTag = tag.getChild("ClosingConditions"); ! if (closureTag != null) { Tag spTag = closureTag.getChild("SpecialProperties"); ! if (spTag != null) { ! String ifAttribute = spTag.getAttributeAsString("condition"); if (ifAttribute != null) { *************** *** 105,109 **** } } ! } catch (Exception e) { --- 101,105 ---- } } ! } catch (Exception e) { *************** *** 115,123 **** /** Initialisation, to be called directly after instantiation (cloning) */ public void init(String name, CompanyTypeI type) { super.init(name, type); specialProperties = new ArrayList<SpecialPropertyI>(); ! } --- 111,120 ---- /** Initialisation, to be called directly after instantiation (cloning) */ + @Override public void init(String name, CompanyTypeI type) { super.init(name, type); specialProperties = new ArrayList<SpecialPropertyI>(); ! } *************** *** 164,167 **** --- 161,165 ---- * @param b */ + @Override public void setClosed() { if (!isClosed()) { *************** *** 205,221 **** } ! public void payOut() { ! if (portfolio.getOwner() != Bank.getInstance()) { ! ReportBuffer.add(LocalText.getText("ReceivesFor", ! new String[] { portfolio.getOwner().getName(), ! Bank.format(revenue), name })); ! new CashMove(null, portfolio.getOwner(), revenue); ! } ! } ! public String toString() { return "Private: " + name; } public Object clone() { --- 203,212 ---- } ! @Override public String toString() { return "Private: " + name; } + @Override public Object clone() { *************** *** 227,231 **** return null; } ! return clone; } --- 218,222 ---- return null; } ! return clone; } *************** *** 242,246 **** * Remove a special property. Only used to transfer a persistent special * property to a Portfolio, where it becomes independent of the private. ! * * @param token The special property object to remove. * @return True if successful. --- 233,237 ---- * Remove a special property. Only used to transfer a persistent special * property to a Portfolio, where it becomes independent of the private. ! * * @param token The special property object to remove. * @return True if successful. *************** *** 248,252 **** public boolean removeObject(Moveable object) { if (object instanceof SpecialPropertyI) { ! return specialProperties.remove((SpecialPropertyI) object); } else { return false; --- 239,243 ---- public boolean removeObject(Moveable object) { if (object instanceof SpecialPropertyI) { ! return specialProperties.remove(object); } else { return false; *************** *** 263,267 **** /** * Do we have any special properties? ! * * @return Boolean */ --- 254,258 ---- /** * Do we have any special properties? ! * * @return Boolean */ *************** *** 285,293 **** return closeAtEndOfTurn; } ! public void checkClosingIfExercised (boolean endOfOR) { ! if (isClosed() || endOfOR != closeAtEndOfTurn) return; ! if (closeIfAllExercised) { for (SpecialPropertyI sp : specialProperties) { --- 276,284 ---- return closeAtEndOfTurn; } ! public void checkClosingIfExercised (boolean endOfOR) { ! if (isClosed() || endOfOR != closeAtEndOfTurn) return; ! if (closeIfAllExercised) { for (SpecialPropertyI sp : specialProperties) { *************** *** 296,300 **** log.debug("CloseIfAll: closing "+name); setClosed(); ! } else if (closeIfAnyExercised) { for (SpecialPropertyI sp : specialProperties) { --- 287,291 ---- log.debug("CloseIfAll: closing "+name); setClosed(); ! } else if (closeIfAnyExercised) { for (SpecialPropertyI sp : specialProperties) { Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ShareSellingRound.java 14 Jan 2009 20:45:07 -0000 1.19 --- ShareSellingRound.java 15 Jan 2009 20:53:28 -0000 1.20 *************** *** 306,311 **** if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CantSell", ! new String[] { playerName, String.valueOf(numberSold), ! companyName, errMsg })); return false; } --- 306,313 ---- if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CantSell", ! playerName, ! numberSold, ! companyName, ! errMsg )); return false; } *************** *** 336,341 **** // Check if the presidency has changed if (presCert != null && dumpedPlayer != null && presSharesToSell > 0) { ! ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { ! dumpedPlayer.getName(), companyName})); // First swap the certificates Portfolio dumpedPortfolio = dumpedPlayer.getPortfolio(); --- 338,344 ---- // Check if the presidency has changed if (presCert != null && dumpedPlayer != null && presSharesToSell > 0) { ! ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! dumpedPlayer.getName(), ! companyName)); // First swap the certificates Portfolio dumpedPortfolio = dumpedPlayer.getPortfolio(); *************** *** 364,370 **** otherPlayer.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! new String[] { otherPlayer.getName(), ! company.getName() ! })); break; } --- 367,372 ---- otherPlayer.getPortfolio()); ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", ! otherPlayer.getName(), ! company.getName())); break; } Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TreasuryShareRound.java 23 Dec 2008 19:57:26 -0000 1.11 --- TreasuryShareRound.java 15 Jan 2009 20:53:28 -0000 1.12 *************** *** 270,275 **** if (company != operatingCompany) { errMsg = ! LocalText.getText("WrongCompany", new String[] { ! companyName, operatingCompany.getName() }); } --- 270,276 ---- if (company != operatingCompany) { errMsg = ! LocalText.getText("WrongCompany", ! companyName, ! operatingCompany.getName() ); } *************** *** 295,300 **** if (shares > from.getShare(company)) { errMsg = ! LocalText.getText("NotAvailable", new String[] { ! companyName, from.getName() }); break; } --- 296,302 ---- if (shares > from.getShare(company)) { errMsg = ! LocalText.getText("NotAvailable", ! companyName, ! from.getName() ); break; } *************** *** 322,328 **** if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuy", new String[] { ! companyName, String.valueOf(shares), companyName, ! from.getName(), errMsg })); return false; } --- 324,333 ---- if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantBuy", ! companyName, ! shares, ! companyName, ! from.getName(), ! errMsg )); return false; } *************** *** 330,342 **** // All seems OK, now buy the shares. if (number == 1) { ! ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", new String[] { ! companyName, String.valueOf(shareUnit), companyName, ! from.getName(), Bank.format(shares * price) })); } else { ! ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", new String[] { ! companyName, String.valueOf(number), ! String.valueOf(shareUnit), ! String.valueOf(number * shareUnit), companyName, ! from.getName(), Bank.format(shares * price) })); } --- 335,353 ---- // All seems OK, now buy the shares. if (number == 1) { ! ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", ! companyName, ! shareUnit, ! companyName, ! from.getName(), ! Bank.format(shares * price) )); } else { ! ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", ! companyName, ! number, ! shareUnit, ! number * shareUnit, ! companyName, ! from.getName(), ! Bank.format(shares * price) )); } *************** *** 381,386 **** if (company != operatingCompany) { errMsg = ! LocalText.getText("WrongCompany", new String[] { ! companyName, operatingCompany.getName() }); break; } --- 392,398 ---- if (company != operatingCompany) { errMsg = ! LocalText.getText("WrongCompany", ! companyName, ! operatingCompany.getName() ); break; } *************** *** 440,446 **** int numberSold = action.getNumberSold(); if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantSell", new String[] { ! companyName, String.valueOf(numberSold), companyName, ! errMsg })); return false; } --- 452,460 ---- int numberSold = action.getNumberSold(); if (errMsg != null) { ! DisplayBuffer.add(LocalText.getText("CantSell", ! companyName, ! numberSold, ! companyName, ! errMsg )); return false; } *************** *** 461,468 **** MoveSet.start(true); ! ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", new String[] { ! companyName, String.valueOf(numberSold), ! String.valueOf((numberSold * company.getShareUnit())), ! companyName, Bank.format(numberSold * price) })); // Transfer the sold certificates --- 475,484 ---- MoveSet.start(true); ! ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", ! companyName, ! numberSold, ! (numberSold * company.getShareUnit()), ! companyName, ! Bank.format(numberSold * price) )); // Transfer the sold certificates Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Round.java 23 Dec 2008 19:55:29 -0000 1.14 --- Round.java 15 Jan 2009 20:53:28 -0000 1.15 *************** *** 201,206 **** if (cash > 0) { new CashMove(Bank.getInstance(), company, cash); ! ReportBuffer.add(LocalText.getText("FloatsWithCash", new String[] { ! company.getName(), Bank.format(cash) })); } else { ReportBuffer.add(LocalText.getText("Floats", --- 201,207 ---- if (cash > 0) { new CashMove(Bank.getInstance(), company, cash); ! ReportBuffer.add(LocalText.getText("FloatsWithCash", ! company.getName(), ! Bank.format(cash) )); } else { ReportBuffer.add(LocalText.getText("Floats", Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** OperatingRound.java 14 Jan 2009 20:45:07 -0000 1.51 --- OperatingRound.java 15 Jan 2009 20:53:28 -0000 1.52 *************** *** 128,132 **** for (PrivateCompanyI priv : companyManager.getAllPrivateCompanies()) { ! if (!priv.isClosed()) priv.payOut(); } --- 128,144 ---- for (PrivateCompanyI priv : companyManager.getAllPrivateCompanies()) { ! if (!priv.isClosed()) { ! //priv.payOut(); ! if (((Portfolio)priv.getHolder()).getOwner().getClass() != Bank.class) { ! CashHolder recipient = ((Portfolio)priv.getHolder()).getOwner(); ! int revenue = priv.getRevenue(); ! ReportBuffer.add(LocalText.getText("ReceivesFor", ! recipient.getName(), ! Bank.format(revenue), ! priv.getName())); ! new CashMove(null, recipient, revenue); ! } ! ! } } *************** *** 169,174 **** if (company != operatingCompany) { DisplayBuffer.add(LocalText.getText("WrongCompany", ! new String[] { company.getName(), ! operatingCompany.getName() })); return false; } --- 181,186 ---- if (company != operatingCompany) { DisplayBuffer.add(LocalText.getText("WrongCompany", ! company.getName(), ! operatingCompany.getName() )); return false; } *************** *** 265,270 **** if (!companyName.equals(operatingCompany.getName())) { errMsg = ! LocalText.getText("WrongCompany", new String[] { ! companyName, operatingCompany.getName() }); break; } --- 277,283 ---- if (!companyName.equals(operatingCompany.getName())) { errMsg = ! LocalText.getText("WrongCompany", ! companyName, ! operatingCompany.getName() ); break; } *************** *** 301,307 **** LocalText.getText( "TileMayNotBeLaidInHex", ! new String[] { ! String.valueOf(tile.getExternalId()), ! hex.getName() }); break; } --- 314,319 ---- LocalText.getText( "TileMayNotBeLaidInHex", ! tile.getExternalId(), ! hex.get... [truncated message content] |
From: Erik V. <ev...@us...> - 2009-01-15 20:53:36
|
Update of /cvsroot/rails/18xx/rails/game/special In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14080/rails/game/special Modified Files: ExchangeForShare.java Log Message: Fixed code to remove compiler warnings Index: ExchangeForShare.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/special/ExchangeForShare.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ExchangeForShare.java 20 Nov 2008 21:49:38 -0000 1.8 --- ExchangeForShare.java 15 Jan 2009 20:53:28 -0000 1.9 *************** *** 4,10 **** import rails.game.*; import rails.game.move.MoveSet; ! import rails.util.LocalText; ! import rails.util.Tag; ! import rails.util.Util; public class ExchangeForShare extends SpecialProperty { --- 4,8 ---- import rails.game.*; import rails.game.move.MoveSet; ! import rails.util.*; public class ExchangeForShare extends SpecialProperty { *************** *** 16,19 **** --- 14,18 ---- int share; + @Override public void configureFromXML(Tag tag) throws ConfigurationException { *************** *** 77,83 **** if (errMsg != null) { DisplayBuffer.add(LocalText.getText( ! "CannotSwapPrivateForCertificate", new String[] { ! player.getName(), privateCompany.getName(), ! String.valueOf(share), publicCompanyName, errMsg })); return false; } --- 76,85 ---- if (errMsg != null) { DisplayBuffer.add(LocalText.getText( ! "CannotSwapPrivateForCertificate", ! player.getName(), ! privateCompany.getName(), ! share, ! publicCompanyName, ! errMsg )); return false; } *************** *** 92,97 **** cert.moveTo(player.getPortfolio()); ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", ! new String[] { player.getName(), privateCompany.getName(), ! String.valueOf(share), publicCompanyName })); setExercised(); privateCompany.setClosed(); --- 94,101 ---- cert.moveTo(player.getPortfolio()); ReportBuffer.add(LocalText.getText("SwapsPrivateForCertificate", ! player.getName(), ! privateCompany.getName(), ! share, ! publicCompanyName )); setExercised(); privateCompany.setClosed(); *************** *** 125,128 **** --- 129,133 ---- } + @Override public String toString() { return "Swap " + privateCompany.getName() + " for " + share *************** *** 130,137 **** } public String toMenu() { ! return LocalText.getText("SwapPrivateForCertificate", new String[] { ! privateCompany.getName(), String.valueOf(share), ! publicCompanyName }); } } --- 135,144 ---- } + @Override public String toMenu() { ! return LocalText.getText("SwapPrivateForCertificate", ! privateCompany.getName(), ! share, ! publicCompanyName ); } } |
From: Erik V. <ev...@us...> - 2009-01-14 20:45:23
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24082/rails/game/action Modified Files: SetDividend.java Log Message: Added 1856 loan interest payment (from all possible sources). Index: SetDividend.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/action/SetDividend.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SetDividend.java 4 Jun 2008 19:00:29 -0000 1.4 --- SetDividend.java 14 Jan 2009 20:45:07 -0000 1.5 *************** *** 1,7 **** --- 1,11 ---- package rails.game.action; + import java.io.IOException; + import java.io.ObjectInputStream; import java.util.Arrays; import rails.game.Bank; + import rails.game.Game; + import rails.util.Util; /** *************** *** 11,17 **** * back-end; in that case, the user can only select the earnings distribution * method. ! * * @author Erik Vos ! * */ public class SetDividend extends PossibleORAction implements Cloneable { --- 15,21 ---- * back-end; in that case, the user can only select the earnings distribution * method. ! * * @author Erik Vos ! * */ public class SetDividend extends PossibleORAction implements Cloneable { *************** *** 27,35 **** new String[] { "WITHHOLD", "SPLIT", "PAYOUT" }; /** * The revenue as proposed by the back-end. Currently this is always the * previous revenue. In the future, this could be the calculated revenue. */ ! private int presetRevenue; /** --- 31,40 ---- new String[] { "WITHHOLD", "SPLIT", "PAYOUT" }; + /*--- Server-side settings ---*/ /** * The revenue as proposed by the back-end. Currently this is always the * previous revenue. In the future, this could be the calculated revenue. */ ! protected int presetRevenue; /** *************** *** 39,46 **** * in 1844, the user may opt for less that maximum revenue is some cases). */ ! private boolean mayUserSetRevenue; ! ! /** The revenue as set (or accepted, or just seen) by the user. */ ! private int actualRevenue; /** --- 44,48 ---- * in 1844, the user may opt for less that maximum revenue is some cases). */ ! protected boolean mayUserSetRevenue; /** *************** *** 49,56 **** * most games). */ ! private int[] allowedRevenueAllocations; /** The revenue destination selected by the user (if he has a choice at all). */ ! private int revenueAllocation; public static final long serialVersionUID = 1L; --- 51,70 ---- * most games). */ ! protected int[] allowedRevenueAllocations; ! ! /** Cash that should be minimally raised as revenue ! * (for instance, to pay loan interest as in 1856). ! * If actual revenue is below this value, the dividend will be zero, ! * and no dividend allocation should be requested. ! * */ ! protected int requiredCash = 0; ! ! /*--- Client-side settings ---*/ ! ! /** The revenue as set (or accepted, or just seen) by the user. */ ! protected int actualRevenue; /** The revenue destination selected by the user (if he has a choice at all). */ ! protected int revenueAllocation; public static final long serialVersionUID = 1L; *************** *** 58,65 **** public SetDividend(int presetRevenue, boolean mayUserSetRevenue, int[] allowedAllocations) { super(); this.presetRevenue = presetRevenue; this.mayUserSetRevenue = mayUserSetRevenue; ! this.allowedRevenueAllocations = (int[]) allowedAllocations.clone(); if (allowedRevenueAllocations.length == 1) { revenueAllocation = allowedRevenueAllocations[0]; --- 72,85 ---- public SetDividend(int presetRevenue, boolean mayUserSetRevenue, int[] allowedAllocations) { + this (presetRevenue, mayUserSetRevenue, allowedAllocations, 0); + } + + public SetDividend(int presetRevenue, boolean mayUserSetRevenue, + int[] allowedAllocations, int requiredCash) { super(); this.presetRevenue = presetRevenue; this.mayUserSetRevenue = mayUserSetRevenue; ! this.allowedRevenueAllocations = allowedAllocations.clone(); ! this.requiredCash = requiredCash; if (allowedRevenueAllocations.length == 1) { revenueAllocation = allowedRevenueAllocations[0]; *************** *** 70,76 **** /** Clone an instance (used by clone) */ ! private SetDividend(SetDividend action) { this(action.presetRevenue, action.mayUserSetRevenue, ! action.allowedRevenueAllocations); } --- 90,97 ---- /** Clone an instance (used by clone) */ ! protected SetDividend(SetDividend action) { this(action.presetRevenue, action.mayUserSetRevenue, ! action.allowedRevenueAllocations, ! action.requiredCash); } *************** *** 98,101 **** --- 119,126 ---- } + public int getRequiredCash() { + return requiredCash; + } + public void setRevenueAllocation(int allocation) { revenueAllocation = allocation; *************** *** 114,117 **** --- 139,143 ---- } + @Override public Object clone() { *************** *** 122,125 **** --- 148,152 ---- } + @Override public boolean equals(PossibleAction action) { if (!(action instanceof SetDividend)) return false; *************** *** 128,138 **** && a.presetRevenue == presetRevenue && a.mayUserSetRevenue == mayUserSetRevenue && Arrays.equals(a.allowedRevenueAllocations, allowedRevenueAllocations); } public String toString() { StringBuffer b = new StringBuffer(); ! b.append("SetDividend: ").append(company.getName()); if (mayUserSetRevenue) { b.append(", settable, previous=").append(Bank.format(presetRevenue)); --- 155,167 ---- && a.presetRevenue == presetRevenue && a.mayUserSetRevenue == mayUserSetRevenue + && a.requiredCash == requiredCash && Arrays.equals(a.allowedRevenueAllocations, allowedRevenueAllocations); } + @Override public String toString() { StringBuffer b = new StringBuffer(); ! b.append(getClass().getSimpleName()).append(": ").append(company.getName()); if (mayUserSetRevenue) { b.append(", settable, previous=").append(Bank.format(presetRevenue)); *************** *** 150,156 **** --- 179,207 ---- b.append(" chosen=").append(allocationNameKeys[revenueAllocation]); } + if (requiredCash > 0) { + b.append(" requiredCash="+requiredCash); + } return b.toString(); } + /** Deserialize */ + @SuppressWarnings("unchecked") + private void readObject(ObjectInputStream in) throws IOException, + ClassNotFoundException { + + // Custom deserialization for backwards compatibility + ObjectInputStream.GetField fields = in.readFields(); + presetRevenue = fields.get("presetRevenue", presetRevenue); + mayUserSetRevenue = fields.get("mayUserSetRevenue", mayUserSetRevenue); + allowedRevenueAllocations = (int[]) fields.get("allowedRevenueAllocations", allowedRevenueAllocations); + requiredCash = fields.get("requiredCash", 0); + actualRevenue = fields.get("actualRevenue", actualRevenue); + revenueAllocation = fields.get("revenueAllocation", revenueAllocation); + + if (Util.hasValue(companyName)) { + company = Game.getCompanyManager().getPublicCompany(companyName); + } + } + } |
From: Erik V. <ev...@us...> - 2009-01-14 20:45:19
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24082/rails/game/specific/_1856 Modified Files: OperatingRound_1856.java Log Message: Added 1856 loan interest payment (from all possible sources). Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OperatingRound_1856.java 11 Jan 2009 17:24:46 -0000 1.4 --- OperatingRound_1856.java 14 Jan 2009 20:45:07 -0000 1.5 *************** *** 4,17 **** import java.util.List; ! import rails.game.Bank; ! import rails.game.DisplayBuffer; ! import rails.game.GameManagerI; ! import rails.game.OperatingRound; ! import rails.game.PublicCompanyI; ! import rails.game.ReportBuffer; ! import rails.game.TrainI; ! import rails.game.TrainManager; ! import rails.game.action.ReachDestinations; ! import rails.game.action.TakeLoans; import rails.game.move.CashMove; import rails.game.state.IntegerState; --- 4,9 ---- import java.util.List; ! import rails.game.*; ! import rails.game.action.*; import rails.game.move.CashMove; import rails.game.state.IntegerState; *************** *** 19,39 **** public class OperatingRound_1856 extends OperatingRound { ! public OperatingRound_1856 (GameManagerI gameManager) { super (gameManager); ! } ! /** * Implements special rules for first time operating in 1856 */ protected boolean setNextOperatingCompany(boolean initial) { ! ! if (operatingCompanyIndexObject == null) { operatingCompanyIndexObject = new IntegerState("OperatingCompanyIndex"); } ! while (true) { if (initial) { --- 11,32 ---- public class OperatingRound_1856 extends OperatingRound { ! public OperatingRound_1856 (GameManagerI gameManager) { super (gameManager); ! } ! /** * Implements special rules for first time operating in 1856 */ + @Override protected boolean setNextOperatingCompany(boolean initial) { ! ! if (operatingCompanyIndexObject == null) { operatingCompanyIndexObject = new IntegerState("OperatingCompanyIndex"); } ! while (true) { if (initial) { *************** *** 43,62 **** operatingCompanyIndexObject.add(1); } ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); ! if (operatingCompanyIndex >= operatingCompanyArray.length) { return false; } else { operatingCompany = operatingCompanyArray[operatingCompanyIndex]; ! // 1856 special: check if the company may operate if (!operatingCompany.hasOperated()) { ! int soldPercentage = 100 - operatingCompany.getUnsoldPercentage(); ! TrainI nextAvailableTrain = TrainManager.get().getAvailableNewTrains().get(0); int trainNumber; ! try { trainNumber = Integer.parseInt(nextAvailableTrain.getName()); } catch (NumberFormatException e) { --- 36,55 ---- operatingCompanyIndexObject.add(1); } ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); ! if (operatingCompanyIndex >= operatingCompanyArray.length) { return false; } else { operatingCompany = operatingCompanyArray[operatingCompanyIndex]; ! // 1856 special: check if the company may operate if (!operatingCompany.hasOperated()) { ! int soldPercentage = 100 - operatingCompany.getUnsoldPercentage(); ! TrainI nextAvailableTrain = TrainManager.get().getAvailableNewTrains().get(0); int trainNumber; ! try { trainNumber = Integer.parseInt(nextAvailableTrain.getName()); } catch (NumberFormatException e) { *************** *** 64,71 **** } int floatPercentage = 10 * trainNumber; ! log.debug ("Float percentage is "+floatPercentage +" sold percentage is "+soldPercentage); ! if (soldPercentage < floatPercentage) { --- 57,64 ---- } int floatPercentage = 10 * trainNumber; ! log.debug ("Float percentage is "+floatPercentage +" sold percentage is "+soldPercentage); ! if (soldPercentage < floatPercentage) { *************** *** 78,82 **** continue; } ! } return true; --- 71,75 ---- continue; } ! } return true; *************** *** 85,90 **** } protected void setDestinationActions() { ! List<PublicCompanyI> possibleDestinations = new ArrayList<PublicCompanyI>(); for (PublicCompanyI comp : operatingCompanyArray) { --- 78,236 ---- } + @Override + protected void prepareRevenueAndDividendAction () { + + int requiredCash = 0; + + // Check if any loan interest can be paid + int loanValue = operatingCompany.getLoanValueModel().intValue(); + if (loanValue > 0) { + int interest = loanValue * operatingCompany.getLoanInterestPct() / 100; + int compCash = (operatingCompany.getCash() / 10) * 10; + requiredCash = Math.max(interest - compCash, 0); + } + + // There is only revenue if there are any trains + if (operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + int[] allowedRevenueActions = + operatingCompany.isSplitAlways() + ? new int[] { SetDividend.SPLIT } + : operatingCompany.isSplitAllowed() + ? new int[] { SetDividend.PAYOUT, + SetDividend.SPLIT, + SetDividend.WITHHOLD } + : new int[] { SetDividend.PAYOUT, + SetDividend.WITHHOLD }; + + possibleActions.add(new SetDividend( + operatingCompany.getLastRevenue(), true, + allowedRevenueActions, + requiredCash)); + // UI directions: + // Any nonzero required cash should be reported to the user. + // If the revenue is less than that, the allocation + // question should be suppressed. + // In that case, the follow-up is done from this class. + } + } + + @Override + protected int checkForDeductions (SetDividend action) { + + int amount = action.getActualRevenue(); + int due = calculateLoanInterest(operatingCompany.getCurrentNumberOfLoans()); + if (due == 0) return amount; + int remainder = due; + + ReportBuffer.add((LocalText.getText("CompanyMustPayLoanInterest", + operatingCompany.getName(), + Bank.format(due)))); + + // Can it be paid from company treasury? + int payment = Math.min(due, (operatingCompany.getCash() / 10) * 10); + if (payment > 0) { + remainder -= payment; + } + if (remainder == 0) return amount; + + // Can any remainder be paid from revenue? + payment = Math.min (remainder, amount); + if (payment > 0) { + remainder -= payment; + // This reduces train income + amount -= payment; + } + if (remainder == 0) return amount; + + // Pay any remainder from president cash + // First check if president has enough cash + Player president = operatingCompany.getPresident(); + int presCash = president.getCash(); + if (remainder > presCash) { + // Start a share selling round + cashToBeRaisedByPresident = remainder - presCash; + log.info("A share selling round must be started as the president cannot pay $" + + remainder + " loan interest"); + log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); + savedAction = action; + gameManager.startShareSellingRound(this, operatingCompany, + cashToBeRaisedByPresident); + // Return arbitrary negative value to signal end of processing to caller. + return -remainder; + + } else { + // OK, nothing more to here + } + + return amount; + } + + @Override + protected int executeDeductions (SetDividend action) { + + int amount = action.getActualRevenue(); + int due = calculateLoanInterest(operatingCompany.getCurrentNumberOfLoans()); + if (due == 0) return amount; + int remainder = due; + + // Pay from company treasury + int payment = Math.min(due, (operatingCompany.getCash() / 10) * 10); + if (payment > 0) { + new CashMove (operatingCompany, null, payment); + if (payment == due) { + ReportBuffer.add (LocalText.getText("InterestPaidFromTreasury", + operatingCompany.getName(), + Bank.format(payment))); + } else { + ReportBuffer.add (LocalText.getText("InterestPartlyPaidFromTreasury", + operatingCompany.getName(), + Bank.format(payment), + Bank.format(due))); + } + remainder -= payment; + } + if (remainder == 0) return amount; + + // Pay any remainder from revenue + payment = Math.min (remainder, amount); + if (payment > 0) { + // Payment money remains in the bank + remainder -= payment; + ReportBuffer.add (LocalText.getText("InterestPaidFromRevenue", + operatingCompany.getName(), + Bank.format(payment), + Bank.format(due))); + // This reduces train income + amount -= payment; + } + if (remainder == 0) return amount; + + // Pay any remainder from president cash + // First check if president has enough cash + Player president = operatingCompany.getPresident(); + int presCash = president.getCash(); + if (remainder > presCash) { + // This can't happen in this stage, log an error + log.error("??? The president still cannot pay $" + + remainder + " loan interest???"); + return 0; + + } else { + + payment = remainder; + new CashMove (president, null, payment); + ReportBuffer.add (LocalText.getText("InterestPaidFromPresidentCash", + operatingCompany.getName(), + Bank.format(payment), + Bank.format(due), + president.getName())); + } + + return amount; + } + + @Override protected void setDestinationActions() { ! List<PublicCompanyI> possibleDestinations = new ArrayList<PublicCompanyI>(); for (PublicCompanyI comp : operatingCompanyArray) { *************** *** 99,103 **** } } ! protected void reachDestination (PublicCompanyI company) { --- 245,250 ---- } } ! ! @Override protected void reachDestination (PublicCompanyI company) { *************** *** 113,141 **** } - - 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", --- 260,289 ---- } + @Override + 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())); } } + @Override 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", *************** *** 158,174 **** } 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; } } --- 306,327 ---- } + @Override protected int calculateLoanAmount (int numberOfLoans) { ! int amount = super.calculateLoanAmount(numberOfLoans); ! // Deduct interest immediately? if (stepObject.intValue() > STEP_PAYOUT) { ! amount -= calculateLoanInterest(numberOfLoans); } ! return amount; } + + protected int calculateLoanInterest (int numberOfLoans) { + + return numberOfLoans + * operatingCompany.getValuePerLoan() + * operatingCompany.getLoanInterestPct() / 100; + } } |
From: Erik V. <ev...@us...> - 2009-01-14 20:45:19
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24082/rails/ui/swing Modified Files: ORUIManager.java Log Message: Added 1856 loan interest payment (from all possible sources). Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ORUIManager.java 11 Jan 2009 17:24:46 -0000 1.23 --- ORUIManager.java 14 Jan 2009 20:45:07 -0000 1.24 *************** *** 1143,1147 **** orPanel.initRevenueEntryStep(orCompIndex, action); ! setMessage(LocalText.getText("EnterRevenue")); } else if (possibleActions.contains(BuyTrain.class)/* --- 1143,1155 ---- orPanel.initRevenueEntryStep(orCompIndex, action); ! ! String message = LocalText.getText("EnterRevenue"); ! if (action.getRequiredCash() > 0) { ! message += "<br><font color=\"red\">" ! + LocalText.getText("WarningNeedCash", ! Bank.format(action.getRequiredCash())) ! + "</font>"; ! } ! setMessage(message); } else if (possibleActions.contains(BuyTrain.class)/* |
From: Erik V. <ev...@us...> - 2009-01-14 20:45:19
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24082/rails/game Modified Files: ShareSellingRound.java OperatingRound.java GameManager.java Log Message: Added 1856 loan interest payment (from all possible sources). Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** OperatingRound.java 11 Jan 2009 17:24:46 -0000 1.50 --- OperatingRound.java 14 Jan 2009 20:45:07 -0000 1.51 *************** *** 5,11 **** import rails.game.action.*; ! import rails.game.move.CashMove; ! import rails.game.move.MapChange; ! import rails.game.move.MoveSet; import rails.game.special.*; import rails.game.state.IntegerState; --- 5,9 ---- import rails.game.action.*; ! import rails.game.move.*; import rails.game.special.*; import rails.game.state.IntegerState; *************** *** 57,61 **** protected List<TrainTypeI> trainsBoughtThisTurn = new ArrayList<TrainTypeI>(4); ! protected Map<PublicCompanyI, Integer> loansThisRound = null; --- 55,59 ---- protected List<TrainTypeI> trainsBoughtThisTurn = new ArrayList<TrainTypeI>(4); ! protected Map<PublicCompanyI, Integer> loansThisRound = null; *************** *** 66,70 **** protected PossibleAction selectedAction = null; ! protected BuyTrain savedAction = null; protected int cashToBeRaisedByPresident = 0; --- 64,68 ---- protected PossibleAction selectedAction = null; ! protected PossibleAction savedAction = null; protected int cashToBeRaisedByPresident = 0; *************** *** 210,216 **** result = reachDestinations ((ReachDestinations) selectedAction); ! } else if (selectedAction instanceof TakeLoans) { ! result = takeLoans((TakeLoans) selectedAction); --- 208,214 ---- result = reachDestinations ((ReachDestinations) selectedAction); ! } else if (selectedAction instanceof TakeLoans) { ! result = takeLoans((TakeLoans) selectedAction); *************** *** 648,651 **** --- 646,677 ---- public boolean setRevenueAndDividend(SetDividend action) { + String errMsg = validateSetRevenueAndDividend (action); + + if (errMsg != null) { + DisplayBuffer.add(LocalText.getText( + "CannotProcessRevenue", + Bank.format (action.getActualRevenue()), + action.getCompanyName(), + errMsg + )); + return false; + } + + MoveSet.start(true); + + int remainingAmount = checkForDeductions (action); + if (remainingAmount < 0) { + // A share selling round will be run to raise cash to pay debts + return true; + } + + executeSetRevenueAndDividend (action); + + return true; + + } + + protected String validateSetRevenueAndDividend (SetDividend action) { + String errMsg = null; PublicCompanyI company; *************** *** 717,743 **** } else { // If there is no revenue, use withhold. ! revenueAllocation = SetDividend.WITHHOLD; } break; } - if (errMsg != null) { - DisplayBuffer.add(LocalText.getText( - "CannotProcessRevenue", - new String[] { String.valueOf(amount), companyName, errMsg })); - return false; - } ! MoveSet.start(true); operatingCompany.setLastRevenue(amount); operatingCompany.setLastRevenueAllocation(revenueAllocation); - ReportBuffer.add(LocalText.getText("CompanyRevenue", new String[] { - companyName, Bank.format(amount) })); ! if (revenueAllocation == SetDividend.PAYOUT) { ReportBuffer.add(LocalText.getText("CompanyPaysOutFull", ! new String[] { companyName, Bank.format(amount) })); operatingCompany.payout(amount); --- 743,786 ---- } else { // If there is no revenue, use withhold. ! action.setRevenueAllocation(SetDividend.WITHHOLD); ! } ! ! ReportBuffer.add(LocalText.getText("CompanyRevenue", ! action.getCompanyName(), ! Bank.format(amount))); ! if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { ! DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", ! operatingCompany.getName(), ! Bank.format(0) )); } break; } ! return errMsg; ! } ! ! protected void executeSetRevenueAndDividend (SetDividend action) { ! ! int amount = action.getActualRevenue(); ! int revenueAllocation = action.getRevenueAllocation(); operatingCompany.setLastRevenue(amount); operatingCompany.setLastRevenueAllocation(revenueAllocation); ! // Pay any debts from treasury, revenue and/or president's cash ! // The remaining dividend may be less that the original income ! amount = executeDeductions (action); ! ! if (amount == 0) { ! ! ReportBuffer.add(LocalText.getText("CompanyDoesNotPayDividend", ! operatingCompany.getName())); ! operatingCompany.withhold(amount); ! ! } else if (revenueAllocation == SetDividend.PAYOUT) { ReportBuffer.add(LocalText.getText("CompanyPaysOutFull", ! operatingCompany.getName(), Bank.format(amount) )); operatingCompany.payout(amount); *************** *** 745,750 **** } else if (revenueAllocation == SetDividend.SPLIT) { ! ReportBuffer.add(LocalText.getText("CompanySplits", new String[] { ! companyName, Bank.format(amount) })); operatingCompany.splitRevenue(amount); --- 788,793 ---- } else if (revenueAllocation == SetDividend.SPLIT) { ! ReportBuffer.add(LocalText.getText("CompanySplits", ! operatingCompany.getName(), Bank.format(amount) )); operatingCompany.splitRevenue(amount); *************** *** 753,757 **** ReportBuffer.add(LocalText.getText("CompanyWithholds", ! new String[] { companyName, Bank.format(amount) })); operatingCompany.withhold(amount); --- 796,801 ---- ReportBuffer.add(LocalText.getText("CompanyWithholds", ! operatingCompany.getName(), ! Bank.format(amount) )); operatingCompany.withhold(amount); *************** *** 764,769 **** // We have done the payout step, so continue from there nextStep(STEP_PAYOUT); ! return true; } --- 808,821 ---- // We have done the payout step, so continue from there nextStep(STEP_PAYOUT); + } ! /** Default version, to be overridden if need be */ ! protected int checkForDeductions (SetDividend action) { ! return action.getActualRevenue(); ! } ! ! /** Default version, to be overridden if need be */ ! protected int executeDeductions (SetDividend action) { ! return action.getActualRevenue(); } *************** *** 799,802 **** --- 851,855 ---- if (operatingCompany.getPortfolio().getNumberOfTrains() == 0) { // No trains, then the revenue is zero. + /* operatingCompany.setLastRevenue(0); operatingCompany.setLastRevenueAllocation(SetDividend.UNKNOWN); *************** *** 804,807 **** --- 857,864 ---- new String[] { operatingCompany.getName(), Bank.format(0) })); + */ + executeSetRevenueAndDividend ( + new SetDividend (0, false, new int[] {SetDividend.WITHHOLD})); + // TODO: This probably does not handle share selling correctly continue; } *************** *** 811,817 **** --- 868,876 ---- // If we already know what to do: do it. + /* int amount = operatingCompany.getLastRevenue(); if (amount == 0) { /* Zero dividend: process it and go to the next step */ + /* operatingCompany.withhold(0); DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", *************** *** 825,832 **** * Automatic revenue split: process it and go to the next * step ! */ operatingCompany.splitRevenue(amount); continue; } } --- 884,893 ---- * Automatic revenue split: process it and go to the next * step ! *//* operatingCompany.splitRevenue(amount); continue; } + */ + continue; } *************** *** 1296,1302 **** } ! public void resumeTrainBuying() { ! buyTrain(savedAction); } --- 1357,1367 ---- } ! public void resume() { ! if (savedAction instanceof BuyTrain) { ! buyTrain ((BuyTrain)savedAction); ! } else if (savedAction instanceof SetDividend) { ! executeSetRevenueAndDividend ((SetDividend) savedAction); ! } } *************** *** 1497,1517 **** } ! protected boolean takeLoans (TakeLoans action) { ! String errMsg = validateTakeLoans (action); ! if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotTakeLoans", ! action.getCompanyName(), action.getNumberTaken(), action.getPrice(), errMsg)); ! return false; } MoveSet.start(true); ! executeTakeLoans (action); --- 1562,1582 ---- } ! protected boolean takeLoans (TakeLoans action) { ! String errMsg = validateTakeLoans (action); ! if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotTakeLoans", ! action.getCompanyName(), action.getNumberTaken(), action.getPrice(), errMsg)); ! return false; } MoveSet.start(true); ! executeTakeLoans (action); *************** *** 1519,1523 **** } ! protected String validateTakeLoans (TakeLoans action) { --- 1584,1588 ---- } ! protected String validateTakeLoans (TakeLoans action) { *************** *** 1560,1566 **** return errMsg; } ! protected void executeTakeLoans (TakeLoans action) { ! int number = action.getNumberTaken(); int amount = calculateLoanAmount (number); --- 1625,1631 ---- return errMsg; } ! protected void executeTakeLoans (TakeLoans action) { ! int number = action.getNumberTaken(); int amount = calculateLoanAmount (number); *************** *** 1581,1585 **** )); } ! if (operatingCompany.getMaxLoansPerRound() > 0) { int oldLoansThisRound = 0; --- 1646,1650 ---- )); } ! if (operatingCompany.getMaxLoansPerRound() > 0) { int oldLoansThisRound = 0; *************** *** 1589,1602 **** oldLoansThisRound = loansThisRound.get(operatingCompany); } ! new MapChange<PublicCompanyI, Integer> (loansThisRound, operatingCompany, new Integer (oldLoansThisRound + number)); } } ! protected int calculateLoanAmount (int numberOfLoans) { return numberOfLoans * operatingCompany.getValuePerLoan(); } ! /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ --- 1654,1667 ---- oldLoansThisRound = loansThisRound.get(operatingCompany); } ! new MapChange<PublicCompanyI, Integer> (loansThisRound, operatingCompany, new Integer (oldLoansThisRound + number)); } } ! protected int calculateLoanAmount (int numberOfLoans) { return numberOfLoans * operatingCompany.getValuePerLoan(); } ! /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ *************** *** 1684,1704 **** possibleActions.add(new NullAction(NullAction.SKIP)); } else if (step == STEP_CALC_REVENUE) { ! if (operatingCompany.getPortfolio().getNumberOfTrains() == 0) { ! // No trains: the revenue is fixed at 0 ! } else { ! int[] allowedRevenueActions = ! operatingCompany.isSplitAlways() ! ? new int[] { SetDividend.SPLIT } ! : operatingCompany.isSplitAllowed() ! ? new int[] { SetDividend.PAYOUT, ! SetDividend.SPLIT, ! SetDividend.WITHHOLD } ! : new int[] { SetDividend.PAYOUT, ! SetDividend.WITHHOLD }; ! ! possibleActions.add(new SetDividend( ! operatingCompany.getLastRevenue(), true, ! allowedRevenueActions)); ! } } else if (step == STEP_BUY_TRAIN) { setBuyableTrains(); --- 1749,1753 ---- possibleActions.add(new NullAction(NullAction.SKIP)); } else if (step == STEP_CALC_REVENUE) { ! prepareRevenueAndDividendAction(); } else if (step == STEP_BUY_TRAIN) { setBuyableTrains(); *************** *** 1751,1754 **** --- 1800,1823 ---- } + protected void prepareRevenueAndDividendAction () { + + // There is only revenue if there are any trains + if (operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + int[] allowedRevenueActions = + operatingCompany.isSplitAlways() + ? new int[] { SetDividend.SPLIT } + : operatingCompany.isSplitAllowed() + ? new int[] { SetDividend.PAYOUT, + SetDividend.SPLIT, + SetDividend.WITHHOLD } + : new int[] { SetDividend.PAYOUT, + SetDividend.WITHHOLD }; + + possibleActions.add(new SetDividend( + operatingCompany.getLastRevenue(), true, + allowedRevenueActions)); + } + } + /** * Get a list of buyable trains for the currently operating company. Omit *************** *** 1954,1958 **** } ! public void repayLoans (int number) { operatingCompany.addLoans(-number); --- 2023,2027 ---- } ! public void repayLoans (int number) { operatingCompany.addLoans(-number); *************** *** 1960,1965 **** new CashMove (operatingCompany, null, amount); DisplayBuffer.add(LocalText.getText("CompanyRepaysLoan", ! new String[] { ! operatingCompany.getName(), String.valueOf(number), Bank.format(operatingCompany.getValuePerLoan()), --- 2029,2034 ---- new CashMove (operatingCompany, null, amount); DisplayBuffer.add(LocalText.getText("CompanyRepaysLoan", ! new String[] { ! operatingCompany.getName(), String.valueOf(number), Bank.format(operatingCompany.getValuePerLoan()), *************** *** 1967,1971 **** })); } ! public void payLoanInterest () { int amount = operatingCompany.getCurrentLoanValue() --- 2036,2040 ---- })); } ! public void payLoanInterest () { int amount = operatingCompany.getCurrentLoanValue() *************** *** 1973,1978 **** new CashMove (operatingCompany, null, amount); DisplayBuffer.add(LocalText.getText("CompanyPaysLoanInterest", ! new String[] { ! operatingCompany.getName(), Bank.format(amount), String.valueOf(operatingCompany.getLoanInterestPct()), --- 2042,2047 ---- new CashMove (operatingCompany, null, amount); DisplayBuffer.add(LocalText.getText("CompanyPaysLoanInterest", ! new String[] { ! operatingCompany.getName(), Bank.format(amount), String.valueOf(operatingCompany.getLoanInterestPct()), Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** GameManager.java 11 Jan 2009 17:24:46 -0000 1.39 --- GameManager.java 14 Jan 2009 20:45:07 -0000 1.40 *************** *** 658,662 **** public void finishShareSellingRound() { setRound(interruptedRound); ! ((OperatingRound) getCurrentRound()).resumeTrainBuying(); } --- 658,662 ---- public void finishShareSellingRound() { setRound(interruptedRound); ! ((OperatingRound) getCurrentRound()).resume(); } Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ShareSellingRound.java 23 Dec 2008 19:57:26 -0000 1.18 --- ShareSellingRound.java 14 Jan 2009 20:45:07 -0000 1.19 *************** *** 21,25 **** OperatingRound or; Player sellingPlayer; ! PublicCompanyI companyNeedingTrain; IntegerState cashToRaise; --- 21,25 ---- OperatingRound or; Player sellingPlayer; ! PublicCompanyI companyNeedingCash; IntegerState cashToRaise; *************** *** 39,47 **** super (gameManager); or = ((OperatingRound) parentRound); ! companyNeedingTrain = or.getOperatingCompany(); cashToRaise = new IntegerState("CashToRaise", or.getCashToBeRaisedByPresident()); ! sellingPlayer = companyNeedingTrain.getPresident(); currentPlayer = sellingPlayer; - log.debug("Creating ShareSellingRound, cash to raise =" + cashToRaise.intValue()); setCurrentPlayerIndex(sellingPlayer.getIndex()); --- 39,46 ---- super (gameManager); or = ((OperatingRound) parentRound); ! companyNeedingCash = or.getOperatingCompany(); cashToRaise = new IntegerState("CashToRaise", or.getCashToBeRaisedByPresident()); ! sellingPlayer = companyNeedingCash.getPresident(); currentPlayer = sellingPlayer; setCurrentPlayerIndex(sellingPlayer.getIndex()); *************** *** 51,54 **** --- 50,57 ---- public void start() { log.info("Share selling round started"); + ReportBuffer.add (LocalText.getText("PlayerMustSellShares", + sellingPlayer.getName(), + Bank.format(cashToRaise.intValue()), + companyNeedingCash.getName())); currentPlayer = sellingPlayer; setPossibleActions(); *************** *** 129,133 **** if (maxShareToSell > share - presidentShare) { dumpAllowed = false; ! if (company != companyNeedingTrain) { int playerShare; List<Player> players = gameManager.getPlayers(); --- 132,136 ---- if (maxShareToSell > share - presidentShare) { dumpAllowed = false; ! if (company != companyNeedingCash) { int playerShare; List<Player> players = gameManager.getPlayers(); *************** *** 263,267 **** && numberToSell <= presCert.getShares()) { // Not allowed to dump the company that needs the train ! if (company == companyNeedingTrain) { errMsg = LocalText.getText("CannotDumpTrainBuyingPresidency"); --- 266,270 ---- && numberToSell <= presCert.getShares()) { // Not allowed to dump the company that needs the train ! if (company == companyNeedingCash) { errMsg = LocalText.getText("CannotDumpTrainBuyingPresidency"); *************** *** 323,330 **** MoveSet.start(true); ! ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", new String[] { ! playerName, String.valueOf(numberSold), ! String.valueOf((numberSold * company.getShareUnit())), ! companyName, Bank.format(numberSold * price) })); // Check if the presidency has changed --- 326,336 ---- MoveSet.start(true); ! ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", ! playerName, ! numberSold, ! company.getShareUnit(), ! numberSold * company.getShareUnit(), ! companyName, ! Bank.format(numberSold * price) )); // Check if the presidency has changed *************** *** 380,384 **** public PublicCompanyI getCompanyNeedingTrain() { ! return companyNeedingTrain; } --- 386,390 ---- public PublicCompanyI getCompanyNeedingTrain() { ! return companyNeedingCash; } |
From: Erik V. <ev...@us...> - 2009-01-14 20:45:19
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24082 Modified Files: LocalisedText.properties Log Message: Added 1856 loan interest payment (from all possible sources). Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** LocalisedText.properties 11 Jan 2009 17:24:46 -0000 1.65 --- LocalisedText.properties 14 Jan 2009 20:45:07 -0000 1.66 *************** *** 80,86 **** --- 80,88 ---- CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train + CompanyDoesNotPayDividend={0} does not pay a dividend CompanyHasNoType=Company {0} has no type defined CompanyHasUnknownType=Company {0} has an undefined type {1} CompanyMustOwnATrain={0} must own a train + CompanyMustPayLoanInterest={0} must pay {1} loan interest CompanyPaysLoanInterest={0} pays {1} as {2}% interest over {3} loans of {4} CompanyPaysOutFull={0} pays out full dividend of {1} *************** *** 157,160 **** --- 159,166 ---- INFO=Game Notes Info=Info + InterestPaidFromTreasury={0} pays {1} loan interest from its treasury + InterestPartlyPaidFromTreasury={0} pays {1} (of {2}) loan interest from its treasury + InterestPaidFromRevenue={0} pays {1} (of {2}) loan interest from its income + InterestPaidFromPresidentCash={0} pays {1} (of {2}) loan interest from {3}''s personal cash IPO=IPO IS_NOW_PRES_OF={0} is now president of {1} *************** *** 257,260 **** --- 263,267 ---- PlayerIs=Player {0} is {1}. PlayerIsBankrupt={0} is bankrupt. + PlayerMustSellShares={0} must sell shares to raise at least {1} for {2} PleaseConfirm=Please confirm PleaseSelect=Please select *************** *** 380,383 **** --- 387,391 ---- VariantIs=Variant is {0}. WantToReplaceToken=Do you want to replace the {0} home token with one of {1}? + WarningNeedCash=Warning: {0} will be deducted from the company revenue or from your personal cash WHICH_PRICE=Which price? WHICH_PRIVATE=Which Private? |
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543/rails/game Modified Files: PublicCompanyI.java BonusToken.java OperatingRound.java PhaseManager.java PublicCompany.java GameManager.java Log Message: Basic loans taking and specific rules for 1856. Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** PublicCompany.java 3 Dec 2008 20:15:15 -0000 1.45 --- PublicCompany.java 11 Jan 2009 17:24:46 -0000 1.46 *************** *** 219,222 **** --- 219,230 ---- protected String initialTrain = null; + /* Loans */ + protected int maxNumberOfLoans = 0; + protected int valuePerLoan = 0; + protected IntegerState currentNumberOfLoans = null; + protected int loanInterestPct = 0; + protected int maxLoansPerRound = 0; + protected MoneyModel currentLoanValue = null; + /** * The constructor. The way this class is instantiated does not allow *************** *** 523,526 **** --- 531,544 ---- mustHaveOperatedToTradeShares); } + + Tag loansTag = tag.getChild("Loans"); + if (loansTag != null) { + maxNumberOfLoans = loansTag.getAttributeAsInteger("number", -1); + // Note: -1 means undefined, to be handled in the code + // (for instance: 1856). + valuePerLoan = loansTag.getAttributeAsInteger("value", 0); + loanInterestPct = loansTag.getAttributeAsInteger("interest", 0); + maxLoansPerRound = loansTag.getAttributeAsInteger("perRound", -1); + } } *************** *** 579,582 **** --- 597,606 ---- } + if (maxNumberOfLoans != 0) { + currentNumberOfLoans = new IntegerState (name+"_Loans", 0); + currentLoanValue = new MoneyModel (name+"_LoanValue", 0); + currentLoanValue.setOption(MoneyModel.SUPPRESS_ZERO); + } + } *************** *** 1241,1252 **** } ! public int percentageOwnedByPlayers() { ! int share = 0; for (PublicCertificateI cert : certificates) { if (cert.getPortfolio().getOwner() instanceof Player) { ! share += cert.getShare(); } } ! return share; } --- 1265,1276 ---- } ! public int sharesOwnedByPlayers() { ! int shares = 0; for (PublicCertificateI cert : certificates) { if (cert.getPortfolio().getOwner() instanceof Player) { ! shares += cert.getShares(); } } ! return shares; } *************** *** 1592,1595 **** --- 1616,1652 ---- } + public int getCurrentNumberOfLoans() { + return currentNumberOfLoans.intValue(); + } + + public int getCurrentLoanValue () { + return getCurrentNumberOfLoans() * getValuePerLoan(); + } + + public void addLoans(int number) { + currentNumberOfLoans.add(number); + currentLoanValue.add(number * getValuePerLoan()); + } + + public int getLoanInterestPct() { + return loanInterestPct; + } + + public int getMaxNumberOfLoans() { + return maxNumberOfLoans; + } + + public int getMaxLoansPerRound() { + return maxLoansPerRound; + } + + public int getValuePerLoan() { + return valuePerLoan; + } + + public MoneyModel getLoanValueModel () { + return currentLoanValue; + } + @Override public Object clone() { Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** GameManager.java 3 Jan 2009 22:51:35 -0000 1.38 --- GameManager.java 11 Jan 2009 17:24:46 -0000 1.39 *************** *** 84,87 **** --- 84,89 ---- protected boolean canAnyCompanyHoldShares = false; protected boolean bonusTokensExist = false; + protected boolean hasAnyCompanyLoans = false; + protected int stockRoundSequenceRule = StockRound.SELL_BUY_SELL; *************** *** 323,326 **** --- 325,329 ---- canAnyCompanyBuyPrivates = canAnyCompanyBuyPrivates || company.canBuyPrivates(); canAnyCompanyHoldShares = canAnyCompanyHoldShares || company.canHoldOwnShares(); + hasAnyCompanyLoans = hasAnyCompanyLoans || company.getMaxNumberOfLoans() != 0; } *************** *** 482,486 **** return new Integer(numOfORs).toString(); } ! /* (non-Javadoc) * @see rails.game.GameManagerI#getSRNumber() --- 485,489 ---- return new Integer(numOfORs).toString(); } ! /* (non-Javadoc) * @see rails.game.GameManagerI#getSRNumber() *************** *** 940,943 **** --- 943,948 ---- case DO_BONUS_TOKENS_EXIST: return bonusTokensExist; + case HAS_ANY_COMPANY_LOANS: + return hasAnyCompanyLoans; default: return null; Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PublicCompanyI.java 3 Dec 2008 20:15:15 -0000 1.26 --- PublicCompanyI.java 11 Jan 2009 17:24:46 -0000 1.27 *************** *** 15,23 **** public static final int CAPITALISE_INCREMENTAL = 1; ! public static final int CAPITALISE_WHEN_BOUGHT = 2; public void init2() throws ConfigurationException; ! public void setIndex (int index); --- 15,23 ---- public static final int CAPITALISE_INCREMENTAL = 1; ! public static final int CAPITALISE_WHEN_BOUGHT = 2; public void init2() throws ConfigurationException; ! public void setIndex (int index); *************** *** 25,29 **** /** * Return the company token background colour. ! * * @return Color object */ --- 25,29 ---- /** * Return the company token background colour. ! * * @return Color object */ *************** *** 32,36 **** /** * Return the company token background colour. ! * * @return Hexadecimal string RRGGBB. */ --- 32,36 ---- /** * Return the company token background colour. ! * * @return Hexadecimal string RRGGBB. */ *************** *** 39,43 **** /** * Return the company token foreground colour. ! * * @return Color object. */ --- 39,43 ---- /** * Return the company token foreground colour. ! * * @return Color object. */ *************** *** 47,51 **** /** * Return the company token foreground colour. ! * * @return Hexadecimal string RRGGBB. */ --- 47,51 ---- /** * Return the company token foreground colour. ! * * @return Hexadecimal string RRGGBB. */ *************** *** 89,93 **** /** * Has the company already floated? ! * * @return true if the company has floated. */ --- 89,93 ---- /** * Has the company already floated? ! * * @return true if the company has floated. */ *************** *** 97,101 **** /** * Has the company already operated? ! * * @return true if the company has operated. */ --- 97,101 ---- /** * Has the company already operated? ! * * @return true if the company has operated. */ *************** *** 106,110 **** /** * Start the company and set its initial (par) price. ! * * @param spaceI */ --- 106,110 ---- /** * Start the company and set its initial (par) price. ! * * @param spaceI */ *************** *** 114,118 **** /** * Get the company par (initial) price. ! * * @return StockSpace object, which defines the company start position on * the stock chart. --- 114,118 ---- /** * Get the company par (initial) price. ! * * @return StockSpace object, which defines the company start position on * the stock chart. *************** *** 122,126 **** /** * Set a new company price. ! * * @param price The StockSpace object that defines the new location on the * stock market. --- 122,126 ---- /** * Set a new company price. ! * * @param price The StockSpace object that defines the new location on the * stock market. *************** *** 130,134 **** /** * Get the current company share price. ! * * @return The StockSpace object that defines the current location on the * stock market. --- 130,134 ---- /** * Get the current company share price. ! * * @return The StockSpace object that defines the current location on the * stock market. *************** *** 143,147 **** public int getIPOPrice (); ! public int getMarketPrice (); --- 143,147 ---- public int getIPOPrice (); ! public int getMarketPrice (); *************** *** 158,162 **** /** * Get a list of this company's certificates. ! * * @return ArrayList containing the certificates (item 0 is the President's * share). --- 158,162 ---- /** * Get a list of this company's certificates. ! * * @return ArrayList containing the certificates (item 0 is the President's * share). *************** *** 166,170 **** /** * Assign a predefined array of certificates to this company. ! * * @param list ArrayList containing the certificates. */ --- 166,170 ---- /** * Assign a predefined array of certificates to this company. ! * * @param list ArrayList containing the certificates. */ *************** *** 173,177 **** /** * Add a certificate to the end of this company's list of certificates. ! * * @param certificate The certificate to add. */ --- 173,177 ---- /** * Add a certificate to the end of this company's list of certificates. ! * * @param certificate The certificate to add. */ *************** *** 181,185 **** * Get the current company treasury. <p> <i>Note: other cash-related methods * are declared in interface CashHolder </i> ! * * @return The current cash amount. */ --- 181,185 ---- * Get the current company treasury. <p> <i>Note: other cash-related methods * are declared in interface CashHolder </i> ! * * @return The current cash amount. */ *************** *** 192,196 **** /** * Get the last revenue earned by this company. ! * * @return The last revenue amount. */ --- 192,196 ---- /** * Get the last revenue earned by this company. ! * * @return The last revenue amount. */ *************** *** 206,210 **** public Player getPresident(); ! public PublicCertificateI getPresidentsShare(); --- 206,210 ---- public Player getPresident(); ! public PublicCertificateI getPresidentsShare(); *************** *** 223,227 **** /** * Get the unit of share. ! * * @return The percentage of ownership that is called "one share". */ --- 223,227 ---- /** * Get the unit of share. ! * * @return The percentage of ownership that is called "one share". */ *************** *** 240,244 **** /** * Is company present on the Stock Market? ! * * @return True if the company has a stock price. */ --- 240,244 ---- /** * Is company present on the Stock Market? ! * * @return True if the company has a stock price. */ *************** *** 322,329 **** public boolean hasReachedDestination(); public void setReachedDestination (boolean value); ! public int getNumberOfTileLays(String tileColour); public boolean mustOwnATrain(); } --- 322,339 ---- public boolean hasReachedDestination(); public void setReachedDestination (boolean value); ! public int getNumberOfTileLays(String tileColour); public boolean mustOwnATrain(); + public int getCurrentNumberOfLoans(); + public int getCurrentLoanValue (); + public void addLoans(int number); + public int getLoanInterestPct(); + public int getMaxNumberOfLoans(); + public int getMaxLoansPerRound(); + public int getValuePerLoan(); + public MoneyModel getLoanValueModel (); + + public int sharesOwnedByPlayers(); } Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** OperatingRound.java 3 Jan 2009 18:24:53 -0000 1.49 --- OperatingRound.java 11 Jan 2009 17:24:46 -0000 1.50 *************** *** 6,9 **** --- 6,10 ---- import rails.game.action.*; import rails.game.move.CashMove; + import rails.game.move.MapChange; import rails.game.move.MoveSet; import rails.game.special.*; *************** *** 56,59 **** --- 57,62 ---- protected List<TrainTypeI> trainsBoughtThisTurn = new ArrayList<TrainTypeI>(4); + + protected Map<PublicCompanyI, Integer> loansThisRound = null; protected PhaseI currentPhase; *************** *** 207,210 **** --- 210,217 ---- result = reachDestinations ((ReachDestinations) selectedAction); + + } else if (selectedAction instanceof TakeLoans) { + + result = takeLoans((TakeLoans) selectedAction); } else if (selectedAction instanceof NullAction) { *************** *** 1490,1494 **** --- 1497,1602 ---- } + + protected boolean takeLoans (TakeLoans action) { + + String errMsg = validateTakeLoans (action); + + if (errMsg != null) { + DisplayBuffer.add(LocalText.getText("CannotTakeLoans", + action.getCompanyName(), + action.getNumberTaken(), + action.getPrice(), + errMsg)); + + return false; + } + + MoveSet.start(true); + + executeTakeLoans (action); + + return true; + + } + + protected String validateTakeLoans (TakeLoans action) { + + String errMsg = null; + PublicCompanyI company = action.getCompany(); + String companyName = company.getName(); + int number = action.getNumberTaken(); + + // Dummy loop to enable a quick jump out. + while (true) { + + // Checks + // Is company operating? + if (company != operatingCompany) { + errMsg = + LocalText.getText("WrongCompany", + companyName, + action.getCompanyName()); + break; + } + // Does company allow any loans? + if (company.getMaxNumberOfLoans() == 0) { + errMsg = LocalText.getText("LoansNotAllowed", + companyName); + break; + } + // Does the company exceed the maximum number of loans? + if (company.getMaxNumberOfLoans() > 0 + && company.getCurrentNumberOfLoans() + number > + company.getMaxNumberOfLoans()) { + errMsg = + LocalText.getText("MoreLoansNotAllowed", + companyName, + company.getMaxNumberOfLoans()); + break; + } + break; + } + return errMsg; + } + + protected void executeTakeLoans (TakeLoans action) { + + int number = action.getNumberTaken(); + int amount = calculateLoanAmount (number); + operatingCompany.addLoans(number); + new CashMove (null, operatingCompany, amount); + if (number == 1) { + ReportBuffer.add(LocalText.getText("CompanyTakesLoan", + operatingCompany.getName(), + Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(amount) + )); + } else { + ReportBuffer.add(LocalText.getText("CompanyTakesLoans", + operatingCompany.getName(), + number, + Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(amount) + )); + } + + if (operatingCompany.getMaxLoansPerRound() > 0) { + int oldLoansThisRound = 0; + if (loansThisRound == null) { + loansThisRound = new HashMap<PublicCompanyI, Integer>(); + } else if (loansThisRound.containsKey(operatingCompany)){ + oldLoansThisRound = loansThisRound.get(operatingCompany); + } + new MapChange<PublicCompanyI, Integer> (loansThisRound, + operatingCompany, + new Integer (oldLoansThisRound + number)); + } + } + + protected int calculateLoanAmount (int numberOfLoans) { + return numberOfLoans * operatingCompany.getValuePerLoan(); + } + /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ *************** *** 1846,1849 **** --- 1954,1985 ---- } + + public void repayLoans (int number) { + operatingCompany.addLoans(-number); + int amount = number * operatingCompany.getValuePerLoan(); + new CashMove (operatingCompany, null, amount); + DisplayBuffer.add(LocalText.getText("CompanyRepaysLoan", + new String[] { + operatingCompany.getName(), + String.valueOf(number), + Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(amount) + })); + } + + public void payLoanInterest () { + int amount = operatingCompany.getCurrentLoanValue() + * operatingCompany.getLoanInterestPct() / 100; + new CashMove (operatingCompany, null, amount); + DisplayBuffer.add(LocalText.getText("CompanyPaysLoanInterest", + new String[] { + operatingCompany.getName(), + Bank.format(amount), + String.valueOf(operatingCompany.getLoanInterestPct()), + String.valueOf(operatingCompany.getCurrentNumberOfLoans()), + Bank.format(operatingCompany.getValuePerLoan()), + })); + } + /* TODO This is just a start of a possible approach to a Help system */ Index: PhaseManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PhaseManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PhaseManager.java 30 Jun 2008 20:35:29 -0000 1.12 --- PhaseManager.java 11 Jan 2009 17:24:46 -0000 1.13 *************** *** 76,85 **** } ! public PhaseI getPhaseNyName(String name) { return phaseMap.get(name); } public boolean hasReachedPhase(String phaseName) { ! return getCurrentPhase().getIndex() >= getPhaseNyName(phaseName).getIndex(); } --- 76,85 ---- } ! public PhaseI getPhaseByName(String name) { return phaseMap.get(name); } public boolean hasReachedPhase(String phaseName) { ! return getCurrentPhase().getIndex() >= getPhaseByName(phaseName).getIndex(); } Index: BonusToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/BonusToken.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BonusToken.java 4 Jun 2008 19:00:31 -0000 1.7 --- BonusToken.java 11 Jan 2009 17:24:46 -0000 1.8 *************** *** 71,75 **** if (spec[0].equalsIgnoreCase("Phase")) { removingObject = ! PhaseManager.getInstance().getPhaseNyName(spec[1]); } } --- 71,75 ---- if (spec[0].equalsIgnoreCase("Phase")) { removingObject = ! PhaseManager.getInstance().getPhaseByName(spec[1]); } } |
From: Erik V. <ev...@us...> - 2009-01-11 17:24:58
|
Update of /cvsroot/rails/18xx/rails/game/action In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543/rails/game/action Added Files: TakeLoans.java RepayLoans.java Log Message: Basic loans taking and specific rules for 1856. --- NEW FILE: RepayLoans.java --- /* $Header: /cvsroot/rails/18xx/rails/game/action/RepayLoans.java,v 1.1 2009/01/11 17:24:46 evos Exp $ * * Created on 17-Sep-2006 * Change Log: */ package rails.game.action; import java.io.IOException; import java.io.ObjectInputStream; import rails.game.Game; import rails.game.PublicCompanyI; /** * @author Erik Vos */ public class RepayLoans extends PossibleORAction { // Initial attributes transient private PublicCompanyI company; private String companyName; private int maxNumber; private int price; // User-assigned attributes private int numberRepaid = 0; public static final long serialVersionUID = 1L; /** * */ public RepayLoans(PublicCompanyI company, int maxNumber, int price) { this.company = company; this.companyName = company.getName(); this.maxNumber = maxNumber; this.price = price; } /** * @return Returns the minimumPrice. */ public int getMaxNumber() { return maxNumber; } /** * @return Returns the company. */ @Override public PublicCompanyI getCompany() { return company; } public int getPrice() { return price; } public void setNumberTaken(int numberRepaid) { this.numberRepaid = numberRepaid; } @Override public boolean equals(PossibleAction action) { if (!(action instanceof RepayLoans)) return false; RepayLoans a = (RepayLoans) action; return a.company == company && a.maxNumber == maxNumber && a.price == price; } @Override public String toString() { StringBuffer b = new StringBuffer(); b.append ("RepayLoans ").append(company.getName()) .append(" maxNumber=").append(maxNumber) .append(" value=").append(price); if (numberRepaid != 0) { b.append(" numberRepaid="+numberRepaid); } return b.toString(); } /** Deserialize */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); company = Game.getCompanyManager().getPublicCompany(companyName); } } --- NEW FILE: TakeLoans.java --- /* $Header: /cvsroot/rails/18xx/rails/game/action/TakeLoans.java,v 1.1 2009/01/11 17:24:46 evos Exp $ * * Created on 17-Sep-2006 * Change Log: */ package rails.game.action; import java.io.IOException; import java.io.ObjectInputStream; import rails.game.Game; import rails.game.PublicCompanyI; /** * @author Erik Vos */ public class TakeLoans extends PossibleORAction { // Initial attributes transient private PublicCompanyI company; private String companyName; private int maxNumber; private int price; // User-assigned attributes private int numberTaken = 0; public static final long serialVersionUID = 1L; /** * */ public TakeLoans(PublicCompanyI company, int maxNumber, int price) { this.company = company; this.companyName = company.getName(); this.maxNumber = maxNumber; this.price = price; } /** * @return Returns the minimumPrice. */ public int getMaxNumber() { return maxNumber; } /** * @return Returns the company. */ @Override public PublicCompanyI getCompany() { return company; } public int getPrice() { return price; } public void setNumberTaken(int numberTaken) { this.numberTaken = numberTaken; } public int getNumberTaken() { return numberTaken; } @Override public boolean equals(PossibleAction action) { if (!(action instanceof TakeLoans)) return false; TakeLoans a = (TakeLoans) action; return a.company == company && a.maxNumber == maxNumber && a.price == price; } @Override public String toString() { StringBuffer b = new StringBuffer(); b.append ("TakeLoans ").append(company.getName()) .append(" maxNumber=").append(maxNumber) .append(" value=").append(price); if (numberTaken != 0) { b.append(" numberTaken="+numberTaken); } return b.toString(); } /** Deserialize */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); company = Game.getCompanyManager().getPublicCompany(companyName); } } |
From: Erik V. <ev...@us...> - 2009-01-11 17:24:58
|
Update of /cvsroot/rails/18xx In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543 Modified Files: LocalisedText.properties Log Message: Basic loans taking and specific rules for 1856. Index: LocalisedText.properties =================================================================== RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** LocalisedText.properties 8 Jan 2009 19:59:39 -0000 1.64 --- LocalisedText.properties 11 Jan 2009 17:24:46 -0000 1.65 *************** *** 63,66 **** --- 63,67 ---- CannotSplitRevenue={0} cannot split revenue of {1}: {2} CannotSwapPrivateForCertificate={0} cannot swap private {1} for a {2}% share of {3}: {3}. + CannotTakeLoans={0} cannot take {1} loan(s) of {2}: {3} CannotWithholdRevenue={0} cannot withhold revenue of {1}: {2} CantBuy={0} cannot buy {1} share(s) of {2} from {3}: {4} *************** *** 79,88 **** CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train ! CompanyHasNoType=Company {0} has no type defined. ! CompanyHasUnknownType=Company {0} has an undefined type {1}. ! CompanyMustOwnATrain={0} must own a train. ! CompanyPaysOutFull={0} pays out full dividend of {1}. ! CompanyRevenue={0} earns {1}. ! CompanySplits={0} splits dividend of {1}. CompanyTypeConfiguredTwice=Company type {0} configured twice. CompanyTypeHasNoClass=Company type {0} has no class defined. --- 80,93 ---- CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train ! CompanyHasNoType=Company {0} has no type defined ! CompanyHasUnknownType=Company {0} has an undefined type {1} ! CompanyMustOwnATrain={0} must own a train ! CompanyPaysLoanInterest={0} pays {1} as {2}% interest over {3} loans of {4} ! CompanyPaysOutFull={0} pays out full dividend of {1} ! CompanyRepaysLoan={0} repays {1} loan(s) of {2} for {3} ! CompanyRevenue={0} earns {1} ! CompanySplits={0} splits dividend of {1} ! CompanyTakesLoan={0} takes a loan of {1} and receives {2} ! CompanyTakesLoans={0} takes {1} loans of {2} and receives {3} CompanyTypeConfiguredTwice=Company type {0} configured twice. CompanyTypeHasNoClass=Company type {0} has no class defined. *************** *** 172,175 **** --- 177,181 ---- LAY_TRACK=Lay Track LIMIT=Limit + LOANS=Loans LayBonusToken=Lay {0} at {1} LaysBonusTokenOn={0} lays a {1} +{2} bonus token on {3} *************** *** 180,183 **** --- 186,190 ---- LoadFailed=Load failed, reason: {0} LoadGame=Load Game + LoansNotAllowed={0} may not take any loans MAP=Map MapWindowTitle=Rails: Map *************** *** 191,194 **** --- 198,202 ---- MinorCloses=Minor {0} is closed MonetiseTreasuryShares={0} puts 5 shares from Treasury in the Pool and receives {1} from the Bank + MoreLoansNotAllowed={0} would exceed loans limit of {1} PaysTo={0} pays {1} to {2} MOVE=Move *************** *** 244,247 **** --- 252,256 ---- PRICE_STAYS_LOG={0} price stays at {1}({2}). PRIVATES=Privates + PaysLoanInterest={0} pays {1} interest for outstanding loans PlayerCash=Each player receives {0} from the Bank. PlayerDoesNotOwn=Player {0} does not own {1} *************** *** 265,268 **** --- 274,278 ---- ReleasedFromEscrow={0} receives {1} released from bank escrow RemainingTiles=Remaining tiles + RepayLoans=Repay loan(s) REPORT=Report Window REVENUE=Revenue *************** *** 336,339 **** --- 346,351 ---- N_Train={0}-train TRAINS=Trains + TakeLoanPrompt=Will {0} take a loan of {1}? + TakeLoans=Take loan(s) ThisItemIsAuctionedNow=This item is auctioned now TileAlreadyHasToken=Tile {0} already has a base token of company {1} *************** *** 385,388 **** --- 397,401 ---- WouldExceedHoldLimit=Would exceed holding limit of {0}%. WouldExceedTrainLimit=Would exceed train limit of {0} + WouldExceedSharesAtPlayers=Number of loans ({0}) would exceed number of shares in player hands ({1}) WrongActionNoDiscardTrain=Wrong action, expected discarded train WrongActionNoDividend=Wrong action, expected dividend assignment *************** *** 392,395 **** --- 405,409 ---- WrongActionNoTrainBuyingCost=Wrong action, expected train buying cost WrongCompany=Wrong company: {0} (expected {1}) + WrongPhase=Wrong phase {0} WrongPlayer=Wrong player {0} - {1} has the turn WrongStartItem=Wrong start item {0}, expected {1} |
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; + } } |
From: Erik V. <ev...@us...> - 2009-01-11 17:24:57
|
Update of /cvsroot/rails/18xx/data/1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543/data/1856 Modified Files: CompanyManager.xml Log Message: Basic loans taking and specific rules for 1856. Index: CompanyManager.xml =================================================================== RCS file: /cvsroot/rails/18xx/data/1856/CompanyManager.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** CompanyManager.xml 20 Nov 2008 21:44:26 -0000 1.23 --- CompanyManager.xml 11 Jan 2009 17:24:46 -0000 1.24 *************** *** 14,17 **** --- 14,19 ---- </BaseTokens> <Trains number="4,4,3,2"/> + <Loans value="100" perRound="1" interest="10"/> + <!-- Number of loans is undefined and handled in the code --> </CompanyType> |
From: Erik V. <ev...@us...> - 2009-01-11 17:24:54
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6543/rails/game/move Added Files: MapChange.java Log Message: Basic loans taking and specific rules for 1856. --- NEW FILE: MapChange.java --- /* $Header: /cvsroot/rails/18xx/rails/game/move/MapChange.java,v 1.1 2009/01/11 17:24:46 evos Exp $ * * Created on 19-Jul-2006 * Change Log: */ package rails.game.move; import java.util.HashMap; import java.util.Map; /** * This Move class handles adding an entry to a 2-D Map (a Map of Maps, or a * matrix). An Undo will remove the second key, but not the first key. * * @author Erik Vos */ public class MapChange<K, V> extends Move { protected Map<K, V> map; protected K key; protected V newValue; protected V oldValue; protected boolean keyExisted; public MapChange (Map<K, V> map, K key, V newValue) { this.map = map; this.key = key; this.newValue = newValue; this.oldValue = map.get(key); this.keyExisted = map.containsKey(key); MoveSet.add(this); } public boolean execute() { map.put(key, newValue); return true; } public boolean undo() { if (keyExisted) { map.put (key, oldValue); } else { map.remove(key); } return true; } } |