From: Erik V. <ev...@us...> - 2009-10-29 19:40:50
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6135/rails/game Modified Files: PublicCompany.java Log Message: Payments are rounded up Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** PublicCompany.java 9 Oct 2009 20:20:34 -0000 1.68 --- PublicCompany.java 29 Oct 2009 19:40:31 -0000 1.69 *************** *** 22,26 **** */ public class PublicCompany extends Company implements PublicCompanyI { ! protected static final int DEFAULT_SHARE_UNIT = 10; --- 22,26 ---- */ public class PublicCompany extends Company implements PublicCompanyI { ! protected static final int DEFAULT_SHARE_UNIT = 10; *************** *** 1215,1235 **** int part; ! Map<CashHolder, Integer> split = new HashMap<CashHolder, Integer>(); for (PublicCertificateI cert : certificates) { CashHolder recipient = getBeneficiary(cert); ! part = amount * cert.getShares() * shareUnit.intValue() / 100; ! // For reporting, we want to add up the amounts per recipient ! if (split.containsKey(recipient)) { ! part += (split.get(recipient)).intValue(); } - split.put(recipient, new Integer(part)); } ! // Report and add the cash ! for (CashHolder recipient : split.keySet()) { if (recipient instanceof Bank) continue; ! part = (split.get(recipient)).intValue(); ! ReportBuffer.add(recipient.getName() + " receives " ! + Bank.format(part)); new CashMove(bank, recipient, part); } --- 1215,1246 ---- int part; ! int shares; ! Map<CashHolder, Integer> sharesPerRecipient = new HashMap<CashHolder, Integer>(); + // Changed to accomodate the CGR 5% share roundup rule. + // For now it is assumed, that actual payouts are always rounded up + // (the withheld half of split revenues is not handled here, see splitRevenue()). + + // First count the shares per recipient for (PublicCertificateI cert : certificates) { CashHolder recipient = getBeneficiary(cert); ! if (!sharesPerRecipient.containsKey(recipient)) { ! sharesPerRecipient.put(recipient, cert.getShares()); ! } else { ! sharesPerRecipient.put(recipient, ! sharesPerRecipient.get(recipient) + cert.getShares()); } } ! ! // Calculate, round up, report and add the cash ! for (CashHolder recipient : sharesPerRecipient.keySet()) { if (recipient instanceof Bank) continue; ! shares = (sharesPerRecipient.get(recipient)); ! part = (int) Math.ceil(amount * shares * shareUnit.intValue() / 100.0); ! ReportBuffer.add(LocalText.getText("Payout", ! recipient.getName(), ! Bank.format(part), ! shares, ! shareUnit.intValue())); new CashMove(bank, recipient, part); } *************** *** 1237,1241 **** // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove || amount >= currentPrice.getPrice().getPrice())) { stockMarket.payOut(this); --- 1248,1252 ---- // Move the token if (hasStockPrice ! && (!payoutMustExceedPriceToMove || amount >= currentPrice.getPrice().getPrice())) { stockMarket.payOut(this); |