From: Stefan F. <ste...@us...> - 2010-03-04 21:17:06
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10478/rails/game Modified Files: StockRound.java Log Message: Fix of incorrect change of director if several candidates are available (bug 2962977) Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** StockRound.java 28 Feb 2010 21:38:05 -0000 1.65 --- StockRound.java 4 Mar 2010 21:16:56 -0000 1.66 *************** *** 948,968 **** && numberToSell <= presCert.getShares()) { // More to sell and we are President: see if we can dump it. ! Player otherPlayer; for (int i = currentIndex + 1; i < currentIndex + numberOfPlayers; i++) { ! otherPlayer = gameManager.getPlayerByIndex(i); ! if (otherPlayer.getPortfolio().getShare(company) >= presCert.getShare()) { // Check if he has the right kind of share if (numberToSell > 1 || otherPlayer.getPortfolio().ownsCertificates( company, 1, false) >= 1) { ! // The poor sod. ! dumpedPlayer = otherPlayer; ! presSharesToSell = numberToSell; ! numberToSell = 0; ! break; } } } } // Check if we could sell them all --- 948,972 ---- && numberToSell <= presCert.getShares()) { // More to sell and we are President: see if we can dump it. ! // search for the player with the most shares (fix of bug 2962977) ! int requiredShares = presCert.getShare(); ! Player potentialDirector = null; for (int i = currentIndex + 1; i < currentIndex + numberOfPlayers; i++) { ! Player otherPlayer = gameManager.getPlayerByIndex(i); ! int otherPlayerShares = otherPlayer.getPortfolio().getShare(company); ! if (otherPlayerShares >= requiredShares) { // Check if he has the right kind of share if (numberToSell > 1 || otherPlayer.getPortfolio().ownsCertificates( company, 1, false) >= 1) { ! potentialDirector = otherPlayer; ! requiredShares = otherPlayerShares + 1; } } } + // The poor sod. + dumpedPlayer = potentialDirector; + presSharesToSell = numberToSell; + numberToSell = 0; } // Check if we could sell them all |