From: <ste...@us...> - 2010-07-11 16:44:35
|
Revision: 1337 http://rails.svn.sourceforge.net/rails/?rev=1337&view=rev Author: stefanfrey Date: 2010-07-11 16:44:29 +0000 (Sun, 11 Jul 2010) Log Message: ----------- Bug 3010534: 1856 1/2 share from limit can't buy 5% share of CGR Fixed now, previous checks assumed that each certificates counts a full slot. Modified Paths: -------------- trunk/18xx/rails/game/StockRound.java Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-07-11 16:40:44 UTC (rev 1336) +++ trunk/18xx/rails/game/StockRound.java 2010-07-11 16:44:29 UTC (rev 1337) @@ -184,7 +184,13 @@ unitsForPrice = comp.getShareUnitsForSharePrice(); if (isSaleRecorded(currentPlayer, comp)) continue; if (maxAllowedNumberOfSharesToBuy(currentPlayer, comp, - cert.getShare()) < 1) continue; + cert.getShare()) < 1 ) continue; + + /* Would the player exceed the total certificate limit? */ + stockSpace = comp.getCurrentSpace(); + if ((stockSpace == null || !stockSpace.isNoCertLimit()) && !mayPlayerBuyCertificate( + currentPlayer, comp, cert.getCertificateCount())) continue; + shares = cert.getShares(); if (!cert.isPresidentShare()) { @@ -279,7 +285,8 @@ /* Would the player exceed the total certificate limit? */ if (!stockSpace.isNoCertLimit() - && !mayPlayerBuyCertificate(currentPlayer, comp, number)) + && !mayPlayerBuyCertificate(currentPlayer, comp, + number * uniqueCerts[shares].getCertificateCount())) continue; } @@ -742,7 +749,7 @@ // Check if player would not exceed the certificate limit. // (shortcut: assume 1 cert == 1 certificate) if (!currentSpace.isNoCertLimit() - && !mayPlayerBuyCertificate(currentPlayer, company, number)) { + && !mayPlayerBuyCertificate(currentPlayer, company, number * cert.getCertificateCount())) { errMsg = currentPlayer.getName() + LocalText.getText("WouldExceedCertLimit", @@ -1401,7 +1408,7 @@ * so). * @return True if it is allowed. */ - public boolean mayPlayerBuyCertificate(Player player, PublicCompanyI comp, int number) { + public boolean mayPlayerBuyCertificate(Player player, PublicCompanyI comp, float number) { if (comp.hasFloated() && comp.getCurrentSpace().isNoCertLimit()) return true; if (player.getPortfolio().getCertificateCount() + number > gameManager.getPlayerCertificateLimit(player)) @@ -1454,7 +1461,9 @@ company.getCurrentSpace().isNoHoldLimit() ? 100 : playerShareLimit; } - return (limit - player.getPortfolio().getShare(company)) / shareSize; + int maxAllowed = (limit - player.getPortfolio().getShare(company)) / shareSize; +// log.debug("MaxAllowedNumberOfSharesToBuy = " + maxAllowed + " for company = " + company + " shareSize " + shareSize); + return maxAllowed; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |