From: Erik V. <ev...@us...> - 2008-11-02 19:52:58
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv7890/rails/game Modified Files: Portfolio.java PublicCompanyI.java StartRound.java StockRound.java ShareSellingRound.java StockMarket.java PublicCertificate.java PublicCertificateI.java StartItem.java Round.java PublicCompany.java TreasuryShareRound.java Player.java Log Message: Reorganized "getPrice" methods of PublicCompany. Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Portfolio.java 28 Oct 2008 21:01:34 -0000 1.27 --- Portfolio.java 2 Nov 2008 19:52:48 -0000 1.28 *************** *** 338,342 **** comp = cert.getCompany(); if (!comp.hasFloated() || !comp.hasStockPrice() ! || !cert.getCompany().getCurrentPrice().isNoCertLimit()) number++; } --- 338,342 ---- comp = cert.getCompany(); if (!comp.hasFloated() || !comp.hasStockPrice() ! || !cert.getCompany().getCurrentSpace().isNoCertLimit()) number++; } Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TreasuryShareRound.java 8 Jul 2008 19:54:08 -0000 1.6 --- TreasuryShareRound.java 2 Nov 2008 19:52:48 -0000 1.7 *************** *** 136,141 **** if (number == 0) continue; ! stockSpace = comp.getCurrentPrice(); ! price = stockSpace.getPrice(); // Does the company have enough cash? --- 136,141 ---- if (number == 0) continue; ! //stockSpace = comp.getCurrentSpace(); ! price = comp.getMarketPrice(); // Does the company have enough cash? *************** *** 228,232 **** price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getCurrentPrice().getPrice(); } --- 228,232 ---- price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getMarketPrice(); } *************** *** 333,339 **** StockSpaceI currentSpace; // TODO NEVER A PAR PRICE ? ! currentSpace = company.getCurrentPrice(); ! price = currentSpace.getPrice(); // Check if the Player has the money. --- 333,339 ---- StockSpaceI currentSpace; // TODO NEVER A PAR PRICE ? ! //currentSpace = company.getCurrentSpace(); ! price = company.getMarketPrice(); // Check if the Player has the money. *************** *** 479,483 **** price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentPrice(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); --- 479,483 ---- price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentSpace(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); Index: StartItem.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartItem.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** StartItem.java 4 Jun 2008 19:00:30 -0000 1.11 --- StartItem.java 2 Nov 2008 19:52:48 -0000 1.12 *************** *** 459,463 **** if (!company.hasStockPrice()) return null; ! if (company.getParPrice() != null) return null; return company; --- 459,463 ---- if (!company.hasStockPrice()) return null; ! if (company.getIPOPrice() != 0) return null; return company; Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** PublicCompany.java 30 Oct 2008 21:48:20 -0000 1.39 --- PublicCompany.java 2 Nov 2008 19:52:48 -0000 1.40 *************** *** 881,885 **** * the stock chart. */ ! public StockSpaceI getParPrice() { if (hasParPrice) { return parPrice != null ? parPrice.getPrice() : null; --- 881,885 ---- * the stock chart. */ ! public StockSpaceI getStartSpace() { if (hasParPrice) { return parPrice != null ? parPrice.getPrice() : null; *************** *** 888,891 **** --- 888,911 ---- } } + + public int getIPOPrice () { + if (hasParPrice) { + if (getStartSpace() != null) { + return getStartSpace().getPrice(); + } else { + return 0; + } + } else { + return getMarketPrice(); + } + } + + public int getMarketPrice () { + if (getCurrentSpace() != null) { + return getCurrentSpace().getPrice(); + } else { + return 0; + } + } /** *************** *** 918,922 **** * stock market. */ ! public StockSpaceI getCurrentPrice() { return currentPrice != null ? currentPrice.getPrice() : null; } --- 938,942 ---- * stock market. */ ! public StockSpaceI getCurrentSpace() { return currentPrice != null ? currentPrice.getPrice() : null; } Index: StartRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StartRound.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** StartRound.java 10 Oct 2008 19:56:30 -0000 1.19 --- StartRound.java 2 Nov 2008 19:52:48 -0000 1.20 *************** *** 275,280 **** // User has told us the start price comp.start(sharePrice); ! } else if (comp.getParPrice() != null) { ! // Company has a fixed start price comp.start(); } else { --- 275,280 ---- // User has told us the start price comp.start(sharePrice); ! } else if (comp.getIPOPrice() != 0) { ! // Company has a known start price comp.start(); } else { Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Player.java 12 Oct 2008 14:36:44 -0000 1.13 --- Player.java 2 Nov 2008 19:52:48 -0000 1.14 *************** *** 135,145 **** } public void buyShare(PublicCertificate share) throws NullPointerException { try { ! buyShare(share, share.getCompany().getCurrentPrice().getPrice()); } catch (NullPointerException e) { throw e; } } public boolean isOverLimits() { --- 135,147 ---- } + /* public void buyShare(PublicCertificate share) throws NullPointerException { try { ! buyShare(share, share.getCompany().getCurrentSpace().getPrice()); } catch (NullPointerException e) { throw e; } } + */ public boolean isOverLimits() { *************** *** 166,170 **** */ public boolean mayBuyCertificate(PublicCompanyI comp, int number) { ! if (comp.hasFloated() && comp.getCurrentPrice().isNoCertLimit()) return true; if (portfolio.getNumberOfCountedCertificates() + number > playerCertificateLimit) --- 168,172 ---- */ public boolean mayBuyCertificate(PublicCompanyI comp, int number) { ! if (comp.hasFloated() && comp.getCurrentSpace().isNoCertLimit()) return true; if (portfolio.getNumberOfCountedCertificates() + number > playerCertificateLimit) *************** *** 185,189 **** // Check for per-company share limit if (portfolio.getShare(company) + number * company.getShareUnit() > playerShareLimit ! && !company.getCurrentPrice().isNoHoldLimit()) return false; return true; } --- 187,191 ---- // Check for per-company share limit if (portfolio.getShare(company) + number * company.getShareUnit() > playerShareLimit ! && !company.getCurrentSpace().isNoHoldLimit()) return false; return true; } *************** *** 209,213 **** } else { limit = ! company.getCurrentPrice().isNoHoldLimit() ? 100 : playerShareLimit; } --- 211,215 ---- } else { limit = ! company.getCurrentSpace().isNoHoldLimit() ? 100 : playerShareLimit; } *************** *** 234,243 **** } public int sellShare(PublicCertificate share) { Portfolio.sellCertificate(share, portfolio, ! share.getCompany().getCurrentPrice().getPrice()); Game.getStockMarket().sell(share.getCompany(), 1); return 1; } /** --- 236,247 ---- } + /* public int sellShare(PublicCertificate share) { Portfolio.sellCertificate(share, portfolio, ! share.getCompany().getCurrentSpace().getPrice()); Game.getStockMarket().sell(share.getCompany(), 1); return 1; } + */ /** *************** *** 284,288 **** for (PublicCertificateI cert : portfolio.getCertificates()) { ! worth += cert.getCertificatePrice(); } for (PrivateCompanyI priv : portfolio.getPrivateCompanies()) { --- 288,292 ---- for (PublicCertificateI cert : portfolio.getCertificates()) { ! worth += cert.getCompany().getMarketPrice(); } for (PrivateCompanyI priv : portfolio.getPrivateCompanies()) { Index: PublicCertificate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificate.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PublicCertificate.java 30 Oct 2008 21:48:20 -0000 1.10 --- PublicCertificate.java 2 Nov 2008 19:52:48 -0000 1.11 *************** *** 114,117 **** --- 114,118 ---- * @return The current certificate price. */ + /* public int getCertificatePrice() { if (company.getCurrentPrice() != null) { *************** *** 121,124 **** --- 122,126 ---- } } + */ /** Index: Round.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Round.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Round.java 8 Jul 2008 19:54:08 -0000 1.10 --- Round.java 2 Nov 2008 19:52:48 -0000 1.11 *************** *** 117,121 **** // is ascending. if (company.hasStockPrice()) { ! space = company.getCurrentPrice(); key = 1000000 * (999 - space.getPrice()) + 10000 --- 117,121 ---- // is ascending. if (company.hasStockPrice()) { ! space = company.getCurrentSpace(); key = 1000000 * (999 - space.getPrice()) + 10000 *************** *** 172,178 **** capFactor = (100 - unsoldPercentage) / shareUnit; } ! int price = ! (company.hasParPrice() ? company.getParPrice() ! : company.getCurrentPrice()).getPrice(); cash = capFactor * price; } else { --- 172,176 ---- capFactor = (100 - unsoldPercentage) / shareUnit; } ! int price = company.getIPOPrice(); cash = capFactor * price; } else { Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PublicCompanyI.java 30 Oct 2008 21:48:20 -0000 1.21 --- PublicCompanyI.java 2 Nov 2008 19:52:48 -0000 1.22 *************** *** 116,120 **** * the stock chart. */ ! public StockSpaceI getParPrice(); /** --- 116,120 ---- * the stock chart. */ ! public StockSpaceI getStartSpace(); /** *************** *** 132,136 **** * stock market. */ ! public StockSpaceI getCurrentPrice(); public PriceModel getCurrentPriceModel(); --- 132,136 ---- * stock market. */ ! public StockSpaceI getCurrentSpace(); public PriceModel getCurrentPriceModel(); *************** *** 140,146 **** public int getFixedPrice(); ! /** ! * @return ! */ public int getPublicNumber(); --- 140,147 ---- public int getFixedPrice(); ! public int getIPOPrice (); ! ! public int getMarketPrice (); ! public int getPublicNumber(); Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ShareSellingRound.java 8 Jul 2008 19:54:08 -0000 1.13 --- ShareSellingRound.java 2 Nov 2008 19:52:48 -0000 1.14 *************** *** 160,164 **** price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getCurrentPrice().getPrice(); } --- 160,164 ---- price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getMarketPrice(); } *************** *** 304,308 **** price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentPrice(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); --- 304,308 ---- price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentSpace(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** StockMarket.java 4 Jun 2008 19:00:30 -0000 1.11 --- StockMarket.java 2 Nov 2008 19:52:48 -0000 1.12 *************** *** 157,162 **** for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { ! if (!comp.hasStarted() && comp.getParPrice() != null) { ! comp.getParPrice().addFixedStartPrice(comp); } } --- 157,162 ---- for (PublicCompanyI comp : Game.getCompanyManager().getAllPublicCompanies()) { ! if (!comp.hasStarted() && comp.getStartSpace() != null) { ! comp.getStartSpace().addFixedStartPrice(comp); } } *************** *** 206,210 **** public void moveUp(PublicCompanyI company) { ! StockSpaceI oldsquare = company.getCurrentPrice(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); --- 206,210 ---- public void moveUp(PublicCompanyI company) { ! StockSpaceI oldsquare = company.getCurrentSpace(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); *************** *** 219,223 **** protected void moveDown(PublicCompanyI company, int numberOfSpaces) { ! StockSpaceI oldsquare = company.getCurrentPrice(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); --- 219,223 ---- protected void moveDown(PublicCompanyI company, int numberOfSpaces) { ! StockSpaceI oldsquare = company.getCurrentSpace(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); *************** *** 253,257 **** protected void moveRightOrUp(PublicCompanyI company) { /* Ignore the amount for now */ ! StockSpaceI oldsquare = company.getCurrentPrice(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); --- 253,257 ---- protected void moveRightOrUp(PublicCompanyI company) { /* Ignore the amount for now */ ! StockSpaceI oldsquare = company.getCurrentSpace(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); *************** *** 267,271 **** protected void moveLeftOrDown(PublicCompanyI company) { ! StockSpaceI oldsquare = company.getCurrentPrice(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); --- 267,271 ---- protected void moveLeftOrDown(PublicCompanyI company) { ! StockSpaceI oldsquare = company.getCurrentSpace(); StockSpaceI newsquare = oldsquare; int row = oldsquare.getRow(); Index: PublicCertificateI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificateI.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PublicCertificateI.java 28 Oct 2008 21:01:34 -0000 1.8 --- PublicCertificateI.java 2 Nov 2008 19:52:48 -0000 1.9 *************** *** 37,41 **** * @return The current certificate price. */ ! public int getCertificatePrice(); /** --- 37,41 ---- * @return The current certificate price. */ ! //public int getCertificatePrice(); /** Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** StockRound.java 31 Oct 2008 20:38:56 -0000 1.30 --- StockRound.java 2 Nov 2008 19:52:48 -0000 1.31 *************** *** 172,183 **** if (!cert.isPresidentShare()) { ! if (cert.getCertificatePrice() <= playerCash) { ! possibleActions.add(new BuyCertificate(cert, from)); } } else if (!comp.hasStarted()) { ! if (comp.getParPrice() != null) { ! price = comp.getParPrice().getPrice() * cert.getShares(); ! possibleActions.add(new StartCompany(cert, ! price)); } else { List<Integer> startPrices = new ArrayList<Integer>(); --- 172,186 ---- if (!cert.isPresidentShare()) { ! price = comp.getIPOPrice(); ! if (price <= playerCash) { ! possibleActions.add(new BuyCertificate(cert, from, price)); } } else if (!comp.hasStarted()) { ! if (comp.getIPOPrice() != 0) { ! price = comp.getIPOPrice() * cert.getShares(); ! if (price <= playerCash) { ! possibleActions.add(new StartCompany(cert, ! price)); ! } } else { List<Integer> startPrices = new ArrayList<Integer>(); *************** *** 196,205 **** } } - } else if (comp.hasParPrice()) { - price = comp.getParPrice().getPrice() * cert.getShares(); - if (price <= playerCash) { - possibleActions.add(new BuyCertificate(cert, from, - price)); - } } --- 199,202 ---- *************** *** 221,225 **** if (currentPlayer.maxAllowedNumberOfSharesToBuy(comp, cert.getShare()) < 1) continue; ! stockSpace = comp.getCurrentPrice(); price = stockSpace.getPrice(); --- 218,222 ---- if (currentPlayer.maxAllowedNumberOfSharesToBuy(comp, cert.getShare()) < 1) continue; ! stockSpace = comp.getCurrentSpace(); price = stockSpace.getPrice(); *************** *** 265,274 **** if (currentPlayer.maxAllowedNumberOfSharesToBuy(company, certs.get(0).getShare()) < 1) continue; ! stockSpace = company.getCurrentPrice(); if (!stockSpace.isNoCertLimit() && !currentPlayer.mayBuyCertificate(company, 1)) continue; ! if (cert.getCertificatePrice() <= playerCash) { possibleActions.add(new BuyCertificate(cert, ! company.getPortfolio())); } } --- 262,272 ---- if (currentPlayer.maxAllowedNumberOfSharesToBuy(company, certs.get(0).getShare()) < 1) continue; ! stockSpace = company.getCurrentSpace(); if (!stockSpace.isNoCertLimit() && !currentPlayer.mayBuyCertificate(company, 1)) continue; ! if (company.getMarketPrice() <= playerCash) { possibleActions.add(new BuyCertificate(cert, ! company.getPortfolio(), ! company.getMarketPrice())); } } *************** *** 362,366 **** price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getCurrentPrice().getPrice(); } --- 360,364 ---- price = (sellPrices.get(compName)).getPrice(); } else { ! price = company.getMarketPrice(); } *************** *** 514,518 **** // Check if the company has a fixed par price (1835). ! startSpace = company.getParPrice(); if (startSpace != null) { // If so, it overrides whatever is given. --- 512,516 ---- // Check if the company has a fixed par price (1835). ! startSpace = company.getStartSpace(); if (startSpace != null) { // If so, it overrides whatever is given. *************** *** 551,555 **** // Transfer the President's certificate currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! cert.getCertificatePrice()); // If more than one certificate is bought at the same time, transfer --- 549,553 ---- // Transfer the President's certificate currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! company.getIPOPrice()); // If more than one certificate is bought at the same time, transfer *************** *** 558,562 **** cert = ipo.findCertificate(company, false); currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! cert.getCertificatePrice()); } --- 556,560 ---- cert = ipo.findCertificate(company, false); currentPlayer.getPortfolio().buyCertificate(cert, ipo, ! company.getIPOPrice()); } *************** *** 643,647 **** (PublicCompanyI) companyBoughtThisTurnWrapper.getObject(); if (companyBoughtThisTurn != null ! && (companyBoughtThisTurn != company || !company.getCurrentPrice().isNoBuyLimit())) { errMsg = LocalText.getText("AlreadyBought", playerName); break; --- 641,645 ---- (PublicCompanyI) companyBoughtThisTurnWrapper.getObject(); if (companyBoughtThisTurn != null ! && (companyBoughtThisTurn != company || !company.getCurrentSpace().isNoBuyLimit())) { errMsg = LocalText.getText("AlreadyBought", playerName); break; *************** *** 658,664 **** StockSpaceI currentSpace; if (from == ipo && company.hasParPrice()) { ! currentSpace = company.getParPrice(); } else { ! currentSpace = company.getCurrentPrice(); } --- 656,662 ---- StockSpaceI currentSpace; if (from == ipo && company.hasParPrice()) { ! currentSpace = company.getStartSpace(); } else { ! currentSpace = company.getCurrentSpace(); } *************** *** 903,907 **** price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentPrice(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); --- 901,905 ---- price = (sellPrices.get(companyName)).getPrice(); } else { ! sellPrice = company.getCurrentSpace(); price = sellPrice.getPrice(); sellPrices.put(companyName, sellPrice); *************** *** 1021,1027 **** for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStockPrice() && company.isSoldOut()) { ! StockSpaceI oldSpace = company.getCurrentPrice(); stockMarket.soldOut(company); ! StockSpaceI newSpace = company.getCurrentPrice(); if (newSpace != oldSpace) { ReportBuffer.add(LocalText.getText("SoldOut", --- 1019,1025 ---- for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStockPrice() && company.isSoldOut()) { ! StockSpaceI oldSpace = company.getCurrentSpace(); stockMarket.soldOut(company); ! StockSpaceI newSpace = company.getCurrentSpace(); if (newSpace != oldSpace) { ReportBuffer.add(LocalText.getText("SoldOut", |