From: <ev...@us...> - 2011-07-07 19:23:39
|
Revision: 1610 http://rails.svn.sourceforge.net/rails/?rev=1610&view=rev Author: evos Date: 2011-07-07 19:23:32 +0000 (Thu, 07 Jul 2011) Log Message: ----------- Phase management step 2: Moved rusted and released trains from <Train> to <Phase>. This has been implemented in the code, but applied to 18TN and 1856 only (the old method still works). Also split some report lines that started with a newline into a blank line and a line without newline (as per SF). Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1856/Game.xml trunk/18xx/data/18TN/Game.xml trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/Phase.java trunk/18xx/rails/game/PhaseI.java trunk/18xx/rails/game/PhaseManager.java trunk/18xx/rails/game/Portfolio.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/TrainManager.java trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/LocalisedText.properties 2011-07-07 19:23:32 UTC (rev 1610) @@ -142,13 +142,13 @@ CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train CompanyDoesNotPayDividend={0} does not pay a dividend -CompanyHasLoans=\n{0} ({1}) has {2} loans of {3}, total is {4} -CompanyHasShares=\n{0} has {1} shares of {2}% each +CompanyHasLoans={0} ({1}) has {2} loans of {3}, total is {4} +CompanyHasShares={0} has {1} shares of {2}% each CompanyHasNoType=Company {0} has no type defined CompanyHasUnknownType=Company {0} has an undefined type {1} CompanyMustOwnATrain={0} must own a train CompanyMustPayLoanInterest={0} must pay {1} loan interest -CompanyOperates=\n{0} ({1}) operates. +CompanyOperates={0} ({1}) operates. CompanyPaysLoanInterest={0} pays {1} as {2}% interest over {3} loans of {4} CompanyPaysOutFull={0} pays out full dividend of {1} CompanyRepaysLoans={0} pays {1} (of {2}) to repay {3} loan(s) of {4} from its treasury @@ -243,15 +243,15 @@ EDIT=Edit EMERGENCY_SHARE_SELLING_TITLE=Rails: Game Status - SELLING SHARES FOR EMERGENCY CASH RAISING END_OF_GAME_CLOSE_ALL_WINDOWS=Close all windows -END_SR=\nAll players have passed, end of SR {0} +END_SR=All players have passed, end of SR {0} EndOfExchangeRound=All minors are closed, end of Exchange Round -EndOfFormationRound=\nEnd of {0} formation round, resuming {1} -EndOfFormationRoundNoInterrupt=\nEnd of {0} formation round +EndOfFormationRound=End of {0} formation round, resuming {1} +EndOfFormationRoundNoInterrupt=End of {0} formation round ENTER_PRICE_OR_CANCEL=Enter a valid price or hit Cancel ERROR=Error EXCHANGED=exchanged EXPORT=Export Map -EndOfOperatingRound=\nEnd of Operating Round {0} +EndOfOperatingRound=End of Operating Round {0} EnterRevenue=Enter the earnings of the operating company EnterSearch=Enter search target EoGFinalRanking=Final ranking @@ -550,7 +550,7 @@ SelectCheapTrain=You can buy a cheaper new train by using {0}. SelectStationForToken={0}, select a station on hex {1} for the {2} home base token SelectStationForTokenOption=Place token in station {0} with tracks to {1} -SelectForAuctioning=\n{0} selects {1} for auctioning +SelectForAuctioning={0} selects {1} for auctioning SELL=Sell SELL_SHARE_LOG={0} sells a {1}% share of {2} to Pool for {3}. SELL_SHARES_LOG={0} sells {1} {2}% shares ({3}%) of {4} to Pool for {5}. Modified: trunk/18xx/data/1856/Game.xml =================================================================== --- trunk/18xx/data/1856/Game.xml 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/data/1856/Game.xml 2011-07-07 19:23:32 UTC (rev 1610) @@ -52,14 +52,20 @@ <Score towns="yes"/> </Defaults> <TrainType name="2" majorStops="2" cost="100" quantity="6"/> - <TrainType name="3" majorStops="3" cost="225" quantity="5" startPhase="2"/> - <TrainType name="4" majorStops="4" cost="350" quantity="4" startPhase="3" - rustedTrain="2"/> - <TrainType name="5" majorStops="5" cost="550" quantity="3" startPhase="4"/> - <TrainType name="6" majorStops="6" cost="700" quantity="2" startPhase="5" - rustedTrain="3" releasedTrain="D"/> - <TrainType name="D" majorStops="99" cost="1100" quantity="-1" startPhase="6" - rustedTrain="4"> + <TrainType name="3" majorStops="3" cost="225" quantity="5"> + <NewPhase phaseName="2"/> + </TrainType> + <TrainType name="4" majorStops="4" cost="350" quantity="4"> + <NewPhase phaseName="3"/> + </TrainType> + <TrainType name="5" majorStops="5" cost="550" quantity="3"> + <NewPhase phaseName="4"/> + </TrainType> + <TrainType name="6" majorStops="6" cost="700" quantity="2"> + <NewPhase phaseName="5"/> + </TrainType> + <TrainType name="D" majorStops="99" cost="1100" quantity="-1"> + <NewPhase phaseName="6"/> <Exchange cost="750"/> </TrainType> </Component> @@ -76,7 +82,7 @@ <Privates sellingAllowed="yes"/> </Phase> <Phase name="3"> - <Tiles colour="yellow,green"/> + <Trains rusted="2"/> </Phase> <Phase name="4"> <Tiles colour="yellow,green,brown"/> @@ -86,10 +92,11 @@ </Phase> <Phase name="5"> <Tiles colour="yellow,green,brown,grey"/> + <Trains rusted="3" released="D"/> <Loans allowed="no"/> </Phase> <Phase name="6"> - <Tiles colour="yellow,green,brown,grey"/> + <Trains rusted="4"/> <OffBoardRevenue step="3"/> </Phase> </Component> Modified: trunk/18xx/data/18TN/Game.xml =================================================================== --- trunk/18xx/data/18TN/Game.xml 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/data/18TN/Game.xml 2011-07-07 19:23:32 UTC (rev 1610) @@ -84,19 +84,17 @@ <NewPhase phaseName="3"/> <NewPhase phaseName="3½" trainIndex="4"/> </TrainType> - <TrainType name="4" majorStops="4" cost="300" quantity="3" obsoleting="yes" - rustedTrain="2"> + <TrainType name="4" majorStops="4" cost="300" quantity="3" obsoleting="yes"> <NewPhase phaseName="4"/> </TrainType> <TrainType name="5" majorStops="5" cost="450" quantity="2"> <NewPhase phaseName="5"/> </TrainType> - <TrainType name="6" majorStops="6" cost="630" quantity="2" rustedTrain="3"> + <TrainType name="6" majorStops="6" cost="630" quantity="2"> <NewPhase phaseName="6"/> <NewPhase phaseName="6½" trainIndex="2"/> - <Sub index="2" rustedTrain="4"/> - </TrainType> - <TrainType name="8" majorStops="8" cost="700" quantity="7" rustedTrain="4"> + </TrainType> + <TrainType name="8" majorStops="8" cost="700" quantity="7"> <NewPhase phaseName="8"/> </TrainType> </Component> @@ -116,10 +114,9 @@ <OperatingRounds number="2"/> </Phase> <Phase name="3½"> - <Tiles colour="yellow,green"/> </Phase> <Phase name="4"> - <Tiles colour="yellow,green"/> + <Trains rusted="2"/> </Phase> <Phase name="5"> <Tiles colour="yellow,green,brown"/> @@ -128,13 +125,12 @@ <OffBoardRevenue step="2"/> </Phase> <Phase name="6"> - <Tiles colour="yellow,green,brown"/> + <Trains rusted="3"/> </Phase> <Phase name="6½"> - <Tiles colour="yellow,green,brown"/> + <Trains rusted="4"/> </Phase> <Phase name="8"> - <Tiles colour="yellow,green,brown"/> </Phase> </Component> </ComponentManager> \ No newline at end of file Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/OperatingRound.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -1302,6 +1302,7 @@ protected void initTurn() { log.debug("Starting turn of "+operatingCompany.get().getName()); + ReportBuffer.add(" "); ReportBuffer.add(LocalText.getText("CompanyOperates", operatingCompany.get().getName(), operatingCompany.get().getPresident().getName())); @@ -1645,6 +1646,7 @@ // priv.checkClosingIfExercised(true); //} + ReportBuffer.add(" "); ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); // Update the worth increase per player Modified: trunk/18xx/rails/game/Phase.java =================================================================== --- trunk/18xx/rails/game/Phase.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/Phase.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -45,6 +45,17 @@ /** Items to close if a phase gets activated */ protected List<Closeable> closedObjects = null; + + /** Train types to rust or obsolete if a phase gets activated */ + protected List<TrainCertificateType> rustedTrains; + String rustedTrainNames; + + /** Train types to release (make available for buying) if a phase gets activated */ + protected List<TrainCertificateType> releasedTrains; + String releasedTrainNames; + + private TrainManager trainManager; + private Portfolio lastTrainBuyer; protected String extraInfo = ""; @@ -123,6 +134,8 @@ Tag trainsTag = tag.getChild("Trains"); if (trainsTag != null) { + rustedTrainNames = trainsTag.getAttributeAsString("rusted", null); + releasedTrainNames = trainsTag.getAttributeAsString("released", null); trainTradingAllowed = trainsTag.getAttributeAsBoolean("tradingAllowed", trainTradingAllowed); @@ -159,8 +172,36 @@ } - public void finishConfiguration (GameManagerI gameManager) {} + public void finishConfiguration (GameManagerI gameManager) + throws ConfigurationException { + + trainManager = gameManager.getTrainManager(); + TrainCertificateType type; + + if (rustedTrainNames != null) { + rustedTrains = new ArrayList<TrainCertificateType>(2); + for (String typeName : rustedTrainNames.split(",")) { + type = trainManager.getCertTypeByName(typeName); + if (type == null) { + throw new ConfigurationException (" Unknown rusted train type '"+typeName+"' for phase '"+name+"'"); + } + rustedTrains.add(type); + type.setPermanent(false); + } + } + if (releasedTrainNames != null) { + releasedTrains = new ArrayList<TrainCertificateType>(2); + for (String typeName : releasedTrainNames.split(",")) { + type = trainManager.getCertTypeByName(typeName); + if (type == null) { + throw new ConfigurationException (" Unknown released train type '"+typeName+"' for phase '"+name+"'"); + } + releasedTrains.add(type); + } + } + } + /** Called when a phase gets activated */ public void activate() { log.debug("Phase " + name + " activated"); @@ -170,8 +211,24 @@ object.close(); } } + + if (rustedTrains != null && !rustedTrains.isEmpty()) { + for (TrainCertificateType type : rustedTrains) { + trainManager.rustTrainType(type, lastTrainBuyer); + } + } + + if (releasedTrains != null && !releasedTrains.isEmpty()) { + for (TrainCertificateType type : releasedTrains) { + trainManager.makeTrainAvailable(type); + } + } } + public void setLastTrainBuyer(Portfolio lastTrainBuyer) { + this.lastTrainBuyer = lastTrainBuyer; + } + public String getInfo() { return extraInfo; } @@ -233,6 +290,14 @@ return numberOfOperatingRounds; } + public List<TrainCertificateType> getRustedTrains() { + return rustedTrains; + } + + public List<TrainCertificateType> getReleasedTrains() { + return releasedTrains; + } + /** * @return Returns the offBoardRevenueStep. */ Modified: trunk/18xx/rails/game/PhaseI.java =================================================================== --- trunk/18xx/rails/game/PhaseI.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/PhaseI.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -39,4 +39,6 @@ public String getParameterAsString (String key); public int getParameterAsInteger (String key); + + public void setLastTrainBuyer(Portfolio lastTrainBuyer); } Modified: trunk/18xx/rails/game/PhaseManager.java =================================================================== --- trunk/18xx/rails/game/PhaseManager.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/PhaseManager.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -51,10 +51,16 @@ } } - public void finishConfiguration (GameManagerI gameManager) { + public void finishConfiguration (GameManagerI gameManager) + throws ConfigurationException { this.gameManager = gameManager; + + for (Phase phase : phaseList) { + phase.finishConfiguration(gameManager); + } + PhaseI initialPhase = phaseList.get(0); - setPhase(initialPhase); + setPhase(initialPhase, null); } public PhaseI getCurrentPhase() { @@ -69,12 +75,13 @@ return getCurrentPhase().getIndex(); } - public void setPhase(String name) { - setPhase(phaseMap.get(name)); + public void setPhase(String name, Portfolio lastTrainBuyer) { + setPhase(phaseMap.get(name), lastTrainBuyer); } - protected void setPhase(PhaseI phase) { + protected void setPhase(PhaseI phase, Portfolio lastTrainBuyer) { if (phase != null) { + phase.setLastTrainBuyer (lastTrainBuyer); currentPhase.set(phase); // TODO Redundant, should be replaced by phase.activate() Modified: trunk/18xx/rails/game/Portfolio.java =================================================================== --- trunk/18xx/rails/game/Portfolio.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/Portfolio.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -544,7 +544,9 @@ if (trainsOfType != null && !trainsOfType.isEmpty()) { for (TrainI train : trainsOfType) { if (b.length() > 0) b.append(" "); + if (train.isObsolete()) b.append("["); b.append(train.getName()); + if (train.isObsolete()) b.append("]"); } } } Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/StockRound.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -1312,6 +1312,7 @@ @Override protected void finishRound () { + ReportBuffer.add(" "); ReportBuffer.add(LocalText.getText("END_SR", String.valueOf(getStockRoundNumber()))); Modified: trunk/18xx/rails/game/TrainManager.java =================================================================== --- trunk/18xx/rails/game/TrainManager.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/TrainManager.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -308,7 +308,7 @@ String newPhase = boughtType.getStartedPhaseName(); if (newPhase != null) { - gameManager.getPhaseManager().setPhase(newPhase); + gameManager.getPhaseManager().setPhase(newPhase, train.getHolder()); phaseHasChanged = true; } @@ -329,7 +329,7 @@ Phase newPhase; if (newPhases.get(boughtType) != null && (newPhase = newPhases.get(boughtType).get(trainIndex)) != null) { - gameManager.getPhaseManager().setPhase(newPhase); + gameManager.getPhaseManager().setPhase(newPhase, train.getHolder()); phaseHasChanged = true; } Modified: trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -435,6 +435,7 @@ @Override protected void finishRound() { RoundI interruptedRound = gameManager.getInterruptedRound(); + ReportBuffer.add(" "); if (interruptedRound != null) { ReportBuffer.add(LocalText.getText("EndOfFormationRound", PR_ID, interruptedRound.getRoundName())); Modified: trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java =================================================================== --- trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -152,6 +152,8 @@ numberOfLoans, Bank.format(valuePerLoan), Bank.format(numberOfLoans * valuePerLoan)); + ReportBuffer.add(" "); + DisplayBuffer.add(" ", false); ReportBuffer.add(message); DisplayBuffer.add(message, false); @@ -428,6 +430,8 @@ } message = LocalText.getText("CompanyHasShares", cgr.getName(), 100/cgr.getShareUnit(), cgr.getShareUnit()); + DisplayBuffer.add(" "); + ReportBuffer.add(" "); DisplayBuffer.add(message); ReportBuffer.add(message); Modified: trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java 2011-07-07 12:58:55 UTC (rev 1609) +++ trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java 2011-07-07 19:23:32 UTC (rev 1610) @@ -244,6 +244,7 @@ setStep(OPEN_STEP); } + ReportBuffer.add(" "); ReportBuffer.add(LocalText.getText("SelectForAuctioning", playerName, item.getName() )); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |