From: Erik V. <ev...@us...> - 2009-11-06 20:23:01
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6106/rails/game Modified Files: StockRound.java Log Message: Fix brown share buying cost problem Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** StockRound.java 31 Oct 2009 17:08:26 -0000 1.48 --- StockRound.java 6 Nov 2009 20:22:44 -0000 1.49 *************** *** 447,450 **** --- 447,451 ---- PublicCertificateI cert = null; String companyName = company.getName(); + int cost = 0; currentPlayer = getCurrentPlayer(); *************** *** 508,512 **** // Check if the Player has the money. ! if (currentPlayer.getCash() < shares * price) { errMsg = LocalText.getText("NoMoney"); break; --- 509,514 ---- // Check if the Player has the money. ! cost = shares * price; ! if (currentPlayer.getCash() < cost) { errMsg = LocalText.getText("NoMoney"); break; *************** *** 533,538 **** // Transfer the President's certificate ! executeTradeCertificate(cert, currentPlayer.getPortfolio(), ! price * cert.getShares(), priceRecipient); // If more than one certificate is bought at the same time, transfer --- 535,540 ---- // Transfer the President's certificate ! cert.moveTo(currentPlayer.getPortfolio()); ! // If more than one certificate is bought at the same time, transfer *************** *** 540,552 **** for (int i = 1; i < numberOfCertsToBuy; i++) { cert = ipo.findCertificate(company, false); ! executeTradeCertificate(cert, currentPlayer.getPortfolio(), ! company.getIPOPrice(), priceRecipient); } ReportBuffer.add(LocalText.getText("START_COMPANY_LOG", playerName, companyName, Bank.format(price), ! Bank.format(shares * price), shares, cert.getShare(), --- 542,556 ---- for (int i = 1; i < numberOfCertsToBuy; i++) { cert = ipo.findCertificate(company, false); ! cert.moveTo(currentPlayer.getPortfolio()); } + // Pay for these shares + new CashMove (currentPlayer, priceRecipient, cost); + ReportBuffer.add(LocalText.getText("START_COMPANY_LOG", playerName, companyName, Bank.format(price), ! Bank.format(cost), shares, cert.getShare(), *************** *** 587,591 **** String errMsg = null; int price = 0; ! int cash = 0; PublicCompanyI company = null; --- 591,595 ---- String errMsg = null; int price = 0; ! int cost = 0; PublicCompanyI company = null; *************** *** 681,688 **** price = currentSpace.getPrice(); ! cash = shares * price; // Check if the Player has the money. ! if (currentPlayer.getCash() < cash) { errMsg = LocalText.getText("NoMoney"); break; --- 685,692 ---- price = currentSpace.getPrice(); ! cost = shares * price; // Check if the Player has the money. ! if (currentPlayer.getCash() < cost) { errMsg = LocalText.getText("NoMoney"); break; *************** *** 705,709 **** moveStack.start(true); ! CashHolder priceRecipient = getSharePriceRecipient (cert, cash); if (number == 1) { --- 709,713 ---- moveStack.start(true); ! CashHolder priceRecipient = getSharePriceRecipient (cert, cost); if (number == 1) { *************** *** 713,717 **** companyName, from.getName(), ! Bank.format(cash) )); } else { ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", --- 717,721 ---- companyName, from.getName(), ! Bank.format(cost) )); } else { ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", *************** *** 722,726 **** companyName, from.getName(), ! Bank.format(cash) )); } ReportBuffer.getAllWaiting(); --- 726,730 ---- companyName, from.getName(), ! Bank.format(cost) )); } ReportBuffer.getAllWaiting(); *************** *** 733,743 **** + "% share in " + from.getName()); } ! executeTradeCertificate(cert2, currentPlayer.getPortfolio(), ! cash, priceRecipient); } if (priceRecipient != from.getOwner()) { ReportBuffer.add(LocalText.getText("PriceIsPaidTo", ! Bank.format(price * shares), priceRecipient.getName() )); } --- 737,747 ---- + "% share in " + from.getName()); } ! cert.moveTo(currentPlayer.getPortfolio()); } + new CashMove (currentPlayer, priceRecipient, cost); if (priceRecipient != from.getOwner()) { ReportBuffer.add(LocalText.getText("PriceIsPaidTo", ! Bank.format(cost), priceRecipient.getName() )); } *************** *** 766,778 **** } ! protected void executeTradeCertificate(Certificate cert, Portfolio newHolder, ! int price, CashHolder priceRecipient) { ! ! cert.moveTo(newHolder); ! new CashMove (newHolder.getOwner(), priceRecipient, price); ! ! } ! ! /** * Who receives the cash when a certificate is bought. * With incremental capitalization, this can be the company treasure. --- 770,774 ---- } ! /** * Who receives the cash when a certificate is bought. * With incremental capitalization, this can be the company treasure. |