From: Erik V. <ev...@us...> - 2010-01-14 21:01:35
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7042/rails/game Modified Files: OperatingRound.java Log Message: Changes some unnecessary class attributes into local variables Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** OperatingRound.java 30 Dec 2009 11:32:00 -0000 1.87 --- OperatingRound.java 14 Jan 2010 21:01:19 -0000 1.88 *************** *** 4,7 **** --- 4,8 ---- import java.util.*; + import rails.common.GuiDef; import rails.game.action.*; import rails.game.move.CashMove; *************** *** 14,18 **** * Implements a basic Operating Round. <p> A new instance must be created for * each new Operating Round. At the end of a round, the current instance should ! * be discarded. <p> Permanent memory is formed by static attributes. */ public class OperatingRound extends Round implements Observer { --- 15,19 ---- * Implements a basic Operating Round. <p> A new instance must be created for * each new Operating Round. At the end of a round, the current instance should ! * be discarded. */ public class OperatingRound extends Round implements Observer { *************** *** 23,28 **** protected boolean actionPossible = true; - protected String actionNotPossibleMessage = ""; - protected TreeMap<Integer, PublicCompanyI> operatingCompanies; protected List<PublicCompanyI> companiesOperatedThisRound --- 24,27 ---- *************** *** 33,38 **** protected IntegerState operatingCompanyIndexObject; - protected int operatingCompanyIndex; - protected PublicCompanyI operatingCompany; --- 32,35 ---- *************** *** 61,66 **** protected Map<PublicCompanyI, Integer> loansThisRound = null; - protected PhaseI currentPhase; - protected String thisOrNumber; --- 58,61 ---- *************** *** 69,86 **** protected PossibleAction savedAction = null; ! protected int cashToBeRaisedByPresident = 0; ! ! protected int splitRule = SPLIT_NOT_ALLOWED; // To be made configurable ! ! /* Permanent memory */ ! static protected List<Player> players; ! ! static protected int numberOfPlayers = 0; ! ! /* Constants */ ! public static final int SPLIT_NOT_ALLOWED = 0; ! ! public static final int SPLIT_ROUND_UP = 1; // More money to the ! // shareholders public static final int SPLIT_ROUND_DOWN = 2; // More to the treasury --- 64,68 ---- protected PossibleAction savedAction = null; ! //protected int cashToBeRaisedByPresident = 0; public static final int SPLIT_ROUND_DOWN = 2; // More to the treasury *************** *** 124,133 **** super (gameManager); - if (players == null) { - players = gameManager.getPlayers(); - numberOfPlayers = players.size(); - } - operatingCompanyArray = super.getOperatingCompanies(); } --- 106,114 ---- super (gameManager); operatingCompanyArray = super.getOperatingCompanies(); + + guiHints.setVisibilityHint(GuiDef.Panel.STOCK_MARKET, false); + guiHints.setVisibilityHint(GuiDef.Panel.STATUS, true); + guiHints.setActivePanel(GuiDef.Panel.MAP); } *************** *** 323,327 **** if (tile == null) break; ! if (!currentPhase.isTileColourAllowed(tile.getColourName())) { errMsg = LocalText.getText("TileNotYetAvailable", --- 304,308 ---- if (tile == null) break; ! if (!getCurrentPhase().isTileColourAllowed(tile.getColourName())) { errMsg = LocalText.getText("TileNotYetAvailable", *************** *** 1033,1038 **** int step = stepObject.intValue(); - currentPhase = gameManager.getCurrentPhase(); - if (step == STEP_LAY_TRACK) { getNormalTileLays(); --- 1014,1017 ---- *************** *** 1063,1067 **** tileLaysPerColour = ! new HashMap<String, Integer>(currentPhase.getTileColours()); // Clone // it. int allowedNumber; --- 1042,1046 ---- tileLaysPerColour = ! new HashMap<String, Integer>(getCurrentPhase().getTileColours()); // Clone // it. int allowedNumber; *************** *** 1258,1262 **** } ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); if (operatingCompanyIndex >= operatingCompanyArray.length) { --- 1237,1241 ---- } ! int operatingCompanyIndex = operatingCompanyIndexObject.intValue(); if (operatingCompanyIndex >= operatingCompanyArray.length) { *************** *** 1265,1268 **** --- 1244,1248 ---- } else { operatingCompany = operatingCompanyArray[operatingCompanyIndex]; + log.debug("Operating company is "+operatingCompany.getName()+" in "+getRoundName()); return true; } *************** *** 1295,1298 **** --- 1275,1279 ---- int price = action.getPricePaid(); int actualPresidentCash = 0; + int cashToBeRaisedByPresident = 0; Player currentPlayer = operatingCompany.getPresident(); *************** *** 1455,1462 **** // Check if the phase has changed. gameManager.getTrainManager().checkTrainAvailability(train, oldHolder); - currentPhase = getCurrentPhase(); // Check if any companies must discard trains ! if (currentPhase != previousPhase && checkForExcessTrains()) { stepObject.set(STEP_DISCARD_TRAINS); } --- 1436,1442 ---- // Check if the phase has changed. gameManager.getTrainManager().checkTrainAvailability(train, oldHolder); // Check if any companies must discard trains ! if (getCurrentPhase() != previousPhase && checkForExcessTrains()) { stepObject.set(STEP_DISCARD_TRAINS); } *************** *** 1470,1474 **** Player player; for (PublicCompanyI comp : operatingCompanyArray) { ! if (comp.getPortfolio().getNumberOfTrains() > comp.getTrainLimit(currentPhase.getIndex())) { player = comp.getPresident(); if (!excessTrainCompanies.containsKey(player)) { --- 1450,1454 ---- Player player; for (PublicCompanyI comp : operatingCompanyArray) { ! if (comp.getPortfolio().getNumberOfTrains() > comp.getTrainLimit(getCurrentPhase().getIndex())) { player = comp.getPresident(); if (!excessTrainCompanies.containsKey(player)) { *************** *** 1604,1608 **** // Is private buying allowed? ! if (!currentPhase.isPrivateSellingAllowed()) { errMsg = LocalText.getText("PrivateBuyingIsNotAllowed"); break; --- 1584,1588 ---- // Is private buying allowed? ! if (!getCurrentPhase().isPrivateSellingAllowed()) { errMsg = LocalText.getText("PrivateBuyingIsNotAllowed"); break; *************** *** 1817,1821 **** if (remainder > presCash) { // Start a share selling round ! cashToBeRaisedByPresident = remainder - presCash; log.info("A share selling round must be started as the president cannot pay $" + remainder + " loan repayment"); --- 1797,1801 ---- if (remainder > presCash) { // Start a share selling round ! int cashToBeRaisedByPresident = remainder - presCash; log.info("A share selling round must be started as the president cannot pay $" + remainder + " loan repayment"); *************** *** 1936,1940 **** public boolean setPossibleActions() { ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); operatingCompany = operatingCompanyArray[operatingCompanyIndex]; --- 1916,1920 ---- public boolean setPossibleActions() { ! int operatingCompanyIndex = operatingCompanyIndexObject.intValue(); operatingCompany = operatingCompanyArray[operatingCompanyIndex]; *************** *** 1981,2003 **** // primary action is not forced. if (step >= 0) { ! setBonusTokenLays(); setDestinationActions(); ! setGameSpecificPossibleActions(); ! // Can private companies be bought? if (getCurrentPhase().isPrivateSellingAllowed()) { ! // Create a list of players with the current one in front int currentPlayerIndex = operatingCompany.getPresident().getIndex(); Player player; int minPrice, maxPrice; for (int i = currentPlayerIndex; i < currentPlayerIndex + numberOfPlayers; i++) { player = players.get(i % numberOfPlayers); for (PrivateCompanyI privComp : player.getPortfolio().getPrivateCompanies()) { ! minPrice = (int) (privComp.getBasePrice() * operatingCompany.getLowerPrivatePriceFactor()); --- 1961,1985 ---- // primary action is not forced. if (step >= 0) { ! setBonusTokenLays(); setDestinationActions(); ! setGameSpecificPossibleActions(); ! // Can private companies be bought? if (getCurrentPhase().isPrivateSellingAllowed()) { ! // Create a list of players with the current one in front int currentPlayerIndex = operatingCompany.getPresident().getIndex(); Player player; int minPrice, maxPrice; + List<Player> players = getPlayers(); + int numberOfPlayers = getNumberOfPlayers(); for (int i = currentPlayerIndex; i < currentPlayerIndex + numberOfPlayers; i++) { player = players.get(i % numberOfPlayers); for (PrivateCompanyI privComp : player.getPortfolio().getPrivateCompanies()) { ! minPrice = (int) (privComp.getBasePrice() * operatingCompany.getLowerPrivatePriceFactor()); *************** *** 2009,2013 **** } } ! // Are there any "common" special properties, // i.e. properties that are available to everyone? --- 1991,1995 ---- } } ! // Are there any "common" special properties, // i.e. properties that are available to everyone? *************** *** 2091,2103 **** // First check if any more trains may be bought from the Bank // Postpone train limit checking, because an exchange might be possible ! if (currentPhase.canBuyMoreTrainsPerTurn() || trainsBoughtThisTurn.isEmpty()) { boolean mayBuyMoreOfEachType = ! currentPhase.canBuyMoreTrainsPerTypePerTurn(); /* New trains */ trains = trainMgr.getAvailableNewTrains(); for (TrainI train : trains) { ! if (!operatingCompany.mayBuyTrainType(train)) continue; if (!mayBuyMoreOfEachType && trainsBoughtThisTurn.contains(train.getType())) { --- 2073,2085 ---- // First check if any more trains may be bought from the Bank // Postpone train limit checking, because an exchange might be possible ! if (getCurrentPhase().canBuyMoreTrainsPerTurn() || trainsBoughtThisTurn.isEmpty()) { boolean mayBuyMoreOfEachType = ! getCurrentPhase().canBuyMoreTrainsPerTypePerTurn(); /* New trains */ trains = trainMgr.getAvailableNewTrains(); for (TrainI train : trains) { ! if (!operatingCompany.mayBuyTrainType(train)) continue; if (!mayBuyMoreOfEachType && trainsBoughtThisTurn.contains(train.getType())) { *************** *** 2179,2183 **** /* Other company trains, sorted by president (current player first) */ ! if (currentPhase.isTrainTradingAllowed()) { PublicCompanyI c; BuyTrain bt; --- 2161,2165 ---- /* Other company trains, sorted by president (current player first) */ ! if (getCurrentPhase().isTrainTradingAllowed()) { PublicCompanyI c; BuyTrain bt; *************** *** 2185,2188 **** --- 2167,2172 ---- Portfolio pf; int index; + int numberOfPlayers = getNumberOfPlayers(); + // Set up a list per player of presided companies List<List<PublicCompanyI>> companiesPerPlayer = *************** *** 2255,2259 **** int currentPlayerIndex = getCurrentPlayerIndex(); for (int i = currentPlayerIndex; i < currentPlayerIndex ! + numberOfPlayers; i++) { player = gameManager.getPlayerByIndex(i); if (excessTrainCompanies.containsKey(player)) { --- 2239,2243 ---- int currentPlayerIndex = getCurrentPlayerIndex(); for (int i = currentPlayerIndex; i < currentPlayerIndex ! + getNumberOfPlayers(); i++) { player = gameManager.getPlayerByIndex(i); if (excessTrainCompanies.containsKey(player)) { *************** *** 2272,2279 **** } - public int getCashToBeRaisedByPresident() { - return cashToBeRaisedByPresident; - } - /** * This is currently a stub, as it is unclear if there is a common --- 2256,2259 ---- |