From: Erik V. <ev...@us...> - 2009-05-24 18:44:51
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv20632/rails/game/specific/_1856 Modified Files: CGRFormationRound.java Log Message: Implemented correct CGR start price Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CGRFormationRound.java 4 May 2009 20:29:14 -0000 1.2 --- CGRFormationRound.java 24 May 2009 18:44:40 -0000 1.3 *************** *** 494,504 **** executeExchangeTokens (nonHomeTokens); } ! ! // Close the absorbed companies and float the CGR for (PublicCompanyI comp : mergingCompanies) { comp.setClosed(); } ! cgr.start(100); // TODO: assign correct starting price cgr.setFloated(); // Check the trains, autodiscard any excess non-permanent trains --- 494,544 ---- executeExchangeTokens (nonHomeTokens); } ! ! // Determine the CGR starting price, ! // and close the absorbed companies. ! int lowestPrice = 999; ! int totalPrice = 0; ! int price; ! int numberMerged = mergingCompanies.size(); for (PublicCompanyI comp : mergingCompanies) { + price = comp.getMarketPrice(); + totalPrice += price; + if (price < lowestPrice) lowestPrice = price; comp.setClosed(); } ! if (numberMerged >= 3) { ! totalPrice -= lowestPrice; ! numberMerged--; ! } ! int cgrPrice = Math.max(100, ((int)((totalPrice/numberMerged)/5))*5); ! ! // Find the correct start space and start the CGR ! if (cgrPrice == 100) { ! cgr.start(100); ! } else { ! StockMarketI sm = StockMarket.getInstance(); ! int prevColPrice = 100; ! int colPrice; ! StockSpaceI startSpace; ! for (int col=6; col <= sm.getNumberOfColumns(); col++) { ! colPrice = sm.getStockSpace(1, col).getPrice(); ! if (cgrPrice > colPrice) continue; ! if (cgrPrice - prevColPrice < colPrice - cgrPrice) { ! startSpace = sm.getStockSpace(1, col-1); ! } else { ! startSpace = sm.getStockSpace(1, col); ! } ! cgr.start(startSpace); ! message = LocalText.getText("START_MERGED_COMPANY", ! "CGR", ! Bank.format(startSpace.getPrice()), ! startSpace.getName()); ! DisplayBuffer.add(message); ! ReportBuffer.add(message); ! break; ! } ! } cgr.setFloated(); + ReportBuffer.add (LocalText.getText("Floats", "CGR")); // Check the trains, autodiscard any excess non-permanent trains |