From: Erik V. <ev...@us...> - 2008-12-23 19:57:33
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27099/rails/game Modified Files: TreasuryShareRound.java ShareSellingRound.java Log Message: Apply new round initialisation logic. Cleanups. Index: TreasuryShareRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TreasuryShareRound.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TreasuryShareRound.java 4 Dec 2008 01:03:40 -0000 1.10 --- TreasuryShareRound.java 23 Dec 2008 19:57:26 -0000 1.11 *************** *** 6,18 **** package rails.game; ! import java.util.ArrayList; ! import java.util.Iterator; ! import java.util.List; ! import java.util.Map; ! import rails.game.action.BuyCertificate; ! import rails.game.action.NullAction; ! import rails.game.action.PossibleAction; ! import rails.game.action.SellShares; import rails.game.move.MoveSet; import rails.game.state.BooleanState; --- 6,12 ---- package rails.game; ! import java.util.*; ! import rails.game.action.*; import rails.game.move.MoveSet; import rails.game.state.BooleanState; *************** *** 26,35 **** Player sellingPlayer; PublicCompanyI operatingCompany; - //GameManager gameMgr; private final BooleanState hasBought; private final BooleanState hasSold; /** ! * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize, and * and other parameters used by the Treasury Share Round Class * --- 20,28 ---- Player sellingPlayer; PublicCompanyI operatingCompany; private final BooleanState hasBought; private final BooleanState hasSold; /** ! * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize, and * and other parameters used by the Treasury Share Round Class * *************** *** 38,45 **** * */ ! public TreasuryShareRound(GameManager aGameManager, ! PublicCompanyI operatingCompany) { super (aGameManager); ! this.operatingCompany = operatingCompany; sellingPlayer = operatingCompany.getPresident(); log.debug("Creating TreasuryShareRound"); --- 31,39 ---- * */ ! public TreasuryShareRound(GameManagerI aGameManager, ! RoundI parentRound) { super (aGameManager); ! ! operatingCompany = ((OperatingRound)parentRound).getOperatingCompany(); sellingPlayer = operatingCompany.getPresident(); log.debug("Creating TreasuryShareRound"); *************** *** 51,55 **** false); - gameManager.setRound(this); setCurrentPlayerIndex(sellingPlayer.getIndex()); --- 45,48 ---- *************** *** 98,102 **** * Create a list of certificates that a player may buy in a Stock Round, * taking all rules into account. ! * * @return List of buyable certificates. */ --- 91,95 ---- * Create a list of certificates that a player may buy in a Stock Round, * taking all rules into account. ! * * @return List of buyable certificates. */ *************** *** 140,144 **** if (number == 0) continue; - //stockSpace = comp.getCurrentSpace(); price = comp.getMarketPrice(); --- 133,136 ---- *************** *** 160,164 **** * presidencies of other companies has been retained, but not tested. This * code will be needed for 1841. ! * * @return List of sellable certificates. */ --- 152,156 ---- * presidencies of other companies has been retained, but not tested. This * code will be needed for 1841. ! * * @return List of sellable certificates. */ *************** *** 189,210 **** if (maxShareToSell == 0) continue; ! // If the current Player is president, check if he can dump ! // the presidency onto someone else ! /* ! * DISABLED, companies cannot yet have another company as a ! * President. We will need this code later for 1841, so it might ! * make sense to retain it. if (company.getPresident() == ! * currentPlayer) { int presidentShare = ! * company.getCertificates().get(0).getShare(); if (maxShareToSell > ! * share - presidentShare) { dumpAllowed = false; if (company != ! * operatingCompany) { int playerShare; List<Player> players = ! * GameManager.getPlayers(); for (Player player : players) { if ! * (player == currentPlayer) continue; playerShare = ! * player.getPortfolio().getShare(company); if (playerShare >= ! * presidentShare) { dumpAllowed = true; break; } } } if ! * (!dumpAllowed) maxShareToSell = share - presidentShare; } } ! */ ! ! /* * Check what share units the player actually owns. In some games * (e.g. 1835) companies may have different ordinary shares: 5% and --- 181,185 ---- if (maxShareToSell == 0) continue; ! /* * Check what share units the player actually owns. In some games * (e.g. 1835) companies may have different ordinary shares: 5% and *************** *** 254,258 **** * Buying one or more single or double-share certificates (more is sometimes * possible) ! * * @param player The player that wants to buy shares. * @param action The executed action --- 229,233 ---- * Buying one or more single or double-share certificates (more is sometimes * possible) ! * * @param player The player that wants to buy shares. * @param action The executed action *************** *** 370,374 **** for (int i = 0; i < number; i++) { cert2 = from.findCertificate(company, cert.getShares(), false); - //portfolio.buyCertificate(cert2, from, shares * price); executeTradeCertificate(cert2, portfolio, shares * price); } --- 345,348 ---- *************** *** 495,500 **** for (PublicCertificateI cert2 : certsToSell) { if (cert2 != null) { ! //pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); ! executeTradeCertificate (cert2, pool, cert2.getShares() * price); } } --- 469,473 ---- for (PublicCertificateI cert2 : certsToSell) { if (cert2 != null) { ! executeTradeCertificate (cert2, pool, cert2.getShares() * price); } } *************** *** 508,512 **** /** * The current Player passes or is done. ! * * @param player Name of the passing player. * @return False if an error is found. --- 481,485 ---- /** * The current Player passes or is done. ! * * @param player Name of the passing player. * @return False if an error is found. Index: ShareSellingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/ShareSellingRound.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ShareSellingRound.java 4 Dec 2008 01:15:35 -0000 1.17 --- ShareSellingRound.java 23 Dec 2008 19:57:26 -0000 1.18 *************** *** 19,22 **** --- 19,23 ---- public class ShareSellingRound extends StockRound { + OperatingRound or; Player sellingPlayer; PublicCompanyI companyNeedingTrain; *************** *** 24,46 **** /** ! * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize, and * and other parameters used by the Share Selling Round Class * * @param aGameManager The GameManager Object needed to initialize the StockRound Class ! * @param compNeedingTraing The PublicCompanyI Object that needs to buy the train, * who is limited on selling shares of * @param cashToRaise The amount of cash needed to be raised during the special sell-off * */ ! public ShareSellingRound(GameManager gameManager, ! PublicCompanyI compNeedingTrain, int cashToRaise) { super (gameManager); ! this.companyNeedingTrain = compNeedingTrain; ! this.cashToRaise = new IntegerState("CashToRaise", cashToRaise); ! sellingPlayer = compNeedingTrain.getPresident(); currentPlayer = sellingPlayer; ! log.debug("Creating ShareSellingRound, cash to raise =" + cashToRaise); ! gameManager.setRound(this); setCurrentPlayerIndex(sellingPlayer.getIndex()); --- 25,47 ---- /** ! * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize, and * and other parameters used by the Share Selling Round Class * * @param aGameManager The GameManager Object needed to initialize the StockRound Class ! * @param compNeedingTraing The PublicCompanyI Object that needs to buy the train, * who is limited on selling shares of * @param cashToRaise The amount of cash needed to be raised during the special sell-off * */ ! public ShareSellingRound(GameManagerI gameManager, ! RoundI parentRound) { super (gameManager); ! or = ((OperatingRound) parentRound); ! companyNeedingTrain = or.getOperatingCompany(); ! cashToRaise = new IntegerState("CashToRaise", or.getCashToBeRaisedByPresident()); ! sellingPlayer = companyNeedingTrain.getPresident(); currentPlayer = sellingPlayer; ! log.debug("Creating ShareSellingRound, cash to raise =" + cashToRaise.intValue()); setCurrentPlayerIndex(sellingPlayer.getIndex()); *************** *** 51,54 **** --- 52,56 ---- log.info("Share selling round started"); currentPlayer = sellingPlayer; + setPossibleActions(); } *************** *** 88,92 **** * Create a list of certificates that a player may sell in a Stock Round, * taking all rules taken into account. ! * * @return List of sellable certificates. */ --- 90,94 ---- * Create a list of certificates that a player may sell in a Stock Round, * taking all rules taken into account. ! * * @return List of sellable certificates. */ *************** *** 342,346 **** for (PublicCertificateI cert2 : certsToSell) { if (cert2 != null) { - //pool.buyCertificate(cert2, portfolio, cert2.getShares() * price); executeTradeCertificate (cert2, pool, cert2.getShares() * price); } --- 344,347 ---- *************** *** 358,362 **** ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { otherPlayer.getName(), ! company.getName() })); break; --- 359,363 ---- ReportBuffer.add(LocalText.getText("IS_NOW_PRES_OF", new String[] { otherPlayer.getName(), ! company.getName() })); break; |