From: Erik V. <ev...@us...> - 2010-04-02 20:04:03
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv8876/rails/game Modified Files: StockRound.java Log Message: 1835 Nationalisation Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** StockRound.java 27 Mar 2010 18:27:08 -0000 1.71 --- StockRound.java 2 Apr 2010 20:03:54 -0000 1.72 *************** *** 265,269 **** number = 1; /* Would the player exceed the per-company share hold limit? */ ! if (!mayPlayerBuyCompanyShare(currentPlayer, comp, number)) continue; /* Would the player exceed the total certificate limit? */ --- 265,269 ---- number = 1; /* Would the player exceed the per-company share hold limit? */ ! if (!checkAgainstHoldLimit(currentPlayer, comp, number)) continue; /* Would the player exceed the total certificate limit? */ *************** *** 296,300 **** cert = certs.get(0); if (isSaleRecorded(currentPlayer, company)) continue; ! if (!mayPlayerBuyCompanyShare(currentPlayer, company, 1)) continue; if (maxAllowedNumberOfSharesToBuy(currentPlayer, company, certs.get(0).getShare()) < 1) continue; --- 296,300 ---- cert = certs.get(0); if (isSaleRecorded(currentPlayer, company)) continue; ! if (!checkAgainstHoldLimit(currentPlayer, company, 1)) continue; if (maxAllowedNumberOfSharesToBuy(currentPlayer, company, certs.get(0).getShare()) < 1) continue; *************** *** 741,752 **** // Check if player would exceed the per-company share limit if (!currentSpace.isNoHoldLimit() ! && !mayPlayerBuyCompanyShare(currentPlayer, company, shares)) { ! errMsg = ! currentPlayer.getName() ! + LocalText.getText("WouldExceedHoldLimit"); break; } ! price = currentSpace.getPrice(); cost = shares * price / company.getShareUnitsForSharePrice(); --- 741,753 ---- // Check if player would exceed the per-company share limit if (!currentSpace.isNoHoldLimit() ! && !checkAgainstHoldLimit(currentPlayer, company, shares)) { ! errMsg = LocalText.getText("WouldExceedHoldLimit", ! currentPlayer.getName(), ! GameDef.Parm.PLAYER_SHARE_LIMIT.defaultValueAsInt()); break; } ! //price = currentSpace.getPrice(); ! price = getBuyPrice (action, currentSpace); cost = shares * price / company.getShareUnitsForSharePrice(); *************** *** 833,836 **** --- 834,842 ---- } + + /** Allow different price setting in subclasses (i.e. 1835 Nationalisation) */ + protected int getBuyPrice (BuyCertificate action, StockSpaceI currentSpace) { + return currentSpace.getPrice(); + } /** *************** *** 1143,1147 **** } /* Check if the player has room for a share of this company */ ! if (!mayPlayerBuyCompanyShare(player, publicCompany, 1)) { // TODO: Not nice to use '1' here, should be percentage. errMsg = --- 1149,1153 ---- } /* Check if the player has room for a share of this company */ ! if (!checkAgainstHoldLimit(player, publicCompany, 1)) { // TODO: Not nice to use '1' here, should be percentage. errMsg = *************** *** 1364,1368 **** for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() ! && !mayPlayerBuyCompanyShare(player, company, 0)) return true; } --- 1370,1374 ---- for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() ! && !checkAgainstHoldLimit(player, company, 0)) return true; } *************** *** 1390,1398 **** * 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). * @return True if it is allowed. */ ! public boolean mayPlayerBuyCompanyShare(Player player, PublicCompanyI company, int number) { // Check for per-company share limit if (player.getPortfolio().getShare(company) --- 1396,1406 ---- * shares of one company that a player may hold (typically 60%). * + * @param player the buying player * @param company The company from which to buy ! * @param number The number of shares (usually 1 but not always so) * @return True if it is allowed. */ ! public boolean checkAgainstHoldLimit(Player player, PublicCompanyI company, ! int number) { // Check for per-company share limit if (player.getPortfolio().getShare(company) |