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-10-30 12:17:14
|
Revision: 1457 http://rails.svn.sourceforge.net/rails/?rev=1457&view=rev Author: stefanfrey Date: 2010-10-30 12:17:07 +0000 (Sat, 30 Oct 2010) Log Message: ----------- Added JScrollPane to GameStatus part of the StatusWindow Modified Paths: -------------- trunk/18xx/rails/ui/swing/StatusWindow.java Modified: trunk/18xx/rails/ui/swing/StatusWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StatusWindow.java 2010-10-28 20:45:43 UTC (rev 1456) +++ trunk/18xx/rails/ui/swing/StatusWindow.java 2010-10-30 12:17:07 UTC (rev 1457) @@ -256,8 +256,11 @@ log.fatal("Cannot instantiate class " + gameStatusClassName, e); System.exit(1); } + gameStatus.init(this, gameUIManager); - + // put gameStatus into a JScrollPane + JScrollPane gameStatusPane = new JScrollPane(gameStatus); + buttonPanel = new JPanel(); passButton = new ActionButton(LocalText.getText("PASS")); @@ -283,8 +286,8 @@ setTitle(LocalText.getText("GAME_STATUS_TITLE")); pane.setLayout(new BorderLayout()); initMenu(); - pane.add(gameStatus, BorderLayout.NORTH); - pane.add(buttonPanel, BorderLayout.CENTER); + pane.add(gameStatusPane, BorderLayout.CENTER); + pane.add(buttonPanel, BorderLayout.SOUTH); pane.setOpaque(true); setContentPane(pane); setVisible(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-10-28 20:45:50
|
Revision: 1456 http://rails.svn.sourceforge.net/rails/?rev=1456&view=rev Author: stefanfrey Date: 2010-10-28 20:45:43 +0000 (Thu, 28 Oct 2010) Log Message: ----------- Added Clipboard export of recent actions at game save Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/ReportBuffer.java trunk/18xx/rails/ui/swing/GameUIManager.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-10-28 18:57:43 UTC (rev 1455) +++ trunk/18xx/LocalisedText.properties 2010-10-28 20:45:43 UTC (rev 1456) @@ -523,6 +523,7 @@ SAVE=Save SAVE_AND_APPLY=Save/Apply SAVEAS=Save As ... +SaveDialogTitle=Save Game. Info: Report of current players action copied to Clipboard. SaveFailed=Save failed, reason: {0} Select=Select SelectCompanyToMergeMinorInto=Select major company to merge minor {0} into Modified: trunk/18xx/rails/game/ReportBuffer.java =================================================================== --- trunk/18xx/rails/game/ReportBuffer.java 2010-10-28 18:57:43 UTC (rev 1455) +++ trunk/18xx/rails/game/ReportBuffer.java 2010-10-28 20:45:43 UTC (rev 1456) @@ -32,13 +32,17 @@ private RoundI round = null; private void addMessage(String message) { - messages.add(Util.convertToHtml(message)); + messages.add(message); } - private String getMessages() { + private String getMessages(boolean html) { StringBuffer s = new StringBuffer(); for (String message:messages) { - s.append(message); + if (html) { + s.append(Util.convertToHtml(message)); + } else { + s.append(message); + } } return s.toString(); } @@ -61,6 +65,7 @@ StringBuffer s = new StringBuffer(); boolean init = true; for (String message:messages) { + message = Util.convertToHtml(message); if (init) { if (activeMessage) { s.append("<span bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR) ; @@ -80,12 +85,21 @@ return s.toString(); } + public String toText() { + StringBuffer s = new StringBuffer(); + for (String message:messages) { + s.append(message + "\n"); + } + return s.toString(); + } + + public String toString() { StringBuffer s = new StringBuffer(); s.append("ReportItem for MoveStackIndex = " + index); s.append(", player = " + player); s.append(", round = " + round); - s.append(", messages = "); s.append(getMessages()); + s.append(", messages = "); s.append(getMessages(false)); return s.toString(); } } @@ -260,6 +274,40 @@ instance.clearFutureItems(index); } + /** + * returns the latest report items + */ + public static String getLatestReportItems(){ + ReportBuffer instance = getInstance(); + + // search for a change of the player + Player currentPlayer = null; + int currentPlayerIndex = 0; + for (ReportItem item:instance.reportItems.values()) { + if (item.player != currentPlayer) { + currentPlayer = item.player; + currentPlayerIndex = item.index; + } + } + + // start with that index and connect data + StringBuffer s = new StringBuffer(); + int index = currentPlayerIndex; + do { + ReportItem item = instance.reportItems.get(index); + String text = item.toText(); + String comment = instance.commentItems.get(index); + if (text == null && comment == null) continue; + // comments first + if (comment != null) { + s.append(item.player.getName() + " says: ' "); + s.append(comment + "'" + NEWLINE_STRING); + } + // text afterwards + if (text != null) s.append(text); + } while (instance.reportItems.containsKey(++index)); + return s.toString(); + } public static String getReportItems() { // activeIndex is the index one before the current index for the next action Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-10-28 18:57:43 UTC (rev 1455) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-10-28 20:45:43 UTC (rev 1456) @@ -7,6 +7,9 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; import java.io.File; import java.text.SimpleDateFormat; import java.util.*; @@ -705,6 +708,7 @@ File proposedFile = new File(filename); jfc.setSelectedFile(proposedFile); + if (jfc.showSaveDialog(statusWindow) == JFileChooser.APPROVE_OPTION) { File selectedFile = jfc.getSelectedFile(); String filepath = selectedFile.getPath(); @@ -720,6 +724,11 @@ public void saveGame(GameAction saveAction) { + // copy latest report buffer entries to clipboard + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringSelection reportText = new StringSelection(ReportBuffer.getLatestReportItems()); + clipboard.setContents(reportText, null); + JFileChooser jfc = new JFileChooser(); String filename; if (providedName != null) { @@ -737,6 +746,10 @@ File proposedFile = new File(filename); jfc.setSelectedFile(proposedFile); + + // allows adjustment of the save dialog title, to add hint about copy to clipboard + jfc.setDialogTitle(LocalText.getText("SaveDialogTitle")); + if (jfc.showSaveDialog(statusWindow) == JFileChooser.APPROVE_OPTION) { File selectedFile = jfc.getSelectedFile(); String filepath = selectedFile.getPath(); @@ -747,6 +760,7 @@ saveAction.setFilepath(filepath); processOnServer(saveAction); } + } public void setSaveDirectory(String saveDirectory) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-28 18:57:49
|
Revision: 1455 http://rails.svn.sourceforge.net/rails/?rev=1455&view=rev Author: evos Date: 2010-10-28 18:57:43 +0000 (Thu, 28 Oct 2010) Log Message: ----------- Final fix of the map display problem when a game is started via RunGame with a saved file parameter. Modified Paths: -------------- trunk/18xx/rails/ui/swing/StartRoundWindow.java trunk/18xx/rails/ui/swing/StatusWindow.java trunk/18xx/rails/ui/swing/StockChart.java trunk/18xx/rails/ui/swing/hexmap/GUIHex.java trunk/18xx/rails/ui/swing/hexmap/HexMap.java Modified: trunk/18xx/rails/ui/swing/StartRoundWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-10-27 21:54:11 UTC (rev 1454) +++ trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-10-28 18:57:43 UTC (rev 1455) @@ -158,7 +158,7 @@ gbc = new GridBagConstraints(); players = gameUIManager.getGameManager().getPlayers().toArray(new Player[0]); - np = GameManager.getInstance().getNumberOfPlayers(); + np = gameUIManager.getGameManager().getNumberOfPlayers(); packet = round.getStartPacket(); crossIndex = new int[packet.getNumberOfItems()]; @@ -185,8 +185,8 @@ requestFocus(); addKeyListener(this); - + pack(); } @@ -692,7 +692,7 @@ b.append("<br>").append(condition); } } - + } if (item.getSecondary() != null) { b.append("<br><b>Also contains:</b><br>"); Modified: trunk/18xx/rails/ui/swing/StatusWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StatusWindow.java 2010-10-27 21:54:11 UTC (rev 1454) +++ trunk/18xx/rails/ui/swing/StatusWindow.java 2010-10-28 18:57:43 UTC (rev 1455) @@ -3,12 +3,8 @@ import java.awt.BorderLayout; import java.awt.Color; -//import java.awt.GraphicsConfiguration; -//import java.awt.Rectangle; import java.awt.event.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import javax.swing.*; @@ -17,10 +13,8 @@ import rails.common.GuiDef; import rails.game.*; import rails.game.action.*; -import rails.game.correct.*; -import rails.ui.swing.elements.ActionButton; -import rails.ui.swing.elements.ActionMenuItem; -import rails.ui.swing.elements.ActionCheckBoxMenuItem; +import rails.game.correct.CorrectionModeAction; +import rails.ui.swing.elements.*; import rails.util.Config; import rails.util.LocalText; @@ -93,7 +87,7 @@ Logger.getLogger(StatusWindow.class.getPackage().getName()); // GraphicsConfiguration graphicsConfiguration; - + // public StatusWindow(GraphicsConfiguration gc) { // super(gc); // this.graphicsConfiguration = gc; @@ -175,7 +169,7 @@ menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(this); optMenu.add(menuItem); - + // new config menu only for non legacy configgfiles if (!Config.isLegacyConfigFile()) { menuItem = new JCheckBoxMenuItem(LocalText.getText("CONFIG")); @@ -354,18 +348,18 @@ } } } - + public void setCorrectionMenu() { // Update the correction menu correctionMenu.removeAll(); correctionMenu.setEnabled(false); - // currently only shows CorrectionModeActions + // currently only shows CorrectionModeActions List<CorrectionModeAction> corrections = possibleActions.getType(CorrectionModeAction.class); - - + + if (corrections != null && !corrections.isEmpty()) { for (CorrectionModeAction a : corrections) { ActionCheckBoxMenuItem item = new ActionCheckBoxMenuItem ( @@ -379,7 +373,7 @@ correctionMenu.setEnabled(true); } } - + public boolean setupFor(RoundI round) { currentRound = round; @@ -397,14 +391,14 @@ // correction actions always possible return gameStatus.initCashCorrectionActions(); - + } public void updateStatus() { - if (!(currentRound instanceof StockRound || currentRound instanceof EndOfGameRound)) + if (!(currentRound instanceof StockRound || currentRound instanceof EndOfGameRound)) return; - + // Moved here from StatusWindow_1856. It's getting generic... if (possibleActions.contains(DiscardTrain.class)) { immediateAction = possibleActions.getType(DiscardTrain.class).get(0); @@ -537,7 +531,7 @@ } if (currentRound instanceof EndOfGameRound) endOfGame(); - + pack(); toFront(); @@ -703,50 +697,50 @@ // setVisible(true); // gameUIManager.reportWindow.setVisible(true); // gameUIManager.stockChart.setVisible(true); - + setTitle(LocalText.getText("EoGTitle")); // Enable Passbutton passButton.setEnabled(true); passButton.setText(LocalText.getText("END_OF_GAME_CLOSE_ALL_WINDOWS")); - + gameUIManager.orWindow.finish(); } public Player getCurrentPlayer () { return gameUIManager.getCurrentPlayer(); } - + public void endOfGameReport() { - GameManagerI gm = GameManager.getInstance(); - - if (gm.getGameOverReportedUI()) + GameManagerI gm = gameUIManager.getGameManager(); + + if (gm.getGameOverReportedUI()) return; else gm.setGameOverReportedUI(true); - + JOptionPane.showMessageDialog(this, LocalText.getText("EoGPressButton"), LocalText.getText("EoGFinalRanking"), JOptionPane.PLAIN_MESSAGE ); - + // show game report line by line - List<String> gameReport = GameManager.getInstance().getGameReport(); + List<String> gameReport = gm.getGameReport(); Collections.reverse(gameReport); - + StringBuilder report = new StringBuilder(); for (String s:gameReport) { report.insert(0, s + "\n"); - JOptionPane.showMessageDialog(this, + JOptionPane.showMessageDialog(this, report, LocalText.getText("EoGFinalRanking"), JOptionPane.PLAIN_MESSAGE ); } } - + public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { Modified: trunk/18xx/rails/ui/swing/StockChart.java =================================================================== --- trunk/18xx/rails/ui/swing/StockChart.java 2010-10-27 21:54:11 UTC (rev 1454) +++ trunk/18xx/rails/ui/swing/StockChart.java 2010-10-28 18:57:43 UTC (rev 1455) @@ -6,7 +6,6 @@ import javax.swing.*; -import rails.game.GameManager; import rails.game.StockSpaceI; import rails.ui.swing.elements.GUIStockSpace; @@ -108,7 +107,7 @@ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { - HelpWindow.displayHelp(GameManager.getInstance().getHelp()); + HelpWindow.displayHelp(gameUIManager.getGameManager().getHelp()); e.consume(); } } Modified: trunk/18xx/rails/ui/swing/hexmap/GUIHex.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-10-27 21:54:11 UTC (rev 1454) +++ trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-10-28 18:57:43 UTC (rev 1455) @@ -411,7 +411,9 @@ if (getHexModel().isBlockedForTileLays()) { List<PrivateCompanyI> privates = - GameManager.getInstance().getCompanyManager().getAllPrivateCompanies(); + //GameManager.getInstance().getCompanyManager().getAllPrivateCompanies(); + hexMap.getOrUIManager().getGameUIManager().getGameManager() + .getCompanyManager().getAllPrivateCompanies(); for (PrivateCompanyI p : privates) { List<MapHex> blocked = p.getBlockedHexes(); if (blocked != null) { Modified: trunk/18xx/rails/ui/swing/hexmap/HexMap.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-10-27 21:54:11 UTC (rev 1454) +++ trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-10-28 18:57:43 UTC (rev 1455) @@ -540,7 +540,10 @@ return mapManager; } - public void mouseClicked(MouseEvent arg0) { + public ORUIManager getOrUIManager() { + return orUIManager; + } + public void mouseClicked(MouseEvent arg0) { Point point = arg0.getPoint(); GUIHex clickedHex = getHexContainingPoint(point); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-27 21:54:18
|
Revision: 1454 http://rails.svn.sourceforge.net/rails/?rev=1454&view=rev Author: evos Date: 2010-10-27 21:54:11 +0000 (Wed, 27 Oct 2010) Log Message: ----------- Partial fix of the map display problem when a game is started via RunGame with a saved file parameter. Modified Paths: -------------- trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameManagerI.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/ui/swing/ORUIManager.java trunk/18xx/rails/ui/swing/UpgradesPanel.java trunk/18xx/rails/ui/swing/hexmap/GUITile.java Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/game/GameManager.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -158,7 +158,7 @@ * It will only be used inside the GM objects. * All other objects will access it via NDC. */ - protected static final String GM_KEY = "01"; + public static final String GM_KEY = "01"; public static final String GM_NAME = "GameManager"; /** @@ -205,9 +205,14 @@ * <br>This is a fix to maintain backwards compatibility when redundant * actions are skipped in new code versions (such as the bypassing of * a treasury trading step if it cannot be executed). - * <br>This flag will be reset after processing <i>any</i> action (not just Done). + * <br>This flag must be reset after processing <i>any</i> action (not just Done). */ protected boolean skipNextDone = false; + /** Step that must be in effect to do an actual Done skip during reloading. + * <br> This is to ensure that Done actions in different OR steps are + * considered separately. + */ + protected GameDef.OrStep skippedStep = null; protected static Logger log = Logger.getLogger(GameManager.class.getPackage().getName()); @@ -950,7 +955,7 @@ DisplayBuffer.clear(); - // XXX TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED + // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (gameName.equals("1856") && possibleActions.contains(RepayLoans.class) && (!possibleActions.contains(action.getClass()) @@ -967,17 +972,19 @@ try { log.debug("Action ("+action.getPlayerName()+"): " + action); - // XXX FOR BACKWARDS COMPATIBILITY + // FOR BACKWARDS COMPATIBILITY boolean doProcess = true; - log.debug("SkipNextDone="+skipNextDone); if (skipNextDone) { if (action instanceof NullAction && ((NullAction)action).getMode() == NullAction.DONE) { - log.info("Skipping processing a Done action during reload"); - doProcess = false; + if (currentRound.get() instanceof OperatingRound + && ((OperatingRound)currentRound.get()).getStep() == skippedStep) { + doProcess = false; + } } } skipNextDone = false; + skippedStep = null; if (doProcess && !processCorrectionActions(action) && !getCurrentRound().process(action)) { String msg = "Player "+action.getPlayerName()+"\'s action \"" @@ -1717,8 +1724,9 @@ this.reloading = reloading; } - public void setSkipDone () { + public void setSkipDone (GameDef.OrStep step) { skipNextDone = true; + skippedStep = step; } } Modified: trunk/18xx/rails/game/GameManagerI.java =================================================================== --- trunk/18xx/rails/game/GameManagerI.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/game/GameManagerI.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -207,5 +207,5 @@ public List<PublicCompanyI> getCompaniesInRunningOrder (); public boolean isReloading(); public void setReloading(boolean reloading); - public void setSkipDone (); + public void setSkipDone (GameDef.OrStep step); } \ No newline at end of file Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -1265,7 +1265,7 @@ // XXX For BACKWARDS COMPATIBILITY only, // register a Done skip action during reloading. if (gameManager.isReloading()) { - gameManager.setSkipDone(); + gameManager.setSkipDone(GameDef.OrStep.TRADE_SHARES); log.debug("If the next saved action is 'Done', skip it"); } log.info("Skipping Treasury share trading step"); Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -31,6 +31,7 @@ private RemainingTilesWindow remainingTiles; public GameUIManager gameUIManager; + protected TileManager tileManager; private OperatingRound oRound; private PublicCompanyI[] companies; @@ -95,6 +96,7 @@ public void setGameUIManager (GameUIManager gameUIManager) { this.gameUIManager = gameUIManager; + this.tileManager = gameUIManager.getGameManager().getTileManager(); } public void init(ORWindow orWindow) { @@ -1904,8 +1906,12 @@ return gameUIManager; } - private void displayRemainingTiles() { + public TileManager getTileManager() { + return tileManager; + } + private void displayRemainingTiles() { + if (remainingTiles == null) { remainingTiles = new RemainingTilesWindow(orWindow); } else { Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -19,12 +19,11 @@ import rails.ui.swing.elements.ActionLabel; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; -import rails.util.Config; import rails.util.LocalText; public class UpgradesPanel extends Box implements MouseListener, ActionListener { private static final long serialVersionUID = 1L; - + private ORUIManager orUIManager; private List<ActionLabel> tokenLabels; private List<CorrectionTokenLabel> correctionTokenLabels; @@ -34,7 +33,7 @@ static private Color defaultLabelBgColour = new JLabel("").getBackground(); static private Color selectedLabelBgColour = new Color(255, 220, 150); private static final int defaultNbPanelElements = 15; - + private JPanel upgradePanel; private JScrollPane scrollPane; private Dimension preferredSize; @@ -109,10 +108,10 @@ } } } - + public void showUpgrades() { upgradePanel.removeAll(); - + // reset to the number of elements GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); panelLayout.setRows(defaultNbPanelElements); @@ -200,12 +199,12 @@ // deactivate correctionTokenMode and tokenmode correctionTokenMode = false; tokenMode = false; - + // activate upgrade panel upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); List<TileI> tiles = orUIManager.tileUpgrades; - + if (tiles == null || tiles.size() == 0) { // reset to the number of elements panelLayout.setRows(defaultNbPanelElements); @@ -249,12 +248,12 @@ // activate correctionTokenMode and deactivate standard tokenMode correctionTokenMode = true; tokenMode = false; - + // activate upgrade panel upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); List<? extends TokenI> tokens = orUIManager.tokenLays; - + if (tokens == null || tokens.size() == 0) { // reset to the number of elements panelLayout.setRows(defaultNbPanelElements); @@ -288,16 +287,16 @@ correctionTokenLabels.add(tokenLabel); upgradePanel.add(tokenLabel); } - + } upgradePanel.add(doneButton); upgradePanel.add(cancelButton); // repaint(); revalidate(); - + } - + public void clear() { upgradePanel.removeAll(); upgradePanel.add(doneButton); @@ -456,25 +455,25 @@ setCancelEnabled(false); } - + /** ActionLabel extension that allows to attach the token */ private class CorrectionTokenLabel extends ActionLabel { - + private static final long serialVersionUID = 1L; - + private TokenI token; - + CorrectionTokenLabel(Icon tokenIcon, TokenI token) { super(tokenIcon); this.token = token; } - + TokenI getToken() { return token; } - + } - + /** JLabel extension to allow attaching the internal hex ID */ private class HexLabel extends JLabel { @@ -496,11 +495,11 @@ public String getToolTip() { return toolTip; } - + void setTextFromTile(TileI tile) { StringBuffer text = new StringBuffer(); if (tile.getExternalId() > 0) { - text.append("<HTML><BODY>" + tile.getExternalId()); + text.append("<HTML><BODY>" + tile.getExternalId()); if (tile.countFreeTiles() != -1) { text.append("<BR> (" + tile.countFreeTiles() + ")"); } Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-10-16 22:43:59 UTC (rev 1453) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-10-27 21:54:11 UTC (rev 1454) @@ -51,7 +51,8 @@ this.guiHex = guiHex; this.tileId = tileId; this.hex = (MapHex)guiHex.getModel(); - tile = GameManager.getInstance().getTileManager().getTile(tileId); + TileManager tileManager = guiHex.getHexMap().orUIManager.getTileManager(); + tile = tileManager.getTile(tileId); if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; @@ -248,6 +249,7 @@ public void paintTile(Graphics2D g2, int x, int y) { int zoomStep = guiHex.getHexMap().getZoomStep(); + tileImage = imageLoader.getTile(tileId, zoomStep); if (tileImage != null) { @@ -280,6 +282,8 @@ AffineTransformOp aop = new AffineTransformOp(af, rh); g2.drawImage(tileImage, aop, x - xCenter, y - yCenter); + } else { + log.error("No image for tile "+tileId+" on hex "+guiHex.getName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-10-16 22:44:05
|
Revision: 1453 http://rails.svn.sourceforge.net/rails/?rev=1453&view=rev Author: stefanfrey Date: 2010-10-16 22:43:59 +0000 (Sat, 16 Oct 2010) Log Message: ----------- Activate 1825 revenue modifiers Modified Paths: -------------- trunk/18xx/data/1825/Game.xml Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-10-16 22:43:25 UTC (rev 1452) +++ trunk/18xx/data/1825/Game.xml 2010-10-16 22:43:59 UTC (rev 1453) @@ -95,5 +95,10 @@ <OperatingRounds number="3"/> </Phase> </Component> - <Component name="RevenueManager" class="rails.algorithms.RevenueManager"/> + <Component name="RevenueManager" class="rails.algorithms.RevenueManager"> +<!-- The terminate modifier has to evaluated before DoubleHeading --> + <Modifier class="rails.game.specific._1825.TerminateAtMajorModifier" /> + <Modifier class="rails.game.specific._1825.DoubleHeadingModifier" /> + <Modifier class="rails.game.specific._1825.ScoreTileOnlyOnceModifier" /> + </Component> </ComponentManager> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-10-16 22:43:32
|
Revision: 1452 http://rails.svn.sourceforge.net/rails/?rev=1452&view=rev Author: stefanfrey Date: 2010-10-16 22:43:25 +0000 (Sat, 16 Oct 2010) Log Message: ----------- Added ScoreTileOnlyOnceModifier for 1825 A few minor fixes Modified Paths: -------------- trunk/18xx/rails/algorithms/RevenueAdapter.java trunk/18xx/rails/algorithms/RevenueTrainRun.java trunk/18xx/rails/game/specific/_1825/DoubleHeadingModifier.java Added Paths: ----------- trunk/18xx/rails/game/specific/_1825/ScoreTileOnlyOnceModifier.java Modified: trunk/18xx/rails/algorithms/RevenueAdapter.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-10-14 22:34:21 UTC (rev 1451) +++ trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-10-16 22:43:25 UTC (rev 1452) @@ -272,7 +272,6 @@ List<RevenueBonusTemplate> tileBonuses = hex.getCurrentTile().getRevenueBonuses(); if (tileBonuses != null) bonuses.addAll(tileBonuses); - if (bonuses == null) continue; for (RevenueBonusTemplate bonus:bonuses) { addRevenueBonus(bonus.toRevenueBonus(hex, gameManager, graphBuilder)); } Modified: trunk/18xx/rails/algorithms/RevenueTrainRun.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueTrainRun.java 2010-10-14 22:34:21 UTC (rev 1451) +++ trunk/18xx/rails/algorithms/RevenueTrainRun.java 2010-10-16 22:43:25 UTC (rev 1452) @@ -139,7 +139,7 @@ NetworkEdge previousEdge = null; NetworkVertex startVertex = null; for (NetworkEdge edge:edges) { - log.info("Processing edge " + edge.toFullInfoString() ); + log.debug("Processing edge " + edge.toFullInfoString() ); // process startEdge if (previousEdge == null) { previousEdge = edge; @@ -151,7 +151,7 @@ if (startVertex == null) { // if there is a joint route => other vertex of previousEdge if (commonVertex != null) { - log.info("Head Run"); + log.debug("Head Run"); startVertex = previousEdge.getOtherVertex(commonVertex); vertices.add(startVertex); vertices.add(commonVertex); @@ -162,12 +162,12 @@ } else { // start vertex is known // if there is a common vertex => continuous route if (commonVertex != null) { - log.info("Added common vertex"); + log.debug("Added common vertex"); vertices.add(commonVertex); } else { // otherwise it is bottom run // add the last vertex of the head train - log.info("Bottom Run"); + log.debug("Bottom Run"); vertices.add(previousEdge.getOtherVertex(vertices.get(vertices.size()-1))); vertices.add(startVertex); } @@ -176,7 +176,7 @@ } // add the last vertex of the route vertices.add(previousEdge.getOtherVertex(vertices.get(vertices.size()-1))); - log.info("Converted edges to vertices " + vertices); + log.debug("Converted edges to vertices " + vertices); } /** defines the edges from the list of vertices */ Modified: trunk/18xx/rails/game/specific/_1825/DoubleHeadingModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/DoubleHeadingModifier.java 2010-10-14 22:34:21 UTC (rev 1451) +++ trunk/18xx/rails/game/specific/_1825/DoubleHeadingModifier.java 2010-10-16 22:43:25 UTC (rev 1452) @@ -2,14 +2,8 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import org.apache.log4j.Logger; - import rails.algorithms.NetworkTrain; import rails.algorithms.RevenueAdapter; import rails.algorithms.RevenueDynamicModifier; @@ -21,9 +15,6 @@ */ public class DoubleHeadingModifier implements RevenueDynamicModifier { - protected static Logger log = - Logger.getLogger(DoubleHeadingModifier.class.getPackage().getName()); - private final static String TRAIN_2_NAME = "2"; private final static String DUALHEAD_NAME = "2&2"; @@ -68,8 +59,6 @@ } Collections.sort(train2Runs); - log.debug("Train2Runs=" + train2Runs); - // keep index on train2Runs int index2Runs = 0; // find DualHeads and remove two 2-train revenues Added: trunk/18xx/rails/game/specific/_1825/ScoreTileOnlyOnceModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/ScoreTileOnlyOnceModifier.java (rev 0) +++ trunk/18xx/rails/game/specific/_1825/ScoreTileOnlyOnceModifier.java 2010-10-16 22:43:25 UTC (rev 1452) @@ -0,0 +1,40 @@ +package rails.game.specific._1825; + +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.List; + +import rails.algorithms.NetworkVertex; +import rails.algorithms.RevenueAdapter; +import rails.algorithms.RevenueStaticModifier; +import rails.game.MapHex; + +/** + * This modifier ensures that on each tile only one station can be visited + */ + +public class ScoreTileOnlyOnceModifier implements RevenueStaticModifier { + + public void modifyCalculator(RevenueAdapter revenueAdapter) { + // 1. define for each hex a list of stations + HashMap<MapHex, List<NetworkVertex>> hexStations = new HashMap<MapHex, List<NetworkVertex>>(); + for (NetworkVertex v:revenueAdapter.getVertices()) { + if (v.isStation()) { + if (!hexStations.containsKey(v.getHex())) { + List<NetworkVertex> stations = new ArrayList<NetworkVertex>(); + hexStations.put(v.getHex(), stations); + } + hexStations.get(v.getHex()).add(v); + } + } + // 2. convert those with more than one station to a vertex visit set + for (MapHex hex:hexStations.keySet()) { + if (hexStations.get(hex).size() >= 2) { + revenueAdapter.addVertexVisitSet(revenueAdapter.new VertexVisit(hexStations.get(hex))); + } + } + + } + +} Property changes on: trunk/18xx/rails/game/specific/_1825/ScoreTileOnlyOnceModifier.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: <ev...@us...> - 2010-10-14 22:34:27
|
Revision: 1451 http://rails.svn.sourceforge.net/rails/?rev=1451&view=rev Author: evos Date: 2010-10-14 22:34:21 +0000 (Thu, 14 Oct 2010) Log Message: ----------- Fixed tile #14/15 upgrade rules: also the double villages can become #63. Modified Paths: -------------- trunk/18xx/data/1856/TileSet.xml Modified: trunk/18xx/data/1856/TileSet.xml =================================================================== --- trunk/18xx/data/1856/TileSet.xml 2010-10-13 19:07:38 UTC (rev 1450) +++ trunk/18xx/data/1856/TileSet.xml 2010-10-14 22:34:21 UTC (rev 1451) @@ -70,11 +70,11 @@ <!-- Green tiles --> <Tile id="14" quantity="4"> - <Upgrade id="63" hex="D17,G12,H15,I8,J11,J13,J15,K8"/> + <Upgrade id="63" hex="-B19,C14,F17,L13,N3,O18,P9"/> <Upgrade id="125" hex="B19,C14,F17,L13,N3,O18,P9"/> </Tile> <Tile id="15" quantity="4"> - <Upgrade id="63" hex="D17,G12,H15,I8,J11,J13,J15,K8"/> + <Upgrade id="63" hex="-B19,C14,F17,L13,N3,O18,P9"/> <Upgrade id="125" hex="B19,C14,F17,L13,N3,O18,P9"/> </Tile> <Tile id="16" quantity="1"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-13 19:07:45
|
Revision: 1450 http://rails.svn.sourceforge.net/rails/?rev=1450&view=rev Author: evos Date: 2010-10-13 19:07:38 +0000 (Wed, 13 Oct 2010) Log Message: ----------- 1. Reset Autopass if the player gets over a share/certificate limit during a Stock Round. 2. Skip Treasury trading step if nothing can be done. Modified Paths: -------------- trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameManagerI.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/StockRound.java Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2010-10-12 18:50:32 UTC (rev 1449) +++ trunk/18xx/rails/game/Game.java 2010-10-13 19:07:38 UTC (rev 1450) @@ -261,6 +261,8 @@ log.debug("Starting to execute loaded actions"); + gameManager.setReloading(true); + Object actionObject = null; while (true) { // Single-pass loop. try { @@ -299,7 +301,7 @@ } break; } - + // load user comments (is the last if (actionObject instanceof SortedMap) { ReportBuffer.setCommentItems((SortedMap<Integer, String>) actionObject); @@ -316,10 +318,11 @@ // but also the java.io.StreamCorruptedException: invalid type code } } - + ois.close(); - game.getGameManager().finishLoading(); + gameManager.setReloading(false); + gameManager.finishLoading(); return game; } catch (Exception e) { Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-10-12 18:50:32 UTC (rev 1449) +++ trunk/18xx/rails/game/GameManager.java 2010-10-13 19:07:38 UTC (rev 1450) @@ -89,6 +89,9 @@ protected boolean dynamicOperatingOrder = true; + /** Will only be set during game reload */ + protected boolean reloading = false; + protected EnumMap<GameDef.Parm, Object> gameParameters = new EnumMap<GameDef.Parm, Object>(GameDef.Parm.class); @@ -198,6 +201,14 @@ /** indicates that the recoverySave already issued a warning, avoids displaying several warnings */ protected boolean recoverySaveWarning = true; + /** Flag to skip a subsequent Done action (if present) during reloading. + * <br>This is a fix to maintain backwards compatibility when redundant + * actions are skipped in new code versions (such as the bypassing of + * a treasury trading step if it cannot be executed). + * <br>This flag will be reset after processing <i>any</i> action (not just Done). + */ + protected boolean skipNextDone = false; + protected static Logger log = Logger.getLogger(GameManager.class.getPackage().getName()); @@ -938,7 +949,8 @@ public boolean processOnReload(PossibleAction action) throws Exception { DisplayBuffer.clear(); - // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED + + // XXX TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (gameName.equals("1856") && possibleActions.contains(RepayLoans.class) && (!possibleActions.contains(action.getClass()) @@ -954,7 +966,20 @@ try { log.debug("Action ("+action.getPlayerName()+"): " + action); - if (!processCorrectionActions(action) && !getCurrentRound().process(action)) { + + // XXX FOR BACKWARDS COMPATIBILITY + boolean doProcess = true; + log.debug("SkipNextDone="+skipNextDone); + if (skipNextDone) { + if (action instanceof NullAction + && ((NullAction)action).getMode() == NullAction.DONE) { + log.info("Skipping processing a Done action during reload"); + doProcess = false; + } + } + skipNextDone = false; + + if (doProcess && !processCorrectionActions(action) && !getCurrentRound().process(action)) { String msg = "Player "+action.getPlayerName()+"\'s action \"" +action.toString()+"\"\n in "+getCurrentRound().getRoundName() +" is considered invalid by the game engine"; @@ -1684,5 +1709,16 @@ return new ArrayList<PublicCompanyI>(operatingCompanies.values()); } + public boolean isReloading() { + return reloading; + } + + public void setReloading(boolean reloading) { + this.reloading = reloading; + } + + public void setSkipDone () { + skipNextDone = true; + } } Modified: trunk/18xx/rails/game/GameManagerI.java =================================================================== --- trunk/18xx/rails/game/GameManagerI.java 2010-10-12 18:50:32 UTC (rev 1449) +++ trunk/18xx/rails/game/GameManagerI.java 2010-10-13 19:07:38 UTC (rev 1450) @@ -205,5 +205,7 @@ public CorrectionManagerI getCorrectionManager(CorrectionType ct); public List<PublicCompanyI> getCompaniesInRunningOrder (); - + public boolean isReloading(); + public void setReloading(boolean reloading); + public void setSkipDone (); } \ No newline at end of file Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-10-12 18:50:32 UTC (rev 1449) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-13 19:07:38 UTC (rev 1450) @@ -247,8 +247,8 @@ NullAction nullAction = (NullAction) action; switch (nullAction.getMode()) { + case NullAction.DONE: case NullAction.PASS: - case NullAction.DONE: result = done(); break; case NullAction.SKIP: @@ -1201,6 +1201,9 @@ /** Take the next step after a given one (see nextStep()) */ protected void nextStep(GameDef.OrStep step) { + + PublicCompanyI company = operatingCompany.get(); + // Cycle through the steps until we reach one where a user action is // expected. int stepIndex; @@ -1212,13 +1215,13 @@ log.debug("Step " + step); if (step == GameDef.OrStep.LAY_TOKEN - && operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { + && company.getNumberOfFreeBaseTokens() == 0) { continue; } if (step == GameDef.OrStep.CALC_REVENUE) { - if (!operatingCompany.get().canRunTrains()) { + if (!company.canRunTrains()) { // No trains, then the revenue is zero. executeSetRevenueAndDividend ( new SetDividend (0, false, new int[] {SetDividend.NO_TRAIN})); @@ -1235,11 +1238,40 @@ if (step == GameDef.OrStep.TRADE_SHARES) { // Is company allowed to trade trasury shares? - if (!operatingCompany.get().mayTradeShares() - || !operatingCompany.get().hasOperated()) { + if (!company.mayTradeShares() + || !company.hasOperated()) { continue; } + /* Check if any trading is possible. + * If not, skip this step. + * (but register a Done action for BACKWARDS COMPATIBILITY only) + */ + // Preload some expensive results + int ownShare = company.getPortfolio().getShare(company); + int poolShare = pool.getShare(company); // Expensive, do it once + // Can it buy? + boolean canBuy = + ownShare < getGameParameterAsInt (GameDef.Parm.TREASURY_SHARE_LIMIT) + && company.getCash() >= company.getCurrentSpace().getPrice() + && poolShare > 0; + // Can it sell? + boolean canSell = + company.getPortfolio().getShare(company) > 0 + && poolShare < getGameParameterAsInt (GameDef.Parm.POOL_SHARE_LIMIT); + // Above we ignore the possible existence of double shares (as in 1835). + + if (!canBuy && !canSell) { + // XXX For BACKWARDS COMPATIBILITY only, + // register a Done skip action during reloading. + if (gameManager.isReloading()) { + gameManager.setSkipDone(); + log.debug("If the next saved action is 'Done', skip it"); + } + log.info("Skipping Treasury share trading step"); + continue; + } + gameManager.startTreasuryShareTradingRound(); } Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-10-12 18:50:32 UTC (rev 1449) +++ trunk/18xx/rails/game/StockRound.java 2010-10-13 19:07:38 UTC (rev 1450) @@ -1365,8 +1365,13 @@ setNextPlayer(); sellPrices.clear(); if (hasAutopassed(currentPlayer)) { - // Process a pass for a player that has set Autopass - done (currentPlayer.getName(), true); + if (isPlayerOverLimits(currentPlayer)) { + // Being over a share/certificate limit undoes an Autopass setting + setAutopass (currentPlayer, false); + } else { + // Process a pass for a player that has set Autopass + done (currentPlayer.getName(), true); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-12 18:50:39
|
Revision: 1449 http://rails.svn.sourceforge.net/rails/?rev=1449&view=rev Author: evos Date: 2010-10-12 18:50:32 +0000 (Tue, 12 Oct 2010) Log Message: ----------- 1. Added reserved hexes facility, and applied to 18EU and 1825 maps. 2. Removed the "no train - no income" popup. 3. Allow (temporary) >60% share ownership in certain cases. Applied to 18EU mergers. Modified Paths: -------------- trunk/18xx/data/1825/Map.xml trunk/18xx/data/18EU/Map.xml trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java trunk/18xx/rails/game/state/HashSetState.java trunk/18xx/rails/ui/swing/hexmap/GUIHex.java Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/data/1825/Map.xml 2010-10-12 18:50:32 UTC (rev 1449) @@ -25,7 +25,7 @@ <Hex name="G7" tile="-2" city="Coatbridge, Airdrie"/> <Hex name="G9" tile="-20" city="Edinburgh, Leith"/> <Hex name="G11" tile="0"/> - <Hex name="H4" tile="-2" city="Ayr, Kilmarnock"/> + <Hex name="H4" tile="-2" city="Ayr, Kilmarnock" reserved="GSWR"/> <Hex name="H6" tile="-10" city="Motherwell"/> <Hex name="H8" tile="0" cost="100"/> <Hex name="H10" tile="0" cost="100"/> @@ -54,7 +54,7 @@ <Hex name="L8" tile="0" open="2,3"/> <Hex name="L10" tile="0" open="2,3"/> <Hex name="L12" tile="0" cost="100" open="2,3"/> - <Hex name="L14" tile="-10" city="Darlington" open="2,3"/> + <Hex name="L14" tile="-10" city="Darlington" open="2,3" reserved="NER"/> <Hex name="L16" tile="0" open="2"/> <Hex name="L18" tile="-1" city="Scarborough"/> <Hex name="M9" tile="-25008" city="Barrow"/> @@ -63,7 +63,7 @@ <Hex name="M15" tile="-2" city="Harrogate, York"/> <Hex name="M17" tile="0"/> <Hex name="M19" tile="0"/> - <Hex name="N10" tile="-10" city="Preston"/> + <Hex name="N10" tile="-10" city="Preston" reserved="L&Y"/> <Hex name="N12" tile="-2" city="Burnley, Halifax"/> <Hex name="N14" tile="-20" city="Bradford, Leeds"/> <Hex name="N16" tile="0"/> @@ -84,7 +84,7 @@ <Hex name="Q9" tile="0" open="0,5"/> <Hex name="Q11" tile="-25004" city="Wolverton"/> <Hex name="Q13" tile="-2" city="Newcastle u/L, Hanley" open="0,5"/> - <Hex name="Q15" tile="-10" city="Derby" open="0,5"/> + <Hex name="Q15" tile="-10" city="Derby" open="0,5" reserved="MR"/> <Hex name="Q17" tile="-10" city="Nottingham" open="0,5"/> <Hex name="Q19" tile="0" open="0,5"/> </IfOption> @@ -92,7 +92,11 @@ <Hex name="R8" tile="0" open="0,1,2,3"/> <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="2"/> <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall" open="2,3"/> - <Hex name="R14" tile="0" open="2,3"/> + <Hex name="R14" tile="0" open="2,3"> + <IfOption name="Include" parm="Unit1" value="yes"> + <Attributes reserved="MR"/> + </IfOption> + </Hex> <Hex name="R16" tile="-10" city="Leicester" open="2,3"/> <Hex name="R18" tile="0" open="2,3"/> <Hex name="R20" tile="-1" city="Peterborough" orientation="3" open="2"/> @@ -122,17 +126,17 @@ orientation="1" ></Hex> <Hex name="U13" tile="0"/> <Hex name="U15" tile="0"/> - <Hex name="U17" tile="0"/> + <Hex name="U17" tile="0" reserved="LNWR"/> <Hex name="U19" tile="0"/> <Hex name="U21" tile="0"/> - <Hex name="U23" tile="-1" city="Colchester" /> + <Hex name="U23" tile="-1" city="Colchester" reserved="GER"/> <Hex name="U25" tile="-104" orientation="2" city="Harwich"/> <Hex name="V8" tile="-20" city="Cardiff, Newport" open="1,2"/> <Hex name="V10" tile="-25003" city="Bristol"/> <Hex name="V12" tile="0"/> <Hex name="V14" tile="-25005" city="Swindon"/> <Hex name="V16" tile="-1" city="Reading" orientation="1"/> - <Hex name="V18" tile="0"/> + <Hex name="V18" tile="0" reserved="GWR"/> <Hex name="V20" tile="-25001" city="London"/> <Hex name="V22" tile="-25006" value="20" city="Southend"/> <IfOption name="Include" parm="R2" value="no"> @@ -146,7 +150,7 @@ <Hex name="W15" tile="0"/> <Hex name="W17" tile="0"/> <Hex name="W19" tile="-2" city="Kingston on Thames, Reigate" - orientation="4" /> + orientation="4" reserved="LSWR"/> <Hex name="W21" tile="0"/> <Hex name="W23" tile="-10" city="Ashford" orientation="5" /> <Hex name="W25" tile="-5" orientation="2" city="Dover"/> @@ -157,7 +161,7 @@ <Hex name="X16" tile="-20" city="Gosport, Portsmouth" orientation="1" /> <Hex name="X18" tile="0"/> - <Hex name="X20" tile="-10" city="Brighton" orientation="5" /> + <Hex name="X20" tile="-10" city="Brighton" orientation="5" reserved="LBSC"/> <Hex name="X22" tile="-1" city="Hastings" orientation="2" /> <Hex name="X24" tile="0"/> <Hex name="Y9" tile="0" open="1"/> Modified: trunk/18xx/data/18EU/Map.xml =================================================================== --- trunk/18xx/data/18EU/Map.xml 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/data/18EU/Map.xml 2010-10-12 18:50:32 UTC (rev 1449) @@ -21,7 +21,7 @@ <Hex name="F3" tile="-1" city="Antwerp"/> <Hex name="F5" tile="-3008" city="Dortmund"/> <Hex name="F7" tile="-1" city="Hannover"/> - <Hex name="F9" tile="0" /> + <Hex name="F9" tile="0" reserved="7"/> <Hex name="F11" tile="0" /> <Hex name="F13" tile="0" /> <Hex name="G2" tile="-1" city="Lille"/> @@ -31,7 +31,7 @@ <Hex name="G10" label="Y" tile="-3007" city="Dresden"/> <Hex name="G12" tile="0" /> <Hex name="H1" tile="0" /> - <Hex name="H3" label="Y" tile="-3007" city="Brussels"/> + <Hex name="H3" label="Y" tile="-3007" city="Brussels" reserved="2"/> <Hex name="H5" tile="0" /> <Hex name="H7" tile="0" /> <Hex name="H9" tile="-1" city="Leipzig"/> @@ -50,7 +50,7 @@ <Hex name="J9" cost="60" tile="0" /> <Hex name="J11" tile="0" /> <Hex name="J13" cost="60" tile="-1" city="Krakau"/> - <Hex name="K2" tile="0" /> + <Hex name="K2" tile="0" reserved="3"/> <Hex name="K4" cost="60" tile="0" /> <Hex name="K6" tile="-1" city="Augsburg"/> <Hex name="K8" tile="0" /> @@ -107,7 +107,7 @@ <Hex name="R11" tile="0" /> <Hex name="S2" tile="-3008" city="Marseille"/> <Hex name="S4" tile="-3008" city="Turin"/> - <Hex name="S6" tile="0" /> + <Hex name="S6" tile="0" reserved="10"/> <Hex name="S8" label="Y" tile="-3007" city="Venice"/> <Hex name="S10" tile="0" /> <Hex name="T1" tile="0" /> @@ -117,7 +117,7 @@ <Hex name="T9" port="yes" value="10" tile="-800" orientation="3"/> <Hex name="U2" port="yes" value="10" tile="-800" orientation="3"/> <Hex name="U4" tile="0" /> - <Hex name="U6" tile="-1" city="Florence"/> + <Hex name="U6" tile="-1" city="Florence" reserved="10"/> <Hex name="U8" tile="0" /> <Hex name="V5" port="yes" value="10" tile="-800" orientation="3"/> <Hex name="V7" label="V" value="30,50" tile="-903" orientation="4" city="Rome"/> Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/game/MapHex.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -66,6 +66,7 @@ protected int[] tileCost; protected String cityName; protected String infoText; + protected String reservedForCompany = null; /** Neighbouring hexes <i>to which track may be laid</i>. */ protected MapHex[] neighbours = new MapHex[6]; @@ -114,7 +115,7 @@ /** Any open sides against which track may be laid even at board edges (1825) */ protected boolean[] openHexSides; - + protected MapManager mapManager = null; protected static Logger log = @@ -206,6 +207,8 @@ setBlockedForTokenLays(tag.getAttributeAsBoolean("unlaidHomeBlocksTokens", false)); } + reservedForCompany = tag.getAttributeAsString("reserved"); + // revenue bonus List<Tag> bonusTags = tag.getChildren("RevenueBonus"); if (bonusTags != null) { @@ -272,7 +275,7 @@ return true; } - + public boolean isOpenSide (int side) { return openHexSides != null && openHexSides[side%6]; } @@ -1144,7 +1147,15 @@ return infoText; } - public List<RevenueBonusTemplate> getRevenueBonuses() { + public String getReservedForCompany() { + return reservedForCompany; + } + + public boolean isReservedForCompany () { + return reservedForCompany != null; + } + + public List<RevenueBonusTemplate> getRevenueBonuses() { return revenueBonuses; } Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -909,11 +909,13 @@ operatingCompany.get().setLastRevenue(amount); operatingCompany.get().setLastRevenueAllocation(revenueAllocation); + /* Seems people don't like this popup... if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", operatingCompany.get().getName(), Bank.format(0) )); } + */ // Pay any debts from treasury, revenue and/or president's cash // The remaining dividend may be less that the original income @@ -1530,9 +1532,10 @@ PublicCompanyI company; for (int i=0; i<newOperatingCompanies.size(); i++) { company = newOperatingCompanies.get(i); - log.debug("+++ Index "+i+" new company="+company.getName()); if (company != operatingCompanies.get(i)) { - log.debug("+++ Index "+i+" old company="+operatingCompanies.get(i).getName()); + log.debug("Company "+company.getName() + +" replaces "+operatingCompanies.get(i).getName() + +" in operating sequence"); operatingCompanies.move(company, i); } } Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/game/StockRound.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -35,6 +35,11 @@ protected Map<String, StockSpaceI> sellPrices = new HashMap<String, StockSpaceI>(); + /** Records lifted share selling obligations in the current round<p> + * Example: >60% ownership allowed after a merger in 18EU. + */ + protected HashSetState<PublicCompanyI> sellObligationLifted = null; + /* Transient data needed for rule enforcing */ /** HashMap per player containing a HashMap per company */ protected HashMap<Player, HashMap<PublicCompanyI, Object>> playersThatSoldThisRound = @@ -1013,9 +1018,6 @@ } } } - if (potentialDirector == null) { - //TODO: No one to dump the Presidency onto, work out how to handle the receivership - } // The poor sod. dumpedPlayer = potentialDirector; presSharesToSell = numberToSell; @@ -1463,7 +1465,6 @@ player.getPortfolio().getCertificateCount(), gameManager.getPlayerCertificateLimit(player))); } - ; // Over the hold limit of any company? for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { @@ -1514,7 +1515,8 @@ if (player.getPortfolio().getShare(company) + number * company.getShareUnit() > getGameParameterAsInt(GameDef.Parm.PLAYER_SHARE_LIMIT) - && !company.getCurrentSpace().isNoHoldLimit()) return false; + && !company.getCurrentSpace().isNoHoldLimit() + && !isSellObligationLifted(company)) return false; return true; } @@ -1572,4 +1574,16 @@ return toString(); } + public boolean isSellObligationLifted(PublicCompanyI company) { + return sellObligationLifted != null + && sellObligationLifted.contains(company); + } + + public void setSellObligationLifted (PublicCompanyI company) { + if (sellObligationLifted == null) { + sellObligationLifted = new HashSetState<PublicCompanyI>("SellObligationLifted"); + } + sellObligationLifted.add(company); + } + } Modified: trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -604,6 +604,13 @@ if (!(this instanceof FinalMinorExchangeRound)) { companyBoughtThisTurnWrapper.set(major); + + // If >60% shares owned, lift sell obligation this round. + if (currentPlayer.getPortfolio().getShare(major) + > getGameParameterAsInt(GameDef.Parm.PLAYER_SHARE_LIMIT)) { + setSellObligationLifted (major); + } + setPriority(); } Modified: trunk/18xx/rails/game/state/HashSetState.java =================================================================== --- trunk/18xx/rails/game/state/HashSetState.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/game/state/HashSetState.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -1,9 +1,6 @@ package rails.game.state; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import rails.game.move.SetChange; /** @@ -12,14 +9,14 @@ * * 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 @@ -35,11 +32,11 @@ 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); @@ -48,22 +45,26 @@ return false; } } - + + public boolean contains (E element) { + return set.contains(element); + } + 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(); } - + } Modified: trunk/18xx/rails/ui/swing/hexmap/GUIHex.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-10-12 17:39:08 UTC (rev 1448) +++ trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2010-10-12 18:50:32 UTC (rev 1449) @@ -8,7 +8,6 @@ import org.apache.log4j.Logger; -import rails.algorithms.RevenueBonus; import rails.algorithms.RevenueBonusTemplate; import rails.game.*; import rails.game.model.ModelObject; @@ -161,9 +160,9 @@ innerHexagonSelected = defineInnerHexagon(0.8, center2D); innerHexagonSelectable = defineInnerHexagon(0.9, center2D); } - + private GeneralPath defineInnerHexagon(double innerScale, Point2D.Double center2D) { - + AffineTransform at = AffineTransform.getScaleInstance(innerScale, innerScale); GeneralPath innerHexagon = (GeneralPath) hexagon.createTransformedShape(at); @@ -182,7 +181,7 @@ return innerHexagon; } - + /** * returns point that corresponds to the definition as networkvertex */ @@ -208,14 +207,14 @@ } public Point2D getSidePoint2D(int side){ - return new Point2D.Double((xVertex[side] + xVertex[(side+1)%6])/2, + return new Point2D.Double((xVertex[side] + xVertex[(side+1)%6])/2, (yVertex[side] + yVertex[(side+1)%6])/2); } - + public Point2D getCenterPoint2D() { return center; } - + public void setHexModel(MapHex model) { this.model = model; currentTile = model.getCurrentTile(); @@ -280,7 +279,7 @@ provisionalGUITile = null; } } - + public boolean isSelectable() { return selectable; } @@ -418,12 +417,11 @@ if (blocked != null) { for (MapHex hex : blocked) { if (getHexModel().equals(hex)) { + String text = "(" + p.getName() + ")"; g2.drawString( - "(" + p.getName() + ")", + text, rectBound.x - + (rectBound.width - fontMetrics.stringWidth("(" - + p.getName() - + ")")) + + (rectBound.width - fontMetrics.stringWidth(text)) * 1 / 2, rectBound.y + ((fontMetrics.getHeight() + rectBound.height) * 5 / 15)); @@ -433,6 +431,18 @@ } } + if (model.isReservedForCompany() + && currentTileId == model.getPreprintedTileId() ) { + String text = "[" + model.getReservedForCompany() + "]"; + g2.drawString( + text, + rectBound.x + + (rectBound.width - fontMetrics.stringWidth(text)) + * 1 / 2, + rectBound.y + + ((fontMetrics.getHeight() + rectBound.height) * 5 / 25)); + } + } private void paintOverlay(Graphics2D g2) { @@ -468,7 +478,7 @@ } private void paintStationTokens(Graphics2D g2) { - + if (getHexModel().getCities().size() > 1) { paintSplitStations(g2); return; @@ -575,7 +585,7 @@ provisionalGUITile.rotate(1, currentGUITile, upgradeMustConnect); } } - + public void forcedRotateTile() { provisionalGUITile.setRotation(provisionalGUITile.getRotation() + 1); } @@ -663,11 +673,11 @@ public String getToolTip() { if (toolTip != null) return toolTip; - else + else return getDefaultToolTip(); } - + private String bonusToolTipText(List<RevenueBonusTemplate> bonuses) { StringBuffer tt = new StringBuffer(); if (bonuses != null) { @@ -684,7 +694,7 @@ } return tt.toString(); } - + private String getDefaultToolTip() { StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Hex</b>: ").append(hexName); @@ -736,7 +746,7 @@ // revenueBonuses tt.append(bonusToolTipText(model.getRevenueBonuses())); - + String upgrades = currentTile.getUpgradesString(model); if (upgrades.equals("")) { tt.append("<br>No upgrades"); @@ -754,8 +764,8 @@ tt.append(dest.getName()); } } - - + + tt.append("</html>"); return tt.toString(); } @@ -777,7 +787,7 @@ } } - + /** forces the tile to drop */ public void forcedDropTile(int tileId, int orientation) { provisionalGUITile = new GUITile(tileId, this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-12 17:39:14
|
Revision: 1448 http://rails.svn.sourceforge.net/rails/?rev=1448&view=rev Author: evos Date: 2010-10-12 17:39:08 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Property Changed: ---------------- trunk/18xx/tiles/ Property changes on: trunk/18xx/tiles ___________________________________________________________________ Modified: svn:ignore - Copy of TileDictionary.18t handmade TDwithID TDwoID xml tileimages.xml Copy (2) of TileDictionary.18t Copy (3) of TileDictionary.18t + Copy of TileDictionary.18t handmade TDwithID TDwoID xml tileimages.xml Copy (2) of TileDictionary.18t Copy (3) of TileDictionary.18t Rails18xx.ini UserGridStyle.ini UserTileStyle.ini This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-12 17:36:15
|
Revision: 1447 http://rails.svn.sourceforge.net/rails/?rev=1447&view=rev Author: evos Date: 2010-10-12 17:36:09 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Phil1825.patch Modified Paths: -------------- trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/PublicCompany.java trunk/18xx/rails/game/PublicCompanyI.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java trunk/18xx/rails/game/specific/_1825/StockRound_1825.java Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/data/GamesList.xml 2010-10-12 17:36:09 UTC (rev 1447) @@ -202,6 +202,7 @@ Designed by Francis Tresham Known Issues: +- change the formationOrderIndex from an Integer variable to an IntegerState variable - BUG: prompt on placing GWR token when upgrading London, needs investigation - BUG: Trains do not have to own a train and directors cannot fund the purchase of one - Tile lays that send track off the board are legal in 1825 as long as they don't run into the Modified: trunk/18xx/rails/game/PublicCompany.java =================================================================== --- trunk/18xx/rails/game/PublicCompany.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/PublicCompany.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -269,8 +269,6 @@ protected StockMarketI stockMarket; protected MapManager mapManager; - //PD: used to track floatation order for games that need this (1825) - protected int formationOrderIndex = 0; /** * The constructor. The way this class is instantiated does not allow * arguments. @@ -2010,12 +2008,4 @@ return ""; } - public int getFormationOrderIndex() { - return formationOrderIndex; - } - - public void setFormationOrderIndex(int formationOrderIndex) { - this.formationOrderIndex = formationOrderIndex; - } - } Modified: trunk/18xx/rails/game/PublicCompanyI.java =================================================================== --- trunk/18xx/rails/game/PublicCompanyI.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/PublicCompanyI.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -358,7 +358,5 @@ public ModelObject getInGameModel (); public ModelObject getIsClosedModel (); - - public int getFormationOrderIndex (); - public void setFormationOrderIndex (int formationOrderIndex); + } Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/StockRound.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -1013,6 +1013,9 @@ } } } + if (potentialDirector == null) { + //TODO: No one to dump the Presidency onto, work out how to handle the receivership + } // The poor sod. dumpedPlayer = potentialDirector; presSharesToSell = numberToSell; Modified: trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -16,18 +16,20 @@ int space; int key; for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { + PublicCompany_1825 companycasted = (PublicCompany_1825)company; + if (!canCompanyOperateThisRound(companycasted)) continue; if (!canCompanyOperateThisRound(company)) continue; // Key must put companies in reverse operating order, because sort // is ascending. - space = company.getIPOPrice(); + space = companycasted.getIPOPrice(); //Corps operate in descending IPO price //Corps with the same IPO price operate in the order they were floated //IPO price will inherently be in the right order //subtracting the formation order index will put it at the right point to operate //This wouldn't work if there are lots of corps at the same price //there are not too many corps in each banding for this to be an issue in 1825 even with all 3 units - key = 1000000 - (space - company.getFormationOrderIndex()); - operatingCompanies.put(new Integer(key), company); + key = 1000000 - (space - companycasted.getFormationOrderIndex()); + operatingCompanies.put(new Integer(key), companycasted); } return new ArrayList<PublicCompanyI>(operatingCompanies.values()); } Modified: trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -2,10 +2,27 @@ import rails.game.PublicCompany; import rails.game.PublicCompanyI; +import rails.game.StockSpaceI; +import rails.game.state.IntegerState; public class PublicCompany_1825 extends PublicCompany { + protected IntegerState formationOrderIndex; + public void start(StockSpaceI startSpace) { + super.start(startSpace); + //PD: used to track flotation order + formationOrderIndex = new IntegerState(name+"_formationOrderIndex"); + } + + public int getFormationOrderIndex() { + return formationOrderIndex.intValue(); + } + + public void setFormationOrderIndex(int formationOrderIndex) { + this.formationOrderIndex.set(formationOrderIndex); + } + @Override public void payout(int amount) { if (amount == 0) return; @@ -39,7 +56,7 @@ //Yes, we share IPO prices, has this other company been launched yet? if (company.hasFloated()){ //it has, we need to skip ahead of this corp - formationOrderIndex++; + formationOrderIndex.add(1); } } Modified: trunk/18xx/rails/game/specific/_1825/StockRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/StockRound_1825.java 2010-10-11 17:31:34 UTC (rev 1446) +++ trunk/18xx/rails/game/specific/_1825/StockRound_1825.java 2010-10-12 17:36:09 UTC (rev 1447) @@ -8,6 +8,7 @@ import java.util.List; import rails.game.*; +import rails.game.action.SellShares; public class StockRound_1825 extends StockRound { @@ -79,4 +80,87 @@ } + @Override + public void setSellableShares() { + if (!mayCurrentPlayerSellAnything()) return; + + String compName; + int price; + int number; + int share, maxShareToSell; + boolean dumpAllowed; + Portfolio playerPortfolio = currentPlayer.getPortfolio(); + + /* + * First check of which companies the player owns stock, and what + * maximum percentage he is allowed to sell. + */ + for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { + + // Check if shares of this company can be sold at all + if (!mayPlayerSellShareOfCompany(company)) continue; + + share = maxShareToSell = playerPortfolio.getShare(company); + if (maxShareToSell == 0) continue; + + /* May not sell more than the Pool can accept */ + maxShareToSell = + Math.min(maxShareToSell, + getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT) + - pool.getShare(company)); + if (maxShareToSell == 0) continue; + + /* + * Check what share units the player actually owns. In some games + * (e.g. 1835) companies may have different ordinary shares: 5% and + * 10%, or 10% and 20%. The president's share counts as a multiple + * of the smallest ordinary share unit type. + */ + // Take care for max. 4 share units per share + int[] shareCountPerUnit = new int[5]; + compName = company.getName(); + for (PublicCertificateI c : playerPortfolio.getCertificatesPerCompany(compName)) { + if (c.isPresidentShare()) { + shareCountPerUnit[1] += c.getShares(); + } else { + ++shareCountPerUnit[c.getShares()]; + } + } + // TODO The above ignores that a dumped player must be + // able to exchange the president's share. + + /* + * Check the price. If a cert was sold before this turn, the + * original price is still valid + */ + price = getCurrentSellPrice(company); + + // removed as this is done in getCurrentSellPrice + // price /= company.getShareUnitsForSharePrice(); + + /* Allow for different share units (as in 1835) */ + for (int i = 1; i <= 4; i++) { + number = shareCountPerUnit[i]; + if (number == 0) continue; + number = + Math.min(number, maxShareToSell + / (i * company.getShareUnit())); + + /* In some games (1856), a just bought share may not be sold */ + // This code ignores the possibility of different share units + if ((Boolean)gameManager.getGameParameter(GameDef.Parm.NO_SALE_OF_JUST_BOUGHT_CERT) + && company.equals(companyBoughtThisTurnWrapper.get())) { + number--; + } + if (number <= 0) continue; + + possibleActions.add(new SellShares(compName, i, number, price)); + + } + } + + + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:31:40
|
Revision: 1446 http://rails.svn.sourceforge.net/rails/?rev=1446&view=rev Author: evos Date: 2010-10-11 17:31:34 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Fix Modified Paths: -------------- trunk/18xx/rails/ui/swing/ORUIManager.java Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-11 17:22:49 UTC (rev 1445) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-11 17:31:34 UTC (rev 1446) @@ -1678,10 +1678,11 @@ if (newCompanies.get(i) != oldCompanies[i]) { log.debug("Detected a OR company sequence change: "+oldCompanies[i].getName() +" becomes "+newCompanies.get(i).getName()); + orPanel.recreate(oRound); + break; } - orPanel.recreate(oRound); - return; } + return; } public void setORCompanyTurn(int orCompIndex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:22:55
|
Revision: 1445 http://rails.svn.sourceforge.net/rails/?rev=1445&view=rev Author: evos Date: 2010-10-11 17:22:49 +0000 (Mon, 11 Oct 2010) Log Message: ----------- At each OR turn end, check if the company order has changed (if dynamic; this does not apply to 1825) Modified Paths: -------------- trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameManagerI.java Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-10-11 17:22:10 UTC (rev 1444) +++ trunk/18xx/rails/game/GameManager.java 2010-10-11 17:22:49 UTC (rev 1445) @@ -87,6 +87,8 @@ protected int gameEndsWhenBankHasLessOrEqual = 0; protected boolean gameEndsAfterSetOfORs = true; + protected boolean dynamicOperatingOrder = true; + protected EnumMap<GameDef.Parm, Object> gameParameters = new EnumMap<GameDef.Parm, Object>(GameDef.Parm.class); @@ -330,6 +332,12 @@ throw new ConfigurationException("Cannot find class " + orClassName, e); } + + Tag orderTag = orTag.getChild("OperatingOrder"); + if (orderTag != null) { + dynamicOperatingOrder = orderTag.getAttributeAsBoolean("dynamic", + dynamicOperatingOrder); + } } /* Max. % of shares of one company that a player may hold */ @@ -1179,7 +1187,12 @@ createRound(EndOfGameRound.class); } - /* (non-Javadoc) + + public boolean isDynamicOperatingOrder() { + return dynamicOperatingOrder; + } + + /* (non-Javadoc) * @see rails.game.GameManagerI#isGameOver() */ public boolean isGameOver() { Modified: trunk/18xx/rails/game/GameManagerI.java =================================================================== --- trunk/18xx/rails/game/GameManagerI.java 2010-10-11 17:22:10 UTC (rev 1444) +++ trunk/18xx/rails/game/GameManagerI.java 2010-10-11 17:22:49 UTC (rev 1445) @@ -68,6 +68,8 @@ public abstract void registerBrokenBank(); + public boolean isDynamicOperatingOrder(); + /** * To be called by the UI to check if the rails.game is over. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:22:16
|
Revision: 1444 http://rails.svn.sourceforge.net/rails/?rev=1444&view=rev Author: evos Date: 2010-10-11 17:22:10 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Added <OperatingOrder dynamic="no"/> Modified Paths: -------------- trunk/18xx/data/1825/Game.xml Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-10-11 17:20:38 UTC (rev 1443) +++ trunk/18xx/data/1825/Game.xml 2010-10-11 17:22:10 UTC (rev 1444) @@ -26,10 +26,17 @@ <BankBreaks limit="0" finish="CurrentOR"/> <!-- "Runs out"; when "broken", -1 is the limit --> </EndOfGame> - <GameParameters><PlayerShareLimit percentage="100" /><BankPoolShareLimit percentage="100"></BankPoolShareLimit> + <GameParameters> + <PlayerShareLimit percentage="100" /> + <BankPoolShareLimit percentage="100"/> <StockRound sequence="SellBuySell" class="rails.game.specific._1825.StockRound_1825"> - <NoSaleInFirstSR></NoSaleInFirstSR></StockRound> - <OperatingRound class="rails.game.specific._1825.OperatingRound_1825"></OperatingRound></GameParameters></Component> + <NoSaleInFirstSR/> + </StockRound> + <OperatingRound class="rails.game.specific._1825.OperatingRound_1825"> + <OperatingOrder dynamic="no"/><!-- default is "yes"--> + </OperatingRound> + </GameParameters> + </Component> <Component name="PlayerManager" class="rails.game.PlayerManager"> <Players number="2" cash="1200" certLimit="24"/> <Players number="3" cash="830" certLimit="16"/> @@ -84,11 +91,9 @@ <OperatingRounds number="2"/> </Phase> <Phase name="3"> - <Tiles colour="yellow,green,brown"/><OperatingRounds - number="3"> -</OperatingRounds> + <Tiles colour="yellow,green,brown"/> + <OperatingRounds number="3"/> </Phase> </Component> - <Component name="RevenueManager" class="rails.algorithms.RevenueManager"> - </Component> + <Component name="RevenueManager" class="rails.algorithms.RevenueManager"/> </ComponentManager> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:20:44
|
Revision: 1443 http://rails.svn.sourceforge.net/rails/?rev=1443&view=rev Author: evos Date: 2010-10-11 17:20:38 +0000 (Mon, 11 Oct 2010) Log Message: ----------- At each OR turn end, check if the company order has changed (if dynamic; this does not apply to 1825) Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/Round.java trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-10-11 17:19:02 UTC (rev 1442) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-11 17:20:38 UTC (rev 1443) @@ -1523,6 +1523,20 @@ if (++index >= operatingCompanies.size()) { return false; } + + // Check if the operating order has changed + List<PublicCompanyI> newOperatingCompanies + = setOperatingCompanies (operatingCompanies.viewList(), operatingCompany.get()); + PublicCompanyI company; + for (int i=0; i<newOperatingCompanies.size(); i++) { + company = newOperatingCompanies.get(i); + log.debug("+++ Index "+i+" new company="+company.getName()); + if (company != operatingCompanies.get(i)) { + log.debug("+++ Index "+i+" old company="+operatingCompanies.get(i).getName()); + operatingCompanies.move(company, i); + } + } + setOperatingCompany(operatingCompanies.get(index)); } Modified: trunk/18xx/rails/game/Round.java =================================================================== --- trunk/18xx/rails/game/Round.java 2010-10-11 17:19:02 UTC (rev 1442) +++ trunk/18xx/rails/game/Round.java 2010-10-11 17:20:38 UTC (rev 1443) @@ -260,26 +260,44 @@ /** Set the operating companies in their current acting order */ public List<PublicCompanyI> setOperatingCompanies() { + return setOperatingCompanies (null, null); + } + public List<PublicCompanyI> setOperatingCompanies(List<PublicCompanyI> oldOperatingCompanies, + PublicCompanyI lastOperatingCompany) { + Map<Integer, PublicCompanyI> operatingCompanies = new TreeMap<Integer, PublicCompanyI>(); StockSpaceI space; int key; int minorNo = 0; + boolean reorder = gameManager.isDynamicOperatingOrder() + && oldOperatingCompanies != null && lastOperatingCompany != null; + + int lastOperatingCompanyIndex; + if (reorder) { + lastOperatingCompanyIndex = oldOperatingCompanies.indexOf(lastOperatingCompany); + } else { + lastOperatingCompanyIndex = -1; + } + for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (!canCompanyOperateThisRound(company)) continue; - // Key must put companies in reverse operating order, because sort - // is ascending. - if (company.hasStockPrice()) { + if (reorder + && oldOperatingCompanies.indexOf(company) <= lastOperatingCompanyIndex) { + // Companies that have operated this round get lowest keys + key = oldOperatingCompanies.indexOf(company); + } else if (company.hasStockPrice()) { + // Key must put companies in reverse operating order, because sort + // is ascending. space = company.getCurrentSpace(); - key = - 1000000 * (999 - space.getPrice()) + 10000 - * (99 - space.getColumn()) + 100 - * space.getRow() - + space.getStackPosition(company); + key = 1000000 * (999 - space.getPrice()) + + 10000 * (99 - space.getColumn()) + + 100 * (space.getRow()+1) + + space.getStackPosition(company); } else { - key = ++minorNo; + key = 50 + ++minorNo; } operatingCompanies.put(new Integer(key), company); } Modified: trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-11 17:19:02 UTC (rev 1442) +++ trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-11 17:20:38 UTC (rev 1443) @@ -1,13 +1,8 @@ package rails.game.specific._1825; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; -import rails.game.GameManagerI; -import rails.game.OperatingRound; -import rails.game.PublicCompanyI; +import rails.game.*; public class OperatingRound_1825 extends OperatingRound { @@ -21,7 +16,7 @@ int space; int key; for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { - if (!canCompanyOperateThisRound(company)) continue; + if (!canCompanyOperateThisRound(company)) continue; // Key must put companies in reverse operating order, because sort // is ascending. space = company.getIPOPrice(); @@ -34,7 +29,12 @@ key = 1000000 - (space - company.getFormationOrderIndex()); operatingCompanies.put(new Integer(key), company); } - return new ArrayList<PublicCompanyI>(operatingCompanies.values()); - } - + return new ArrayList<PublicCompanyI>(operatingCompanies.values()); + } + + @Override + public List<PublicCompanyI> setOperatingCompanies(List<PublicCompanyI> oldOperatingCompanies, + PublicCompanyI lastOperatingCompany) { + return setOperatingCompanies(); + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:19:08
|
Revision: 1442 http://rails.svn.sourceforge.net/rails/?rev=1442&view=rev Author: evos Date: 2010-10-11 17:19:02 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Check company order after each turn. If changed, recreate ORPanel. Modified Paths: -------------- trunk/18xx/rails/ui/swing/ORUIManager.java Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-11 17:18:21 UTC (rev 1441) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-11 17:19:02 UTC (rev 1442) @@ -1433,6 +1433,9 @@ if (oRound.getOperatingCompanyIndex() != orCompIndex) { if (orCompIndex >= 0) orPanel.finishORCompanyTurn(orCompIndex); + + // Check if sequence has changed + checkORCompanySequence(companies, oRound.getOperatingCompanies()); setORCompanyTurn(oRound.getOperatingCompanyIndex()); } @@ -1669,6 +1672,18 @@ } + /** Redraw the ORPanel if the company operating order has changed */ + protected void checkORCompanySequence (PublicCompanyI[] oldCompanies, List<PublicCompanyI> newCompanies) { + for (int i=0; i<newCompanies.size(); i++) { + if (newCompanies.get(i) != oldCompanies[i]) { + log.debug("Detected a OR company sequence change: "+oldCompanies[i].getName() + +" becomes "+newCompanies.get(i).getName()); + } + orPanel.recreate(oRound); + return; + } + } + public void setORCompanyTurn(int orCompIndex) { this.orCompIndex = orCompIndex; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-11 17:18:28
|
Revision: 1441 http://rails.svn.sourceforge.net/rails/?rev=1441&view=rev Author: evos Date: 2010-10-11 17:18:21 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Added move() to support OR company reordering Modified Paths: -------------- trunk/18xx/rails/game/state/ArrayListState.java Modified: trunk/18xx/rails/game/state/ArrayListState.java =================================================================== --- trunk/18xx/rails/game/state/ArrayListState.java 2010-10-10 16:16:23 UTC (rev 1440) +++ trunk/18xx/rails/game/state/ArrayListState.java 2010-10-11 17:18:21 UTC (rev 1441) @@ -1,13 +1,9 @@ package rails.game.state; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import rails.game.move.AddToList; import rails.game.move.RemoveFromList; -import rails.game.move.SetChange; /** * State class that wraps an ArrayList @@ -16,16 +12,16 @@ * 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 lists by this class and simplify according move objects - * + * */ public class ArrayListState<E> { - + private final ArrayList<E> list = new ArrayList<E>(); private String listName; - + /** * constructor for an empty list * @param name @@ -41,15 +37,15 @@ this(listName); list.addAll(collection); } - + public void add(E element) { new AddToList<E>(list, element, listName); } - + public void add(int index, E element) { new AddToList<E>(list, element, listName).atIndex(index); } - + public boolean remove(E element) { if (list.contains(element)) { new RemoveFromList<E>(list, element, listName); @@ -58,28 +54,32 @@ return false; } } - + + public void move (E element, int toIndex) { + if (remove (element)) add (toIndex, element); + } + public void clear() { for (E element:list) { remove(element); } } - - /** + + /** * returns unmodifiable view of list */ public List<E> viewList() { return Collections.unmodifiableList(list); } - + public int size() { return list.size(); } - + public int indexOf(Object o) { return list.indexOf(o); } - + public E get(int index) { return list.get(index); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-10 16:16:29
|
Revision: 1440 http://rails.svn.sourceforge.net/rails/?rev=1440&view=rev Author: evos Date: 2010-10-10 16:16:23 +0000 (Sun, 10 Oct 2010) Log Message: ----------- Should not be in repository Removed Paths: ------------- trunk/18xx/tiles/Rails18xx.ini trunk/18xx/tiles/UserGridStyle.ini trunk/18xx/tiles/UserTileStyle.ini Deleted: trunk/18xx/tiles/Rails18xx.ini =================================================================== --- trunk/18xx/tiles/Rails18xx.ini 2010-10-08 19:42:05 UTC (rev 1439) +++ trunk/18xx/tiles/Rails18xx.ini 2010-10-10 16:16:23 UTC (rev 1440) @@ -1,180 +0,0 @@ -[TFormMDITileDictionary] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1152x864)=-1,-1,-4,-4 -MinMaxPos=-1,-1,-4,-4 -NormPos(1152x864)=0,0,872,512 -NormPos=0,0,872,512 -Visible=0 -pProperties_Width=280 -gbConnection_Height=107 -gbJunction_Height=105 -sTileSide_Value=160 -kbDrawTileID_Checked=True -kbDrawFrame_Checked=True -kbDrawGrid_Checked=True -MinMaxPos(1440x900)=-1,-1,-4,-4 -NormPos(1440x900)=0,0,872,512 -[TFormMDITileDictionarydgJun] -Item0=64 -Item1=64 -Item2=64 -Item3=64 -Item4=64 -Item5=64 -[TFormMDITileDictionarydgCon] -Item0=64 -Item1=64 -Item2=64 -Item3=64 -[TFormMDITileDictionarydgTil] -Item0=64 -Item1=64 -Item2=64 -Item3=64 -Item4=64 -Item5=64 -[TFormMainTileDesigner] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1152x864)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1152x864)=66,69,905,698 -NormPos=190,69,1029,698 -Visible=0 -tbFile_Top=28 -tbFile_Left=11 -tbFileWrite_Top=28 -tbFileWrite_Left=142 -tbEditRUndoRedo_Top=28 -tbEditRUndoRedo_Left=226 -tbEdit_Top=28 -tbEdit_Left=288 -tbTile_Top=28 -tbTile_Left=420 -tbMainMenu_Top=2 -tbMainMenu_Left=11 -MinMaxPos(1440x900)=-1,-1,-1,-1 -NormPos(1440x900)=190,69,1029,698 -[Common] -Language=1 -AutoSaveForm=1 -AutoSaveGrid=1 -[HTML] -Folder=html -ImageFormat=2 -ImageScale=1 -TileSize=80 -DrawTileID=0 -DrawGrid=0 -DrawFrame=1 -SquareImages=0 -TransparentImages=0 -TileShapeOrientationTriangleTop=1 -TileShapeOrientationTriangleBottom=0 -TileShapeOrientationTriangleLeft=0 -TileShapeOrientationTriangleRight=0 -TileShapeOrientationSquareTop=1 -TileShapeOrientationSquareTopLeft=0 -TileShapeOrientationHexagonTop=1 -TileShapeOrientationHexagonLeft=0 -TileShapeOrientationOctagonTop=1 -ImageRotation=0 -FileNameTemplate=tile<c0000>.<r> -[XML] -Folder=xml -ImageFormat=2 -ImageScale=1 -TileSize=80 -DrawTileID=0 -DrawGrid=0 -DrawFrame=1 -SquareImages=0 -TransparentImages=0 -TileShapeOrientationTriangleTop=1 -TileShapeOrientationTriangleBottom=0 -TileShapeOrientationTriangleLeft=0 -TileShapeOrientationTriangleRight=0 -TileShapeOrientationSquareTop=1 -TileShapeOrientationSquareTopLeft=0 -TileShapeOrientationHexagonTop=1 -TileShapeOrientationHexagonLeft=0 -TileShapeOrientationOctagonTop=1 -ImageRotation=0 -FileNameTemplate=tile<c0000>.<r> -[Images] -Folder=C:\Projects\Rails\18xx\tiles\TDwithID -ImageFormat=3 -ImageScale=1 -TileSize=170 -DrawTileID=0 -DrawGrid=0 -DrawFrame=1 -SquareImages=0 -TransparentImages=0 -TileShapeOrientationTriangleTop=1 -TileShapeOrientationTriangleBottom=0 -TileShapeOrientationTriangleLeft=0 -TileShapeOrientationTriangleRight=0 -TileShapeOrientationSquareTop=1 -TileShapeOrientationSquareTopLeft=0 -TileShapeOrientationHexagonTop=1 -TileShapeOrientationHexagonLeft=0 -TileShapeOrientationOctagonTop=1 -ImageRotation=0 -FileNameTemplate=tile<c0> -[TFormDiaSetupTileStyle] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1440x900)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1440x900)=353,176,731,442 -NormPos=353,176,731,442 -Visible=0 -pcStyle_ActivePage=tsScale -[TFormDiaTileStylePreview] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1440x900)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1440x900)=809,207,1208,434 -NormPos=809,207,1208,434 -Visible=1 -[TFormDiaSetup] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1440x900)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1440x900)=274,148,685,293 -NormPos=274,148,685,293 -Visible=0 -[TFormDiaExportImages] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1440x900)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1440x900)=286,146,724,442 -NormPos=286,146,724,442 -Visible=0 -[TFormDiaExportXML] -FormVersion=0 -Flags=0 -ShowCmd=1 -PixelsPerInch=96 -MinMaxPos(1440x900)=-1,-1,-1,-1 -MinMaxPos=-1,-1,-1,-1 -NormPos(1440x900)=286,146,724,442 -NormPos=286,146,724,442 -Visible=0 Deleted: trunk/18xx/tiles/UserGridStyle.ini =================================================================== --- trunk/18xx/tiles/UserGridStyle.ini 2010-10-08 19:42:05 UTC (rev 1439) +++ trunk/18xx/tiles/UserGridStyle.ini 2010-10-10 16:16:23 UTC (rev 1440) @@ -1,41 +0,0 @@ -object TGridStyleWrapper - GridStyle.WaterColor = clBlue - GridStyle.LabelCell = True - GridStyle.LabelRowLeft = True - GridStyle.LabelRowRight = True - GridStyle.LabelColTop = True - GridStyle.LabelColBottom = True - GridStyle.Texts = < - item - TextType = gttID - FontName = 'Arial' - FontStyle = [] - FontSizeDivider = 9 - FontColor = clBlack - Shape = ttsNone - end - item - TextType = gttGameSet - FontName = 'TimpaniHeavy' - FontStyle = [] - FontSizeDivider = 1 - FontColor = clBlack - Shape = ttsRoundedRectangle - end - item - TextType = gttGame - FontName = 'Bookman Old Style' - FontStyle = [] - FontSizeDivider = 2 - FontColor = clBlack - Shape = ttsRoundedRectangle - end - item - TextType = gttLocation - FontName = 'Bookman Old Style' - FontStyle = [] - FontSizeDivider = 9 - FontColor = clBlack - Shape = ttsNone - end> -end Deleted: trunk/18xx/tiles/UserTileStyle.ini =================================================================== --- trunk/18xx/tiles/UserTileStyle.ini 2010-10-08 19:42:05 UTC (rev 1439) +++ trunk/18xx/tiles/UserTileStyle.ini 2010-10-10 16:16:23 UTC (rev 1440) @@ -1,173 +0,0 @@ -object TTileStyleWrapper - TileStyle.WhiteBase = True - TileStyle.LevelColors = < - item - TileLevel = tlYellow - Background = clYellow - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlGreen - Background = 44088 - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlBrown - Background = 91060 - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlGray - Background = clGray - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlMapFixed - Background = clSilver - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlMapUpgradableToYellow - Background = clMoneyGreen - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlMapUpgradableToGreen - Background = clYellow - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlMapUpgradableToBrown - Background = 44088 - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlMapUpgradableToGray - Background = 91060 - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end - item - TileLevel = tlOffMap - Background = clRed - ID = clBlack - Category = clBlack - Refuel = clBlack - Revenue = clBlack - end> - TileStyle.Connections = < - item - ConnectionType = ctNone - Style = [] - PrimaryColor = clBlack - SecondaryColor = clBlack - end - item - ConnectionType = ctNormal - Style = [csVisible] - PrimaryColor = clBlack - SecondaryColor = clBlack - end - item - ConnectionType = ctSmall - Style = [csVisible, csDashed, csBordered] - PrimaryColor = clBlack - SecondaryColor = clWhite - end - item - ConnectionType = ctUniversal - Style = [csVisible, csBordered] - PrimaryColor = clBlack - SecondaryColor = clWhite - end - item - ConnectionType = ctMountain - Style = [csVisible, csBordered] - PrimaryColor = clGray - SecondaryColor = clSilver - end - item - ConnectionType = ctTunnel - Style = [csVisible, csBordered] - PrimaryColor = clBlack - SecondaryColor = clGray - end> - TileStyle.Texts = < - item - TextType = tttID - TextColor = clBlack - FontName = 'Arial' - FontStyle = [] - FontScale = 2000 - Shape = ttsNone - ShapeColor = clWhite - ShapeBorder = True - end - item - TextType = tttCategory - TextColor = clBlack - FontName = 'TimpaniHeavy' - FontStyle = [] - FontScale = 3000 - Shape = ttsNone - ShapeColor = clWhite - ShapeBorder = True - end - item - TextType = tttRefuel - TextColor = clBlack - FontName = 'Bookman Old Style' - FontStyle = [] - FontScale = 2000 - Shape = ttsDiamond - ShapeColor = clWhite - ShapeBorder = True - end - item - TextType = tttRevenue - TextColor = clBlack - FontName = 'Bookman Old Style' - FontStyle = [] - FontScale = 3000 - Shape = ttsEllipse - ShapeColor = clWhite - ShapeBorder = True - end> - TileStyle.Whistlestop = wsBarOrRound - TileStyle.WhistlestopColor = clBlack - TileStyle.City = csCircle - TileStyle.CityBorderColor = clBlack - TileStyle.CityShapeColor = clWhite - TileStyle.CityForceInside = False - TileStyle.LineWidthScale = 250 - TileStyle.ConnectionWidthScale = 1500 - TileStyle.BarDitRadiusScale = 1500 - TileStyle.RoundDitRadiusScale = 1000 - TileStyle.CityRadiusScale = 3000 -end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-08 19:42:13
|
Revision: 1439 http://rails.svn.sourceforge.net/rails/?rev=1439&view=rev Author: evos Date: 2010-10-08 19:42:05 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Fix treasury share selling tooltip Modified Paths: -------------- trunk/18xx/rails/ui/swing/GameStatus.java Modified: trunk/18xx/rails/ui/swing/GameStatus.java =================================================================== --- trunk/18xx/rails/ui/swing/GameStatus.java 2010-10-08 19:26:11 UTC (rev 1438) +++ trunk/18xx/rails/ui/swing/GameStatus.java 2010-10-08 19:42:05 UTC (rev 1439) @@ -363,7 +363,7 @@ new ClickField( certInTreasury[i].getText(), BUY_FROM_POOL_CMD, - LocalText.getText("ClickToSelectForBuying"), + LocalText.getText("ClickForSell"), this, buySellGroup); addField(f, certInTreasuryXOffset, certInTreasuryYOffset + i, 1, 1, WIDE_RIGHT, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-08 19:26:17
|
Revision: 1438 http://rails.svn.sourceforge.net/rails/?rev=1438&view=rev Author: evos Date: 2010-10-08 19:26:11 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Fix: always display Buy Train button in train buying step. Grey out button if no possible train actions exist. Modified Paths: -------------- trunk/18xx/rails/ui/swing/ORUIManager.java Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-08 19:25:05 UTC (rev 1437) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-10-08 19:26:11 UTC (rev 1438) @@ -18,9 +18,7 @@ import rails.ui.swing.elements.*; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; -import rails.util.Config; -import rails.util.LocalText; -import rails.util.Util; +import rails.util.*; public class ORUIManager implements DialogOwner { @@ -199,7 +197,7 @@ // check actions for allowed hexes boolean mapHexes = false; hexUpgrades = new ArrayList<MapHex>(); - + if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) { for (LayTile layTile:allowedTileLays) { switch (layTile.getType()) { @@ -240,7 +238,7 @@ GUIHex guiHex = map.getHexByName(hex.getName()); guiHex.setSelectable(true); } - + } } @@ -909,7 +907,7 @@ PublicCompanyI company = token.getCompany(); List<String> prompts = new ArrayList<String>(); - + Map<String, Station> promptToStationMap = new HashMap<String, Station>(); String prompt; for (Station station:possibleStations) { @@ -936,8 +934,8 @@ Station station = promptToStationMap.get(selected); return station; } - - + + /** * Lay Token finished. * @@ -1419,7 +1417,7 @@ mapRelatedActions.clear(); orPanel.resetActions(); - + messagePanel.setMessage(null); if (actionToComplete != null) { @@ -1446,22 +1444,21 @@ // initialize operating costs actions orPanel.initOperatingCosts(possibleActions.contains(OperatingCost.class)); - // initial deactivation of MapTileCorrection Actions + // initial deactivation of MapTileCorrection Actions mapCorrectionEnabled = false; mapCorrectionAction = null; - + // initial deactivation of revenue calculation if (!possibleActions.contains(SetDividend.class)) { orPanel.stopRevenueUpdate(); orPanel.resetCurrentRevenueDisplay(); } - + if (possibleActions.contains(MapCorrectionAction.class)) { orPanel.initTileLayingStep(); orWindow.requestFocus(); - MapCorrectionAction action = (MapCorrectionAction) - (possibleActions.getType(MapCorrectionAction.class)).get(0); + MapCorrectionAction action = (possibleActions.getType(MapCorrectionAction.class)).get(0); mapCorrectionEnabled = true; mapCorrectionAction = action; @@ -1526,9 +1523,10 @@ } setMessage(message); - } else if (possibleActions.contains(BuyTrain.class)) { + } else if (orStep == GameDef.OrStep.BUY_TRAIN) { - orPanel.initTrainBuying(true); + boolean canBuyTrain = possibleActions.contains(BuyTrain.class); + orPanel.initTrainBuying(canBuyTrain); StringBuffer b = new StringBuffer(LocalText.getText("BuyTrain")); @@ -1846,7 +1844,7 @@ upgradePanel.setCancelEnabled(true); showTilesInUpgrade = true; } - + log.debug("Active map tile correction"); if (showTilesInUpgrade) { upgradePanel.showCorrectionTileUpgrades(); @@ -1858,11 +1856,11 @@ public void setMessage(String message) { messagePanel.setMessage(message); } - + public void addInformation(String infoText) { messagePanel.addInformation(infoText); } - + public void addDetail(String detailText) { messagePanel.addDetail(detailText); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-08 19:25:12
|
Revision: 1437 http://rails.svn.sourceforge.net/rails/?rev=1437&view=rev Author: evos Date: 2010-10-08 19:25:05 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Skip creating train actions if no cash and at least 1 train. Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-10-08 19:23:59 UTC (rev 1436) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-08 19:25:05 UTC (rev 1437) @@ -1040,6 +1040,8 @@ // Move the token company.withhold(amount); + if (!company.hasStockPrice()) return; + // Check if company has entered a closing area StockSpaceI newSpace = company.getCurrentSpace(); if (newSpace.closesCompany() && company.canClose()) { @@ -2491,18 +2493,22 @@ if (operatingCompany.get() == null) return; - TrainManager trainMgr = gameManager.getTrainManager(); + int cash = operatingCompany.get().getCash(); - int cash = operatingCompany.get().getCash(); int cost; List<TrainI> trains; boolean hasTrains = operatingCompany.get().getPortfolio().getNumberOfTrains() > 0; + + // Cannot buy a train without any cash, unless you have to + if (cash == 0 && hasTrains) return; + boolean canBuyTrainNow = canBuyTrainNow(); boolean presidentMayHelp = !hasTrains && operatingCompany.get().mustOwnATrain(); TrainI cheapestTrain = null; int costOfCheapestTrain = 0; + TrainManager trainMgr = gameManager.getTrainManager(); // First check if any more trains may be bought from the Bank // Postpone train limit checking, because an exchange might be possible Modified: trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-10-08 19:23:59 UTC (rev 1436) +++ trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-10-08 19:25:05 UTC (rev 1437) @@ -40,22 +40,25 @@ if (operatingCompany.get() == null) return; - TrainManager trainMgr = gameManager.getTrainManager(); + int cash = operatingCompany.get().getCash(); - int cash = operatingCompany.get().getCash(); int cost; List<TrainI> trains; BuyTrain bt; boolean hasTrains = operatingCompany.get().getPortfolio().getNumberOfTrains() > 0; + + // Cannot buy a train without any cash, unless you have to + if (cash == 0 && hasTrains) return; + boolean canBuyTrainNow = canBuyTrainNow(); - if (!canBuyTrainNow) return; boolean presidentMayHelp = operatingCompany.get().mustOwnATrain(); TrainI cheapestTrain = null; int costOfCheapestTrain = 0; + TrainManager trainMgr = gameManager.getTrainManager(); String extraMessage = null; boolean mustExchangePullmann = !isBelowTrainLimit() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-08 19:24:06
|
Revision: 1436 http://rails.svn.sourceforge.net/rails/?rev=1436&view=rev Author: evos Date: 2010-10-08 19:23:59 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Bug fix Modified Paths: -------------- trunk/18xx/rails/game/ShareSellingRound.java Modified: trunk/18xx/rails/game/ShareSellingRound.java =================================================================== --- trunk/18xx/rails/game/ShareSellingRound.java 2010-10-07 21:12:04 UTC (rev 1435) +++ trunk/18xx/rails/game/ShareSellingRound.java 2010-10-08 19:23:59 UTC (rev 1436) @@ -380,7 +380,7 @@ boolean soldBefore = sellPrices.containsKey(companyName); - pay (bank, company, cashAmount); + pay (bank, currentPlayer, cashAmount); adjustSharePrice (company, numberSold, soldBefore); if (!company.isClosed()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-07 21:12:10
|
Revision: 1435 http://rails.svn.sourceforge.net/rails/?rev=1435&view=rev Author: evos Date: 2010-10-07 21:12:04 +0000 (Thu, 07 Oct 2010) Log Message: ----------- Added unstriped versions of the 1825 'striped' tiles 119, 166 and 200. Modified Paths: -------------- trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/TileDictionary.xml trunk/18xx/tiles/Tiles.xml Added Paths: ----------- trunk/18xx/tiles/svg/tile119.svg trunk/18xx/tiles/svg/tile166.svg trunk/18xx/tiles/svg/tile200.svg Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/TileDictionary.xml =================================================================== --- trunk/18xx/tiles/TileDictionary.xml 2010-10-07 19:41:11 UTC (rev 1434) +++ trunk/18xx/tiles/TileDictionary.xml 2010-10-07 21:12:04 UTC (rev 1435) @@ -20193,4 +20193,128 @@ </connection> </connections> </tile> + <tile> + <ID>119</ID> + <shape>tsHexagon</shape> + <level>tlGreen</level> + <name>119</name> + <junctions> + <junction> + <junType>jtDoubleCity</junType> + <position>tpCenter</position> + <revenue> + <value>30</value> + <position>tp3CornerA</position> + </revenue> + </junction> + </junctions> + <connections> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideD</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideF</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideA</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideB</position2> + </connection> + </connections> + </tile> + <tile> + <ID>166</ID> + <shape>tsHexagon</shape> + <level>tlGray</level> + <name>166</name> + <junctions> + <junction> + <junType>jtDoubleCity</junType> + <position>tpCenter</position> + <revenue> + <value>40</value> + <position>tp3CornerA</position> + </revenue> + </junction> + </junctions> + <connections> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideB</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideC</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideD</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideE</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideF</position2> + </connection> + </connections> + </tile> + <tile> + <ID>200</ID> + <shape>tsHexagon</shape> + <level>tlBrown</level> + <name>200</name> + <junctions> + <junction> + <junType>jtCity</junType> + <position>tpCenter</position> + <revenue> + <value>10</value> + <position>tp3CornerA</position> + </revenue> + </junction> + </junctions> + <connections> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideB</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideC</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideD</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideE</position2> + </connection> + <connection> + <conType>ctNormal</conType> + <position1>tpCenter</position1> + <position2>tp4SideF</position2> + </connection> + </connections> + </tile> </tiles> \ No newline at end of file Modified: trunk/18xx/tiles/Tiles.xml =================================================================== --- trunk/18xx/tiles/Tiles.xml 2010-10-07 19:41:11 UTC (rev 1434) +++ trunk/18xx/tiles/Tiles.xml 2010-10-07 21:12:04 UTC (rev 1435) @@ -1,45 +1,3574 @@ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-10-07 19:41:17
|
Revision: 1434 http://rails.svn.sourceforge.net/rails/?rev=1434&view=rev Author: evos Date: 2010-10-07 19:41:11 +0000 (Thu, 07 Oct 2010) Log Message: ----------- Display "No train" in stead of "Withhold" if company has had no revenue because of no trains. Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/action/SetDividend.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-24 21:55:37 UTC (rev 1433) +++ trunk/18xx/LocalisedText.properties 2010-10-07 19:41:11 UTC (rev 1434) @@ -410,6 +410,7 @@ NoTilesXML=No Tiles XML file specified NoToken=No Token NoTokenPossible=No token can be placed in hex {0} +NO_TRAIN=No train NoTrainSpecified=No train specified NonNumericUpgrade=Tile {0}: non-numeric upgrade {1} NormalToken= You can lay a connected token on {0}. Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-24 21:55:37 UTC (rev 1433) +++ trunk/18xx/rails/game/OperatingRound.java 2010-10-07 19:41:11 UTC (rev 1434) @@ -1217,7 +1217,7 @@ if (!operatingCompany.get().canRunTrains()) { // No trains, then the revenue is zero. executeSetRevenueAndDividend ( - new SetDividend (0, false, new int[] {SetDividend.WITHHOLD})); + new SetDividend (0, false, new int[] {SetDividend.NO_TRAIN})); // TODO: This probably does not handle share selling correctly continue; } @@ -2499,160 +2499,160 @@ boolean hasTrains = operatingCompany.get().getPortfolio().getNumberOfTrains() > 0; - boolean canBuyTrainNow = canBuyTrainNow(); - boolean presidentMayHelp = !hasTrains && operatingCompany.get().mustOwnATrain(); - TrainI cheapestTrain = null; - int costOfCheapestTrain = 0; + boolean canBuyTrainNow = canBuyTrainNow(); + boolean presidentMayHelp = !hasTrains && operatingCompany.get().mustOwnATrain(); + TrainI cheapestTrain = null; + int costOfCheapestTrain = 0; - // First check if any more trains may be bought from the Bank - // Postpone train limit checking, because an exchange might be possible - if (getCurrentPhase().canBuyMoreTrainsPerTurn() - || trainsBoughtThisTurn.isEmpty()) { - boolean mayBuyMoreOfEachType = - getCurrentPhase().canBuyMoreTrainsPerTypePerTurn(); + // First check if any more trains may be bought from the Bank + // Postpone train limit checking, because an exchange might be possible + if (getCurrentPhase().canBuyMoreTrainsPerTurn() + || trainsBoughtThisTurn.isEmpty()) { + boolean mayBuyMoreOfEachType = + getCurrentPhase().canBuyMoreTrainsPerTypePerTurn(); - /* New trains */ - trains = trainMgr.getAvailableNewTrains(); - for (TrainI train : trains) { - if (!operatingCompany.get().mayBuyTrainType(train)) continue; - if (!mayBuyMoreOfEachType - && trainsBoughtThisTurn.contains(train.getType())) { - continue; + /* New trains */ + trains = trainMgr.getAvailableNewTrains(); + for (TrainI train : trains) { + if (!operatingCompany.get().mayBuyTrainType(train)) continue; + if (!mayBuyMoreOfEachType + && trainsBoughtThisTurn.contains(train.getType())) { + continue; + } + cost = train.getCost(); + if (cost <= cash) { + if (canBuyTrainNow) { + BuyTrain action = new BuyTrain(train, ipo, cost); + action.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY + possibleActions.add(action); } - cost = train.getCost(); + } else if (costOfCheapestTrain == 0 + || cost < costOfCheapestTrain) { + cheapestTrain = train; + costOfCheapestTrain = cost; + } + // Even at train limit, exchange is allowed (per 1856) + if (train.canBeExchanged() && hasTrains) { + cost = train.getType().getExchangeCost(); if (cost <= cash) { - if (canBuyTrainNow) { - BuyTrain action = new BuyTrain(train, ipo, cost); - action.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY - possibleActions.add(action); - } - } else if (costOfCheapestTrain == 0 - || cost < costOfCheapestTrain) { - cheapestTrain = train; - costOfCheapestTrain = cost; + List<TrainI> exchangeableTrains = + operatingCompany.get().getPortfolio().getUniqueTrains(); + BuyTrain action = new BuyTrain(train, ipo, cost); + action.setTrainsForExchange(exchangeableTrains); + //if (atTrainLimit) action.setForcedExchange(true); + possibleActions.add(action); + canBuyTrainNow = true; } - // Even at train limit, exchange is allowed (per 1856) - if (train.canBeExchanged() && hasTrains) { - cost = train.getType().getExchangeCost(); - if (cost <= cash) { - List<TrainI> exchangeableTrains = - operatingCompany.get().getPortfolio().getUniqueTrains(); - BuyTrain action = new BuyTrain(train, ipo, cost); - action.setTrainsForExchange(exchangeableTrains); - //if (atTrainLimit) action.setForcedExchange(true); - possibleActions.add(action); - canBuyTrainNow = true; - } - } + } - if (!canBuyTrainNow) continue; + if (!canBuyTrainNow) continue; - // Can a special property be used? - // N.B. Assume that this never occurs in combination with - // a train exchange, otherwise the below code must be duplicated - // above. - for (SpecialTrainBuy stb : getSpecialProperties(SpecialTrainBuy.class)) { - int reducedPrice = stb.getPrice(cost); - if (reducedPrice > cash) continue; - BuyTrain bt = new BuyTrain(train, ipo, reducedPrice); - bt.setSpecialProperty(stb); - bt.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY - possibleActions.add(bt); - } - + // Can a special property be used? + // N.B. Assume that this never occurs in combination with + // a train exchange, otherwise the below code must be duplicated + // above. + for (SpecialTrainBuy stb : getSpecialProperties(SpecialTrainBuy.class)) { + int reducedPrice = stb.getPrice(cost); + if (reducedPrice > cash) continue; + BuyTrain bt = new BuyTrain(train, ipo, reducedPrice); + bt.setSpecialProperty(stb); + bt.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY + possibleActions.add(bt); } - if (!canBuyTrainNow) return; - /* Used trains */ - trains = pool.getUniqueTrains(); - for (TrainI train : trains) { - if (!mayBuyMoreOfEachType - && trainsBoughtThisTurn.contains(train.getType())) { - continue; - } - cost = train.getCost(); - if (cost <= cash) { - BuyTrain bt = new BuyTrain(train, pool, cost); - bt.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY - possibleActions.add(bt); - } else if (costOfCheapestTrain == 0 - || cost < costOfCheapestTrain) { - cheapestTrain = train; - costOfCheapestTrain = cost; - } + } + if (!canBuyTrainNow) return; + + /* Used trains */ + trains = pool.getUniqueTrains(); + for (TrainI train : trains) { + if (!mayBuyMoreOfEachType + && trainsBoughtThisTurn.contains(train.getType())) { + continue; } - if (!hasTrains && possibleActions.getType(BuyTrain.class).isEmpty() - && cheapestTrain != null && presidentMayHelp) { - BuyTrain bt = new BuyTrain(cheapestTrain, - cheapestTrain.getHolder(), costOfCheapestTrain); - bt.setPresidentMustAddCash(costOfCheapestTrain - cash); - bt.setForcedBuyIfNoRoute(presidentMayHelp); // TODO TEMPORARY + cost = train.getCost(); + if (cost <= cash) { + BuyTrain bt = new BuyTrain(train, pool, cost); + bt.setForcedBuyIfNoRoute(presidentMayHelp); // TEMPORARY possibleActions.add(bt); + } else if (costOfCheapestTrain == 0 + || cost < costOfCheapestTrain) { + cheapestTrain = train; + costOfCheapestTrain = cost; } } + if (!hasTrains && possibleActions.getType(BuyTrain.class).isEmpty() + && cheapestTrain != null && presidentMayHelp) { + BuyTrain bt = new BuyTrain(cheapestTrain, + cheapestTrain.getHolder(), costOfCheapestTrain); + bt.setPresidentMustAddCash(costOfCheapestTrain - cash); + bt.setForcedBuyIfNoRoute(presidentMayHelp); // TODO TEMPORARY + possibleActions.add(bt); + } + } - if (!canBuyTrainNow) return; + if (!canBuyTrainNow) return; - /* Other company trains, sorted by president (current player first) */ - if (getCurrentPhase().isTrainTradingAllowed()) { - BuyTrain bt; - Player p; - Portfolio pf; - int index; - int numberOfPlayers = getNumberOfPlayers(); + /* Other company trains, sorted by president (current player first) */ + if (getCurrentPhase().isTrainTradingAllowed()) { + BuyTrain bt; + Player p; + Portfolio pf; + int index; + int numberOfPlayers = getNumberOfPlayers(); - // Set up a list per player of presided companies - List<List<PublicCompanyI>> companiesPerPlayer = - new ArrayList<List<PublicCompanyI>>(numberOfPlayers); - for (int i = 0; i < numberOfPlayers; i++) - companiesPerPlayer.add(new ArrayList<PublicCompanyI>(4)); - List<PublicCompanyI> companies; - // Sort out which players preside over which companies. - for (PublicCompanyI c : getOperatingCompanies()) { - if (c.isClosed() || c == operatingCompany.get()) continue; - p = c.getPresident(); - index = p.getIndex(); - companiesPerPlayer.get(index).add(c); - } - // Scan trains per company per player, operating company president - // first - //int currentPlayerIndex = operatingCompany.getObject().getPresident().getIndex(); - int currentPlayerIndex = getCurrentPlayer().getIndex(); - for (int i = currentPlayerIndex; i < currentPlayerIndex - + numberOfPlayers; i++) { - companies = companiesPerPlayer.get(i % numberOfPlayers); - for (PublicCompanyI company : companies) { - pf = company.getPortfolio(); - trains = pf.getUniqueTrains(); + // Set up a list per player of presided companies + List<List<PublicCompanyI>> companiesPerPlayer = + new ArrayList<List<PublicCompanyI>>(numberOfPlayers); + for (int i = 0; i < numberOfPlayers; i++) + companiesPerPlayer.add(new ArrayList<PublicCompanyI>(4)); + List<PublicCompanyI> companies; + // Sort out which players preside over which companies. + for (PublicCompanyI c : getOperatingCompanies()) { + if (c.isClosed() || c == operatingCompany.get()) continue; + p = c.getPresident(); + index = p.getIndex(); + companiesPerPlayer.get(index).add(c); + } + // Scan trains per company per player, operating company president + // first + //int currentPlayerIndex = operatingCompany.getObject().getPresident().getIndex(); + int currentPlayerIndex = getCurrentPlayer().getIndex(); + for (int i = currentPlayerIndex; i < currentPlayerIndex + + numberOfPlayers; i++) { + companies = companiesPerPlayer.get(i % numberOfPlayers); + for (PublicCompanyI company : companies) { + pf = company.getPortfolio(); + trains = pf.getUniqueTrains(); - for (TrainI train : trains) { - if (train.isObsolete()) continue; - if (i != currentPlayerIndex - //&& trainMgr.buyAtFaceValueBetweenDifferentPresidents() - && getGameParameterAsBoolean(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS) - || operatingCompany.get().mustTradeTrainsAtFixedPrice() - || company.mustTradeTrainsAtFixedPrice()) { - if (cash >= train.getCost()) { - bt = new BuyTrain(train, pf, train.getCost()); - } else { - continue; - } + for (TrainI train : trains) { + if (train.isObsolete()) continue; + if (i != currentPlayerIndex + //&& trainMgr.buyAtFaceValueBetweenDifferentPresidents() + && getGameParameterAsBoolean(GameDef.Parm.FIXED_PRICE_TRAINS_BETWEEN_PRESIDENTS) + || operatingCompany.get().mustTradeTrainsAtFixedPrice() + || company.mustTradeTrainsAtFixedPrice()) { + if (cash >= train.getCost()) { + bt = new BuyTrain(train, pf, train.getCost()); } else { - bt = new BuyTrain(train, pf, 0); + continue; } - if (presidentMayHelp && cash < train.getCost()) { - bt.setPresidentMayAddCash(train.getCost() - cash); - } - possibleActions.add(bt); + } else { + bt = new BuyTrain(train, pf, 0); } + if (presidentMayHelp && cash < train.getCost()) { + bt.setPresidentMayAddCash(train.getCost() - cash); + } + possibleActions.add(bt); } } } + } - if (!operatingCompany.get().mustOwnATrain() - || operatingCompany.get().getPortfolio().getNumberOfTrains() > 0) { - doneAllowed = true; - } + if (!operatingCompany.get().mustOwnATrain() + || operatingCompany.get().getPortfolio().getNumberOfTrains() > 0) { + doneAllowed = true; + } } /** Modified: trunk/18xx/rails/game/action/SetDividend.java =================================================================== --- trunk/18xx/rails/game/action/SetDividend.java 2010-09-24 21:55:37 UTC (rev 1433) +++ trunk/18xx/rails/game/action/SetDividend.java 2010-10-07 19:41:11 UTC (rev 1434) @@ -23,11 +23,12 @@ public static final int WITHHOLD = 0; public static final int SPLIT = 1; public static final int PAYOUT = 2; - public static final int NUM_OPTIONS = 3; + public static final int NO_TRAIN = 3; + public static final int NUM_OPTIONS = 4; /** Allocation name keys in the resource bundle */ public static final String[] allocationNameKeys = - new String[] { "WITHHOLD", "SPLIT", "PAYOUT" }; + new String[] { "WITHHOLD", "SPLIT", "PAYOUT", "NO_TRAIN" }; /*--- Server-side settings ---*/ /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-09-24 21:55:43
|
Revision: 1433 http://rails.svn.sourceforge.net/rails/?rev=1433&view=rev Author: evos Date: 2010-09-24 21:55:37 +0000 (Fri, 24 Sep 2010) Log Message: ----------- Manchester fixed (rotation) Modified Paths: -------------- trunk/18xx/data/1825/Map.xml Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-23 23:01:59 UTC (rev 1432) +++ trunk/18xx/data/1825/Map.xml 2010-09-24 21:55:37 UTC (rev 1433) @@ -69,7 +69,7 @@ <Hex name="N16" tile="0"/> <Hex name="N18" tile="-10" cost="40" city="Hull"/> <Hex name="O9" tile="-25009" cost="40" city="Liverpool"/> - <Hex name="O11" tile="-25002" city="Manchester"/> + <Hex name="O11" tile="-25002" orientation="1" city="Manchester"/> <Hex name="O13" tile="0" cost="100"/> <Hex name="O15" tile="-25010" city="Barnsley, Doncaster"/> <Hex name="O17" tile="0" cost="40"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |