From: Erik V. <ev...@us...> - 2009-09-04 18:38:23
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27467/rails/game Modified Files: PublicCompanyI.java PublicCompany.java StockMarket.java Log Message: Added canClose attribute - CGR cannot close. StockMarket checks this Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** StockMarket.java 4 May 2009 20:29:14 -0000 1.15 --- StockMarket.java 4 Sep 2009 18:38:11 -0000 1.16 *************** *** 216,220 **** prepareMove(company, oldsquare, newsquare); } ! public void close (PublicCompanyI company) { prepareMove(company, company.getCurrentSpace(), null); --- 216,220 ---- prepareMove(company, oldsquare, newsquare); } ! public void close (PublicCompanyI company) { prepareMove(company, company.getCurrentSpace(), null); *************** *** 234,237 **** --- 234,241 ---- newrow--; + // Check if company may enter a "Closed" area + while (getStockSpace(newrow, col).closesCompany() && !company.canClose()) + newrow--; + /* * If marker landed just below a ledge, and NOT because it was bounced *************** *** 261,269 **** int col = oldsquare.getColumn(); if (col < numCols - 1 && !oldsquare.isLeftOfLedge() ! && (newsquare = getStockSpace(row, col + 1)) != null) {} else if (row > 0 ! && (newsquare = ! getStockSpace( ! row - 1, ! col)) != null) {} prepareMove(company, oldsquare, newsquare); } --- 265,272 ---- int col = oldsquare.getColumn(); if (col < numCols - 1 && !oldsquare.isLeftOfLedge() ! && (newsquare = getStockSpace(row, col + 1)) != null) {} ! else if (row > 0 ! && (newsquare = getStockSpace(row - 1, col)) != null) {} ! if (newsquare == oldsquare) return; prepareMove(company, oldsquare, newsquare); } *************** *** 274,283 **** int row = oldsquare.getRow(); int col = oldsquare.getColumn(); ! if (col > 0 && (newsquare = getStockSpace(row, col - 1)) != null) {} else if (row < numRows - 1 ! && (newsquare = ! getStockSpace( ! row + 1, ! col)) != null) {} ! if (newsquare != oldsquare && newsquare.closesCompany()) { company.setClosed(); oldsquare.removeToken(company); --- 277,286 ---- int row = oldsquare.getRow(); int col = oldsquare.getColumn(); ! if (col > 0 && (newsquare = getStockSpace(row, col - 1)) != null) {} ! else if (row < numRows - 1 && ! (newsquare = getStockSpace(row + 1, col)) != null) {} ! if (newsquare == oldsquare) return; ! if (newsquare.closesCompany()) { ! if (!company.canClose()) return; // E.g. 1856 CGR company.setClosed(); oldsquare.removeToken(company); Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** PublicCompany.java 2 Sep 2009 21:47:47 -0000 1.55 --- PublicCompany.java 4 Sep 2009 18:38:11 -0000 1.56 *************** *** 220,223 **** --- 220,228 ---- protected boolean mustTradeTrainsAtFixedPrice = false; + /** Can the company price token go down to a "Close" square? + * 1856 CGR cannot. + */ + protected boolean canClose = true; + /** Initial train at floating time */ protected String initialTrain = null; *************** *** 230,234 **** protected int maxLoansPerRound = 0; protected MoneyModel currentLoanValue = null; ! protected BooleanState canSharePriceVary = null; --- 235,239 ---- protected int maxLoansPerRound = 0; protected MoneyModel currentLoanValue = null; ! protected BooleanState canSharePriceVary = null; *************** *** 551,554 **** --- 556,566 ---- maxLoansPerRound = loansTag.getAttributeAsInteger("perRound", -1); } + + Tag optionsTag = tag.getChild("Options"); + if (optionsTag != null) { + mustTradeTrainsAtFixedPrice = optionsTag.getAttributeAsBoolean + ("mustTradeTrainsAtFixedPrice", mustTradeTrainsAtFixedPrice); + canClose = optionsTag.getAttributeAsBoolean("canClose", canClose); + } } *************** *** 772,776 **** return mustHaveOperatedToTradeShares; } ! public void start(StockSpaceI startSpace) { --- 784,788 ---- return mustHaveOperatedToTradeShares; } ! public void start(StockSpaceI startSpace) { *************** *** 1415,1419 **** return portfolio.getNumberOfTrains() > 0; } ! /** * Must be called in stead of Portfolio.buyTrain if side-effects can occur. --- 1427,1431 ---- return portfolio.getNumberOfTrains() > 0; } ! /** * Must be called in stead of Portfolio.buyTrain if side-effects can occur. *************** *** 1692,1696 **** } ! @Override public Object clone() { --- 1704,1712 ---- } ! public boolean canClose() { ! return canClose; ! } ! ! @Override public Object clone() { Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** PublicCompanyI.java 2 Sep 2009 21:47:47 -0000 1.32 --- PublicCompanyI.java 4 Sep 2009 18:38:11 -0000 1.33 *************** *** 246,252 **** public boolean hasParPrice(); ! public boolean canSharePriceVary(); ! public boolean isSplitAllowed(); --- 246,252 ---- public boolean hasParPrice(); ! public boolean canSharePriceVary(); ! public boolean isSplitAllowed(); *************** *** 267,271 **** public int getNumberOfTrains(); public boolean canRunTrains(); ! public void initTurn(); --- 267,271 ---- public int getNumberOfTrains(); public boolean canRunTrains(); ! public void initTurn(); *************** *** 337,340 **** --- 337,341 ---- public int getMaxNumberOfLoans(); public boolean canLoan(); + public boolean canClose(); public int getMaxLoansPerRound(); public int getValuePerLoan(); |