From: Erik V. <ev...@us...> - 2009-09-06 13:59:41
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1856 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12356/rails/game/specific/_1856 Modified Files: CGRFormationRound.java PublicCompany_CGR.java OperatingRound_1856.java Log Message: CGR price down on selling every *two* 5% shares Index: CGRFormationRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/CGRFormationRound.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CGRFormationRound.java 4 Sep 2009 18:40:29 -0000 1.14 --- CGRFormationRound.java 6 Sep 2009 12:27:31 -0000 1.15 *************** *** 563,567 **** tokensToExchangeFrom.add(new ExchangeableToken( key, oldTokens.get(key))); ! } } else { executeExchangeTokens (nonHomeTokens); --- 563,567 ---- tokensToExchangeFrom.add(new ExchangeableToken( key, oldTokens.get(key))); ! } } else { executeExchangeTokens (nonHomeTokens); Index: OperatingRound_1856.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/OperatingRound_1856.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** OperatingRound_1856.java 4 Sep 2009 18:40:30 -0000 1.19 --- OperatingRound_1856.java 6 Sep 2009 12:27:31 -0000 1.20 *************** *** 66,69 **** --- 66,72 ---- // This check does not apply to the CGR if (operatingCompany instanceof PublicCompany_CGR) return true; + + if (operatingCompany.isClosed()) continue; + if (!operatingCompany.hasOperated()) { int soldPercentage *************** *** 471,475 **** // and is not closed. while (setNextOperatingCompany(false) ! && getOperatingCompany().isClosed()); // Remove closed companies from the operating company list --- 474,478 ---- // and is not closed. while (setNextOperatingCompany(false) ! && operatingCompany.isClosed()); // Remove closed companies from the operating company list *************** *** 487,491 **** for (PublicCompanyI c : companies) { ! log.debug("Now operating: "+c.getName()); } --- 490,498 ---- for (PublicCompanyI c : companies) { ! if (c.isClosed()) { ! log.info(c.getName()+" is closed"); ! } else { ! log.debug(c.getName()+" is operating"); ! } } Index: PublicCompany_CGR.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1856/PublicCompany_CGR.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublicCompany_CGR.java 4 Sep 2009 18:40:30 -0000 1.1 --- PublicCompany_CGR.java 6 Sep 2009 12:27:31 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- import rails.game.move.*; import rails.game.state.BooleanState; + import rails.game.state.IntegerState; public class PublicCompany_CGR extends PublicCompany { *************** *** 12,17 **** public static final String NAME = "CGR"; ! /** Used for CGR */ private BooleanState hadPermanentTrain; /** Initialisation, to be called directly after instantiation (cloning) */ --- 13,22 ---- public static final String NAME = "CGR"; ! /** Special rules apply before CGR has got its first permanent train */ private BooleanState hadPermanentTrain; + + /* Cope with multiple 5% share sales in one turn */ + private IntegerState sharesSoldSoFar; + private IntegerState squaresDownSoFar; /** Initialisation, to be called directly after instantiation (cloning) */ *************** *** 23,26 **** --- 28,34 ---- // Share price is initially fixed canSharePriceVary.set(false); + + sharesSoldSoFar = new IntegerState(name+"_SharesSoldSoFar", 0); + squaresDownSoFar = new IntegerState(name+"_SquaresDownSoFar", 0); } *************** *** 99,102 **** --- 107,140 ---- } + public void adjustSharePrice (int actionPerformed, int numberOfSharesSold, + StockMarketI stockMarket) { + + if (actionPerformed == StockRound.SOLD) { + if (canSharePriceVary()) { + int numberOfSpaces; + if (shareUnit.intValue() == 5) { + // Take care for selling 5% shares in multiple blocks per turn + numberOfSpaces + = (sharesSoldSoFar.intValue() + numberOfSharesSold)/2 + - squaresDownSoFar.intValue(); + sharesSoldSoFar.add(numberOfSharesSold); + squaresDownSoFar.add(numberOfSpaces); + } else { + numberOfSpaces = numberOfSharesSold; + } + stockMarket.sell(this, numberOfSpaces); + } + } + } + + public void setOperated() { + super.setOperated(); + + // Reset the share selling counts + // TODO Should this be a generic function? + sharesSoldSoFar.set(0); + squaresDownSoFar.set(0); + } + @Override public boolean mustOwnATrain() { |