From: Martin B. <dr....@t-...> - 2013-10-20 20:54:09
|
Am 15.10.2013 15:58, schrieb Erik Vos: > Stefan, > > Prussian operation looks correct to me, it's the payout process that gets > mangled. > Here I have tried to implement the rule that one share can never earn income > twice in an OR. > > The problem surfaces in OperatingRound_1835.countSharesPerRecipient(), where > a subtraction occurs. > I guess there is some error in handling the sharesPerRecipient and/or > deniedIncomeShare maps. > One point to note is that Stan occurs twice in the payout report of the PR > turn. That looks wrong too, and may be a starting point for analysis. > > Erik > > Hi Erik & Stefan, protected Map<CashHolder, Integer> countSharesPerRecipient () { Map<CashHolder, Integer> sharesPerRecipient = super.countSharesPerRecipient(); if (operatingCompany.get().getName().equalsIgnoreCase(GameManager_1835.PR_ID)) { for (Player player : deniedIncomeShare.keySet()) { if (!sharesPerRecipient.containsKey(player)) continue; int share = deniedIncomeShare.get(player); int shares = share / operatingCompany.get().getShareUnit(); sharesPerRecipient.put (player, sharesPerRecipient.get(player) - shares); ReportBuffer.add(LocalText.getText("NoIncomeForPreviousOperation", player.getName(), share, GameManager_1835.PR_ID)); The Map sharesPerRecipient contains the actual exchanged Prussian shares plus the IPO shares. The map deniedIncomeShare contains the Shares that have operated that round and are NOT included in sharesPerRecipient. So by subtracting those from the SharesPerRecipient in this case (shares have not been exchanged..) its bringing wrong results. protected void initTurn() { super.initTurn(); List<SpecialPropertyI> sps = operatingCompany.get().getSpecialProperties(); if (sps != null && !sps.isEmpty()) { ExchangeForShare efs = (ExchangeForShare) sps.get(0); addIncomeDenialShare (operatingCompany.get().getPresident(), efs.getShare()); } } Here the code adds the shares related to the Minors (still operating) to the DeniedShares but ... nowhere is checked if those are exchanged later on and thus land as Prussianshares in the wallet of the players. What should be done then is on Prussian starting to operate if those deniedshares are still operating and then clear the map deniedIncomeShares, or reduce the amount if not all shares are converted... I think i found a solution here... Map<CashHolder, Integer> sharesPerRecipient = super.countSharesPerRecipient(); if (operatingCompany.get().getName().equalsIgnoreCase(GameManager_1835.PR_ID)) { for (Player player : deniedIncomeShare.keySet()) { if (!sharesPerRecipient.containsKey(player)) continue; int share = deniedIncomeShare.get(player); int shares = share / operatingCompany.get().getShareUnit(); -->>>> if (this.wasInterrupted()) { //Assuming that an OR Interruption was caused by a Formationround for the Prussian.. sharesPerRecipient.put (player, sharesPerRecipient.get(player) - shares); ReportBuffer.add(LocalText.getText("NoIncomeForPreviousOperation", player.getName(), share, GameManager_1835.PR_ID)); } Only then count the deniedshares against shares in the wallet. Comments ? Regards, Martin |