You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: <ste...@us...> - 2010-08-28 16:58:06
|
Revision: 1407 http://rails.svn.sourceforge.net/rails/?rev=1407&view=rev Author: stefanfrey Date: 2010-08-28 16:57:59 +0000 (Sat, 28 Aug 2010) Log Message: ----------- - Fix of 18AL coalfield token bug: The bonus was not correctly removed at phase 6. - Also changed Set of revenue modifiers to stateful lists. Modified Paths: -------------- trunk/18xx/rails/algorithms/RevenueManager.java trunk/18xx/rails/game/Bonus.java trunk/18xx/rails/game/PublicCompany.java trunk/18xx/rails/game/move/RemoveFromList.java Added Paths: ----------- trunk/18xx/rails/game/state/HashSetState.java Modified: trunk/18xx/rails/algorithms/RevenueManager.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueManager.java 2010-08-22 20:48:44 UTC (rev 1406) +++ trunk/18xx/rails/algorithms/RevenueManager.java 2010-08-28 16:57:59 UTC (rev 1407) @@ -10,6 +10,7 @@ import rails.game.ConfigurableComponentI; import rails.game.ConfigurationException; import rails.game.GameManagerI; +import rails.game.state.HashSetState; import rails.util.LocalText; import rails.util.Tag; @@ -29,15 +30,15 @@ Logger.getLogger(RevenueManager.class.getPackage().getName()); - private final Set<NetworkGraphModifier> graphModifiers; - private final Set<RevenueStaticModifier> staticModifiers; - private final Set<RevenueDynamicModifier> dynamicModifiers; - private final Set<ConfigurableComponentI> configurableModifiers; + private final HashSetState<NetworkGraphModifier> graphModifiers; + private final HashSetState<RevenueStaticModifier> staticModifiers; + private final HashSetState<RevenueDynamicModifier> dynamicModifiers; + private final HashSet<ConfigurableComponentI> configurableModifiers; public RevenueManager() { - graphModifiers = new HashSet<NetworkGraphModifier>(); - staticModifiers = new HashSet<RevenueStaticModifier>(); - dynamicModifiers = new HashSet<RevenueDynamicModifier>(); + graphModifiers = new HashSetState<NetworkGraphModifier>("NetworkGraphModifiers"); + staticModifiers = new HashSetState<RevenueStaticModifier>("RevenueStaticModifiers"); + dynamicModifiers = new HashSetState<RevenueDynamicModifier>("RevenueDynamicModifiers"); configurableModifiers = new HashSet<ConfigurableComponentI>(); } @@ -144,20 +145,20 @@ } void callGraphModifiers(NetworkGraphBuilder graphBuilder) { - for (NetworkGraphModifier modifier:graphModifiers) { + for (NetworkGraphModifier modifier:graphModifiers.viewSet()) { modifier.modifyGraph(graphBuilder); } } void callStaticModifiers(RevenueAdapter revenueAdapter) { - for (RevenueStaticModifier modifier:staticModifiers) { + for (RevenueStaticModifier modifier:staticModifiers.viewSet()) { modifier.modifyCalculator(revenueAdapter); } } Set<RevenueDynamicModifier> callDynamicModifiers(RevenueAdapter revenueAdapter) { Set<RevenueDynamicModifier> activeModifiers = new HashSet<RevenueDynamicModifier>(); - for (RevenueDynamicModifier modifier:dynamicModifiers) { + for (RevenueDynamicModifier modifier:dynamicModifiers.viewSet()) { if (modifier.prepareModifier(revenueAdapter)) activeModifiers.add(modifier); } Modified: trunk/18xx/rails/game/Bonus.java =================================================================== --- trunk/18xx/rails/game/Bonus.java 2010-08-22 20:48:44 UTC (rev 1406) +++ trunk/18xx/rails/game/Bonus.java 2010-08-28 16:57:59 UTC (rev 1407) @@ -40,8 +40,8 @@ // add them to the call list of the RevenueManager GameManager.getInstance().getRevenueManager().addStaticModifier(this); - } + } public boolean isExecutionable() { return false; } @@ -77,38 +77,15 @@ } /** - * Remove the token. + * Remove the bonus * This method can be called by a certain phase when it starts. * See prepareForRemovel(). */ public void close() { - owner.removeBonus(name); - // remove it from the call list of the RevenueManager GameManager.getInstance().getRevenueManager().removeStaticModifier(this); } - /** - * Prepare the bonus token for removal, if so configured. - * The only case currently implemented to trigger removal - * is the start of a given phase. - */ - public void prepareForRemoval (PhaseManager phaseManager) { - - if (removingObjectDesc == null) return; - - if (removingObject == null) { - String[] spec = removingObjectDesc.split(":"); - if (spec[0].equalsIgnoreCase("Phase")) { - removingObject = - phaseManager.getPhaseByName(spec[1]); - } - } - - if (removingObject instanceof Phase) { - ((Phase) removingObject).addObjectToClose(this); - } - } - + public boolean equals (Bonus b) { return (b.name.equals(name)) && b.value == value; Modified: trunk/18xx/rails/game/PublicCompany.java =================================================================== --- trunk/18xx/rails/game/PublicCompany.java 2010-08-22 20:48:44 UTC (rev 1406) +++ trunk/18xx/rails/game/PublicCompany.java 2010-08-28 16:57:59 UTC (rev 1407) @@ -1755,6 +1755,7 @@ } public boolean removeBonus(Bonus bonus) { + bonus.close(); // close the bonus new RemoveFromList<Bonus> (bonuses, bonus, name+"_Bonuses", bonusValue); return true; } Modified: trunk/18xx/rails/game/move/RemoveFromList.java =================================================================== --- trunk/18xx/rails/game/move/RemoveFromList.java 2010-08-22 20:48:44 UTC (rev 1406) +++ trunk/18xx/rails/game/move/RemoveFromList.java 2010-08-28 16:57:59 UTC (rev 1407) @@ -37,12 +37,14 @@ @Override public boolean execute() { list.remove(object); + updateModels(); return true; } @Override public boolean undo() { list.add(index, object); + updateModels(); return true; } Added: trunk/18xx/rails/game/state/HashSetState.java =================================================================== --- trunk/18xx/rails/game/state/HashSetState.java (rev 0) +++ trunk/18xx/rails/game/state/HashSetState.java 2010-08-28 16:57:59 UTC (rev 1407) @@ -0,0 +1,69 @@ +package rails.game.state; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import rails.game.move.SetChange; +/** + * State class that wraps a HashSet + * Generates according set moves + * + * Remark: Does not extend State or implements StateI do avoid additional overhead + * All state/move mechanisms already contained in Move objects + * + * TODO: Replace all stateful sets by this class and simplify according move objects + */ +public class HashSetState<E> { + + private final HashSet<E> set = new HashSet<E>(); + private final String setName; + + /** + * constructor for an empty set + * @param name + */ + public HashSetState(String setName) { + this.setName = setName; + } + /** + * constructor for a prefilled set + * @param element + */ + public HashSetState(String setName, Collection<E> collection) { + this(setName); + set.addAll(collection); + } + + public void add(E element) { + new SetChange<E>(set, element, true); + } + + public boolean remove(E element) { + if (set.contains(element)) { + new SetChange<E>(set, element, false); + return true; + } else { + return false; + } + } + + public void clear() { + for (E element:set) { + remove(element); + } + } + + /** + * returns unmodifiable view of set + */ + public Set<E> viewSet() { + return Collections.unmodifiableSet(set); + } + + public int size() { + return set.size(); + } + +} Property changes on: trunk/18xx/rails/game/state/HashSetState.java ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 20:48:50
|
Revision: 1406 http://rails.svn.sourceforge.net/rails/?rev=1406&view=rev Author: stefanfrey Date: 2010-08-22 20:48:44 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Changed 1889 limitations Modified Paths: -------------- trunk/18xx/data/GamesList.xml Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-08-22 20:13:41 UTC (rev 1405) +++ trunk/18xx/data/GamesList.xml 2010-08-22 20:48:44 UTC (rev 1406) @@ -78,7 +78,7 @@ Published by Wild Heaven Productions and Deep Thought Games Limitation: -- Forced Selling: Change of director in other company is not prevented by Rails (see rule 10.6.2) +- Privates cannot be traded between players. </Description> <Players minimum="2" maximum="6"/> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 20:13:47
|
Revision: 1405 http://rails.svn.sourceforge.net/rails/?rev=1405&view=rev Author: stefanfrey Date: 2010-08-22 20:13:41 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Fixed undo problem for time history Modified Paths: -------------- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 19:58:50 UTC (rev 1404) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 20:13:41 UTC (rev 1405) @@ -164,10 +164,16 @@ boolean haveRedo = false; List<GameAction> gameActions = PossibleActions.getInstance().getType(GameAction.class); + boolean undoFlag = false; for (GameAction action:gameActions) { switch (action.getMode()) { case GameAction.UNDO: + undoFlag = true; + backwardButton.setPossibleAction(action); + backwardButton.setEnabled(true); + break; case GameAction.FORCED_UNDO: + if (undoFlag) break; // only activate forced undo, if no other undo available backwardButton.setPossibleAction(action); backwardButton.setEnabled(true); break; @@ -175,7 +181,6 @@ forwardButton.setPossibleAction(action); forwardButton.setEnabled(true); haveRedo = true; - if (!timeWarpMode) activateTimeWarp(); break; } } @@ -205,6 +210,13 @@ public void actionPerformed(ActionEvent e) { ActionButton button = (ActionButton)e.getSource(); GameAction action = (GameAction)button.getPossibleActions().get(0); + if (action instanceof GameAction && (action.getMode() == GameAction.FORCED_UNDO)) { + if (!timeWarpMode) { + activateTimeWarp(); + } + } + + gameUIManager.processOnServer(action); } @@ -214,6 +226,9 @@ // String protocol = e.getURL().getProtocol(); int index = url.getPort(); gotoIndex(index + 1); + if (!timeWarpMode) { + activateTimeWarp(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 19:58:56
|
Revision: 1404 http://rails.svn.sourceforge.net/rails/?rev=1404&view=rev Author: stefanfrey Date: 2010-08-22 19:58:50 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Updated 1870 to not yet playable status Modified Paths: -------------- trunk/18xx/data/GamesList.xml Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-08-22 19:53:34 UTC (rev 1403) +++ trunk/18xx/data/GamesList.xml 2010-08-22 19:58:50 UTC (rev 1404) @@ -180,12 +180,12 @@ </Game> <Game name="1870"> - <Note>Partly playable</Note> + <Note>Not yet playable</Note> <Description>1870 - Railroading across the Trans Mississippi (c) 1992, 1995 Mayfair Games, Inc. Designed by Bill Dixon - -Aspects not present in 1830 have not been implemented yet. +Limitations: +All aspects not present in 1830 have not been implemented yet. </Description> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 19:53:40
|
Revision: 1403 http://rails.svn.sourceforge.net/rails/?rev=1403&view=rev Author: stefanfrey Date: 2010-08-22 19:53:34 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Final improvements to Gamehistory report window for upcoming release Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/move/MoveStack.java trunk/18xx/rails/ui/swing/AbstractReportWindow.java trunk/18xx/rails/ui/swing/ConfigWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/ui/swing/MessagePanel.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/LocalisedText.properties 2010-08-22 19:53:34 UTC (rev 1403) @@ -494,11 +494,14 @@ RepayLoans=Repay loan(s) RepayLoan=Repay {0} loan(s) of {1} for {2} REPORT=Report Window -REPORT_MOVE_BACKWARD=< -REPORT_MOVE_FORWARD=> REPORT_COMMENT=Comment REPORT_COMMENT_TITLE=Add Comment REPORT_COMMENT_ASK=Add a comment to the previous action +REPORT_MOVE_BACKWARD=< +REPORT_MOVE_FORWARD=> +REPORT_PLAY_FROM_HERE=Play from here +REPORT_LEAVE_TIMEWARP=Leave history +REPORT_TIMEWARP_ACTIVE=<html><center><font color="red"> Game history active <br> (Other windows disabled) </font></center></html> REVENUE=Revenue RevenueBonus=Bonus(es) = {0} RevenueCalculation=support for revenue calculation Modified: trunk/18xx/rails/game/move/MoveStack.java =================================================================== --- trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -178,6 +178,10 @@ } } + public int size() { + return moveStack.size(); + } + /** * undo/redo to a given moveStack index */ Modified: trunk/18xx/rails/ui/swing/AbstractReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -10,6 +10,9 @@ public abstract class AbstractReportWindow extends JFrame { private static final long serialVersionUID = 1L; + + // can be set to false, than it cannot be closed + protected boolean closeable = true; public void init() { setSize(400, 400); @@ -17,13 +20,16 @@ setTitle(LocalText.getText("GameReportTitle")); final JFrame frame = this; + this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { + if (!closeable) return; StatusWindow.uncheckMenuItemBox(StatusWindow.REPORT_CMD); frame.dispose(); } }); + setVisible("yes".equalsIgnoreCase(Config.get("report.window.open"))); } Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -555,6 +555,12 @@ private boolean saveConfig() { Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile + + if (fromStatusWindow) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), + LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); + } + if (Config.saveActiveProfile()) { JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_CONFIRM_MESSAGE", Config.getActiveProfileName()), LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE); Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -1,5 +1,7 @@ package rails.ui.swing; +import java.awt.Component; +import java.awt.Container; import java.awt.EventQueue; import java.awt.Font; import java.awt.GraphicsConfiguration; @@ -822,7 +824,26 @@ public boolean getGameParameterAsBoolean (GuiDef.Parm key) { return (Boolean) getGameParameter(key); } + + private void setEnabledWindow(boolean enabled, JFrame window, JFrame exceptionWindow) { + + if (window != null && window != exceptionWindow) { + window.setEnabled(enabled); + } + } + /** + * deactivate all game windows, except the argument one + */ + public void setEnabledAllWindows(boolean enabled, JFrame exceptionWindow) { + setEnabledWindow(enabled, stockChart, exceptionWindow); + setEnabledWindow(enabled, reportWindow, exceptionWindow); + setEnabledWindow(enabled, configWindow, exceptionWindow); + setEnabledWindow(enabled, orWindow, exceptionWindow); + setEnabledWindow(enabled, startRoundWindow, exceptionWindow); + setEnabledWindow(enabled, statusWindow, exceptionWindow); + } + private void updateWindowsLookAndFeel() { SwingUtilities.updateComponentTreeUI(statusWindow); statusWindow.pack(); @@ -843,11 +864,5 @@ Scale.initFromConfiguration(); instance.initFontSettings(); instance.updateWindowsLookAndFeel(); - -// EventQueue.invokeLater(new Runnable() { -// public void run() { -// instance.repaintWindows(); -// } -// }); } } Modified: trunk/18xx/rails/ui/swing/MessagePanel.java =================================================================== --- trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -75,7 +75,7 @@ // display String text = messageText.toString(); int lines = text.split("<[Bb][Rr]>").length + 1; - setLines(lines); +// setLines(lines); message.setText("<html><center>" + text + "</center></html>"); } Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -1,7 +1,10 @@ package rails.ui.swing; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Font; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URL; @@ -9,6 +12,7 @@ import javax.swing.JButton; import javax.swing.JEditorPane; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -36,14 +40,20 @@ private GameUIManager gameUIManager; + private JLabel message; + private JScrollPane reportPane; private JEditorPane editorPane; private JPanel buttonPanel; private ActionButton forwardButton; private ActionButton backwardButton; + private JButton returnButton; + private JButton playFromHereButton; private JButton commentButton; + private boolean timeWarpMode; + protected static Logger log = Logger.getLogger(ReportWindowDynamic.class.getPackage().getName()); @@ -54,6 +64,41 @@ } public void init() { + super.init(); + + setLayout(new BorderLayout()); + + JPanel messagePanel = new JPanel(); + messagePanel.setLayout(new BorderLayout()); + + message = new JLabel(); + message.setText( LocalText.getText("REPORT_TIMEWARP_ACTIVE")); + message.setHorizontalAlignment(JLabel.CENTER); + messagePanel.add(message, "North"); + + JPanel timeWarpButtons = new JPanel(); + returnButton = new JButton(LocalText.getText("REPORT_LEAVE_TIMEWARP")); + returnButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + gotoLastIndex(); + } + } + ); + timeWarpButtons.add(returnButton); + + playFromHereButton = new JButton(LocalText.getText("REPORT_PLAY_FROM_HERE")); + playFromHereButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + deactivateTimeWarp(); + } + } + ); + timeWarpButtons.add(playFromHereButton); + messagePanel.add(timeWarpButtons, "South"); + add(messagePanel, "North"); + editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setContentType("text/html"); @@ -74,7 +119,6 @@ buttonPanel = new JPanel(); add(buttonPanel, "South"); - backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD")); backwardButton.addActionListener(this); buttonPanel.add(backwardButton); @@ -83,6 +127,7 @@ forwardButton.addActionListener(this); buttonPanel.add(forwardButton); + commentButton = new JButton(LocalText.getText("REPORT_COMMENT")); commentButton.addActionListener( new ActionListener() { @@ -106,7 +151,6 @@ ); buttonPanel.add(commentButton); - super.init(); } @Override @@ -116,7 +160,9 @@ scrollDown(); forwardButton.setEnabled(false); - backwardButton.setEnabled(true); + backwardButton.setEnabled(false); + + boolean haveRedo = false; List<GameAction> gameActions = PossibleActions.getInstance().getType(GameAction.class); for (GameAction action:gameActions) { switch (action.getMode()) { @@ -128,9 +174,12 @@ case GameAction.REDO: forwardButton.setPossibleAction(action); forwardButton.setEnabled(true); + haveRedo = true; + if (!timeWarpMode) activateTimeWarp(); break; } } + if (!haveRedo) deactivateTimeWarp(); } @Override @@ -168,6 +217,10 @@ } } + private void gotoLastIndex() { + gotoIndex(gameUIManager.getGameManager().getMoveStack().size()); + } + private void gotoIndex(int index) { MoveStack stack = gameUIManager.getGameManager().getMoveStack(); int currentIndex = stack.getIndex(); @@ -182,4 +235,21 @@ } } + private void activateTimeWarp() { + message.setVisible(true); + playFromHereButton.setVisible(true); + returnButton.setVisible(true); + gameUIManager.setEnabledAllWindows(false, this); + timeWarpMode = true; + closeable = false; + } + + private void deactivateTimeWarp() { + gameUIManager.setEnabledAllWindows(true, this); + message.setVisible(false); + playFromHereButton.setVisible(false); + returnButton.setVisible(false); + timeWarpMode = false; + closeable = true; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-22 15:47:34
|
Revision: 1402 http://rails.svn.sourceforge.net/rails/?rev=1402&view=rev Author: evos Date: 2010-08-22 15:47:27 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Minor comment fix Modified Paths: -------------- trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java Modified: trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-22 15:47:01 UTC (rev 1401) +++ trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-22 15:47:27 UTC (rev 1402) @@ -79,9 +79,8 @@ bankrupter.getPortfolio().swapPresidentCertificate(company, newPresident.getPortfolio()); } else { - company.setClosed(); + company.setClosed(); // This also makes majors restartable ReportBuffer.add(LocalText.getText("CompanyCloses", company.getName())); - // TODO: can be restarted (in 18EU) } } // Dump all shares This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-22 15:47:07
|
Revision: 1401 http://rails.svn.sourceforge.net/rails/?rev=1401&view=rev Author: evos Date: 2010-08-22 15:47:01 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Reset 'operated' flag when making a bankrupted 18EU major restartable. Modified Paths: -------------- trunk/18xx/rails/game/PublicCompany.java Modified: trunk/18xx/rails/game/PublicCompany.java =================================================================== --- trunk/18xx/rails/game/PublicCompany.java 2010-08-22 15:32:27 UTC (rev 1400) +++ trunk/18xx/rails/game/PublicCompany.java 2010-08-22 15:47:01 UTC (rev 1401) @@ -829,16 +829,16 @@ public void setHomeCityNumber(int number) { this.homeCityNumber = number; } - + /** * @return true -> requires an open slot in each city of the hex, false -> one slot on the hex - * + * */ public boolean isHomeBlockedForAllCities() { return homeAllCitiesBlocked; } - + /** * @return Returns the destinationHex. */ @@ -1035,6 +1035,7 @@ protected void reinitialise () { hasStarted.set(false); hasFloated.set(false); + hasOperated.set(false); if (parPrice != null && fixedPrice <= 0) parPrice.setPrice(null); if (currentPrice != null) currentPrice.setPrice(null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 15:32:33
|
Revision: 1400 http://rails.svn.sourceforge.net/rails/?rev=1400&view=rev Author: stefanfrey Date: 2010-08-22 15:32:27 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Added HashMapState Used that to fix problems with TileLaysPerColour And fixed wrong valuation of bankrupt player Modified Paths: -------------- trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/Player.java trunk/18xx/rails/game/ShareSellingRound.java trunk/18xx/rails/game/move/MapChange.java trunk/18xx/rails/game/state/ArrayListState.java Added Paths: ----------- trunk/18xx/rails/game/move/RemoveFromMap.java trunk/18xx/rails/game/state/HashMapState.java Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/GameManager.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -995,12 +995,12 @@ File recoveryFile = null; boolean result; try { - log.debug("Created temporary recovery file, path = " + tempFile.getAbsolutePath()); + log.debug("Created temporary recovery file, path = " + tempFile.getPath()); // check if previous save file exists recoveryFile = new File(filePath); - log.debug("Potential recovery filePath = " + recoveryFile.getAbsolutePath()); + log.debug("Potential recovery filePath = " + recoveryFile.getPath()); if (recoveryFile.exists()) { - log.debug("Potential recovery filePath = " + recoveryFile.getAbsolutePath()); + log.debug("Potential recovery filePath = " + recoveryFile.getPath()); File backupFile = new File(filePath + ".bak"); if (recoveryFile.renameTo(backupFile)) { result = tempFile.renameTo(recoveryFile); @@ -1018,7 +1018,7 @@ } if (result) { - log.debug("Renamed to recovery file, path = " + recoveryFile.getAbsolutePath()); + log.debug("Renamed to recovery file, path = " + recoveryFile.getPath()); if (!recoverySaveWarning) { DisplayBuffer.add(LocalText.getText("RecoverySaveSuccessAgain")); recoverySaveWarning = true; Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/OperatingRound.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -13,6 +13,7 @@ import rails.game.state.ArrayListState; import rails.game.state.EnumState; import rails.game.state.GenericState; +import rails.game.state.HashMapState; import rails.util.LocalText; import rails.util.SequenceUtil; @@ -49,8 +50,8 @@ protected List<LayTile> currentNormalTileLays = new ArrayList<LayTile>(); - protected Map<String, Integer> tileLaysPerColour = - new HashMap<String, Integer>(); + protected HashMapState<String, Integer> tileLaysPerColour = + new HashMapState<String, Integer>("tileLaysPerColour"); protected List<LayBaseToken> currentNormalTokenLays = new ArrayList<LayBaseToken>(); @@ -450,10 +451,6 @@ protected boolean checkNormalTileLay(TileI tile, boolean update) { - // Map<String,Integer> tileLaysPerColour = tileLaysPerColourState.getObject(); - - // if (tileLaysPerColour.isEmpty()) return false; - String colour = tile.getColourName(); Integer oldAllowedNumberObject = tileLaysPerColour.get(colour); @@ -471,28 +468,23 @@ * different colours may be laid. THIS MAY NOT BE TRUE FOR ALL GAMES! */ - // Map<String,Integer> tileLaysPerColourUpdated = new HashMap<String, Integer>(); // new (empty) map - if (oldAllowedNumber <= 1) { - for (String key:tileLaysPerColour.keySet()) - new MapChange<String,Integer>(tileLaysPerColour, key, new Integer(0)); + for (String key:tileLaysPerColour.viewKeySet()) { + tileLaysPerColour.put(key, new Integer(0)); + } log.debug("No more normal tile lays allowed"); currentNormalTileLays.clear(); } else { - // tileLaysPerColourUpdated.put(colour, new Integer(oldAllowedNumber - 1)); - for (String key:tileLaysPerColour.keySet()) - if (colour.equals(key)) - new MapChange<String,Integer> - (tileLaysPerColour, colour, new Integer(oldAllowedNumber-1)); - else - new MapChange<String,Integer>(tileLaysPerColour, key, new Integer(0)); - + for (String key:tileLaysPerColour.viewKeySet()) { + if (colour.equals(key)) { + tileLaysPerColour.put(colour, new Integer(oldAllowedNumber-1)); + } else { + tileLaysPerColour.put(key, new Integer(0)); + } + } log.debug((oldAllowedNumber - 1) + " more " + colour + " tile lays allowed"); } - - // tileLaysPerColourState.set(tileLaysPerColourUpdated); - return true; } @@ -1306,20 +1298,16 @@ * of the tile laying step. */ protected void getNormalTileLays() { - - // Map<String,Integer> - tileLaysPerColour = - new HashMap<String, Integer>(getCurrentPhase().getTileColours()); // Clone - - int allowedNumber; - for (String colour : tileLaysPerColour.keySet()) { - allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); + + // duplicate the phase colours + Map<String, Integer> newTileColours = new HashMap<String, Integer>(getCurrentPhase().getTileColours()); + for (String colour : newTileColours.keySet()) { + int allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); // Replace the null map value with the allowed number of lays - new MapChange<String, Integer>(tileLaysPerColour, colour, new Integer(allowedNumber)); + newTileColours.put(colour, new Integer(allowedNumber)); } - - // store state - // tileLaysPerColourState = new GenericState<Map<String,Integer>>("tileLaysPerColour", tileLaysPerColour); + // store to state + tileLaysPerColour.initFromMap(newTileColours); } protected void setNormalTileLays() { @@ -1330,11 +1318,11 @@ // Map<String,Integer> tileLaysPerColour = (Map<String,Integer>)(tileLaysPerColourState.getObject()); int sumLays = 0; - for (Integer i: tileLaysPerColour.values()) + for (Integer i: tileLaysPerColour.viewValues()) sumLays = sumLays + i; if (sumLays != 0) { // if (!tileLaysPerColour.isEmpty()) { - currentNormalTileLays.add(new LayTile(tileLaysPerColour)); + currentNormalTileLays.add(new LayTile(tileLaysPerColour.viewMap())); } } Modified: trunk/18xx/rails/game/Player.java =================================================================== --- trunk/18xx/rails/game/Player.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/Player.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -83,8 +83,15 @@ * @return Total worth */ public int getWorth() { - int worth = wallet.getCash(); - + // if player is bankrupt cash is not counted + // as this was generated during forced selling + int worth; + if (bankrupt.booleanValue()) { + worth = 0; + } else { + worth = wallet.getCash(); + } + for (PublicCertificateI cert : portfolio.getCertificates()) { worth += cert.getCompany().getGameEndPrice() * cert.getShares(); } Modified: trunk/18xx/rails/game/ShareSellingRound.java =================================================================== --- trunk/18xx/rails/game/ShareSellingRound.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/ShareSellingRound.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -423,7 +423,7 @@ } else if (getSellableShares().isEmpty()) { DisplayBuffer.add(LocalText.getText("YouMustRaiseCashButCannot", Bank.format(cashToRaise.intValue()))); - + currentPlayer.setBankrupt(); gameManager.registerBankruptcy(); } Modified: trunk/18xx/rails/game/move/MapChange.java =================================================================== --- trunk/18xx/rails/game/move/MapChange.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/move/MapChange.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -20,6 +20,10 @@ protected V oldValue; protected boolean keyExisted; + /** + * Creates a move that changes a map <key,value> pair + */ + public MapChange (Map<K, V> map, K key, V newValue) { this.map = map; @@ -30,29 +34,22 @@ MoveSet.add(this); } - + @Override public boolean execute() { - map.put(key, newValue); - return true; } @Override public boolean undo() { - if (keyExisted) { map.put (key, oldValue); - } else { - map.remove(key); } - return true; } public String toString() { return "MapChange: key="+key+" from "+oldValue+" to "+newValue; } - } Added: trunk/18xx/rails/game/move/RemoveFromMap.java =================================================================== --- trunk/18xx/rails/game/move/RemoveFromMap.java (rev 0) +++ trunk/18xx/rails/game/move/RemoveFromMap.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -0,0 +1,55 @@ +/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/move/MapChange.java,v 1.4 2010/05/05 21:36:59 evos Exp $ + * + * Created on 19-Jul-2006 + * Change Log: + */ +package rails.game.move; + +import java.util.Map; + +/** + * This Move class handles removable from a stateful map (collection) + * + * @author Erik Vos + */ +public class RemoveFromMap<K, V> extends Move { + + protected Map<K, V> map; + protected K key; + protected V oldValue; + protected boolean keyExisted; + + /** + * Creates a move that removes key from map + */ + + public RemoveFromMap (Map<K, V> map, K key) { + + this.map = map; + this.key = key; + this.keyExisted = map.containsKey(key); + + MoveSet.add(this); + } + + @Override + public boolean execute() { + if (keyExisted) { + map.remove(key); + } + return true; + } + + @Override + public boolean undo() { + if (keyExisted) { + map.put (key, oldValue); + } + return true; + } + + public String toString() { + return "RemoveFromMap: remove key="+key+" from map"; + } + +} Property changes on: trunk/18xx/rails/game/move/RemoveFromMap.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/18xx/rails/game/state/ArrayListState.java =================================================================== --- trunk/18xx/rails/game/state/ArrayListState.java 2010-08-22 15:30:41 UTC (rev 1399) +++ trunk/18xx/rails/game/state/ArrayListState.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import rails.game.move.AddToList; @@ -12,50 +11,57 @@ /** * State class that wraps an ArrayList * Generates according list moves + * + * Remark: Does not extend State or implements StateI do avoid additional overhead + * All state/move mechanisms already contained in Move objects + * For the future a simpler unified StateI would make things clearer * - * @author freystef - * + * TODO: Replace all stateful lists by this class and simplify according move objects + * */ -public class ArrayListState<E> extends State { +public class ArrayListState<E> { private final ArrayList<E> list = new ArrayList<E>(); + private String listName; + /** * constructor for an empty list * @param name */ - public ArrayListState(String name) { - super(name, ArrayList.class); + public ArrayListState(String listName) { + this.listName = listName; } /** * constructor for a prefilled list * @param element */ - public ArrayListState(String name, Collection<E> collection) { - super(name, ArrayList.class); - for (E element:collection) { - add(element); - } + public ArrayListState(String listName, Collection<E> collection) { + this(listName); + list.addAll(collection); } public void add(E element) { - new AddToList<E>(list, element, name); + new AddToList<E>(list, element, listName); } public void add(int index, E element) { - new AddToList<E>(list, element, name).atIndex(index); + new AddToList<E>(list, element, listName).atIndex(index); } public void remove(E element) { - new RemoveFromList<E>(list, element, name); + new RemoveFromList<E>(list, element, listName); } public void clear() { for (E element:list) { - new RemoveFromList<E>(list, element, name); + remove(element); } } + /** + * returns unmodifiable view of list + */ public List<E> viewList() { return Collections.unmodifiableList(list); } Added: trunk/18xx/rails/game/state/HashMapState.java =================================================================== --- trunk/18xx/rails/game/state/HashMapState.java (rev 0) +++ trunk/18xx/rails/game/state/HashMapState.java 2010-08-22 15:32:27 UTC (rev 1400) @@ -0,0 +1,103 @@ +package rails.game.state; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import rails.game.move.MapChange; +import rails.game.move.RemoveFromMap; + +/** + * State class that wraps a HashMap + * Generates according map moves + * + * Remark: Does not extend State or implements StateI do avoid additional overhead + * All state/move mechanisms already contained in Move objects + * For the future a simpler unified StateI would make things clearer + * + * TODO: Replace all stateful HashMaps by this class and simplify according move objects + * + */ + +public class HashMapState<K,V>{ + + private final HashMap<K,V> map = new HashMap<K,V>(); + private String mapName; + + /** + * constructor for an empty map + */ + public HashMapState(String listName) { + this.mapName = listName; + } + /** + * constructor for a prefilled map + */ + public HashMapState(String listName, Map<K,V> map) { + this(listName); + } + + public void put(K key, V value) { + new MapChange<K,V>(map, key, value); + } + + public void putAll(Map<K,V> map) { + for (K key:map.keySet()) { + new MapChange<K,V>(map, key, map.get(key)); + } + } + + public V get(K key) { + return map.get(key); + } + + public void remove(K key) { + new RemoveFromMap<K,V>(map, key); + } + + public void clear() { + for (K key:map.keySet()) { + remove(key); + } + } + + /** + * (re)intializes the state map from another map + * efficiently generates the required moves + */ + public void initFromMap(Map<K,V> initMap) { + for (K key:map.keySet()) { + // union elements + if (initMap.containsKey(key)) { + new MapChange<K,V>(map, key, initMap.get(key)); + } else { // only in the old map + new RemoveFromMap<K,V>(map, key); + } + } + for (K key:initMap.keySet()) { + // new elements + if (!map.containsKey(key)) { + new MapChange<K,V>(map, key, initMap.get(key)); + } + } + } + + /** + * @return unmodifiable view of map + */ + public Map<K,V> viewMap() { + return Collections.unmodifiableMap(map); + } + /** + * @return unmodifiable view of keyset + */ + public Set<K> viewKeySet() { + return Collections.unmodifiableSet(map.keySet()); + } + + public Collection<V> viewValues() { + return Collections.unmodifiableCollection(map.values()); + } +} Property changes on: trunk/18xx/rails/game/state/HashMapState.java ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 15:30:48
|
Revision: 1399 http://rails.svn.sourceforge.net/rails/?rev=1399&view=rev Author: stefanfrey Date: 2010-08-22 15:30:41 +0000 (Sun, 22 Aug 2010) Log Message: ----------- A simplification of the config window before the upcoming release Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/ui/swing/ConfigWindow.java trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/util/Config.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/LocalisedText.properties 2010-08-22 15:30:41 UTC (rev 1399) @@ -71,16 +71,21 @@ CONFIG=Configuration CONFIG_APPLY_MESSAGE=<html>Current changes (will be) applied.<br>Be aware that some changes to be active require <br> UI redraws or a restart of Rails.</html> CONFIG_APPLY_TITLE=Apply confirmation +CONFIG_CURRENT_PATH=Active filepath = {0} CONFIG_CURRENT_PROFILE=Active profile = {0} (based on = {1}) CONFIG_DEFAULT_TITLE=Default profile CONFIG_DEFAULT_MESSAGE=Select a template for settings CONFIG_INFO_TITLE=Info text for {0} +CONFIF_LOAD_ERROR_MESSAGE=An error occurred during load of the file {0}.\nProfile was not loaded. +CONFIG_LOAD_TITLE=Load of profile CONFIG_NEW_MESSAGE=Select a name of the new profile CONFIG_NEW_TITLE=Create profile +CONFIG_PROFILE_ERROR_MESSAGE=An error occurred during save of the profile list in the current working directory.\nCould not store the name and filepath of the new profile. CONFIG_SELECT_PROFILE=Select profile -> CONFIG_SETTINGS=Profile settings -CONFIG_SAVE_MESSAGE=Active profile {0} was saved -CONFIG_SAVE_TITLE=Save confirmation +CONFIG_SAVE_ERROR_MESSAGE=An error occurred during save of active profile {0}.\nProfile was not saved. +CONFIG_SAVE_CONFIRM_MESSAGE=Active profile {0} was saved. +CONFIG_SAVE_TITLE=Save of profile CONFIG_WINDOW_TITLE=Rails Configuration CORRECT_CASH=Cash Correction CORRECT_MAP=Map Correction @@ -296,6 +301,7 @@ HIDE_OPTIONS=Hide Options HoldMoneyInEscrow=The price of {0} is paid to the Bank, which now holds {1} in escrow for {2} HOW_MANY_SHARES=How many shares? +IMPORT=Import INFO=Game Notes Info=Info Insert=Insert @@ -507,6 +513,7 @@ RustsTrains=Rusts {0}-trains SaleNotAllowed=Selling shares of company {0} is not allowed SAVE=Save +SAVE_AND_APPLY=Save/Apply SAVEAS=Save As ... SaveFailed=Save failed, reason: {0} Select=Select Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -6,7 +6,6 @@ import java.awt.GraphicsEnvironment; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -57,16 +56,21 @@ private static final long serialVersionUID = 1L; private static final String CONFIG_EXTENSION = ".rails_config"; - private static final String CONFIG_DESCRIPTION = "Rails configuration files ( *.rails_config )"; + private static final String LEGACY_EXTENSION = ".properties"; + private static final String CONFIG_DESCRIPTION = "Rails configuration files ( *.rails_config, *.properties)"; private JPanel profilePanel; private JTabbedPane configPane; private JPanel buttonPanel; - ConfigWindow() { - // JFrame properties + private boolean fromStatusWindow; + + ConfigWindow(boolean fromStatusWindow) { + // store for handling of close + this.fromStatusWindow = fromStatusWindow; + + // JFrame properties setTitle(LocalText.getText("CONFIG_WINDOW_TITLE")); -// setSize(400,300); // add profile panel profilePanel = new JPanel(); @@ -80,12 +84,13 @@ buttonPanel = new JPanel(); add(buttonPanel, "South"); + // hide on close and inform this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - closeConfig(); + closeConfig(false); } }); } @@ -95,13 +100,12 @@ setupConfigPane(); setupButtonPanel(); this.pack(); + setSize(600,400); } private void setupProfilePanel() { profilePanel.removeAll(); - - profilePanel.setLayout(new GridLayout(0,4)); - + String activeProfile = Config.getActiveProfileName(); String defaultProfile = Config.getDefaultProfileName(); Border etched = BorderFactory.createEtchedBorder(); @@ -134,16 +138,27 @@ buttonPanel.add(newButton); // button to load a new profile - JButton loadButton = new JButton(LocalText.getText("LOAD")); - loadButton.addActionListener( + JButton importButton = new JButton(LocalText.getText("IMPORT")); + importButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - loadProfile(); + importProfile(); } } ); - buttonPanel.add(loadButton); + buttonPanel.add(importButton); + // saveas button +// JButton saveAsButton = new JButton(LocalText.getText("SAVEAS")); +// saveAsButton.addActionListener( +// new ActionListener() { +// public void actionPerformed(ActionEvent arg0) { +// ConfigWindow.this.saveAsConfig(); +// } +// } +// ); +// buttonPanel.add(saveAsButton); + profilePanel.add(buttonPanel); } @@ -322,8 +337,8 @@ int state = fc.showOpenDialog(ConfigWindow.this); if ( state == JFileChooser.APPROVE_OPTION ){ File file = fc.getSelectedFile(); - dirLabel.setText(file.getAbsolutePath()); - item.setNewValue(file.getAbsolutePath()); + dirLabel.setText(file.getPath()); + item.setNewValue(file.getPath()); } } } @@ -430,47 +445,43 @@ private void setupButtonPanel() { buttonPanel.removeAll(); + + String activeFilePath = Config.getActiveFilepath(); + Border etched = BorderFactory.createEtchedBorder(); + Border titled = BorderFactory.createTitledBorder(etched, LocalText.getText("CONFIG_CURRENT_PATH", activeFilePath)); + buttonPanel.setBorder(titled); - // saveas button - JButton saveAsButton = new JButton(LocalText.getText("SAVEAS")); - saveAsButton.addActionListener( + // save button + JButton saveButton = new JButton(LocalText.getText("SAVE_AND_APPLY")); + saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.saveAsConfig(); - } - } - ); - buttonPanel.add(saveAsButton); - - // save button - if (Config.isFilePathDefined()) { - JButton saveButton = new JButton(LocalText.getText("SAVE")); - saveButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent arg0) { + if (Config.isFilePathDefined()) { ConfigWindow.this.saveConfig(); + } else { + ConfigWindow.this.saveAsConfig(); } } - ); - buttonPanel.add(saveButton); - } - - JButton applyButton = new JButton(LocalText.getText("APPLY")); - applyButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.applyConfig(); - } } ); - buttonPanel.add(applyButton); + buttonPanel.add(saveButton); + +// JButton applyButton = new JButton(LocalText.getText("APPLY")); +// applyButton.addActionListener( +// new ActionListener() { +// public void actionPerformed(ActionEvent arg0) { +// ConfigWindow.this.applyConfig(); +// } +// } +// ); +// buttonPanel.add(applyButton); JButton cancelButton = new JButton(LocalText.getText("CANCEL")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.closeConfig(); + ConfigWindow.this.closeConfig(true); } } ); @@ -479,8 +490,13 @@ } private void newProfile() { - String newProfile = JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_NEW_MESSAGE"), + List<String> allProfileNames = Config.getAllProfiles(); + String newProfile = null; + do { + newProfile = JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_NEW_MESSAGE"), LocalText.getText("CONFIG_NEW_TITLE"), JOptionPane.QUESTION_MESSAGE); + } while (allProfileNames.contains(newProfile)); + if (Util.hasValue(newProfile)) { String defaultProfile = (String)JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_DEFAULT_MESSAGE"), LocalText.getText("CONFIG_DEFAULT_TITLE"), JOptionPane.QUESTION_MESSAGE, null, @@ -497,7 +513,7 @@ }); } - private void loadProfile() { + private void importProfile() { String directory = Config.get("save.directory"); JFileChooser fc = new JFileChooser(directory); @@ -505,7 +521,9 @@ new FileFilter() { public boolean accept( File f ){ return f.isDirectory() || - f.getName().toLowerCase().endsWith( ".rails_config" ); + f.getName().toLowerCase().endsWith( CONFIG_EXTENSION) || + f.getName().toLowerCase().endsWith( LEGACY_EXTENSION) + ; } public String getDescription() { return CONFIG_DESCRIPTION; @@ -516,8 +534,11 @@ if ( state == JFileChooser.APPROVE_OPTION ) { File file = fc.getSelectedFile(); - if (Config.loadProfileFromFile(file)) { + if (Config.importProfileFromFile(file)) { changeProfile(Config.getActiveProfileName()); + } else { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_LOAD_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_LOAD_TITLE"), JOptionPane.ERROR_MESSAGE); } } } @@ -532,11 +553,17 @@ }); } - private void saveConfig() { - Config.updateProfile(); // transfer the configitem to the active profile - Config.saveActiveProfile(); - JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_MESSAGE", Config.getActiveProfileName()), + private boolean saveConfig() { + Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile + if (Config.saveActiveProfile()) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_CONFIRM_MESSAGE", Config.getActiveProfileName()), LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE); + return true; + } else { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.ERROR_MESSAGE); + return false; + } } private void saveAsConfig() { @@ -561,11 +588,14 @@ } ); int state = fc.showSaveDialog(this); - if ( state == JFileChooser.APPROVE_OPTION ) - { + if ( state == JFileChooser.APPROVE_OPTION ) { File file = fc.getSelectedFile(); - Config.setActiveFilepath(file.getPath()); + if (!Config.setActiveFilepath(file.getPath())) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_PROFILE_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.ERROR_MESSAGE); + } saveConfig(); + // update panel for file path EventQueue.invokeLater(new Runnable() { public void run() { setupButtonPanel(); @@ -576,16 +606,18 @@ } } - private void applyConfig() { - Config.updateProfile(); // transfer the configitem to the active profile - JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), - LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); - } +// private void applyConfig() { +// Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile +// JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), +// LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); +// } - private void closeConfig() { - Config.revertProfile(); - StatusWindow.uncheckMenuItemBox(StatusWindow.CONFIG_CMD); + private void closeConfig(boolean cancel) { + if (cancel) Config.revertProfile(); this.setVisible(false); + if (fromStatusWindow) { + StatusWindow.uncheckMenuItemBox(StatusWindow.CONFIG_CMD); + } } } Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -25,8 +25,8 @@ private static final long serialVersionUID = 1L; GridBagConstraints gc; JPanel gameListPane, playersPane, buttonPane, optionsPane; - JButton newButton, loadButton, recoveryButton, quitButton, optionButton, infoButton; - JButton creditsButton, randomizeButton; + JButton newButton, loadButton, recoveryButton, quitButton, optionButton, infoButton, + creditsButton, randomizeButton, configureButton; JComboBox gameNameBox = new JComboBox(); JComboBox[] playerBoxes = new JComboBox[Player.MAX_PLAYERS]; JTextField[] playerNameFields = new JTextField[Player.MAX_PLAYERS]; @@ -40,6 +40,8 @@ String gameName; Game game; + private ConfigWindow configWindow; + // Used by the player selection combo box. static final int NONE_PLAYER = 0; static final int HUMAN_PLAYER = 1; @@ -71,6 +73,7 @@ optionButton = new JButton(LocalText.getText("OPTIONS")); infoButton = new JButton(LocalText.getText("INFO")); creditsButton = new JButton(LocalText.getText("CREDITS")); + configureButton= new JButton(LocalText.getText("CONFIG")); newButton.setMnemonic(KeyEvent.VK_N); loadButton.setMnemonic(KeyEvent.VK_L); @@ -78,7 +81,8 @@ quitButton.setMnemonic(KeyEvent.VK_Q); optionButton.setMnemonic(KeyEvent.VK_O); infoButton.setMnemonic(KeyEvent.VK_G); - creditsButton.setMnemonic(KeyEvent.VK_C); + creditsButton.setMnemonic(KeyEvent.VK_E); + configureButton.setMnemonic(KeyEvent.VK_C); this.getContentPane().setLayout(new GridBagLayout()); this.setTitle("Rails: New Game"); @@ -87,9 +91,9 @@ populateGameList(GamesInfo.getGameNames(), gameNameBox); gameListPane.add(new JLabel("Available Games:")); - gameListPane.add(new JLabel("")); // empty slot gameListPane.add(gameNameBox); gameListPane.add(optionButton); + gameListPane.add(configureButton); // empty slot gameListPane.setLayout(new GridLayout(2, 2)); gameListPane.setBorder(BorderFactory.createLoweredBevelBorder()); @@ -101,12 +105,13 @@ infoButton.addActionListener(this); creditsButton.addActionListener(this); gameNameBox.addActionListener(this); + configureButton.addActionListener(this); buttonPane.add(newButton); buttonPane.add(loadButton); - if (!Config.get("save.recovery.active", "yes").equalsIgnoreCase("no")) { - buttonPane.add(recoveryButton); - } + recoveryButton.setEnabled(Config.get("save.recovery.active", "no").equalsIgnoreCase("yes")); + buttonPane.add(recoveryButton); + buttonPane.add(infoButton); buttonPane.add(quitButton); buttonPane.add(creditsButton); @@ -212,14 +217,30 @@ } gameUIManager.startLoadedGame(); setVisible(false); + killConfigWindow(); } + private void killConfigWindow() { + if (configWindow == null) return; + configWindow.dispose(); + configWindow = null; + } + public void actionPerformed(ActionEvent arg0) { if (arg0.getSource().equals(newButton)) { startNewGame(); } else if (arg0.getSource().equals(optionButton)) { toggleOptions(); this.pack(); + } else if (arg0.getSource().equals(configureButton)) { + // start configureWindow + if (configWindow == null) { + configWindow = new ConfigWindow(false); + configWindow.init(); + configWindow.setVisible(true); + } else { + configWindow.setVisible(true); + } } else if (arg0.getSource().equals(loadButton)) { String saveDirectory = Config.get("save.directory"); JFileChooser jfc = new JFileChooser(); @@ -421,6 +442,7 @@ this.setVisible(false); // XXX: At some point we should destroy this // XXX: object rather than just making it invisible + killConfigWindow(); } private void startGameUIManager(Game game) { Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -184,7 +184,7 @@ reportWindow.scrollDown(); // define configWindow - configWindow = new ConfigWindow(); + configWindow = new ConfigWindow(true); configWindow.init(); } Modified: trunk/18xx/rails/util/Config.java =================================================================== --- trunk/18xx/rails/util/Config.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/util/Config.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -133,7 +133,7 @@ /** * updates the profile according to the changes in configitems */ - public static void updateProfile() { + public static void updateProfile(boolean applyInitMethods) { for (List<ConfigItem> items:configSections.values()) { for (ConfigItem item:items) { if (!item.hasNewValue()) continue; @@ -142,7 +142,7 @@ continue; } userProperties.setProperty(item.name, item.getNewValue()); - item.callInitMethod(); + if (applyInitMethods) item.callInitMethod(); log.debug("Changed property name = " + item.name + " to value = " + item.getNewValue()); item.setNewValue(null); } @@ -224,6 +224,7 @@ // add to list of user profiles userProfiles.setProperty(profileName, ""); + // define and load default profile String defaultConfigFile = defaultProfiles.getProperty(defaultProfile); userProperties.setProperty(PROFILENAME_PROPERTY, profileName); @@ -268,6 +269,22 @@ } /** + * get all (visible default + user) profiles + */ + public static List<String> getAllProfiles() { + List<String> profiles = getDefaultProfiles(true); + profiles.addAll(getUserProfiles()); + return profiles; + } + + /** + * checks if profile is default profile + */ + public static boolean isDefaultProfile(String profileName) { + return !(defaultProfiles.get(profileName) == null); + } + + /** * returns name of (active) default profile */ public static String getDefaultProfileName() { @@ -290,6 +307,7 @@ /** * sets filename for an active profile (and store list of profiles) + * @return false if list of profiles cannot be stored */ public static boolean setActiveFilepath(String filepath) { userProfiles.setProperty(selectedProfile, filepath); @@ -423,15 +441,15 @@ * loads an external user profile * defined by the filepath */ - public static boolean loadProfileFromFile(File file) { - String filepath = file.getAbsolutePath(); + public static boolean importProfileFromFile(File file) { + String filepath = file.getPath(); if (loadPropertyFile(userProperties, filepath, false)) { String profile = userProperties.getProperty(PROFILENAME_PROPERTY); if (!Util.hasValue(profile)) { profile = STANDARD_PROFILE_SELECTION; } selectedProfile = profile; - setActiveFilepath(filepath); +// setActiveFilepath(filepath); // do not set filepath on import loadDefaultProfile(); setSaveDirDefaults(); return true; @@ -509,9 +527,8 @@ } properties.load(inFile); } catch (Exception e) { - System.err.println(e + " whilst loading properties file " + log.error(e + " whilst loading properties file " + filepath); -// e.printStackTrace(System.err); result = false; } return result; @@ -531,6 +548,8 @@ properties.store(new FileOutputStream(outFile), "Automatically generated, do not edit"); log.info("Storing properties to file " + filepath); } catch (IOException e) { + log.error(e + " whilst storing properties file " + + filepath); result = false; } return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-21 19:36:52
|
Revision: 1398 http://rails.svn.sourceforge.net/rails/?rev=1398&view=rev Author: evos Date: 2010-08-21 19:36:46 +0000 (Sat, 21 Aug 2010) Log Message: ----------- Fixed: 18EU FMER did not start correctly if 5-train buyer went bankrupt as prersident of last OR company Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/LocalisedText.properties 2010-08-21 19:36:46 UTC (rev 1398) @@ -125,6 +125,8 @@ ComesWithPresidency=Comes with {0} {1}% presidency certificate Companies=Companies CompanyAlreadyStarted={0} has already been started. +CompanyCloses={0} closes +CompanyClosesAt={0} closes because price token reaches square {1} CompanyDiscardsTrain={0} discards a {1}-train to Pool CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/GameManager.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -356,7 +356,7 @@ if (endOfGameTag != null) { Tag forcedSellingTag = endOfGameTag.getChild("ForcedSelling"); if (forcedSellingTag != null) { - forcedSellingCompanyDump = + forcedSellingCompanyDump = forcedSellingTag.getAttributeAsBoolean("CompanyDump", true); } if (endOfGameTag.getChild("Bankruptcy") != null) { @@ -725,7 +725,7 @@ // check if other companies can be dumped createRound (ShareSellingRound.class, interruptedRound) - .start(player, cashToRaise, cashNeedingCompany, + .start(player, cashToRaise, cashNeedingCompany, !problemDumpOtherCompanies || forcedSellingCompanyDump); // the last parameter indicates if the dump of other companies is allowed, either this is explicit or // the action does not require that check @@ -883,7 +883,7 @@ private boolean processGameActions(GameAction gameAction) { // Process undo/redo centrally boolean result = false; - + int index = gameAction.getmoveStackIndex(); switch (gameAction.getMode()) { case GameAction.SAVE: @@ -916,7 +916,7 @@ return result; } - + /* (non-Javadoc) * @see rails.game.GameManagerI#processOnReload(java.util.List) */ @@ -1132,53 +1132,15 @@ if (gameEndsWithBankruptcy) { finishGame(); } else { - Player player, newPresident; - int numberOfPlayers = getNumberOfPlayers(); - int maxShare; - int share; - - // Assume default case as in 18EU: all assets to Bank/Pool - Player bankrupter = getCurrentPlayer(); - new CashMove (bankrupter, bank, bankrupter.getCash()); - Portfolio bpf = bankrupter.getPortfolio(); - List<PublicCompanyI> presidencies = new ArrayList<PublicCompanyI>(); - for (PublicCertificateI cert : bpf.getCertificates()) { - if (cert.isPresidentShare()) presidencies.add(cert.getCompany()); - } - for (PublicCompanyI company : presidencies) { - // Check if the presidency is dumped on someone - newPresident = null; - maxShare = 0; - for (int index=getCurrentPlayerIndex()+1; - index<getCurrentPlayerIndex()+numberOfPlayers; index++) { - player = getPlayerByIndex(index%numberOfPlayers); - share = player.getPortfolio().getShare(company); - if (share >= company.getPresidentsShare().getShare() - && (share > maxShare)) { - maxShare = share; - newPresident = player; - } - } - if (newPresident != null) { - bankrupter.getPortfolio().swapPresidentCertificate(company, - newPresident.getPortfolio()); - } else { - company.setClosed(); - // TODO: can be restarted (in 18EU) - } - } - // Dump all shares - Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); - - bankrupter.setBankrupt(); - - // Finish the share selling round - if (getCurrentRound() instanceof ShareSellingRound) { - finishShareSellingRound(); - } + processBankruptcy (); } } + protected void processBankruptcy () { + // Currently a stub, don't know if there is any generic handling (EV) + } + + public void registerBrokenBank(){ ReportBuffer.add(LocalText.getText("BankIsBrokenReportText")); String msgContinue; Modified: trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -1,10 +1,14 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/specific/_18EU/GameManager_18EU.java,v 1.5 2010/01/18 22:51:47 evos Exp $ */ package rails.game.specific._18EU; -import rails.game.GameManager; -import rails.game.Player; -import rails.game.RoundI; +import java.util.ArrayList; +import java.util.List; + +import rails.game.*; +import rails.game.move.CashMove; import rails.game.state.State; +import rails.util.LocalText; +import rails.util.Util; /** * This class manages the playing rounds by supervising all implementations of @@ -12,7 +16,7 @@ */ public class GameManager_18EU extends GameManager { - protected State playerToStartFMERound = + protected State playerToStartFMERound = new State("playerToStartFMERound", Player.class); @Override @@ -20,7 +24,7 @@ if (round instanceof OperatingRound_18EU) { if (playerToStartFMERound.get() != null && relativeORNumber.intValue() == numOfORs.intValue()) { - createRound (FinalMinorExchangeRound.class).start + createRound (FinalMinorExchangeRound.class).start ((Player)playerToStartFMERound.get()); playerToStartFMERound.set(null); } else { @@ -41,7 +45,53 @@ public Player getPlayerToStartFMERound() { return (Player) playerToStartFMERound.get(); } - - + @Override + protected void processBankruptcy () { + Player player, newPresident; + int numberOfPlayers = getNumberOfPlayers(); + int maxShare; + int share; + + // Assume default case as in 18EU: all assets to Bank/Pool + Player bankrupter = getCurrentPlayer(); + new CashMove (bankrupter, bank, bankrupter.getCash()); + Portfolio bpf = bankrupter.getPortfolio(); + List<PublicCompanyI> presidencies = new ArrayList<PublicCompanyI>(); + for (PublicCertificateI cert : bpf.getCertificates()) { + if (cert.isPresidentShare()) presidencies.add(cert.getCompany()); + } + for (PublicCompanyI company : presidencies) { + // Check if the presidency is dumped on someone + newPresident = null; + maxShare = 0; + for (int index=getCurrentPlayerIndex()+1; + index<getCurrentPlayerIndex()+numberOfPlayers; index++) { + player = getPlayerByIndex(index%numberOfPlayers); + share = player.getPortfolio().getShare(company); + if (share >= company.getPresidentsShare().getShare() + && (share > maxShare)) { + maxShare = share; + newPresident = player; + } + } + if (newPresident != null) { + bankrupter.getPortfolio().swapPresidentCertificate(company, + newPresident.getPortfolio()); + } else { + company.setClosed(); + ReportBuffer.add(LocalText.getText("CompanyCloses", company.getName())); + // TODO: can be restarted (in 18EU) + } + } + // Dump all shares + Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); + + bankrupter.setBankrupt(); + + // Finish the share selling round + if (getCurrentRound() instanceof ShareSellingRound) { + finishShareSellingRound(); + } + } } Modified: trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -266,7 +266,9 @@ savedAction = null; finishTurn(); } - super.resume(); + if (gameManager.getCurrentRound() == this) { + super.resume(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-21 19:34:58
|
Revision: 1397 http://rails.svn.sourceforge.net/rails/?rev=1397&view=rev Author: evos Date: 2010-08-21 19:34:52 +0000 (Sat, 21 Aug 2010) Log Message: ----------- Fixed two message text internationalisations Modified Paths: -------------- trunk/18xx/rails/game/StockMarket.java Modified: trunk/18xx/rails/game/StockMarket.java =================================================================== --- trunk/18xx/rails/game/StockMarket.java 2010-08-21 12:23:09 UTC (rev 1396) +++ trunk/18xx/rails/game/StockMarket.java 2010-08-21 19:34:52 UTC (rev 1397) @@ -251,8 +251,9 @@ if (newsquare != oldsquare && newsquare.closesCompany()) { company.setClosed(); oldsquare.removeToken(company); - ReportBuffer.add(company.getName() + " closes at " - + newsquare.getName()); + ReportBuffer.add(LocalText.getText("CompanyClosesAt", + company.getName(), + newsquare.getName())); } else { prepareMove(company, oldsquare, newsquare); } @@ -286,8 +287,9 @@ if (!company.canClose()) return; // E.g. 1856 CGR company.setClosed(); oldsquare.removeToken(company); - ReportBuffer.add(company.getName() + LocalText.getText("CLOSES_AT") - + " " + newsquare.getName()); + ReportBuffer.add(LocalText.getText("CompanyClosesAt", + company.getName(), + newsquare.getName())); } else { prepareMove(company, oldsquare, newsquare); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-21 12:23:15
|
Revision: 1396 http://rails.svn.sourceforge.net/rails/?rev=1396&view=rev Author: evos Date: 2010-08-21 12:23:09 +0000 (Sat, 21 Aug 2010) Log Message: ----------- Fix: if merging minor and major both bave a Pullmann, discard one. Modified Paths: -------------- trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java Modified: trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java 2010-08-21 06:49:48 UTC (rev 1395) +++ trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java 2010-08-21 12:23:09 UTC (rev 1396) @@ -495,6 +495,7 @@ PublicCompanyI major = action.getSelectedTargetCompany(); PublicCertificateI cert = null; CashHolder cashDestination = null; // Bank + TrainI pullmannToDiscard = null; // TODO Validation to be added? @@ -521,6 +522,18 @@ } else { // Assets go to the major company major.transferAssetsFrom(minor); + + // Check for multiple Pullmanns + boolean hasPullmann = false; + for (TrainI train : major.getPortfolio().getTrainList()) { + if (train.getName().equalsIgnoreCase("P")) { + if (!hasPullmann) { + hasPullmann = true; + } else { + pullmannToDiscard = train; // Can only have two Pullmanns. + } + } + } } MapHex homeHex = minor.getHomeHex(); @@ -572,6 +585,13 @@ cert.moveTo(currentPlayer.getPortfolio()); ReportBuffer.add(LocalText.getText("MinorCloses", minor.getName())); checkFlotation(major); + + if (pullmannToDiscard != null) { + pullmannToDiscard.moveTo(pool); + ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", + major.getName(), + pullmannToDiscard.getName() )); + } } else { ReportBuffer.add(""); ReportBuffer.add(LocalText.getText("CLOSE_MINOR_LOG", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-21 06:49:57
|
Revision: 1395 http://rails.svn.sourceforge.net/rails/?rev=1395&view=rev Author: stefanfrey Date: 2010-08-21 06:49:48 +0000 (Sat, 21 Aug 2010) Log Message: ----------- - Added stateful list class - OperatingCompany in OR implements that - Added forced sell protection of operating company - Added game option for 1889 for according protection of all owned companies Modified Paths: -------------- trunk/18xx/data/1889/Game.xml trunk/18xx/rails/common/GuiHints.java trunk/18xx/rails/game/City.java trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameManagerI.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/PhaseManager.java trunk/18xx/rails/game/ShareSellingRound.java trunk/18xx/rails/game/StartRound_1830.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/model/PriceModel.java trunk/18xx/rails/game/move/AddToList.java trunk/18xx/rails/game/move/StateChange.java trunk/18xx/rails/game/special/SellBonusToken.java trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java trunk/18xx/rails/game/specific/_1835/StockRound_1835.java trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java trunk/18xx/rails/game/specific/_1856/StockRound_1856.java trunk/18xx/rails/game/specific/_1889/OperatingRound_1889.java trunk/18xx/rails/game/specific/_18AL/NameableTrain.java trunk/18xx/rails/game/specific/_18AL/OperatingRound_18AL.java trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java trunk/18xx/rails/game/state/GenericState.java trunk/18xx/rails/game/state/State.java trunk/18xx/rails/game/state/StateI.java Added Paths: ----------- trunk/18xx/rails/game/state/ArrayListState.java Modified: trunk/18xx/data/1889/Game.xml =================================================================== --- trunk/18xx/data/1889/Game.xml 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/data/1889/Game.xml 2010-08-21 06:49:48 UTC (rev 1395) @@ -40,6 +40,7 @@ <OperatingRound class="rails.game.specific._1889.OperatingRound_1889"/> </GameParameters> <EndOfGame> + <ForcedSelling CompanyDump="no"/> <Bankruptcy/> <BankBreaks limit="0" finish="setOfORs"/> <!-- "Runs out"; when "broken", -1 is the limit --> Modified: trunk/18xx/rails/common/GuiHints.java =================================================================== --- trunk/18xx/rails/common/GuiHints.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/common/GuiHints.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -32,7 +32,7 @@ private EnumState<GuiDef.Panel> activePanel = null; public Class<? extends RoundI> getCurrentRoundType() { - return currentRoundType.getObject(); + return currentRoundType.get(); } public void setCurrentRoundType(Class<? extends RoundI> currentRoundType) { @@ -63,7 +63,7 @@ } public GuiDef.Panel getActivePanel() { - return (GuiDef.Panel)activePanel.getObject(); + return (GuiDef.Panel)activePanel.get(); } public void setActivePanel(GuiDef.Panel activePanel) { Modified: trunk/18xx/rails/game/City.java =================================================================== --- trunk/18xx/rails/game/City.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/City.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -68,7 +68,7 @@ } public Station getRelatedStation() { - return relatedStation.getObject(); + return relatedStation.get(); } public void setRelatedStation(Station relatedStation) { Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/GameManager.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -82,6 +82,7 @@ protected boolean skipFirstStockRound = false; protected boolean showCompositeORNumber = true; + protected boolean forcedSellingCompanyDump = true; protected boolean gameEndsWithBankruptcy = false; protected int gameEndsWhenBankHasLessOrEqual = 0; protected boolean gameEndsAfterSetOfORs = true; @@ -353,6 +354,11 @@ /* End of rails.game criteria */ Tag endOfGameTag = tag.getChild("EndOfGame"); if (endOfGameTag != null) { + Tag forcedSellingTag = endOfGameTag.getChild("ForcedSelling"); + if (forcedSellingTag != null) { + forcedSellingCompanyDump = + forcedSellingTag.getAttributeAsBoolean("CompanyDump", true); + } if (endOfGameTag.getChild("Bankruptcy") != null) { gameEndsWithBankruptcy = true; } @@ -713,11 +719,16 @@ * @see rails.game.GameManagerI#startShareSellingRound(rails.game.OperatingRound, rails.game.PublicCompanyI, int) */ public void startShareSellingRound(Player player, int cashToRaise, - PublicCompanyI unsellableCompany) { + PublicCompanyI cashNeedingCompany, boolean problemDumpOtherCompanies) { interruptedRound = getCurrentRound(); + + // check if other companies can be dumped createRound (ShareSellingRound.class, interruptedRound) - .start(player, cashToRaise, unsellableCompany); + .start(player, cashToRaise, cashNeedingCompany, + !problemDumpOtherCompanies || forcedSellingCompanyDump); + // the last parameter indicates if the dump of other companies is allowed, either this is explicit or + // the action does not require that check } /* (non-Javadoc) @@ -825,7 +836,7 @@ // logging of game actions activated for (PossibleAction pa : possibleActions.getList()) { - log.debug(((Player) currentPlayer.getObject()).getName() + " may: " + log.debug(((Player) currentPlayer.get()).getName() + " may: " + pa.toString()); } @@ -1247,7 +1258,7 @@ * @see rails.game.GameManagerI#getCurrentRound() */ public RoundI getCurrentRound() { - return (RoundI) currentRound.getObject(); + return (RoundI) currentRound.get(); } /* (non-Javadoc) @@ -1272,7 +1283,7 @@ */ public void setCurrentPlayer(Player player) { // transfer messages for the next player to the display buffer - if ((Player)currentPlayer.getObject() != player && !nextPlayerMessages.isEmpty()) { + if ((Player)currentPlayer.get() != player && !nextPlayerMessages.isEmpty()) { DisplayBuffer.add( LocalText.getText("NextPlayerMessage", getCurrentPlayer().getName())); for (String s:nextPlayerMessages) @@ -1305,14 +1316,14 @@ * @see rails.game.GameManagerI#getPriorityPlayer() */ public Player getPriorityPlayer() { - return (Player) priorityPlayer.getObject(); + return (Player) priorityPlayer.get(); } /* (non-Javadoc) * @see rails.game.GameManagerI#getCurrentPlayer() */ public Player getCurrentPlayer() { - return (Player) currentPlayer.getObject(); + return (Player) currentPlayer.get(); } /* (non-Javadoc) Modified: trunk/18xx/rails/game/GameManagerI.java =================================================================== --- trunk/18xx/rails/game/GameManagerI.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/GameManagerI.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -41,8 +41,8 @@ public abstract int getSRNumber(); - public abstract void startShareSellingRound(Player sellingPlayer, - int cashToRaise, PublicCompanyI unsellableCompany); + public abstract void startShareSellingRound(Player player, int cashToRaise, + PublicCompanyI cashNeedingCompany, boolean checkDumpOtherCompanies); public abstract void startTreasuryShareTradingRound(); Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/OperatingRound.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -10,6 +10,7 @@ import rails.game.move.CashMove; import rails.game.move.MapChange; import rails.game.special.*; +import rails.game.state.ArrayListState; import rails.game.state.EnumState; import rails.game.state.GenericState; import rails.util.LocalText; @@ -33,13 +34,14 @@ protected List<PublicCompanyI> companiesOperatedThisRound = new ArrayList<PublicCompanyI> (); - protected List<PublicCompanyI> operatingCompanies; + protected ArrayListState<PublicCompanyI> operatingCompanies; //protected IntegerState operatingCompanyIndexObject; - protected GenericState<PublicCompanyI> operatingCompanyObject; - protected PublicCompanyI operatingCompany = null; - + protected GenericState<PublicCompanyI> operatingCompany; + // do not use a operatingCompany.getObject() as reference + // protected PublicCompanyI operatingCompany.getObject() = null; + // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; @@ -95,7 +97,7 @@ public OperatingRound(GameManagerI gameManager) { super (gameManager); - operatingCompanies = setOperatingCompanies(); + operatingCompanies = new ArrayListState<PublicCompanyI>("operatingCompanies", setOperatingCompanies()); // sfy NoMapMode noMapMode = GameOption.convertValueToBoolean(getGameOption("NoMapMode")); @@ -116,7 +118,7 @@ if (operatingCompanies.size() > 0) { StringBuilder msg = new StringBuilder(); - for (PublicCompanyI company : operatingCompanies) { + for (PublicCompanyI company : operatingCompanies.viewList()) { msg.append(",").append(company.getName()); } if (msg.length() > 0) msg.deleteCharAt(0); @@ -173,10 +175,10 @@ if (action instanceof PossibleORAction && !(action instanceof DiscardTrain)) { PublicCompanyI company = ((PossibleORAction) action).getCompany(); - if (company != operatingCompany) { + if (company != operatingCompany.get()) { DisplayBuffer.add(LocalText.getText("WrongCompany", company.getName(), - operatingCompany.getName() )); + operatingCompany.get().getName() )); return false; } } @@ -289,11 +291,11 @@ while (true) { // Checks // Must be correct company. - if (!companyName.equals(operatingCompany.getName())) { + if (!companyName.equals(operatingCompany.get().getName())) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // Must be correct step @@ -368,11 +370,11 @@ break; } // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost) ); break; } @@ -393,8 +395,8 @@ if (tile != null) { if (cost > 0) - new CashMove(operatingCompany, bank, cost); - operatingCompany.layTile(hex, tile, orientation, cost); + new CashMove(operatingCompany.get(), bank, cost); + operatingCompany.get().layTile(hex, tile, orientation, cost); if (cost == 0) { ReportBuffer.add(LocalText.getText("LaysTileAt", @@ -503,7 +505,7 @@ MapHex hex = action.getChosenHex(); int station = action.getChosenStation(); - String companyName = operatingCompany.getName(); + String companyName = operatingCompany.get().getName(); // TEMPORARY FIX to enable fixing invalidated saved files //if ("N11".equals(hex.getName()) && station == 2) { @@ -523,12 +525,12 @@ break; } - if (operatingCompany.getNumberOfFreeBaseTokens() == 0) { + if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { errMsg = LocalText.getText("HasNoTokensLeft", companyName); break; } - if (!isTokenLayAllowed (operatingCompany, hex, station)) { + if (!isTokenLayAllowed (operatingCompany.get(), hex, station)) { errMsg = LocalText.getText("BaseTokenSlotIsReserved"); break; } @@ -543,7 +545,7 @@ * cities on one tile may hold tokens of the same company; this case * is not yet covered. */ - if (hex.hasTokenOfCompany(operatingCompany)) { + if (hex.hasTokenOfCompany(operatingCompany.get())) { errMsg = LocalText.getText("TileAlreadyHasToken", hex.getName(), @@ -565,14 +567,14 @@ if (stl != null) extra = stl.isExtra(); } - cost = operatingCompany.getBaseTokenLayCost(hex); + cost = operatingCompany.get().getBaseTokenLayCost(hex); if (stl != null && stl.isFree()) cost = 0; // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost)); break; } @@ -590,10 +592,10 @@ /* End of validation, start of execution */ moveStack.start(true); - if (hex.layBaseToken(operatingCompany, station)) { + if (hex.layBaseToken(operatingCompany.get(), station)) { /* TODO: the false return value must be impossible. */ - operatingCompany.layBaseToken(hex, cost); + operatingCompany.get().layBaseToken(hex, cost); // If this is a home base token lay, stop here if (action.getType() == LayBaseToken.HOME_CITY) { @@ -601,7 +603,7 @@ } if (cost > 0) { - new CashMove(operatingCompany, bank, cost); + new CashMove(operatingCompany.get(), bank, cost); ReportBuffer.add(LocalText.getText("LAYS_TOKEN_ON", companyName, hex.getName(), @@ -631,7 +633,7 @@ if (currentNormalTokenLays.isEmpty()) { log.debug("No more normal token lays are allowed"); - } else if (operatingCompany.getNumberOfFreeBaseTokens() == 0) { + } else if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { log.debug("Normal token lay allowed by no more tokens"); currentNormalTokenLays.clear(); } else { @@ -680,10 +682,10 @@ if (stl != null && stl.isFree()) cost = 0; // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", - operatingCompany.getName()); + operatingCompany.get().getName()); break; } break; @@ -703,13 +705,13 @@ if (hex.layBonusToken(token, gameManager.getPhaseManager())) { /* TODO: the false return value must be impossible. */ - operatingCompany.addBonus(new Bonus(operatingCompany, + operatingCompany.get().addBonus(new Bonus(operatingCompany.get(), token.getName(), token.getValue(), Collections.singletonList(hex))); - token.setUser(operatingCompany); + token.setUser(operatingCompany.get()); ReportBuffer.add(LocalText.getText("LaysBonusTokenOn", - operatingCompany.getName(), + operatingCompany.get().getName(), token.getName(), Bank.format(token.getValue()), hex.getName() )); @@ -744,11 +746,11 @@ seller = sbt.getSeller(); // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", - operatingCompany.getName(), - Bank.format(operatingCompany.getCash()), + operatingCompany.get().getName(), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost)); break; } @@ -756,7 +758,7 @@ } if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotBuyBonusToken", - operatingCompany.getName(), + operatingCompany.get().getName(), sbt.getName(), seller.getName(), Bank.format(cost), @@ -767,14 +769,14 @@ /* End of validation, start of execution */ moveStack.start(true); - new CashMove (operatingCompany, seller, cost); - operatingCompany.addBonus(new Bonus(operatingCompany, + new CashMove (operatingCompany.get(), seller, cost); + operatingCompany.get().addBonus(new Bonus(operatingCompany.get(), sbt.getName(), sbt.getValue(), sbt.getLocations())); ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom", - operatingCompany.getName(), + operatingCompany.get().getName(), sbt.getName(), Bank.format(sbt.getValue()), seller.getName(), @@ -834,11 +836,11 @@ // Must be correct company. company = action.getCompany(); companyName = company.getName(); - if (company != operatingCompany) { + if (company != operatingCompany.get()) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // Must be correct step @@ -894,9 +896,9 @@ action.setRevenueAllocation(SetDividend.WITHHOLD); } - if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { + if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(0) )); } @@ -911,12 +913,12 @@ int amount = action.getActualRevenue(); int revenueAllocation = action.getRevenueAllocation(); - operatingCompany.setLastRevenue(amount); - operatingCompany.setLastRevenueAllocation(revenueAllocation); + operatingCompany.get().setLastRevenue(amount); + operatingCompany.get().setLastRevenueAllocation(revenueAllocation); - if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { + if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(0) )); } @@ -927,27 +929,27 @@ if (amount == 0) { ReportBuffer.add(LocalText.getText("CompanyDoesNotPayDividend", - operatingCompany.getName())); + operatingCompany.get().getName())); withhold(amount); } else if (revenueAllocation == SetDividend.PAYOUT) { ReportBuffer.add(LocalText.getText("CompanyPaysOutFull", - operatingCompany.getName(), Bank.format(amount) )); + operatingCompany.get().getName(), Bank.format(amount) )); payout(amount); } else if (revenueAllocation == SetDividend.SPLIT) { ReportBuffer.add(LocalText.getText("CompanySplits", - operatingCompany.getName(), Bank.format(amount) )); + operatingCompany.get().getName(), Bank.format(amount) )); splitRevenue(amount); } else if (revenueAllocation == SetDividend.WITHHOLD) { ReportBuffer.add(LocalText.getText("CompanyWithholds", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); withhold(amount); @@ -955,7 +957,7 @@ } // Rust any obsolete trains - operatingCompany.getPortfolio().rustObsoleteTrains(); + operatingCompany.get().getPortfolio().rustObsoleteTrains(); // We have done the payout step, so continue from there nextStep(GameDef.OrStep.PAYOUT); @@ -983,17 +985,17 @@ if (recipient instanceof Bank) continue; shares = (sharesPerRecipient.get(recipient)); if (shares == 0) continue; - part = (int) Math.ceil(amount * shares * operatingCompany.getShareUnit() / 100.0); + part = (int) Math.ceil(amount * shares * operatingCompany.get().getShareUnit() / 100.0); ReportBuffer.add(LocalText.getText("Payout", recipient.getName(), Bank.format(part), shares, - operatingCompany.getShareUnit())); + operatingCompany.get().getShareUnit())); new CashMove(bank, recipient, part); } // Move the token - operatingCompany.payout(amount); + operatingCompany.get().payout(amount); } @@ -1006,7 +1008,7 @@ // (the withheld half of split revenues is not handled here, see splitRevenue()). // First count the shares per recipient - for (PublicCertificateI cert : operatingCompany.getCertificates()) { + for (PublicCertificateI cert : operatingCompany.get().getCertificates()) { CashHolder recipient = getBeneficiary(cert); if (!sharesPerRecipient.containsKey(recipient)) { sharesPerRecipient.put(recipient, cert.getShares()); @@ -1024,8 +1026,8 @@ Portfolio holder = cert.getPortfolio(); CashHolder beneficiary = holder.getOwner(); // Special cases apply if the holder is the IPO or the Pool - if (operatingCompany.paysOutToTreasury(cert)) { - beneficiary = operatingCompany; + if (operatingCompany.get().paysOutToTreasury(cert)) { + beneficiary = operatingCompany.get(); } return beneficiary; } @@ -1036,9 +1038,9 @@ * @param The revenue amount. */ public void withhold(int amount) { - if (amount > 0) new CashMove(bank, operatingCompany, amount); + if (amount > 0) new CashMove(bank, operatingCompany.get(), amount); // Move the token - operatingCompany.withhold(amount); + operatingCompany.get().withhold(amount); } /** Split a dividend. TODO Optional rounding down the payout @@ -1050,11 +1052,11 @@ if (amount > 0) { // Withhold half of it // For now, hardcode the rule that payout is rounded up. - int numberOfShares = operatingCompany.getNumberOfShares(); + int numberOfShares = operatingCompany.get().getNumberOfShares(); int withheld = (amount / (2 * numberOfShares)) * numberOfShares; - new CashMove(bank, operatingCompany, withheld); - ReportBuffer.add(operatingCompany.getName() + " receives " + Bank.format(withheld)); + new CashMove(bank, operatingCompany.get(), withheld); + ReportBuffer.add(operatingCompany.get().getName() + " receives " + Bank.format(withheld)); // Payout the remainder int payed = amount - withheld; @@ -1084,24 +1086,24 @@ while (true) { // Must be correct company. - if (!companyName.equals(operatingCompany.getName())) { + if (!companyName.equals(operatingCompany.get().getName())) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // amount is available - if ((amount + operatingCompany.getCash()) < 0) { + if ((amount + operatingCompany.get().getCash()) < 0) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(amount) ); break; } - if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN && operatingCompany.getNumberOfFreeBaseTokens() == 0) { + if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN && operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { errMsg = LocalText.getText("HasNoTokensLeft", companyName); break; @@ -1120,30 +1122,30 @@ if (amount > 0) { // positive amounts: remove cash from cashholder - new CashMove(operatingCompany, bank, amount); + new CashMove(operatingCompany.get(), bank, amount); } else if (amount > 0) { // negative amounts: add cash to cashholder - new CashMove(bank, operatingCompany, -amount); + new CashMove(bank, operatingCompany.get(), -amount); } if (typeOC == OperatingCost.OCType.LAY_TILE) { - operatingCompany.layTileInNoMapMode(amount); + operatingCompany.get().layTileInNoMapMode(amount); ReportBuffer.add(LocalText.getText("OCLayTileExecuted", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); } if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN) { // move token to Bank - BaseToken token = operatingCompany.getFreeToken(); + BaseToken token = operatingCompany.get().getFreeToken(); if (token == null) { - log.error("Company " + operatingCompany.getName() + " has no free token"); + log.error("Company " + operatingCompany.get().getName() + " has no free token"); return false; } else { token.moveTo(bank.getUnavailable()); } - operatingCompany.layBaseTokenInNoMapMode(amount); + operatingCompany.get().layBaseTokenInNoMapMode(amount); ReportBuffer.add(LocalText.getText("OCLayBaseTokenExecuted", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); } @@ -1196,13 +1198,13 @@ log.debug("Step " + step); if (step == GameDef.OrStep.LAY_TOKEN - && operatingCompany.getNumberOfFreeBaseTokens() == 0) { + && operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { continue; } if (step == GameDef.OrStep.CALC_REVENUE) { - if (!operatingCompany.canRunTrains()) { + if (!operatingCompany.get().canRunTrains()) { // No trains, then the revenue is zero. executeSetRevenueAndDividend ( new SetDividend (0, false, new int[] {SetDividend.WITHHOLD})); @@ -1219,8 +1221,8 @@ if (step == GameDef.OrStep.TRADE_SHARES) { // Is company allowed to trade trasury shares? - if (!operatingCompany.mayTradeShares() - || !operatingCompany.hasOperated()) { + if (!operatingCompany.get().mayTradeShares() + || !operatingCompany.get().hasOperated()) { continue; } @@ -1248,23 +1250,23 @@ } protected void initTurn() { - log.debug("Starting turn of "+operatingCompany.getName()); + log.debug("Starting turn of "+operatingCompany.get().getName()); ReportBuffer.add(LocalText.getText("CompanyOperates", - operatingCompany.getName(), - operatingCompany.getPresident().getName())); - setCurrentPlayer(operatingCompany.getPresident()); + operatingCompany.get().getName(), + operatingCompany.get().getPresident().getName())); + setCurrentPlayer(operatingCompany.get().getPresident()); - if (noMapMode && !operatingCompany.hasLaidHomeBaseTokens()){ + if (noMapMode && !operatingCompany.get().hasLaidHomeBaseTokens()){ // Lay base token in noMapMode - BaseToken token = operatingCompany.getFreeToken(); + BaseToken token = operatingCompany.get().getFreeToken(); if (token == null) { - log.error("Company " + operatingCompany.getName() + " has no free token to lay base token"); + log.error("Company " + operatingCompany.get().getName() + " has no free token to lay base token"); } else { - log.debug("Company " + operatingCompany.getName() + " lays base token in nomap mode"); + log.debug("Company " + operatingCompany.get().getName() + " lays base token in nomap mode"); token.moveTo(bank.getUnavailable()); } } - operatingCompany.initTurn(); + operatingCompany.get().initTurn(); trainsBoughtThisTurn.clear(); } @@ -1288,11 +1290,11 @@ protected <T extends SpecialPropertyI> List<T> getSpecialProperties( Class<T> clazz) { List<T> specialProperties = new ArrayList<T>(); - if (!operatingCompany.isClosed()) { + if (!operatingCompany.get().isClosed()) { // OC may have closed itself (e.g. in 1835 when M2 buys 1st 4T and starts PR) - specialProperties.addAll(operatingCompany.getPortfolio().getSpecialProperties( + specialProperties.addAll(operatingCompany.get().getPortfolio().getSpecialProperties( clazz, false)); - specialProperties.addAll(operatingCompany.getPresident().getPortfolio().getSpecialProperties( + specialProperties.addAll(operatingCompany.get().getPresident().getPortfolio().getSpecialProperties( clazz, false)); } return specialProperties; @@ -1311,9 +1313,9 @@ int allowedNumber; for (String colour : tileLaysPerColour.keySet()) { - allowedNumber = operatingCompany.getNumberOfTileLays(colour); + allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); // Replace the null map value with the allowed number of lays - tileLaysPerColour.put(colour, new Integer(allowedNumber)); + new MapChange<String, Integer>(tileLaysPerColour, colour, new Integer(allowedNumber)); } // store state @@ -1346,7 +1348,7 @@ /* Special-property tile lays */ currentSpecialTileLays.clear(); - if (!operatingCompany.canUseSpecialProperties()) return; + if (!operatingCompany.get().canUseSpecialProperties()) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { if (stl.isExtra() || !currentNormalTileLays.isEmpty()) { @@ -1365,7 +1367,7 @@ currentNormalTokenLays.clear(); /* For now, we allow one token of the currently operating company */ - if (operatingCompany.getNumberOfFreeBaseTokens() > 0) { + if (operatingCompany.get().getNumberOfFreeBaseTokens() > 0) { currentNormalTokenLays.add(new LayBaseToken((List<MapHex>) null)); } @@ -1382,13 +1384,13 @@ /* Special-property tile lays */ currentSpecialTokenLays.clear(); - if (!operatingCompany.canUseSpecialProperties()) return; + if (!operatingCompany.get().canUseSpecialProperties()) return; /* * In 1835, this only applies to major companies. TODO: For now, * hardcode this, but it must become configurable later. */ - if (operatingCompany.getType().getName().equals("Minor")) return; + if (operatingCompany.get().getType().getName().equals("Minor")) return; for (SpecialTokenLay stl : getSpecialProperties(SpecialTokenLay.class)) { log.debug("Spec.prop:" + stl); @@ -1443,14 +1445,14 @@ */ public boolean done() { - if (operatingCompany.getPortfolio().getNumberOfTrains() == 0 - && operatingCompany.mustOwnATrain()) { + if (operatingCompany.get().getPortfolio().getNumberOfTrains() == 0 + && operatingCompany.get().mustOwnATrain()) { // FIXME: Need to check for valid route before throwing an // error. /* Check TEMPORARILY disabled errMsg = LocalText.getText("CompanyMustOwnATrain", - operatingCompany.getName()); + operatingCompany.getObject().getName()); setStep(STEP_BUY_TRAIN); DisplayBuffer.add(errMsg); return false; @@ -1470,14 +1472,14 @@ protected void finishTurn() { - if (!operatingCompany.isClosed()) { - operatingCompany.setOperated(); - companiesOperatedThisRound.add(operatingCompany); + if (!operatingCompany.get().isClosed()) { + operatingCompany.get().setOperated(); + companiesOperatedThisRound.add(operatingCompany.get()); // Check if any privates must be closed (now only applies to 1856 W&SR) // Copy list first to avoid concurrent modifications for (PrivateCompanyI priv : - new ArrayList<PrivateCompanyI> (operatingCompany.getPortfolio().getPrivateCompanies())) { + new ArrayList<PrivateCompanyI> (operatingCompany.get().getPortfolio().getPrivateCompanies())) { priv.checkClosingIfExercised(true); } } @@ -1503,31 +1505,30 @@ protected boolean setNextOperatingCompany(boolean initial) { while (true) { - if (initial || operatingCompany == null || operatingCompanyObject == null) { + if (initial || operatingCompany.get() == null || operatingCompany == null) { setOperatingCompany(operatingCompanies.get(0)); initial = false; } else { - int index = operatingCompanies.indexOf(operatingCompany); + int index = operatingCompanies.indexOf(operatingCompany.get()); if (++index >= operatingCompanies.size()) { return false; } setOperatingCompany(operatingCompanies.get(index)); } - if (operatingCompany.isClosed()) continue; + if (operatingCompany.get().isClosed()) continue; return true; } } protected void setOperatingCompany (PublicCompanyI company) { - if (operatingCompanyObject == null) { - operatingCompanyObject = - new GenericState<PublicCompanyI>("OperatingCompanyIndex", company); + if (operatingCompany == null) { + operatingCompany = + new GenericState<PublicCompanyI>("OperatingCompany", company); } else { - operatingCompanyObject.set(company); + operatingCompany.set(company); } - operatingCompany = company; } protected void finishOR() { @@ -1557,7 +1558,7 @@ int price = action.getPricePaid(); int actualPresidentCash = 0; int cashToBeRaisedByPresident = 0; - Player currentPlayer = operatingCompany.getPresident(); + Player currentPlayer = operatingCompany.get().getPresident(); // Dummy loop to enable a quick jump out. while (true) { @@ -1590,7 +1591,7 @@ } // Does the company have room for another train? - int trainLimit = operatingCompany.getCurrentTrainLimit(); + int trainLimit = operatingCompany.get().getCurrentTrainLimit(); if (!canBuyTrainNow() && !action.isForExchange()) { errMsg = LocalText.getText("WouldExceedTrainLimit", @@ -1611,7 +1612,7 @@ } } else if (action.mayPresidentAddCash()) { // From another company - presidentCash = price - operatingCompany.getCash(); + presidentCash = price - operatingCompany.get().getCash(); if (presidentCash > action.getPresidentCashToAdd()) { errMsg = LocalText.getText("PresidentMayNotAddMoreThan", @@ -1627,11 +1628,11 @@ } else { // No forced buy - does the company have the money? - if (price > operatingCompany.getCash()) { + if (price > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(price) ); break; } @@ -1641,12 +1642,12 @@ if (exchangedTrain == null) { errMsg = LocalText.getText("NoExchangedTrainSpecified"); // TEMPORARY FIX to clean up invalidated saved files - DOES NOT WORK!!?? - //exchangedTrain = operatingCompany.getPortfolio().getTrainList().get(0); + //exchangedTrain = operatingCompany.getObject().getPortfolio().getTrainList().get(0); //action.setExchangedTrain(exchangedTrain); break; - } else if (operatingCompany.getPortfolio().getTrainOfType(exchangedTrain.getType()) == null) { + } else if (operatingCompany.get().getPortfolio().getTrainOfType(exchangedTrain.getType()) == null) { errMsg = LocalText.getText("CompanyDoesNotOwnTrain", - operatingCompany.getName(), + operatingCompany.get().getName(), exchangedTrain.getName()); break; } @@ -1674,21 +1675,21 @@ if (presidentMustSellShares) { savedAction = action; - gameManager.startShareSellingRound(operatingCompany.getPresident(), - cashToBeRaisedByPresident, operatingCompany); + gameManager.startShareSellingRound(operatingCompany.get().getPresident(), + cashToBeRaisedByPresident, operatingCompany.get(), true); return true; } if (actualPresidentCash > 0) { - new CashMove(currentPlayer, operatingCompany, presidentCash); + new CashMove(currentPlayer, operatingCompany.get(), presidentCash); } Portfolio oldHolder = train.getHolder(); if (exchangedTrain != null) { TrainI oldTrain = - operatingCompany.getPortfolio().getTrainOfType( + operatingCompany.get().getPortfolio().getTrainOfType( exchangedTrain.getType()); pool.buyTrain(oldTrain, 0); ReportBuffer.add(LocalText.getText("ExchangesTrain", @@ -1712,7 +1713,7 @@ stb.getOriginalCompany().getName() )); } - operatingCompany.buyTrain(train, price); + operatingCompany.get().buyTrain(train, price); if (oldHolder == ipo) { train.getType().addToBoughtFromIPO(); // Clone the train if infinitely available @@ -1748,7 +1749,7 @@ excessTrainCompanies = new HashMap<Player, List<PublicCompanyI>>(); Player player; - for (PublicCompanyI comp : operatingCompanies) { + for (PublicCompanyI comp : operatingCompanies.viewList()) { if (comp.getPortfolio().getNumberOfTrains() > comp.getTrainLimit(getCurrentPhase().getIndex())) { player = comp.getPresident(); if (!excessTrainCompanies.containsKey(player)) { @@ -1901,29 +1902,29 @@ // Price must be in the allowed range if (price < basePrice - * operatingCompany.getLowerPrivatePriceFactor()) { + * operatingCompany.get().getLowerPrivatePriceFactor()) { errMsg = LocalText.getText("PriceBelowLowerLimit", Bank.format(price), - Bank.format((int) (basePrice * operatingCompany.getLowerPrivatePriceFactor())), + Bank.format((int) (basePrice * operatingCompany.get().getLowerPrivatePriceFactor())), privateCompanyName ); break; } if (price > basePrice - * operatingCompany.getUpperPrivatePriceFactor()) { + * operatingCompany.get().getUpperPrivatePriceFactor()) { errMsg = LocalText.getText("PriceAboveUpperLimit", Bank.format(price), - Bank.format((int) (basePrice * operatingCompany.getUpperPrivatePriceFactor())), + Bank.format((int) (basePrice * operatingCompany.get().getUpperPrivatePriceFactor())), privateCompanyName ); break; } // Does the company have the money? - if (price > operatingCompany.getCash()) { + if (price > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", publicCompanyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(price) ); break; } @@ -1949,7 +1950,7 @@ moveStack.start(true); - operatingCompany.buyPrivate(privateCompany, player.getPortfolio(), + operatingCompany.get().buyPrivate(privateCompany, player.getPortfolio(), price); return true; @@ -2013,7 +2014,7 @@ // Checks // Is company operating? - if (company != operatingCompany) { + if (company != operatingCompany.get()) { errMsg = LocalText.getText("WrongCompany", companyName, @@ -2046,32 +2047,32 @@ int number = action.getNumberTaken(); int amount = calculateLoanAmount (number); - operatingCompany.addLoans(number); - new CashMove (bank, operatingCompany, amount); + operatingCompany.get().addLoans(number); + new CashMove (bank, operatingCompany.get(), amount); if (number == 1) { ReportBuffer.add(LocalText.getText("CompanyTakesLoan", - operatingCompany.getName(), - Bank.format(operatingCompany.getValuePerLoan()), + operatingCompany.get().getName(), + Bank.format(operatingCompany.get().getValuePerLoan()), Bank.format(amount) )); } else { ReportBuffer.add(LocalText.getText("CompanyTakesLoans", - operatingCompany.getName(), + operatingCompany.get().getName(), number, - Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(operatingCompany.get().getValuePerLoan()), Bank.format(amount) )); } - if (operatingCompany.getMaxLoansPerRound() > 0) { + if (operatingCompany.get().getMaxLoansPerRound() > 0) { int oldLoansThisRound = 0; if (loansThisRound == null) { loansThisRound = new HashMap<PublicCompanyI, Integer>(); - } else if (loansThisRound.containsKey(operatingCompany)){ - oldLoansThisRound = loansThisRound.get(operatingCompany); + } else if (loansThisRound.containsKey(operatingCompany.get())){ + oldLoansThisRound = loansThisRound.get(operatingCompany.get()); } new MapChange<PublicCompanyI, Integer> (loansThisRound, - operatingCompany, + operatingCompany.get(), new Integer (oldLoansThisRound + number)); } } @@ -2099,11 +2100,11 @@ return false; } - int repayment = action.getNumberRepaid() * operatingCompany.getValuePerLoan(); - if (repayment > 0 && repayment > operatingCompany.getCash()) { + int repayment = action.getNumberRepaid() * operatingCompany.get().getValuePerLoan(); + if (repayment > 0 && repayment > operatingCompany.get().getCash()) { // President must contribute - int remainder = repayment - operatingCompany.getCash(); - Player president = operatingCompany.getPresident(); + int remainder = repayment - operatingCompany.get().getCash(); + Player president = operatingCompany.get().getPresident(); int presCash = president.getCash(); if (remainder > presCash) { // Start a share selling round @@ -2113,8 +2114,8 @@ log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; moveStack.start(true); - gameManager.startShareSellingRound(operatingCompany.getPresident(), - cashToBeRaisedByPresident, operatingCompany); + gameManager.startShareSellingRound(operatingCompany.get().getPresident(), + cashToBeRaisedByPresident, operatingCompany.get(), false); return true; } } @@ -2139,37 +2140,37 @@ int payment; int remainder = 0; - operatingCompany.addLoans(-number); - int amount = number * operatingCompany.getValuePerLoan(); - payment = Math.min(amount, operatingCompany.getCash()); + operatingCompany.get().addLoans(-number); + int amount = number * operatingCompany.get().getValuePerLoan(); + payment = Math.min(amount, operatingCompany.get().getCash()); remainder = amount - payment; if (payment > 0) { - new CashMove (operatingCompany, bank, payment); + new CashMove (operatingCompany.get(), bank, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoans", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(payment), Bank.format(amount), number, - Bank.format(operatingCompany.getValuePerLoan()))); + Bank.format(operatingCompany.get().getValuePerLoan()))); } if (remainder > 0) { - Player president = operatingCompany.getPresident(); + Player president = operatingCompany.get().getPresident(); if (president.getCash() >= remainder) { payment = remainder; new CashMove (president, bank, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoansWithPresCash", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(payment), Bank.format(amount), number, - Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(operatingCompany.get().getValuePerLoan()), president.getName())); } } } protected int calculateLoanAmount (int numberOfLoans) { - return numberOfLoans * operatingCompany.getValuePerLoan(); + return numberOfLoans * operatingCompany.get().getValuePerLoan(); } /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ @@ -2180,11 +2181,11 @@ * @return The currently operating company object. */ public PublicCompanyI getOperatingCompany() { - return operatingCompanyObject.getObject(); + return operatingCompany.get(); } public List<PublicCompanyI> getOperatingCompanies() { - return operatingCompanies; + return operatingCompanies.viewList(); } /** @@ -2193,7 +2194,7 @@ * @return The number that defines the next action. */ public GameDef.OrStep getStep() { - return (GameDef.OrStep) stepObject.getObject(); + return (GameDef.OrStep) stepObject.get(); } /** @@ -2222,8 +2223,6 @@ @Override public boolean setPossibleActions() { - operatingCompany = getOperatingCompany(); - /* Create a new list of possible actions for the UI */ possibleActions.clear(); selectedAction = null; @@ -2244,10 +2243,10 @@ GameDef.OrStep step = getStep(); if (step == GameDef.OrStep.LAY_TRACK) { - if (!operatingCompany.hasLaidHomeBaseTokens()) { + if (!operatingCompany.get().hasLaidHomeBaseTokens()) { // This can occur if the home hex has two cities and track, // such as the green OO tile #59 - possibleActions.add(new LayBaseToken (operatingCompany.getHomeHex())); + possibleActions.add(new LayBaseToken (operatingCompany.get().getHomeHex())); forced = true; } else { setNormalTileLays(); @@ -2277,11 +2276,11 @@ setBuyableTrains(); // TODO Need route checking here. // TEMPORARILY allow not buying a train if none owned - //if (!operatingCompany.mustOwnATrain() - // || operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + //if (!operatingCompany.getObject().mustOwnATrain() + // || operatingCompany.getObject().getPortfolio().getNumberOfTrains() > 0) { doneAllowed = true; //} - if (noMapMode && (operatingCompany.getLastRevenue() == 0)) + if (noMapMode && (operatingCompany.get().getLastRevenue() == 0)) prepareNoMapActions(); } else if (step == GameDef.OrStep.DISCARD_TRAINS) { @@ -2310,7 +2309,7 @@ if (getCurrentPhase().isPrivateSellingAllowed()) { // Create a list of players with the current one in front - int currentPlayerIndex = operatingCompany.getPresident().getIndex(); + int currentPlayerIndex = operatingCompany.get().getPresident().getIndex(); Player player; int minPrice, maxPrice; List<Player> players = getPlayers(); @@ -2321,16 +2320,16 @@ for (PrivateCompanyI privComp : player.getPortfolio().getPrivateCompanies()) { minPrice = - (int) (privComp.getBasePrice() * operatingCompany.getLowerPrivatePriceFactor()); + (int) (privComp.getBasePrice() * operatingCompany.get().getLowerPrivatePriceFactor()); maxPrice = - (int) (privComp.getBasePrice() * operatingCompany.getUpperPrivatePriceFactor()); + (int) (privComp.getBasePrice() * operatingCompany.get().getUpperPrivatePriceFactor()); possibleActions.add(new BuyPrivate(privComp, minPrice, maxPrice)); } } } - if (operatingCompany.canUseSpecialProperties()) { + if (operatingCompany.get().canUseSpecialProperties()) { // Are there any "common" special properties, // i.e. properties that are available to everyone? @@ -2341,8 +2340,8 @@ if (sp instanceof SellBonusToken) { sbt = (SellBonusToken) sp; // Can't buy if already owned - if (operatingCompany.getBonuses() != null) { - for (Bonus bonus : operatingCompany.getBonuses()) { + if (operatingCompany.get().getBonuses() != null) { + for (Bonus bonus : operatingCompany.get().getBonuses()) { if (bonus.getName().equals(sp.getName())) continue loop; } } @@ -2352,7 +2351,7 @@ } // Are there other step-independent special properties owned by the company? - List<SpecialPropertyI> orsps = operatingCompany.getPortfolio().getAllSpecialProperties(); + List<SpecialPropertyI> orsps = operatingCompany.get().getPortfolio().getAllSpecialProperties(); if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() @@ -2392,7 +2391,7 @@ for (PossibleAction pa : possibleActions.getList()) { try { - log.debug(operatingCompany.getName() + " may: " + pa.toString()); + log.debug(operatingCompany.get().getName() + " may: " + pa.toString()); } catch (Exception e) { log.error("Error in toString() of " + pa.getClass(), e); } @@ -2404,11 +2403,11 @@ protected void prepareRevenueAndDividendAction () { // There is only revenue if there are any trains - if (operatingCompany.canRunTrains()) { + if (operatingCompany.get().canRunTrains()) { int[] allowedRevenueActions = - operatingCompany.isSplitAlways() + operatingCompany.get().isSplitAlways() ? new int[] { SetDividend.SPLIT } - : operatingCompany.isSplitAllowed() + : operatingCompany.get().isSplitAllowed() ? new int[] { SetDividend.PAYOUT, SetDividend.SPLIT, SetDividend.WITHHOLD } @@ -2416,7 +2415,7 @@ SetDividend.WITHHOLD }; possibleActions.add(new SetDividend( - operatingCompany.getLastRevenue(), true, + operatingCompany.get().getLastRevenue(), true, allowedRevenueActions)); } } @@ -2425,13 +2424,13 @@ // LayTile Actions for (Integer tc: mapManager.getPossibleTileCosts()) { - if (tc <= operatingCompany.getCash()) + if (tc <= operatingCompany.get().getCash()) possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_TILE, tc, false)); } // LayBaseToken Actions - if (operatingCompany.getNumberOfFreeBaseTokens() != 0) { - int[] costsArray = operatingCompany.getBaseTokenLayCosts(); + if (operatingCompany.get().getNumberOfFreeBaseTokens() != 0) { + int[] costsArray = operatingCompany.get().getBaseTokenLayCosts(); // change to set to allow for identity and ordering Set<Integer> costsSet = new TreeSet<Integer>(); @@ -2447,7 +2446,7 @@ } for (int cost : costsSet) { - if (cost <= operatingCompany.getCash()) // distance method returns home base, but in sequence costsSet can be zero + if (cost <= operatingCompany.get().getCash()) // distance method returns home base, but in sequence costsSet can be zero possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, cost, false)); } } @@ -2456,8 +2455,8 @@ // possibleActions.add(new OperatingCost( // OperatingCost.OCType.LAY_TILE, 0, true // )); - // if (operatingCompany.getNumberOfFreeBaseTokens() != 0 - // && operatingCompany.getBaseTokenLayCost(null) != 0) { + // if (operatingCompany.getObject().getNumberOfFreeBaseTokens() != 0 + // && operatingCompany.getObject().getBaseTokenLayCost(null) != 0) { // possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, 0, true)); // } @@ -2470,18 +2469,18 @@ */ public void setBuyableTrains() { - if (operatingCompany == null) return; + if (operatingCompany.get() == null) return; TrainManager trainMgr = gameManager.getTrainManager(); - int cash = operatingCompany.getCash(); + int cash = operatingCompany.get().getCash(); int cost; List<TrainI> trains; boolean hasTrains = - operatingCompany.getPortfolio().getNumberOfTrains() > 0; + operatingCompany.get().getPortfolio().getNumberOfTrains() > 0; boolean canBuyTrainNow = canBuyTrainNow(); - boolean presidentMayHelp = !hasTrains && operatingCompany.mustOwnATrain(); + boolean presidentMayHelp = !hasTrains && operatingCompany.get().mustOwnATrain(); TrainI cheapestTrain = null; int costOfCheapestTrain = 0; @@ -2495,7 +2494,7 @@ /* New trains */ trains = trainMgr.getAvailableNewTrains(); for (TrainI train : trains) { - if (!operatingCompany.mayBuyTrainType(train)) continue; + if (!operatingCompany.get().mayBuyTrainType(train)) continue; if (!mayBuyMoreOfEachType && trainsBoughtThisTurn.contains(train.getType())) { continue; @@ -2517,7 +2516,7 @@ cost = train.getType().getExchangeCost(); if (cost <= cash) { ... [truncated message content] |
From: <ste...@us...> - 2010-08-18 22:03:07
|
Revision: 1394 http://rails.svn.sourceforge.net/rails/?rev=1394&view=rev Author: stefanfrey Date: 2010-08-18 22:03:00 +0000 (Wed, 18 Aug 2010) Log Message: ----------- - Fixed display issues on the NetworkInfo->RevenueRun - Added static modifier for 1856 CGR leased Diesel Modified Paths: -------------- trunk/18xx/rails/algorithms/RevenueAdapter.java trunk/18xx/rails/algorithms/RevenueTrainRun.java trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java trunk/18xx/rails/ui/swing/ORPanel.java Modified: trunk/18xx/rails/algorithms/RevenueAdapter.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-17 20:07:46 UTC (rev 1393) +++ trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-18 22:03:00 UTC (rev 1394) @@ -635,10 +635,9 @@ StringBuffer runPrettyPrint = new StringBuffer(); for (RevenueTrainRun run:listRuns) { runPrettyPrint.append(run.prettyPrint(includeDetails)); - if (includeDetails) - runPrettyPrint.append("<BR>"); - else if (run != listRuns.get(listRuns.size()-1)) - runPrettyPrint.append("; "); + if (!includeDetails && run != listRuns.get(listRuns.size()-1)) { + runPrettyPrint.append("; "); + } } if (includeDetails) { for (RevenueDynamicModifier modifier:dynamicModifiers) { Modified: trunk/18xx/rails/algorithms/RevenueTrainRun.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueTrainRun.java 2010-08-17 20:07:46 UTC (rev 1393) +++ trunk/18xx/rails/algorithms/RevenueTrainRun.java 2010-08-18 22:03:00 UTC (rev 1394) @@ -195,7 +195,7 @@ int length = runPrettyPrint.length() - initLength; if (length / PRETTY_PRINT_LENGTH != multiple) { multiple = length / PRETTY_PRINT_LENGTH; - runPrettyPrint.append("<BR>"); + runPrettyPrint.append("\n"); for (int i=0; i < PRETTY_PRINT_INDENT; i++) runPrettyPrint.append(" ") ; } Modified: trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java =================================================================== --- trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java 2010-08-17 20:07:46 UTC (rev 1393) +++ trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java 2010-08-18 22:03:00 UTC (rev 1394) @@ -3,11 +3,13 @@ import java.util.ArrayList; import java.util.List; +import rails.algorithms.RevenueAdapter; +import rails.algorithms.RevenueStaticModifier; import rails.game.*; import rails.game.move.*; import rails.game.state.*; -public class PublicCompany_CGR extends PublicCompany { +public class PublicCompany_CGR extends PublicCompany implements RevenueStaticModifier { public static final String NAME = "CGR"; @@ -29,8 +31,17 @@ // Share price is initially fixed canSharePriceVary.set(false); + } + + @Override + public void finishConfiguration(GameManagerI gameManager) throws ConfigurationException { + super.finishConfiguration(gameManager); + // add revenue modifier for the case that there is no train + gameManager.getRevenueManager().addStaticModifier(this); + } + public boolean hadPermanentTrain() { return hadPermanentTrain.booleanValue(); } @@ -149,4 +160,14 @@ public String getExtraShareMarks () { return (hasTemporaryPresident() ? "T" : ""); } + + public void modifyCalculator(RevenueAdapter revenueAdapter) { + // check if the running company is the cgr + if (revenueAdapter.getCompany() != this) return; + + // add the diesel train + if (runsWithBorrowedTrain()) { + revenueAdapter.addTrainByString("D"); + } + } } Modified: trunk/18xx/rails/ui/swing/ORPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/ORPanel.java 2010-08-17 20:07:46 UTC (rev 1393) +++ trunk/18xx/rails/ui/swing/ORPanel.java 2010-08-18 22:03:00 UTC (rev 1394) @@ -629,33 +629,18 @@ for (String addTrain:addTrainList) { ra.addTrainByString(addTrain); } - ra.initRevenueCalculator(true); - log.info("Revenue Adapter:" + ra); + ra.initRevenueCalculator(true); // true => multigraph, false => simplegraph + log.debug("Revenue Adapter:" + ra); int revenueValue = ra.calculateRevenue(); - log.info("Revenue Value:" + revenueValue); - log.info("Revenue Run:" + ra.getOptimalRunPrettyPrint(true)); + log.debug("Revenue Value:" + revenueValue); + log.debug("Revenue Run:" + ra.getOptimalRunPrettyPrint(true)); ra.drawOptimalRunAsPath(orUIManager.getMap()); orUIManager.getMap().repaint(); JOptionPane.showMessageDialog(orWindow, "RevenueValue = " + revenueValue + "\nRevenueRun = \n" + ra.getOptimalRunPrettyPrint(true)); - // simple - ra = RevenueAdapter.createRevenueAdapter(gm, company, gm.getCurrentPhase()); - for (String addTrain:addTrainList) { - ra.addTrainByString(addTrain); - } - ra.initRevenueCalculator(false); - log.info("Revenue Adapter:" + ra); - revenueValue = ra.calculateRevenue(); - log.info("Revenue Value:" + revenueValue); - log.info("Revenue Run:" + ra.getOptimalRunPrettyPrint(true)); - ra.drawOptimalRunAsPath(orUIManager.getMap()); - orUIManager.getMap().repaint(); - JOptionPane.showMessageDialog(orWindow, "RevenueValue = " + revenueValue + - "\nRevenueRun = \n" + ra.getOptimalRunPrettyPrint(true)); - String trainString = - JOptionPane.showInputDialog(orWindow, "Another train", + JOptionPane.showInputDialog(null, "Enter train string (Examples: 5, 3+3, 4D, 6E, D)", "Add another train to run?", JOptionPane.QUESTION_MESSAGE); if (trainString == null || trainString.equals("")) { @@ -842,8 +827,8 @@ revenueAdapter.drawOptimalRunAsPath(orUIManager.getMap()); orUIManager.getMap().repaint(); orUIManager.addInformation("Best Run Value = " + bestRevenue + - " with " + revenueAdapter.getOptimalRunPrettyPrint(false)); - orUIManager.addDetail(revenueAdapter.getOptimalRunPrettyPrint(true)); + " with " + Util.convertToHtml(revenueAdapter.getOptimalRunPrettyPrint(false))); + orUIManager.addDetail(Util.convertToHtml(revenueAdapter.getOptimalRunPrettyPrint(true))); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-17 20:07:53
|
Revision: 1393 http://rails.svn.sourceforge.net/rails/?rev=1393&view=rev Author: stefanfrey Date: 2010-08-17 20:07:46 +0000 (Tue, 17 Aug 2010) Log Message: ----------- Fixed several bugs: - IOException error on reload of rails 1.3 files - IsHome function did not recognize companies with undecided city - BuyTrain toString() was not defined for unlimited trains on reload in ListandFixGames function Modified Paths: -------------- trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/game/action/BuyTrain.java Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2010-08-16 19:48:31 UTC (rev 1392) +++ trunk/18xx/rails/game/Game.java 2010-08-17 20:07:46 UTC (rev 1393) @@ -310,8 +310,10 @@ if (object instanceof SortedMap) { ReportBuffer.setCommentItems((SortedMap<Integer, String>) object); } - } catch (EOFException e) { - // continue without comments + } catch (IOException e) { + // continue without comments, if any IOException occurs + // sometimes not only the EOF Exception is raised + // but also the java.io.StreamCorruptedException: invalid type code } } Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-08-16 19:48:31 UTC (rev 1392) +++ trunk/18xx/rails/game/MapHex.java 2010-08-17 20:07:46 UTC (rev 1393) @@ -949,7 +949,7 @@ } public boolean isHomeFor(PublicCompanyI company) { - boolean result = homes != null && homes.get(company) != null; + boolean result = homes != null && homes.containsKey(company); return result; } Modified: trunk/18xx/rails/game/action/BuyTrain.java =================================================================== --- trunk/18xx/rails/game/action/BuyTrain.java 2010-08-16 19:48:31 UTC (rev 1392) +++ trunk/18xx/rails/game/action/BuyTrain.java 2010-08-17 20:07:46 UTC (rev 1393) @@ -209,7 +209,11 @@ StringBuffer b = new StringBuffer(); b.append(company.getName()); - b.append(": buy ").append(getTrain().getName()); + if (train != null) { + b.append(": buy ").append(getTrain().getName()); + } else { + b.append(": buy unlimited train, unique id = ").append(trainUniqueId); + } b.append("-train from ").append(from.getName()); if (fixedCost > 0) { b.append(" for ").append(Bank.format(fixedCost)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-16 19:48:39
|
Revision: 1392 http://rails.svn.sourceforge.net/rails/?rev=1392&view=rev Author: stefanfrey Date: 2010-08-16 19:48:31 +0000 (Mon, 16 Aug 2010) Log Message: ----------- Fixed toolTip update issue (tooltip did not update after undos) Modified Paths: -------------- trunk/18xx/rails/ui/swing/hexmap/GUIHex.java trunk/18xx/rails/ui/swing/hexmap/HexMap.java Modified: trunk/18xx/rails/ui/swing/hexmap/GUIHex.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-08-16 19:06:47 UTC (rev 1391) +++ trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-08-16 19:48:31 UTC (rev 1392) @@ -224,7 +224,7 @@ currentTileOrientation = model.getCurrentTileRotation(); currentGUITile = new GUITile(currentTileId, this); currentGUITile.setRotation(currentTileOrientation); - setToolTip(); + toolTip = null; model.addObserver(this); @@ -661,7 +661,10 @@ } public String getToolTip() { - return toolTip; + if (toolTip != null) + return toolTip; + else + return getDefaultToolTip(); } @@ -682,7 +685,7 @@ return tt.toString(); } - protected void setToolTip() { + private String getDefaultToolTip() { StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Hex</b>: ").append(hexName); String name = model.getCityName(); @@ -754,7 +757,7 @@ tt.append("</html>"); - toolTip = tt.toString(); + return tt.toString(); } public boolean dropTile(int tileId, boolean upgradeMustConnect) { @@ -786,7 +789,7 @@ public void removeTile() { provisionalGUITile = null; setSelected(false); - setToolTip(); + toolTip = null; } public boolean canFixTile() { @@ -804,18 +807,18 @@ public void fixTile() { setSelected(false); - setToolTip(); + toolTip = null; } public void removeToken() { provisionalGUIToken = null; setSelected(false); - setToolTip(); + toolTip = null; } public void fixToken() { setSelected(false); - setToolTip(); + toolTip = null; } /** Needed to satisfy the ViewObject interface. Currently not used. */ Modified: trunk/18xx/rails/ui/swing/hexmap/HexMap.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-08-16 19:06:47 UTC (rev 1391) +++ trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-08-16 19:48:31 UTC (rev 1392) @@ -561,10 +561,11 @@ public void mouseReleased(MouseEvent arg0) {} public void updateOffBoardToolTips() { - for (GUIHex hex : hexes) { - if (hex.getHexModel().hasOffBoardValues()) { - hex.setToolTip(); - } - } +// for (GUIHex hex : hexes) { +// if (hex.getHexModel().hasOffBoardValues()) { +// hex.setToolTip(); +// } +// } + // do nothing as tooltip update before display } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-16 19:06:53
|
Revision: 1391 http://rails.svn.sourceforge.net/rails/?rev=1391&view=rev Author: evos Date: 2010-08-16 19:06:47 +0000 (Mon, 16 Aug 2010) Log Message: ----------- Fixed: if company sells a train, a lone remaining Pullmann muet be discarded. Modified Paths: -------------- trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java Modified: trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-15 19:54:57 UTC (rev 1390) +++ trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-16 19:06:47 UTC (rev 1391) @@ -58,7 +58,7 @@ int costOfCheapestTrain = 0; String extraMessage = null; - boolean mustExchangePullmann = !isBelowTrainLimit() + boolean mustExchangePullmann = !isBelowTrainLimit() && hasPullmannAtStart.booleanValue() && !possibleActions.contains(BuyTrain.class); if (mustExchangePullmann) { @@ -88,7 +88,7 @@ // May not buy Pullmann if one is already owned, // or if no train is owned at all if (train.getType().getName().equals("P") - &&(operatingCompany.getPortfolio().getTrainOfType(pullmannType) != null + &&(operatingCompany.getPortfolio().getTrainOfType(pullmannType) != null || !hasTrains)) { continue; } @@ -150,7 +150,7 @@ } } } - + } /** In 18EU, a company can (effectively) exchange a Pullmann */ @@ -162,9 +162,9 @@ @Override public boolean buyTrain(BuyTrain action) { - + boolean mustDiscardPullmann = !super.isBelowTrainLimit() && hasPullmann (); - + boolean result = super.buyTrain(action); // If we are at train limit and have a Pullmann, discard it @@ -178,7 +178,30 @@ } } - + + // If train was bought from another company, check for a lone Pullmann + Portfolio seller = action.getFromPortfolio(); + if (seller.getOwner() instanceof PublicCompanyI + && !action.getTrain().getName().equalsIgnoreCase("P")) { + boolean hasPullmann = false; + boolean hasNonPullmann = false; + TrainI pullmann = null; + for (TrainI sellerTrain : seller.getTrainList()) { + if ("P".equalsIgnoreCase(sellerTrain.getName())) { + hasPullmann = true; + pullmann = sellerTrain; + } else if (sellerTrain != null){ + hasNonPullmann = true; + } + } + if (hasPullmann && !hasNonPullmann) { + pullmann.moveTo (pool); + ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", + seller.getOwner().getName(), + pullmann.getName() )); + } + } + // Check if we have just started Phase 5 and // if we still have at least one Minor operating. // If so, record the current player as the first @@ -231,7 +254,7 @@ } return !excessTrainCompanies.isEmpty(); } - + private boolean hasPullmann () { return operatingCompany.getPortfolio().getTrainOfType(pullmannType) != null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-08-15 19:55:03
|
Revision: 1390 http://rails.svn.sourceforge.net/rails/?rev=1390&view=rev Author: evos Date: 2010-08-15 19:54:57 +0000 (Sun, 15 Aug 2010) Log Message: ----------- Fixed: Config.label.or.number_format=OR number format Modified Paths: -------------- trunk/18xx/LocalisedText.properties Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-15 19:40:47 UTC (rev 1389) +++ trunk/18xx/LocalisedText.properties 2010-08-15 19:54:57 UTC (rev 1390) @@ -164,7 +164,7 @@ Config.label.map.autoscroll=Map autoscroll Config.label.map.zoomstep=Map zoomstep Config.label.money_format=Money format -Config.label.or.number_format=Number format +Config.label.or.number_format=OR number format Config.label.report.directory=Report directory Config.label.report.filename.date_time_pattern=Report filename date pattern Config.label.report.filename.extension=Report filename extension This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-15 19:40:54
|
Revision: 1389 http://rails.svn.sourceforge.net/rails/?rev=1389&view=rev Author: stefanfrey Date: 2010-08-15 19:40:47 +0000 (Sun, 15 Aug 2010) Log Message: ----------- Added display of revenue bonus in non-detailed revenue results Some refactoring of the dynamic revenue modifier Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/algorithms/RevenueAdapter.java trunk/18xx/rails/algorithms/RevenueDynamicModifier.java trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/LocalisedText.properties 2010-08-15 19:40:47 UTC (rev 1389) @@ -492,7 +492,9 @@ REPORT_COMMENT_TITLE=Add Comment REPORT_COMMENT_ASK=Add a comment to the previous action REVENUE=Revenue +RevenueBonus=Bonus(es) = {0} RevenueCalculation=support for revenue calculation +RevenueNoRun=No Optimal Run RevenueStations=, Cities = {0}, Towns = {1} RevenueStationsIgnoreMinors=, Cities = {0} ReceivesFor={0} receives {1} for {2}. Modified: trunk/18xx/rails/algorithms/RevenueAdapter.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -19,12 +19,12 @@ import rails.game.GameManagerI; import rails.game.MapHex; -import rails.game.MapManager; import rails.game.PhaseI; import rails.game.PublicCompanyI; import rails.game.TrainI; import rails.game.TrainTypeI; import rails.ui.swing.hexmap.HexMap; +import rails.util.LocalText; public final class RevenueAdapter implements Runnable { @@ -587,7 +587,7 @@ int dynamicEvaluation() { int value = 0; for (RevenueDynamicModifier modifier:dynamicModifiers) { - value += modifier.evaluationValue(this); + value += modifier.evaluationValue(this.getCurrentRun()); } return value; } @@ -598,7 +598,7 @@ int dynamicPrediction() { int value = 0; for (RevenueDynamicModifier modifier:dynamicModifiers) { - value += modifier.predictionValue(this); + value += modifier.predictionValue(); } return value; } @@ -630,7 +630,7 @@ public String getOptimalRunPrettyPrint(boolean includeDetails) { List<RevenueTrainRun> listRuns = getOptimalRun(); - if (listRuns== null) return "No Optimal Run"; + if (listRuns== null) return LocalText.getText("RevenueNoRun"); StringBuffer runPrettyPrint = new StringBuffer(); for (RevenueTrainRun run:listRuns) { @@ -641,12 +641,19 @@ runPrettyPrint.append("; "); } if (includeDetails) { - // add dynamic Modifier for (RevenueDynamicModifier modifier:dynamicModifiers) { runPrettyPrint.append(modifier.prettyPrint(this)); } + } else { + int dynamicBonuses = 0; + for (RevenueDynamicModifier modifier:dynamicModifiers) { + dynamicBonuses += modifier.evaluationValue(this.getOptimalRun()); + } + if (dynamicBonuses != 0) { + runPrettyPrint.append("; " + + LocalText.getText("RevenueBonus", dynamicBonuses)); + } } - return runPrettyPrint.toString(); } Modified: trunk/18xx/rails/algorithms/RevenueDynamicModifier.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueDynamicModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/algorithms/RevenueDynamicModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -1,4 +1,7 @@ package rails.algorithms; + +import java.util.List; + /** * Classes that change properties of the revenue calculation * after the actual calculation started implement the dynamic modifier. @@ -15,12 +18,12 @@ public boolean prepareModifier(RevenueAdapter revenueAdapter); /** returns the value used for prediction */ - public int predictionValue(RevenueAdapter revenueAdapter); + public int predictionValue(); - /** returns the value used for evaluation */ - public int evaluationValue(RevenueAdapter revenueAdapter); + /** returns the value used for evaluation (at the run supplied) */ + public int evaluationValue(List<RevenueTrainRun> runs); - /** returns the prettyPrintName */ - public String prettyPrint(RevenueAdapter revenueAdapter); + /** returns the results as pretty prints */ + public String prettyPrint(RevenueAdapter adapter); } Modified: trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -98,14 +98,13 @@ return true; } - public int predictionValue(RevenueAdapter revenueAdapter) { + public int predictionValue() { return bonusMaximum; } - public int evaluationValue(RevenueAdapter revenueAdapter) { - List<RevenueTrainRun> runs = revenueAdapter.getCurrentRun(); + public int evaluationValue(List<RevenueTrainRun> runs) { int bonusValue = 0; - // due to the geography each train can only score one bonus + // due to the geography (off-map areas!) each train can only score one bonus for (RevenueBonus bonus:bonuses) { for (RevenueTrainRun run:runs) { if (run.getUniqueVertices().containsAll(bonus.getVertices())) { @@ -123,7 +122,7 @@ for (RevenueBonus bonus:bonuses) { for (RevenueTrainRun run:runs) { if (run.getUniqueVertices().containsAll(bonus.getVertices())) { - prettyPrint.append(bonus.getName() + ": " + bonus.getValue() + "\n"); + prettyPrint.append(bonus.getName() + " = " + bonus.getValue() + "\n"); continue; // each bonus can only be scored once } } Modified: trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -32,8 +32,8 @@ return true; } - public int evaluationValue(RevenueAdapter revenueAdapter) { - return pullmanValue(revenueAdapter.getCurrentRun()); + public int evaluationValue(List<RevenueTrainRun> runs) { + return pullmanValue(runs); } private int pullmanValue(List<RevenueTrainRun> trainRuns) { @@ -45,12 +45,12 @@ return maximum; } - public int predictionValue(RevenueAdapter revenueAdapter) { + public int predictionValue() { return maxValue; } public String prettyPrint(RevenueAdapter revenueAdapter) { - return LocalText.getText("Pullman") + ": " + pullmanValue(revenueAdapter.getOptimalRun()); + return LocalText.getText("Pullman") + " = " + pullmanValue(revenueAdapter.getOptimalRun()); } private int maximumMajorValue(Collection<NetworkVertex> vertices) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-15 12:09:14
|
Revision: 1388 http://rails.svn.sourceforge.net/rails/?rev=1388&view=rev Author: stefanfrey Date: 2010-08-15 12:09:08 +0000 (Sun, 15 Aug 2010) Log Message: ----------- Fixed missing default value for font scaling using legacy config files Modified Paths: -------------- trunk/18xx/rails/ui/swing/Scale.java Modified: trunk/18xx/rails/ui/swing/Scale.java =================================================================== --- trunk/18xx/rails/ui/swing/Scale.java 2010-08-14 19:53:42 UTC (rev 1387) +++ trunk/18xx/rails/ui/swing/Scale.java 2010-08-15 12:09:08 UTC (rev 1388) @@ -43,8 +43,9 @@ } catch (NumberFormatException e) { fontScale = 1; } + } else { + fontScale = 1; } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-14 19:53:49
|
Revision: 1387 http://rails.svn.sourceforge.net/rails/?rev=1387&view=rev Author: stefanfrey Date: 2010-08-14 19:53:42 +0000 (Sat, 14 Aug 2010) Log Message: ----------- Further fixes to the new report window functionality Added user comments Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/ReportBuffer.java trunk/18xx/rails/game/move/MoveStack.java trunk/18xx/rails/ui/swing/MessagePanel.java trunk/18xx/rails/ui/swing/ORUIManager.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java trunk/18xx/rails/util/Util.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/LocalisedText.properties 2010-08-14 19:53:42 UTC (rev 1387) @@ -486,8 +486,11 @@ RepayLoans=Repay loan(s) RepayLoan=Repay {0} loan(s) of {1} for {2} REPORT=Report Window -REPORT_MOVE_BACKWARD=<< -REPORT_MOVE_FORWARD=>> +REPORT_MOVE_BACKWARD=< +REPORT_MOVE_FORWARD=> +REPORT_COMMENT=Comment +REPORT_COMMENT_TITLE=Add Comment +REPORT_COMMENT_ASK=Add a comment to the previous action REVENUE=Revenue RevenueCalculation=support for revenue calculation RevenueStations=, Cities = {0}, Towns = {1} Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/Game.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -261,18 +261,18 @@ log.debug("Starting to execute loaded actions"); + Object actionObject = null; while (true) { // Single-pass loop. - Object firstActionObject; try { - firstActionObject = ois.readObject(); + actionObject = ois.readObject(); } catch (EOFException e) { // Allow saved file at start of game (with no actions). break; } - if (firstActionObject instanceof List) { + if (actionObject instanceof List) { // Old-style: one List of PossibleActions List<PossibleAction> executedActions = - (List<PossibleAction>) firstActionObject; + (List<PossibleAction>) actionObject; numberOfActions = executedActions.size(); for (PossibleAction action : executedActions) { if (!gameManager.processOnReload(action)) { @@ -281,19 +281,17 @@ break; } } - - } else { + } else if (actionObject instanceof PossibleAction) { // New style: separate PossibleActionsObjects, since Rails 1.3.1 - PossibleAction action = (PossibleAction) firstActionObject; - while (true) { + while (actionObject instanceof PossibleAction) { numberOfActions++; - if (!gameManager.processOnReload(action)) { + if (!gameManager.processOnReload((PossibleAction)actionObject)) { log.error ("Load interrupted"); DisplayBuffer.add(LocalText.getText("LoadInterrupted")); break; } try { - action = (PossibleAction) ois.readObject(); + actionObject = ois.readObject(); } catch (EOFException e) { break; } @@ -301,6 +299,22 @@ } break; } + + // load user comments (is the last + if (actionObject instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) actionObject); + log.debug("Found sorted map"); + } else { + try { + object = ois.readObject(); + if (object instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) object); + } + } catch (EOFException e) { + // continue without comments + } + } + ois.close(); game.getGameManager().finishLoading(); Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/GameManager.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -1040,6 +1040,7 @@ for (PossibleAction action : executedActions) { oos.writeObject(action); } + oos.writeObject(ReportBuffer.getCommentItems()); oos.close(); result = true; Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/OperatingRound.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -803,6 +803,10 @@ moveStack.start(true); + ReportBuffer.add(LocalText.getText("CompanyRevenue", + action.getCompanyName(), + Bank.format(action.getActualRevenue()))); + int remainingAmount = checkForDeductions (action); if (remainingAmount < 0) { // A share selling round will be run to raise cash to pay debts @@ -890,9 +894,6 @@ action.setRevenueAllocation(SetDividend.WITHHOLD); } - ReportBuffer.add(LocalText.getText("CompanyRevenue", - action.getCompanyName(), - Bank.format(amount))); if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", operatingCompany.getName(), Modified: trunk/18xx/rails/game/ReportBuffer.java =================================================================== --- trunk/18xx/rails/game/ReportBuffer.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/ReportBuffer.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -27,13 +27,12 @@ /** defines the collection of data that is stored in the report buffer */ private class ReportItem { private List<String> messages = new ArrayList<String>(); - private int index = 0; + private int index = -1; private Player player = null; private RoundI round = null; private void addMessage(String message) { - // ignore undos and redos - messages.add(message); + messages.add(Util.convertToHtml(message)); } private String getMessages() { @@ -44,17 +43,38 @@ return s.toString(); } - private String toHtml() { + /** + * converts messages to html string + * @param activeMessage if true, adds indicator and highlighting for active message + */ + + private String toHtml(boolean activeMessage) { + if (messages.isEmpty()) { + if (activeMessage) { + return ("<span bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR + "</span>" + + NEWLINE_STRING); + } else { + return null; + } + } + StringBuffer s = new StringBuffer(); boolean init = true; for (String message:messages) { if (init) { + if (activeMessage) { + s.append("<span bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR) ; + } s.append("<a href=http://rails:" + index + ">"); s.append(message); - s.append("</a><br> "); // is the linefeed character to induce line feed on copy & paste + s.append("</a>"); + if (activeMessage) { + s.append("</span>"); + } + s.append(NEWLINE_STRING); init = false; } else { - s.append(message + "<br> "); // see above + s.append(message + NEWLINE_STRING); // see above } } return s.toString(); @@ -70,8 +90,25 @@ } } + /* + * All variables below are required for the dynamic preprot window + */ + /** Indicator string to find the active message position in the parsed html document */ + public static final String ACTIVE_MESSAGE_INDICATOR = "(**)"; - /** + /** Newline string + * is the linefeed character to induce line feed on copy & paste + */ + private static final String NEWLINE_STRING = "<br> "; + + /** Archive stack of messages, the integer index corresponds with the moveset items */ + private SortedMap<Integer, ReportItem> reportItems = new TreeMap<Integer, ReportItem>(); + + /** Archive stack of user supplied comments, integer index corresponds with moveset items */ + private SortedMap<Integer, String> commentItems = new TreeMap<Integer, String>(); + + /* + * All variables below are required for the static report window * A stack for displaying messages in the Log Window. Such messages are * intended to record the progress of the rails.game and can be used as a * rails.game report. @@ -81,11 +118,6 @@ /** Another stack for messages that must "wait" for other messages */ private List<String> waitQueue = new ArrayList<String> (); - /** Archive stack, the integer index corresponds with the moveset items */ - private SortedMap<Integer, ReportItem> reportItems = new TreeMap<Integer, ReportItem>(); - /** Indicator string to find the active message position in the parsed html document */ - public static final String ACTIVE_MESSAGE_INDICATOR = "(**)"; - private String reportPathname = null; private PrintWriter report = null; @@ -108,7 +140,7 @@ public ReportBuffer() { - reportItems.put(0, new ReportItem()); + reportItems.put(-1, new ReportItem()); if (!initialQueue.isEmpty()) { for (String s : initialQueue) { addMessage(s, -1); // start of the game @@ -129,7 +161,8 @@ private void addMessage(String message, int moveStackIndex) { if (message != null) { if (message.equals("")) { - message = "---"; // workaround for testing + return; + // message = "---"; // workaround for testing } // legacy report queue reportQueue.add(message); @@ -191,20 +224,25 @@ } } + private void clearFutureItems(int index) { + // delete future items + Set<Integer> deleteIndices = new HashSet<Integer> + (reportItems.tailMap(index + 1).keySet()); + for (Integer i:deleteIndices) { + reportItems.remove(i); + commentItems.remove(i); + } + } + private void addReportItem(int index, Player player, RoundI round) { ReportItem newItem = new ReportItem(); newItem.index = index; newItem.player = player; newItem.round = round; reportItems.put(index, newItem); - Set<Integer> deleteIndices = new HashSet<Integer> - (reportItems.tailMap(index + 1).keySet()); - for (Integer i:deleteIndices) { - reportItems.remove(i); - } } - - /** Movestack calls the report item to update */ + + /** Creates a new report item */ public static void createNewReportItem(int index) { // check availablity GameManagerI gm = GameManager.getInstance(); @@ -219,23 +257,33 @@ Player player = gm.getCurrentPlayer(); RoundI round = gm.getCurrentRound(); instance.addReportItem(index, player, round); + instance.clearFutureItems(index); } public static String getReportItems() { - int index = GameManager.getInstance().getMoveStack().getIndex(); + // activeIndex is the index one before the current index for the next action + int activeIndex = GameManager.getInstance().getMoveStack().getCurrentIndex(); ReportBuffer instance = getInstance(); StringBuffer s = new StringBuffer(); s.append("<html>"); - for (ReportItem item:instance.reportItems.values()) { - if (item.index == index-1) { - s.append("<p bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR) ; + for (Integer index:instance.reportItems.keySet()) { + ReportItem item = instance.reportItems.get(index); + String text = item.toHtml(index == activeIndex); + String comment = instance.commentItems.get(index); + if (text == null && comment == null) continue; + s.append("<p>"); + // comments first + if (comment != null) { + s.append("<span style='color:green;font-size:80%;font-style:italic;'>"); + s.append(item.player.getName() + " says: ' "); + s.append(comment + "'" + NEWLINE_STRING); + s.append("</span>"); } - s.append(item.toHtml()); - if (item.index == (index-1)) { - s.append("</p><"); - } + // text afterwards + if (text != null) s.append(text); + s.append("</p>"); } s.append("</html>"); @@ -273,10 +321,69 @@ instance.reportQueue.add(message); return; } - int moveStackIndex = gm.getMoveStack().getIndex(); + int moveStackIndex = gm.getMoveStack().getCurrentIndex(); instance.addMessage(message, moveStackIndex); } } + + /** Add a user comment to the report window */ + public static void addComment(String comment) { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + int index = gm.getMoveStack().getCurrentIndex(); // add one index before (active) + instance.commentItems.put(index, comment); + log.debug("Added comment = " + comment + " at index = " + index); + } + } + + /** Retrieves the current user comment */ + public static String getComment() { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + String comment = null; + if (instance != null) { + int index = gm.getMoveStack().getCurrentIndex(); + comment = instance.commentItems.get(index); + } + return comment; + } + + /** Retrieves all user comments */ + public static SortedMap<Integer, String> getCommentItems() { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + return instance.commentItems; + } else { + // return empty map + return new TreeMap<Integer, String>(); + } + } + + /** sets user comments */ + public static void setCommentItems(SortedMap<Integer, String> commentItems) { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + instance.commentItems = commentItems; + } + } + + + /** return the current buffer as list */ public static List<String> getAsList() { Modified: trunk/18xx/rails/game/move/MoveStack.java =================================================================== --- trunk/18xx/rails/game/move/MoveStack.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/move/MoveStack.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -48,6 +48,7 @@ while (lastIndex < moveStack.size() - 1) { moveStack.remove(moveStack.size() - 1); } + ReportBuffer.createNewReportItem(getCurrentIndex()); return currentMoveSet; } else { log.warn("MoveSet is already open"); @@ -68,7 +69,6 @@ moveStack.add(currentMoveSet); lastIndex++; currentMoveSet = null; - ReportBuffer.createNewReportItem(this.getIndex()); return true; } } @@ -117,6 +117,7 @@ undoAction = moveStack.get(lastIndex--); undoAction.unexecute(); } while (undoAction.isLinkedToPreviousMove()); + return true; } else { log.error("Invalid undo: index=" + lastIndex + " size=" @@ -165,6 +166,18 @@ return lastIndex + 1; } + /** + * the current index is the one of either the open moveset or + * if none is open of the latest added + */ + public int getCurrentIndex() { + if (isOpen()) { + return lastIndex + 1; + } else { + return lastIndex; + } + } + /** * undo/redo to a given moveStack index */ Modified: trunk/18xx/rails/ui/swing/MessagePanel.java =================================================================== --- trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -62,22 +62,21 @@ messageText.append("</span>"); } if (showDetails) { - messageText.append("<span style='color:blue'>"); + messageText.append("<span style='color:blue; font-size:80%'>"); for (String detail:currentDetails) { messageText.append(detail); } messageText.append("</span>"); } else if (currentDetails.size() != 0) { - messageText.append("<span style='color:blue'>"); + messageText.append("<span style='color:blue; font-size:80%'>"); messageText.append("<BR> Click for more details"); messageText.append("</span>"); } - if (currentMessage != null) { - String text = messageText.toString(); - int lines = text.split("<[Bb][Rr]>").length + 1; - setLines(lines); - message.setText("<html><center>" + text + "</center></html>"); - } + // display + String text = messageText.toString(); + int lines = text.split("<[Bb][Rr]>").length + 1; + setLines(lines); + message.setText("<html><center>" + text + "</center></html>"); } Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -1419,6 +1419,8 @@ mapRelatedActions.clear(); orPanel.resetActions(); + + messagePanel.setMessage(null); if (actionToComplete != null) { log.debug("ExecutedAction: " + actionToComplete); Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -7,7 +7,9 @@ import java.net.URL; import java.util.List; +import javax.swing.JButton; import javax.swing.JEditorPane; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.UIManager; @@ -40,6 +42,7 @@ private JPanel buttonPanel; private ActionButton forwardButton; private ActionButton backwardButton; + private JButton commentButton; protected static Logger log = Logger.getLogger(ReportWindowDynamic.class.getPackage().getName()); @@ -80,6 +83,29 @@ forwardButton.addActionListener(this); buttonPanel.add(forwardButton); + commentButton = new JButton(LocalText.getText("REPORT_COMMENT")); + commentButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + String newComment = (String)JOptionPane.showInputDialog( + ReportWindowDynamic.this, + LocalText.getText("REPORT_COMMENT_ASK"), + LocalText.getText("REPORT_COMMENT_TITLE"), + JOptionPane.PLAIN_MESSAGE, + null, + null, + ReportBuffer.getComment() + ); + if (newComment != null) { + ReportBuffer.addComment(newComment); + updateLog(); + scrollDown(); + } + } + } + ); + buttonPanel.add(commentButton); + super.init(); } Modified: trunk/18xx/rails/util/Util.java =================================================================== --- trunk/18xx/rails/util/Util.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/util/Util.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -79,7 +79,19 @@ } } + /** + * Convert java string to html string + * Transformations: + * - Converts \n to <br> + */ + public static String convertToHtml(String javaString) { + return javaString.replace("\n", "<br>"); + } + + + + /** * Safely move a list of objects from one holder to another, avoiding * ConcurrentModificationExceptions. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-13 16:30:26
|
Revision: 1386 http://rails.svn.sourceforge.net/rails/?rev=1386&view=rev Author: stefanfrey Date: 2010-08-13 16:30:20 +0000 (Fri, 13 Aug 2010) Log Message: ----------- Fixed problem with UI init at start of new game Modified Paths: -------------- trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-13 16:03:47 UTC (rev 1385) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-13 16:30:20 UTC (rev 1386) @@ -416,7 +416,7 @@ System.exit(-1); } startGameUIManager (game); - gameUIManager.gameUIInit(); + gameUIManager.gameUIInit(true); // true indicates new game } this.setVisible(false); // XXX: At some point we should destroy this Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-13 16:03:47 UTC (rev 1385) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-13 16:30:20 UTC (rev 1386) @@ -146,7 +146,7 @@ } - public void gameUIInit() { + public void gameUIInit(boolean newGame) { imageLoader = new ImageLoader(); stockChart = new StockChart(this); @@ -176,8 +176,10 @@ System.exit(1); } - // uncommented by sfy on 13/08/10 to avoid double revenue calculation -// updateUI(); + // removed for reloaded games to avoid double revenue calculation + if (newGame) { + updateUI(); + } reportWindow.scrollDown(); @@ -187,7 +189,7 @@ } public void startLoadedGame() { - gameUIInit(); + gameUIInit(false); // false indicates reload processOnServer(new NullAction(NullAction.START_GAME)); statusWindow.setGameActions(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-13 16:04:06
|
Revision: 1385 http://rails.svn.sourceforge.net/rails/?rev=1385&view=rev Author: stefanfrey Date: 2010-08-13 16:03:47 +0000 (Fri, 13 Aug 2010) Log Message: ----------- Remaining changes of THB fix Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1856/Game.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/MapHex.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-13 15:59:03 UTC (rev 1384) +++ trunk/18xx/LocalisedText.properties 2010-08-13 16:03:47 UTC (rev 1385) @@ -1,6 +1,6 @@ # Texts with lowercase keys are intended to be inserted into other messages 1856MergerDialog=Repay loan decision of {0} for CGR merger -1856THBHomeBlocked=THB home hex is blocked for token lays (unless gray tile) +1856THBHomeBlocked=THB home hex is blocked (until gray tile) 1889PrivateBactive=Player {0} (owner of Private B) may lay port tile 1889PrivateCactive=Player {0} (previous owner of Private C) may lay tile on C4 immediately 18ALOptimizeNamedTrains=Optimize named train assignment Modified: trunk/18xx/data/1856/Game.xml =================================================================== --- trunk/18xx/data/1856/Game.xml 2010-08-13 15:59:03 UTC (rev 1384) +++ trunk/18xx/data/1856/Game.xml 2010-08-13 16:03:47 UTC (rev 1385) @@ -9,7 +9,7 @@ <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> - <GameOption name="1856THBHomeBlocked" type="toggle" default="yes" /> + <GameOption name="1856THBHomeBlocked" type="toggle" default="no" /> <GameParameters> <StockRound class="rails.game.specific._1856.StockRound_1856" sequence="SellBuyOrBuySell"> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-08-13 15:59:03 UTC (rev 1384) +++ trunk/18xx/data/GamesList.xml 2010-08-13 16:03:47 UTC (rev 1385) @@ -67,6 +67,7 @@ <Option name="UnlimitedTiles" type="toggle" default="no"/> <Option name="LeaveAuctionOnPass" type="toggle" default="no"/> <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> + <Option name="1856THBHomeBlocked" type="toggle" default="no" /> <Players minimum="3" maximum="6"/> </Game> Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-08-13 15:59:03 UTC (rev 1384) +++ trunk/18xx/rails/game/MapHex.java 2010-08-13 16:03:47 UTC (rev 1385) @@ -1030,10 +1030,10 @@ * C) Or the company does not block its home city at all (example:Pr in 1835) * then isBlockedForTokenLays attribute is used * - * NOTE: It assumes that not two company share the same home city. - * Undecided companies cannot share the same hex with any other company. + * NOTE: It now deals with more than one company with a home base on the + * same hex. * - * Previously used was the variable isBlockedForTokenLays + * Previously there was only the variable isBlockedForTokenLays * which is set to yes to block the whole hex for the token lays * until the (home) company laid their token * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-13 15:59:09
|
Revision: 1384 http://rails.svn.sourceforge.net/rails/?rev=1384&view=rev Author: stefanfrey Date: 2010-08-13 15:59:03 +0000 (Fri, 13 Aug 2010) Log Message: ----------- Updated test reports Modified Paths: -------------- trunk/18xx/test/data/1856/finished/1856_A_OR5_b.report trunk/18xx/test/data/1889/test/1889_B_OR4_b.report trunk/18xx/test/data/18AL/bug/18AL_20100303_2323Brian.report trunk/18xx/test/data/18AL/finished/18AL_A_OR6_e.report Modified: trunk/18xx/test/data/1856/finished/1856_A_OR5_b.report =================================================================== --- trunk/18xx/test/data/1856/finished/1856_A_OR5_b.report 2010-08-13 15:58:30 UTC (rev 1383) +++ trunk/18xx/test/data/1856/finished/1856_A_OR5_b.report 2010-08-13 15:59:03 UTC (rev 1384) @@ -251,11 +251,11 @@ CompanyTakesLoan,TGB,$100,$100 BuysPrivateFromFor,TGB,W&SR,Wesaq,$80 LAYS_FREE_TOKEN_ON,TGB,I12 -PrivateCloses,W&SR InterestPaidFromTreasury,TGB,$10 CompanyDoesNotPayDividend,TGB PRICE_MOVES_LOG,TGB,$70,E5,$65,D5 BuysTrain,TGB,3,IPO,$225 +PrivateCloses,W&SR CompanyOperates,GT,Wesaq LaysTileAt,GT,9,O8,NW CompanyRevenue,GT,$60 Modified: trunk/18xx/test/data/1889/test/1889_B_OR4_b.report =================================================================== --- trunk/18xx/test/data/1889/test/1889_B_OR4_b.report 2010-08-13 15:58:30 UTC (rev 1383) +++ trunk/18xx/test/data/1889/test/1889_B_OR4_b.report 2010-08-13 15:59:03 UTC (rev 1384) @@ -323,10 +323,10 @@ --- PASSES,Fred END_SR,3 +PRICE_MOVES_LOG,UR,¥60,C6,¥65,C5 +SoldOut,UR,¥60,C6,¥65,C5 PRICE_MOVES_LOG,TR,¥55,C7,¥60,C6 SoldOut,TR,¥55,C7,¥60,C6 -PRICE_MOVES_LOG,UR,¥60,C6,¥65,C5 -SoldOut,UR,¥60,C6,¥65,C5 --- Has,IR,¥900 Has,SR,¥120 @@ -507,14 +507,14 @@ END_SR,4 PRICE_MOVES_LOG,IR,¥90,D2,¥100,D1 SoldOut,IR,¥90,D2,¥100,D1 +PRICE_MOVES_LOG,KO,¥80,G6,¥90,G5 +SoldOut,KO,¥80,G6,¥90,G5 PRICE_MOVES_LOG,SR,¥70,F7,¥75,F6 SoldOut,SR,¥70,F7,¥75,F6 -PRICE_MOVES_LOG,KO,¥80,G6,¥90,G5 -SoldOut,KO,¥80,G6,¥90,G5 +PRICE_MOVES_LOG,UR,¥70,E6,¥75,E5 +SoldOut,UR,¥70,E6,¥75,E5 PRICE_MOVES_LOG,TR,¥60,E8,¥65,E7 SoldOut,TR,¥60,E8,¥65,E7 -PRICE_MOVES_LOG,UR,¥70,E6,¥75,E5 -SoldOut,UR,¥70,E6,¥75,E5 --- Has,AR,¥1000 Has,IR,¥510 Modified: trunk/18xx/test/data/18AL/bug/18AL_20100303_2323Brian.report =================================================================== --- trunk/18xx/test/data/18AL/bug/18AL_20100303_2323Brian.report 2010-08-13 15:58:30 UTC (rev 1383) +++ trunk/18xx/test/data/18AL/bug/18AL_20100303_2323Brian.report 2010-08-13 15:59:03 UTC (rev 1384) @@ -248,12 +248,12 @@ PASSES,Peter PASSES,Chris END_SR,3 +PRICE_MOVES_LOG,L&N,$55,C4,$60,C3 +SoldOut,L&N,$55,C4,$60,C3 PRICE_MOVES_LOG,WRA,$50,C5,$55,C4 SoldOut,WRA,$50,C5,$55,C4 PRICE_MOVES_LOG,AB&C,$40,B6,$45,B5 SoldOut,AB&C,$40,B6,$45,B5 -PRICE_MOVES_LOG,L&N,$55,C4,$60,C3 -SoldOut,L&N,$55,C4,$60,C3 --- Has,WRA,$404 Has,AB&C,$500 @@ -349,10 +349,10 @@ Autopasses,Matt PASSES,Brian END_SR,4 +PRICE_MOVES_LOG,L&N,$60,D4,$65,D3 +SoldOut,L&N,$60,D4,$65,D3 PRICE_MOVES_LOG,WRA,$55,D5,$60,D4 SoldOut,WRA,$55,D5,$60,D4 -PRICE_MOVES_LOG,L&N,$60,D4,$65,D3 -SoldOut,L&N,$60,D4,$65,D3 --- Has,WRA,$284 Has,ATN,$600 @@ -508,12 +508,12 @@ Autopasses,Chris PASSES,Matt END_SR,5 +PRICE_MOVES_LOG,L&N,$60,D4,$65,D3 +SoldOut,L&N,$60,D4,$65,D3 PRICE_MOVES_LOG,WRA,$55,D5,$60,D4 SoldOut,WRA,$55,D5,$60,D4 PRICE_MOVES_LOG,AB&C,$50,E7,$55,E6 SoldOut,AB&C,$50,E7,$55,E6 -PRICE_MOVES_LOG,L&N,$60,D4,$65,D3 -SoldOut,L&N,$60,D4,$65,D3 --- Has,WRA,$24 Has,M&O,$900 Modified: trunk/18xx/test/data/18AL/finished/18AL_A_OR6_e.report =================================================================== --- trunk/18xx/test/data/18AL/finished/18AL_A_OR6_e.report 2010-08-13 15:58:30 UTC (rev 1383) +++ trunk/18xx/test/data/18AL/finished/18AL_A_OR6_e.report 2010-08-13 15:59:03 UTC (rev 1384) @@ -749,12 +749,12 @@ PASSES,Steve PASSES,Peter END_SR,6 +PRICE_MOVES_LOG,AB&C,$90,I4,$105,I3 +SoldOut,AB&C,$90,I4,$105,I3 +PRICE_MOVES_LOG,ATN,$80,H4,$90,H3 +SoldOut,ATN,$80,H4,$90,H3 PRICE_MOVES_LOG,TAG,$70,F4,$75,F3 SoldOut,TAG,$70,F4,$75,F3 -PRICE_MOVES_LOG,ATN,$80,H4,$90,H3 -SoldOut,ATN,$80,H4,$90,H3 -PRICE_MOVES_LOG,AB&C,$90,I4,$105,I3 -SoldOut,AB&C,$90,I4,$105,I3 --- Has,WRA,$354 Has,TAG,$77 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-13 15:58:37
|
Revision: 1383 http://rails.svn.sourceforge.net/rails/?rev=1383&view=rev Author: stefanfrey Date: 2010-08-13 15:58:30 +0000 (Fri, 13 Aug 2010) Log Message: ----------- Fixed problems with TestGame integration tests Modified Paths: -------------- trunk/18xx/data/profiles/test.profile trunk/18xx/rails/util/Config.java trunk/18xx/rails/util/LocalText.java trunk/18xx/test/TestGame.java Modified: trunk/18xx/data/profiles/test.profile =================================================================== --- trunk/18xx/data/profiles/test.profile 2010-08-13 15:57:46 UTC (rev 1382) +++ trunk/18xx/data/profiles/test.profile 2010-08-13 15:58:30 UTC (rev 1383) @@ -17,7 +17,7 @@ # (implying a language variant of that country; no default). # Locale: concatenation of the above. If present, overrides any of the above. # Examples: en, en_US, en_UK, fr_FR, fr_CA. -locale=te_st +locale=te_ST #language= #country= @@ -25,7 +25,7 @@ # Each game has a specific format for monetary amounts (e.g. $100, 100M). # An overriding format can be specified here, but then applies to all games. # The @ character must be present and is replaced by the amount. -# Example: \xA3@ to specify a pound sign prefix: \xA3100. +# Example: �@ to specify a pound sign prefix: �100. #money_format=$@ ### Save file directory Modified: trunk/18xx/rails/util/Config.java =================================================================== --- trunk/18xx/rails/util/Config.java 2010-08-13 15:57:46 UTC (rev 1382) +++ trunk/18xx/rails/util/Config.java 2010-08-13 15:58:30 UTC (rev 1383) @@ -51,8 +51,8 @@ private static String userProfilesFile = "user.profiles"; private static Properties userProfiles = new Properties(); private static boolean profilesLoaded = false; - private static final String TEST_PROFILE_SELECTION = ".test"; - private static final String DEFAULT_PROFILE_SELECTION = "default"; + private static String DEFAULT_PROFILE_SELECTION = "default"; // can be overwritten + private static final String TEST_PROFILE_SELECTION = ".test"; // used as default profile for integration tests private static final String STANDARD_PROFILE_SELECTION = "user"; private static final String DEFAULTPROFILE_PROPERTY = "default.profile"; private static final String PROFILENAME_PROPERTY = "profile.name"; @@ -329,8 +329,11 @@ // delayed setting of logger log = Logger.getLogger(Config.class.getPackage().getName()); + // define settings for testing legacyConfigFile = false; - selectedProfile = TEST_PROFILE_SELECTION; + DEFAULT_PROFILE_SELECTION = TEST_PROFILE_SELECTION; + selectedProfile = null; + initialLoad(); } @@ -447,19 +450,23 @@ userProperties = new Properties(); defaultProperties = new Properties(); - // check if the profile is already defined under userProfiles - String userConfigFile = userProfiles.getProperty(userProfile); - if (Util.hasValue(userConfigFile) && // load user profile - loadPropertyFile(userProperties, userConfigFile, false)) { - // do nothing, only side effects - } else { // if not defined or loadable, define userprofile with file association - userProfiles.setProperty(userProfile, ""); + String userConfigFile = null; + if (Util.hasValue(userProfile)) { + // check if the profile is already defined under userProfiles + userConfigFile = userProfiles.getProperty(userProfile); + if (Util.hasValue(userConfigFile) && // load user profile + loadPropertyFile(userProperties, userConfigFile, false)) { + // do nothing, only side effects + } else { // if not defined or loadable, define userprofile with file association + userProfiles.setProperty(userProfile, ""); + } + + // check if profilename is defined in user properties + if (!Util.hasValue(userProfiles.getProperty(PROFILENAME_PROPERTY))) { + userProperties.setProperty(PROFILENAME_PROPERTY, userProfile); + } } - // check if profilename is defined in user properties - if (!Util.hasValue(userProfiles.getProperty(PROFILENAME_PROPERTY))) { - userProperties.setProperty(PROFILENAME_PROPERTY, userProfile); - } loadDefaultProfile(); setSaveDirDefaults(); } Modified: trunk/18xx/rails/util/LocalText.java =================================================================== --- trunk/18xx/rails/util/LocalText.java 2010-08-13 15:57:46 UTC (rev 1382) +++ trunk/18xx/rails/util/LocalText.java 2010-08-13 15:58:30 UTC (rev 1383) @@ -11,6 +11,8 @@ public class LocalText extends ResourceBundle { + private static final String TEST_LOCALE = "te_ST"; + protected static String language = "en"; protected static String country = ""; @@ -92,8 +94,8 @@ } } - // special treatment for te_ST (test) - if (localeCode.equals("te_ST")) { + // special treatment for test locale + if (localeCode.equals(TEST_LOCALE)) { StringBuffer s = new StringBuffer(key); if (parameters != null) for (Object o:parameters) Modified: trunk/18xx/test/TestGame.java =================================================================== --- trunk/18xx/test/TestGame.java 2010-08-13 15:57:46 UTC (rev 1382) +++ trunk/18xx/test/TestGame.java 2010-08-13 15:58:30 UTC (rev 1383) @@ -2,7 +2,6 @@ import java.io.File; import java.io.FileReader; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |