From: <ste...@us...> - 2010-08-14 19:53:49
|
Revision: 1387 http://rails.svn.sourceforge.net/rails/?rev=1387&view=rev Author: stefanfrey Date: 2010-08-14 19:53:42 +0000 (Sat, 14 Aug 2010) Log Message: ----------- Further fixes to the new report window functionality Added user comments Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/ReportBuffer.java trunk/18xx/rails/game/move/MoveStack.java trunk/18xx/rails/ui/swing/MessagePanel.java trunk/18xx/rails/ui/swing/ORUIManager.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java trunk/18xx/rails/util/Util.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/LocalisedText.properties 2010-08-14 19:53:42 UTC (rev 1387) @@ -486,8 +486,11 @@ RepayLoans=Repay loan(s) RepayLoan=Repay {0} loan(s) of {1} for {2} REPORT=Report Window -REPORT_MOVE_BACKWARD=<< -REPORT_MOVE_FORWARD=>> +REPORT_MOVE_BACKWARD=< +REPORT_MOVE_FORWARD=> +REPORT_COMMENT=Comment +REPORT_COMMENT_TITLE=Add Comment +REPORT_COMMENT_ASK=Add a comment to the previous action REVENUE=Revenue RevenueCalculation=support for revenue calculation RevenueStations=, Cities = {0}, Towns = {1} Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/Game.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -261,18 +261,18 @@ log.debug("Starting to execute loaded actions"); + Object actionObject = null; while (true) { // Single-pass loop. - Object firstActionObject; try { - firstActionObject = ois.readObject(); + actionObject = ois.readObject(); } catch (EOFException e) { // Allow saved file at start of game (with no actions). break; } - if (firstActionObject instanceof List) { + if (actionObject instanceof List) { // Old-style: one List of PossibleActions List<PossibleAction> executedActions = - (List<PossibleAction>) firstActionObject; + (List<PossibleAction>) actionObject; numberOfActions = executedActions.size(); for (PossibleAction action : executedActions) { if (!gameManager.processOnReload(action)) { @@ -281,19 +281,17 @@ break; } } - - } else { + } else if (actionObject instanceof PossibleAction) { // New style: separate PossibleActionsObjects, since Rails 1.3.1 - PossibleAction action = (PossibleAction) firstActionObject; - while (true) { + while (actionObject instanceof PossibleAction) { numberOfActions++; - if (!gameManager.processOnReload(action)) { + if (!gameManager.processOnReload((PossibleAction)actionObject)) { log.error ("Load interrupted"); DisplayBuffer.add(LocalText.getText("LoadInterrupted")); break; } try { - action = (PossibleAction) ois.readObject(); + actionObject = ois.readObject(); } catch (EOFException e) { break; } @@ -301,6 +299,22 @@ } break; } + + // load user comments (is the last + if (actionObject instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) actionObject); + log.debug("Found sorted map"); + } else { + try { + object = ois.readObject(); + if (object instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) object); + } + } catch (EOFException e) { + // continue without comments + } + } + ois.close(); game.getGameManager().finishLoading(); Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/GameManager.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -1040,6 +1040,7 @@ for (PossibleAction action : executedActions) { oos.writeObject(action); } + oos.writeObject(ReportBuffer.getCommentItems()); oos.close(); result = true; Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/OperatingRound.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -803,6 +803,10 @@ moveStack.start(true); + ReportBuffer.add(LocalText.getText("CompanyRevenue", + action.getCompanyName(), + Bank.format(action.getActualRevenue()))); + int remainingAmount = checkForDeductions (action); if (remainingAmount < 0) { // A share selling round will be run to raise cash to pay debts @@ -890,9 +894,6 @@ action.setRevenueAllocation(SetDividend.WITHHOLD); } - ReportBuffer.add(LocalText.getText("CompanyRevenue", - action.getCompanyName(), - Bank.format(amount))); if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", operatingCompany.getName(), Modified: trunk/18xx/rails/game/ReportBuffer.java =================================================================== --- trunk/18xx/rails/game/ReportBuffer.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/ReportBuffer.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -27,13 +27,12 @@ /** defines the collection of data that is stored in the report buffer */ private class ReportItem { private List<String> messages = new ArrayList<String>(); - private int index = 0; + private int index = -1; private Player player = null; private RoundI round = null; private void addMessage(String message) { - // ignore undos and redos - messages.add(message); + messages.add(Util.convertToHtml(message)); } private String getMessages() { @@ -44,17 +43,38 @@ return s.toString(); } - private String toHtml() { + /** + * converts messages to html string + * @param activeMessage if true, adds indicator and highlighting for active message + */ + + private String toHtml(boolean activeMessage) { + if (messages.isEmpty()) { + if (activeMessage) { + return ("<span bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR + "</span>" + + NEWLINE_STRING); + } else { + return null; + } + } + StringBuffer s = new StringBuffer(); boolean init = true; for (String message:messages) { if (init) { + if (activeMessage) { + s.append("<span bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR) ; + } s.append("<a href=http://rails:" + index + ">"); s.append(message); - s.append("</a><br> "); // is the linefeed character to induce line feed on copy & paste + s.append("</a>"); + if (activeMessage) { + s.append("</span>"); + } + s.append(NEWLINE_STRING); init = false; } else { - s.append(message + "<br> "); // see above + s.append(message + NEWLINE_STRING); // see above } } return s.toString(); @@ -70,8 +90,25 @@ } } + /* + * All variables below are required for the dynamic preprot window + */ + /** Indicator string to find the active message position in the parsed html document */ + public static final String ACTIVE_MESSAGE_INDICATOR = "(**)"; - /** + /** Newline string + * is the linefeed character to induce line feed on copy & paste + */ + private static final String NEWLINE_STRING = "<br> "; + + /** Archive stack of messages, the integer index corresponds with the moveset items */ + private SortedMap<Integer, ReportItem> reportItems = new TreeMap<Integer, ReportItem>(); + + /** Archive stack of user supplied comments, integer index corresponds with moveset items */ + private SortedMap<Integer, String> commentItems = new TreeMap<Integer, String>(); + + /* + * All variables below are required for the static report window * A stack for displaying messages in the Log Window. Such messages are * intended to record the progress of the rails.game and can be used as a * rails.game report. @@ -81,11 +118,6 @@ /** Another stack for messages that must "wait" for other messages */ private List<String> waitQueue = new ArrayList<String> (); - /** Archive stack, the integer index corresponds with the moveset items */ - private SortedMap<Integer, ReportItem> reportItems = new TreeMap<Integer, ReportItem>(); - /** Indicator string to find the active message position in the parsed html document */ - public static final String ACTIVE_MESSAGE_INDICATOR = "(**)"; - private String reportPathname = null; private PrintWriter report = null; @@ -108,7 +140,7 @@ public ReportBuffer() { - reportItems.put(0, new ReportItem()); + reportItems.put(-1, new ReportItem()); if (!initialQueue.isEmpty()) { for (String s : initialQueue) { addMessage(s, -1); // start of the game @@ -129,7 +161,8 @@ private void addMessage(String message, int moveStackIndex) { if (message != null) { if (message.equals("")) { - message = "---"; // workaround for testing + return; + // message = "---"; // workaround for testing } // legacy report queue reportQueue.add(message); @@ -191,20 +224,25 @@ } } + private void clearFutureItems(int index) { + // delete future items + Set<Integer> deleteIndices = new HashSet<Integer> + (reportItems.tailMap(index + 1).keySet()); + for (Integer i:deleteIndices) { + reportItems.remove(i); + commentItems.remove(i); + } + } + private void addReportItem(int index, Player player, RoundI round) { ReportItem newItem = new ReportItem(); newItem.index = index; newItem.player = player; newItem.round = round; reportItems.put(index, newItem); - Set<Integer> deleteIndices = new HashSet<Integer> - (reportItems.tailMap(index + 1).keySet()); - for (Integer i:deleteIndices) { - reportItems.remove(i); - } } - - /** Movestack calls the report item to update */ + + /** Creates a new report item */ public static void createNewReportItem(int index) { // check availablity GameManagerI gm = GameManager.getInstance(); @@ -219,23 +257,33 @@ Player player = gm.getCurrentPlayer(); RoundI round = gm.getCurrentRound(); instance.addReportItem(index, player, round); + instance.clearFutureItems(index); } public static String getReportItems() { - int index = GameManager.getInstance().getMoveStack().getIndex(); + // activeIndex is the index one before the current index for the next action + int activeIndex = GameManager.getInstance().getMoveStack().getCurrentIndex(); ReportBuffer instance = getInstance(); StringBuffer s = new StringBuffer(); s.append("<html>"); - for (ReportItem item:instance.reportItems.values()) { - if (item.index == index-1) { - s.append("<p bgcolor=Yellow>" + ACTIVE_MESSAGE_INDICATOR) ; + for (Integer index:instance.reportItems.keySet()) { + ReportItem item = instance.reportItems.get(index); + String text = item.toHtml(index == activeIndex); + String comment = instance.commentItems.get(index); + if (text == null && comment == null) continue; + s.append("<p>"); + // comments first + if (comment != null) { + s.append("<span style='color:green;font-size:80%;font-style:italic;'>"); + s.append(item.player.getName() + " says: ' "); + s.append(comment + "'" + NEWLINE_STRING); + s.append("</span>"); } - s.append(item.toHtml()); - if (item.index == (index-1)) { - s.append("</p><"); - } + // text afterwards + if (text != null) s.append(text); + s.append("</p>"); } s.append("</html>"); @@ -273,10 +321,69 @@ instance.reportQueue.add(message); return; } - int moveStackIndex = gm.getMoveStack().getIndex(); + int moveStackIndex = gm.getMoveStack().getCurrentIndex(); instance.addMessage(message, moveStackIndex); } } + + /** Add a user comment to the report window */ + public static void addComment(String comment) { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + int index = gm.getMoveStack().getCurrentIndex(); // add one index before (active) + instance.commentItems.put(index, comment); + log.debug("Added comment = " + comment + " at index = " + index); + } + } + + /** Retrieves the current user comment */ + public static String getComment() { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + String comment = null; + if (instance != null) { + int index = gm.getMoveStack().getCurrentIndex(); + comment = instance.commentItems.get(index); + } + return comment; + } + + /** Retrieves all user comments */ + public static SortedMap<Integer, String> getCommentItems() { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + return instance.commentItems; + } else { + // return empty map + return new TreeMap<Integer, String>(); + } + } + + /** sets user comments */ + public static void setCommentItems(SortedMap<Integer, String> commentItems) { + GameManagerI gm = GameManager.getInstance(); + ReportBuffer instance = null; + if (gm != null) { + instance = gm.getReportBuffer(); + } + if (instance != null) { + instance.commentItems = commentItems; + } + } + + + /** return the current buffer as list */ public static List<String> getAsList() { Modified: trunk/18xx/rails/game/move/MoveStack.java =================================================================== --- trunk/18xx/rails/game/move/MoveStack.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/game/move/MoveStack.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -48,6 +48,7 @@ while (lastIndex < moveStack.size() - 1) { moveStack.remove(moveStack.size() - 1); } + ReportBuffer.createNewReportItem(getCurrentIndex()); return currentMoveSet; } else { log.warn("MoveSet is already open"); @@ -68,7 +69,6 @@ moveStack.add(currentMoveSet); lastIndex++; currentMoveSet = null; - ReportBuffer.createNewReportItem(this.getIndex()); return true; } } @@ -117,6 +117,7 @@ undoAction = moveStack.get(lastIndex--); undoAction.unexecute(); } while (undoAction.isLinkedToPreviousMove()); + return true; } else { log.error("Invalid undo: index=" + lastIndex + " size=" @@ -165,6 +166,18 @@ return lastIndex + 1; } + /** + * the current index is the one of either the open moveset or + * if none is open of the latest added + */ + public int getCurrentIndex() { + if (isOpen()) { + return lastIndex + 1; + } else { + return lastIndex; + } + } + /** * undo/redo to a given moveStack index */ Modified: trunk/18xx/rails/ui/swing/MessagePanel.java =================================================================== --- trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -62,22 +62,21 @@ messageText.append("</span>"); } if (showDetails) { - messageText.append("<span style='color:blue'>"); + messageText.append("<span style='color:blue; font-size:80%'>"); for (String detail:currentDetails) { messageText.append(detail); } messageText.append("</span>"); } else if (currentDetails.size() != 0) { - messageText.append("<span style='color:blue'>"); + messageText.append("<span style='color:blue; font-size:80%'>"); messageText.append("<BR> Click for more details"); messageText.append("</span>"); } - if (currentMessage != null) { - String text = messageText.toString(); - int lines = text.split("<[Bb][Rr]>").length + 1; - setLines(lines); - message.setText("<html><center>" + text + "</center></html>"); - } + // display + String text = messageText.toString(); + int lines = text.split("<[Bb][Rr]>").length + 1; + setLines(lines); + message.setText("<html><center>" + text + "</center></html>"); } Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -1419,6 +1419,8 @@ mapRelatedActions.clear(); orPanel.resetActions(); + + messagePanel.setMessage(null); if (actionToComplete != null) { log.debug("ExecutedAction: " + actionToComplete); Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -7,7 +7,9 @@ import java.net.URL; import java.util.List; +import javax.swing.JButton; import javax.swing.JEditorPane; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.UIManager; @@ -40,6 +42,7 @@ private JPanel buttonPanel; private ActionButton forwardButton; private ActionButton backwardButton; + private JButton commentButton; protected static Logger log = Logger.getLogger(ReportWindowDynamic.class.getPackage().getName()); @@ -80,6 +83,29 @@ forwardButton.addActionListener(this); buttonPanel.add(forwardButton); + commentButton = new JButton(LocalText.getText("REPORT_COMMENT")); + commentButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + String newComment = (String)JOptionPane.showInputDialog( + ReportWindowDynamic.this, + LocalText.getText("REPORT_COMMENT_ASK"), + LocalText.getText("REPORT_COMMENT_TITLE"), + JOptionPane.PLAIN_MESSAGE, + null, + null, + ReportBuffer.getComment() + ); + if (newComment != null) { + ReportBuffer.addComment(newComment); + updateLog(); + scrollDown(); + } + } + } + ); + buttonPanel.add(commentButton); + super.init(); } Modified: trunk/18xx/rails/util/Util.java =================================================================== --- trunk/18xx/rails/util/Util.java 2010-08-13 16:30:20 UTC (rev 1386) +++ trunk/18xx/rails/util/Util.java 2010-08-14 19:53:42 UTC (rev 1387) @@ -79,7 +79,19 @@ } } + /** + * Convert java string to html string + * Transformations: + * - Converts \n to <br> + */ + public static String convertToHtml(String javaString) { + return javaString.replace("\n", "<br>"); + } + + + + /** * Safely move a list of objects from one holder to another, avoiding * ConcurrentModificationExceptions. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-15 19:40:54
|
Revision: 1389 http://rails.svn.sourceforge.net/rails/?rev=1389&view=rev Author: stefanfrey Date: 2010-08-15 19:40:47 +0000 (Sun, 15 Aug 2010) Log Message: ----------- Added display of revenue bonus in non-detailed revenue results Some refactoring of the dynamic revenue modifier Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/algorithms/RevenueAdapter.java trunk/18xx/rails/algorithms/RevenueDynamicModifier.java trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/LocalisedText.properties 2010-08-15 19:40:47 UTC (rev 1389) @@ -492,7 +492,9 @@ REPORT_COMMENT_TITLE=Add Comment REPORT_COMMENT_ASK=Add a comment to the previous action REVENUE=Revenue +RevenueBonus=Bonus(es) = {0} RevenueCalculation=support for revenue calculation +RevenueNoRun=No Optimal Run RevenueStations=, Cities = {0}, Towns = {1} RevenueStationsIgnoreMinors=, Cities = {0} ReceivesFor={0} receives {1} for {2}. Modified: trunk/18xx/rails/algorithms/RevenueAdapter.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -19,12 +19,12 @@ import rails.game.GameManagerI; import rails.game.MapHex; -import rails.game.MapManager; import rails.game.PhaseI; import rails.game.PublicCompanyI; import rails.game.TrainI; import rails.game.TrainTypeI; import rails.ui.swing.hexmap.HexMap; +import rails.util.LocalText; public final class RevenueAdapter implements Runnable { @@ -587,7 +587,7 @@ int dynamicEvaluation() { int value = 0; for (RevenueDynamicModifier modifier:dynamicModifiers) { - value += modifier.evaluationValue(this); + value += modifier.evaluationValue(this.getCurrentRun()); } return value; } @@ -598,7 +598,7 @@ int dynamicPrediction() { int value = 0; for (RevenueDynamicModifier modifier:dynamicModifiers) { - value += modifier.predictionValue(this); + value += modifier.predictionValue(); } return value; } @@ -630,7 +630,7 @@ public String getOptimalRunPrettyPrint(boolean includeDetails) { List<RevenueTrainRun> listRuns = getOptimalRun(); - if (listRuns== null) return "No Optimal Run"; + if (listRuns== null) return LocalText.getText("RevenueNoRun"); StringBuffer runPrettyPrint = new StringBuffer(); for (RevenueTrainRun run:listRuns) { @@ -641,12 +641,19 @@ runPrettyPrint.append("; "); } if (includeDetails) { - // add dynamic Modifier for (RevenueDynamicModifier modifier:dynamicModifiers) { runPrettyPrint.append(modifier.prettyPrint(this)); } + } else { + int dynamicBonuses = 0; + for (RevenueDynamicModifier modifier:dynamicModifiers) { + dynamicBonuses += modifier.evaluationValue(this.getOptimalRun()); + } + if (dynamicBonuses != 0) { + runPrettyPrint.append("; " + + LocalText.getText("RevenueBonus", dynamicBonuses)); + } } - return runPrettyPrint.toString(); } Modified: trunk/18xx/rails/algorithms/RevenueDynamicModifier.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueDynamicModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/algorithms/RevenueDynamicModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -1,4 +1,7 @@ package rails.algorithms; + +import java.util.List; + /** * Classes that change properties of the revenue calculation * after the actual calculation started implement the dynamic modifier. @@ -15,12 +18,12 @@ public boolean prepareModifier(RevenueAdapter revenueAdapter); /** returns the value used for prediction */ - public int predictionValue(RevenueAdapter revenueAdapter); + public int predictionValue(); - /** returns the value used for evaluation */ - public int evaluationValue(RevenueAdapter revenueAdapter); + /** returns the value used for evaluation (at the run supplied) */ + public int evaluationValue(List<RevenueTrainRun> runs); - /** returns the prettyPrintName */ - public String prettyPrint(RevenueAdapter revenueAdapter); + /** returns the results as pretty prints */ + public String prettyPrint(RevenueAdapter adapter); } Modified: trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/game/specific/_18AL/NamedTrainRevenueModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -98,14 +98,13 @@ return true; } - public int predictionValue(RevenueAdapter revenueAdapter) { + public int predictionValue() { return bonusMaximum; } - public int evaluationValue(RevenueAdapter revenueAdapter) { - List<RevenueTrainRun> runs = revenueAdapter.getCurrentRun(); + public int evaluationValue(List<RevenueTrainRun> runs) { int bonusValue = 0; - // due to the geography each train can only score one bonus + // due to the geography (off-map areas!) each train can only score one bonus for (RevenueBonus bonus:bonuses) { for (RevenueTrainRun run:runs) { if (run.getUniqueVertices().containsAll(bonus.getVertices())) { @@ -123,7 +122,7 @@ for (RevenueBonus bonus:bonuses) { for (RevenueTrainRun run:runs) { if (run.getUniqueVertices().containsAll(bonus.getVertices())) { - prettyPrint.append(bonus.getName() + ": " + bonus.getValue() + "\n"); + prettyPrint.append(bonus.getName() + " = " + bonus.getValue() + "\n"); continue; // each bonus can only be scored once } } Modified: trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java 2010-08-15 12:09:08 UTC (rev 1388) +++ trunk/18xx/rails/game/specific/_18EU/PullmanRevenueModifier.java 2010-08-15 19:40:47 UTC (rev 1389) @@ -32,8 +32,8 @@ return true; } - public int evaluationValue(RevenueAdapter revenueAdapter) { - return pullmanValue(revenueAdapter.getCurrentRun()); + public int evaluationValue(List<RevenueTrainRun> runs) { + return pullmanValue(runs); } private int pullmanValue(List<RevenueTrainRun> trainRuns) { @@ -45,12 +45,12 @@ return maximum; } - public int predictionValue(RevenueAdapter revenueAdapter) { + public int predictionValue() { return maxValue; } public String prettyPrint(RevenueAdapter revenueAdapter) { - return LocalText.getText("Pullman") + ": " + pullmanValue(revenueAdapter.getOptimalRun()); + return LocalText.getText("Pullman") + " = " + pullmanValue(revenueAdapter.getOptimalRun()); } private int maximumMajorValue(Collection<NetworkVertex> vertices) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-21 06:49:57
|
Revision: 1395 http://rails.svn.sourceforge.net/rails/?rev=1395&view=rev Author: stefanfrey Date: 2010-08-21 06:49:48 +0000 (Sat, 21 Aug 2010) Log Message: ----------- - Added stateful list class - OperatingCompany in OR implements that - Added forced sell protection of operating company - Added game option for 1889 for according protection of all owned companies Modified Paths: -------------- trunk/18xx/data/1889/Game.xml trunk/18xx/rails/common/GuiHints.java trunk/18xx/rails/game/City.java trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameManagerI.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/PhaseManager.java trunk/18xx/rails/game/ShareSellingRound.java trunk/18xx/rails/game/StartRound_1830.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/model/PriceModel.java trunk/18xx/rails/game/move/AddToList.java trunk/18xx/rails/game/move/StateChange.java trunk/18xx/rails/game/special/SellBonusToken.java trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java trunk/18xx/rails/game/specific/_1835/StockRound_1835.java trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java trunk/18xx/rails/game/specific/_1856/PublicCompany_CGR.java trunk/18xx/rails/game/specific/_1856/StockRound_1856.java trunk/18xx/rails/game/specific/_1889/OperatingRound_1889.java trunk/18xx/rails/game/specific/_18AL/NameableTrain.java trunk/18xx/rails/game/specific/_18AL/OperatingRound_18AL.java trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java trunk/18xx/rails/game/specific/_18EU/StockRound_18EU.java trunk/18xx/rails/game/state/GenericState.java trunk/18xx/rails/game/state/State.java trunk/18xx/rails/game/state/StateI.java Added Paths: ----------- trunk/18xx/rails/game/state/ArrayListState.java Modified: trunk/18xx/data/1889/Game.xml =================================================================== --- trunk/18xx/data/1889/Game.xml 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/data/1889/Game.xml 2010-08-21 06:49:48 UTC (rev 1395) @@ -40,6 +40,7 @@ <OperatingRound class="rails.game.specific._1889.OperatingRound_1889"/> </GameParameters> <EndOfGame> + <ForcedSelling CompanyDump="no"/> <Bankruptcy/> <BankBreaks limit="0" finish="setOfORs"/> <!-- "Runs out"; when "broken", -1 is the limit --> Modified: trunk/18xx/rails/common/GuiHints.java =================================================================== --- trunk/18xx/rails/common/GuiHints.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/common/GuiHints.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -32,7 +32,7 @@ private EnumState<GuiDef.Panel> activePanel = null; public Class<? extends RoundI> getCurrentRoundType() { - return currentRoundType.getObject(); + return currentRoundType.get(); } public void setCurrentRoundType(Class<? extends RoundI> currentRoundType) { @@ -63,7 +63,7 @@ } public GuiDef.Panel getActivePanel() { - return (GuiDef.Panel)activePanel.getObject(); + return (GuiDef.Panel)activePanel.get(); } public void setActivePanel(GuiDef.Panel activePanel) { Modified: trunk/18xx/rails/game/City.java =================================================================== --- trunk/18xx/rails/game/City.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/City.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -68,7 +68,7 @@ } public Station getRelatedStation() { - return relatedStation.getObject(); + return relatedStation.get(); } public void setRelatedStation(Station relatedStation) { Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/GameManager.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -82,6 +82,7 @@ protected boolean skipFirstStockRound = false; protected boolean showCompositeORNumber = true; + protected boolean forcedSellingCompanyDump = true; protected boolean gameEndsWithBankruptcy = false; protected int gameEndsWhenBankHasLessOrEqual = 0; protected boolean gameEndsAfterSetOfORs = true; @@ -353,6 +354,11 @@ /* End of rails.game criteria */ Tag endOfGameTag = tag.getChild("EndOfGame"); if (endOfGameTag != null) { + Tag forcedSellingTag = endOfGameTag.getChild("ForcedSelling"); + if (forcedSellingTag != null) { + forcedSellingCompanyDump = + forcedSellingTag.getAttributeAsBoolean("CompanyDump", true); + } if (endOfGameTag.getChild("Bankruptcy") != null) { gameEndsWithBankruptcy = true; } @@ -713,11 +719,16 @@ * @see rails.game.GameManagerI#startShareSellingRound(rails.game.OperatingRound, rails.game.PublicCompanyI, int) */ public void startShareSellingRound(Player player, int cashToRaise, - PublicCompanyI unsellableCompany) { + PublicCompanyI cashNeedingCompany, boolean problemDumpOtherCompanies) { interruptedRound = getCurrentRound(); + + // check if other companies can be dumped createRound (ShareSellingRound.class, interruptedRound) - .start(player, cashToRaise, unsellableCompany); + .start(player, cashToRaise, cashNeedingCompany, + !problemDumpOtherCompanies || forcedSellingCompanyDump); + // the last parameter indicates if the dump of other companies is allowed, either this is explicit or + // the action does not require that check } /* (non-Javadoc) @@ -825,7 +836,7 @@ // logging of game actions activated for (PossibleAction pa : possibleActions.getList()) { - log.debug(((Player) currentPlayer.getObject()).getName() + " may: " + log.debug(((Player) currentPlayer.get()).getName() + " may: " + pa.toString()); } @@ -1247,7 +1258,7 @@ * @see rails.game.GameManagerI#getCurrentRound() */ public RoundI getCurrentRound() { - return (RoundI) currentRound.getObject(); + return (RoundI) currentRound.get(); } /* (non-Javadoc) @@ -1272,7 +1283,7 @@ */ public void setCurrentPlayer(Player player) { // transfer messages for the next player to the display buffer - if ((Player)currentPlayer.getObject() != player && !nextPlayerMessages.isEmpty()) { + if ((Player)currentPlayer.get() != player && !nextPlayerMessages.isEmpty()) { DisplayBuffer.add( LocalText.getText("NextPlayerMessage", getCurrentPlayer().getName())); for (String s:nextPlayerMessages) @@ -1305,14 +1316,14 @@ * @see rails.game.GameManagerI#getPriorityPlayer() */ public Player getPriorityPlayer() { - return (Player) priorityPlayer.getObject(); + return (Player) priorityPlayer.get(); } /* (non-Javadoc) * @see rails.game.GameManagerI#getCurrentPlayer() */ public Player getCurrentPlayer() { - return (Player) currentPlayer.getObject(); + return (Player) currentPlayer.get(); } /* (non-Javadoc) Modified: trunk/18xx/rails/game/GameManagerI.java =================================================================== --- trunk/18xx/rails/game/GameManagerI.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/GameManagerI.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -41,8 +41,8 @@ public abstract int getSRNumber(); - public abstract void startShareSellingRound(Player sellingPlayer, - int cashToRaise, PublicCompanyI unsellableCompany); + public abstract void startShareSellingRound(Player player, int cashToRaise, + PublicCompanyI cashNeedingCompany, boolean checkDumpOtherCompanies); public abstract void startTreasuryShareTradingRound(); Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-08-18 22:03:00 UTC (rev 1394) +++ trunk/18xx/rails/game/OperatingRound.java 2010-08-21 06:49:48 UTC (rev 1395) @@ -10,6 +10,7 @@ import rails.game.move.CashMove; import rails.game.move.MapChange; import rails.game.special.*; +import rails.game.state.ArrayListState; import rails.game.state.EnumState; import rails.game.state.GenericState; import rails.util.LocalText; @@ -33,13 +34,14 @@ protected List<PublicCompanyI> companiesOperatedThisRound = new ArrayList<PublicCompanyI> (); - protected List<PublicCompanyI> operatingCompanies; + protected ArrayListState<PublicCompanyI> operatingCompanies; //protected IntegerState operatingCompanyIndexObject; - protected GenericState<PublicCompanyI> operatingCompanyObject; - protected PublicCompanyI operatingCompany = null; - + protected GenericState<PublicCompanyI> operatingCompany; + // do not use a operatingCompany.getObject() as reference + // protected PublicCompanyI operatingCompany.getObject() = null; + // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; @@ -95,7 +97,7 @@ public OperatingRound(GameManagerI gameManager) { super (gameManager); - operatingCompanies = setOperatingCompanies(); + operatingCompanies = new ArrayListState<PublicCompanyI>("operatingCompanies", setOperatingCompanies()); // sfy NoMapMode noMapMode = GameOption.convertValueToBoolean(getGameOption("NoMapMode")); @@ -116,7 +118,7 @@ if (operatingCompanies.size() > 0) { StringBuilder msg = new StringBuilder(); - for (PublicCompanyI company : operatingCompanies) { + for (PublicCompanyI company : operatingCompanies.viewList()) { msg.append(",").append(company.getName()); } if (msg.length() > 0) msg.deleteCharAt(0); @@ -173,10 +175,10 @@ if (action instanceof PossibleORAction && !(action instanceof DiscardTrain)) { PublicCompanyI company = ((PossibleORAction) action).getCompany(); - if (company != operatingCompany) { + if (company != operatingCompany.get()) { DisplayBuffer.add(LocalText.getText("WrongCompany", company.getName(), - operatingCompany.getName() )); + operatingCompany.get().getName() )); return false; } } @@ -289,11 +291,11 @@ while (true) { // Checks // Must be correct company. - if (!companyName.equals(operatingCompany.getName())) { + if (!companyName.equals(operatingCompany.get().getName())) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // Must be correct step @@ -368,11 +370,11 @@ break; } // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost) ); break; } @@ -393,8 +395,8 @@ if (tile != null) { if (cost > 0) - new CashMove(operatingCompany, bank, cost); - operatingCompany.layTile(hex, tile, orientation, cost); + new CashMove(operatingCompany.get(), bank, cost); + operatingCompany.get().layTile(hex, tile, orientation, cost); if (cost == 0) { ReportBuffer.add(LocalText.getText("LaysTileAt", @@ -503,7 +505,7 @@ MapHex hex = action.getChosenHex(); int station = action.getChosenStation(); - String companyName = operatingCompany.getName(); + String companyName = operatingCompany.get().getName(); // TEMPORARY FIX to enable fixing invalidated saved files //if ("N11".equals(hex.getName()) && station == 2) { @@ -523,12 +525,12 @@ break; } - if (operatingCompany.getNumberOfFreeBaseTokens() == 0) { + if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { errMsg = LocalText.getText("HasNoTokensLeft", companyName); break; } - if (!isTokenLayAllowed (operatingCompany, hex, station)) { + if (!isTokenLayAllowed (operatingCompany.get(), hex, station)) { errMsg = LocalText.getText("BaseTokenSlotIsReserved"); break; } @@ -543,7 +545,7 @@ * cities on one tile may hold tokens of the same company; this case * is not yet covered. */ - if (hex.hasTokenOfCompany(operatingCompany)) { + if (hex.hasTokenOfCompany(operatingCompany.get())) { errMsg = LocalText.getText("TileAlreadyHasToken", hex.getName(), @@ -565,14 +567,14 @@ if (stl != null) extra = stl.isExtra(); } - cost = operatingCompany.getBaseTokenLayCost(hex); + cost = operatingCompany.get().getBaseTokenLayCost(hex); if (stl != null && stl.isFree()) cost = 0; // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost)); break; } @@ -590,10 +592,10 @@ /* End of validation, start of execution */ moveStack.start(true); - if (hex.layBaseToken(operatingCompany, station)) { + if (hex.layBaseToken(operatingCompany.get(), station)) { /* TODO: the false return value must be impossible. */ - operatingCompany.layBaseToken(hex, cost); + operatingCompany.get().layBaseToken(hex, cost); // If this is a home base token lay, stop here if (action.getType() == LayBaseToken.HOME_CITY) { @@ -601,7 +603,7 @@ } if (cost > 0) { - new CashMove(operatingCompany, bank, cost); + new CashMove(operatingCompany.get(), bank, cost); ReportBuffer.add(LocalText.getText("LAYS_TOKEN_ON", companyName, hex.getName(), @@ -631,7 +633,7 @@ if (currentNormalTokenLays.isEmpty()) { log.debug("No more normal token lays are allowed"); - } else if (operatingCompany.getNumberOfFreeBaseTokens() == 0) { + } else if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { log.debug("Normal token lay allowed by no more tokens"); currentNormalTokenLays.clear(); } else { @@ -680,10 +682,10 @@ if (stl != null && stl.isFree()) cost = 0; // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", - operatingCompany.getName()); + operatingCompany.get().getName()); break; } break; @@ -703,13 +705,13 @@ if (hex.layBonusToken(token, gameManager.getPhaseManager())) { /* TODO: the false return value must be impossible. */ - operatingCompany.addBonus(new Bonus(operatingCompany, + operatingCompany.get().addBonus(new Bonus(operatingCompany.get(), token.getName(), token.getValue(), Collections.singletonList(hex))); - token.setUser(operatingCompany); + token.setUser(operatingCompany.get()); ReportBuffer.add(LocalText.getText("LaysBonusTokenOn", - operatingCompany.getName(), + operatingCompany.get().getName(), token.getName(), Bank.format(token.getValue()), hex.getName() )); @@ -744,11 +746,11 @@ seller = sbt.getSeller(); // Does the company have the money? - if (cost > operatingCompany.getCash()) { + if (cost > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", - operatingCompany.getName(), - Bank.format(operatingCompany.getCash()), + operatingCompany.get().getName(), + Bank.format(operatingCompany.get().getCash()), Bank.format(cost)); break; } @@ -756,7 +758,7 @@ } if (errMsg != null) { DisplayBuffer.add(LocalText.getText("CannotBuyBonusToken", - operatingCompany.getName(), + operatingCompany.get().getName(), sbt.getName(), seller.getName(), Bank.format(cost), @@ -767,14 +769,14 @@ /* End of validation, start of execution */ moveStack.start(true); - new CashMove (operatingCompany, seller, cost); - operatingCompany.addBonus(new Bonus(operatingCompany, + new CashMove (operatingCompany.get(), seller, cost); + operatingCompany.get().addBonus(new Bonus(operatingCompany.get(), sbt.getName(), sbt.getValue(), sbt.getLocations())); ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom", - operatingCompany.getName(), + operatingCompany.get().getName(), sbt.getName(), Bank.format(sbt.getValue()), seller.getName(), @@ -834,11 +836,11 @@ // Must be correct company. company = action.getCompany(); companyName = company.getName(); - if (company != operatingCompany) { + if (company != operatingCompany.get()) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // Must be correct step @@ -894,9 +896,9 @@ action.setRevenueAllocation(SetDividend.WITHHOLD); } - if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { + if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(0) )); } @@ -911,12 +913,12 @@ int amount = action.getActualRevenue(); int revenueAllocation = action.getRevenueAllocation(); - operatingCompany.setLastRevenue(amount); - operatingCompany.setLastRevenueAllocation(revenueAllocation); + operatingCompany.get().setLastRevenue(amount); + operatingCompany.get().setLastRevenueAllocation(revenueAllocation); - if (amount == 0 && operatingCompany.getNumberOfTrains() == 0) { + if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) { DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(0) )); } @@ -927,27 +929,27 @@ if (amount == 0) { ReportBuffer.add(LocalText.getText("CompanyDoesNotPayDividend", - operatingCompany.getName())); + operatingCompany.get().getName())); withhold(amount); } else if (revenueAllocation == SetDividend.PAYOUT) { ReportBuffer.add(LocalText.getText("CompanyPaysOutFull", - operatingCompany.getName(), Bank.format(amount) )); + operatingCompany.get().getName(), Bank.format(amount) )); payout(amount); } else if (revenueAllocation == SetDividend.SPLIT) { ReportBuffer.add(LocalText.getText("CompanySplits", - operatingCompany.getName(), Bank.format(amount) )); + operatingCompany.get().getName(), Bank.format(amount) )); splitRevenue(amount); } else if (revenueAllocation == SetDividend.WITHHOLD) { ReportBuffer.add(LocalText.getText("CompanyWithholds", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); withhold(amount); @@ -955,7 +957,7 @@ } // Rust any obsolete trains - operatingCompany.getPortfolio().rustObsoleteTrains(); + operatingCompany.get().getPortfolio().rustObsoleteTrains(); // We have done the payout step, so continue from there nextStep(GameDef.OrStep.PAYOUT); @@ -983,17 +985,17 @@ if (recipient instanceof Bank) continue; shares = (sharesPerRecipient.get(recipient)); if (shares == 0) continue; - part = (int) Math.ceil(amount * shares * operatingCompany.getShareUnit() / 100.0); + part = (int) Math.ceil(amount * shares * operatingCompany.get().getShareUnit() / 100.0); ReportBuffer.add(LocalText.getText("Payout", recipient.getName(), Bank.format(part), shares, - operatingCompany.getShareUnit())); + operatingCompany.get().getShareUnit())); new CashMove(bank, recipient, part); } // Move the token - operatingCompany.payout(amount); + operatingCompany.get().payout(amount); } @@ -1006,7 +1008,7 @@ // (the withheld half of split revenues is not handled here, see splitRevenue()). // First count the shares per recipient - for (PublicCertificateI cert : operatingCompany.getCertificates()) { + for (PublicCertificateI cert : operatingCompany.get().getCertificates()) { CashHolder recipient = getBeneficiary(cert); if (!sharesPerRecipient.containsKey(recipient)) { sharesPerRecipient.put(recipient, cert.getShares()); @@ -1024,8 +1026,8 @@ Portfolio holder = cert.getPortfolio(); CashHolder beneficiary = holder.getOwner(); // Special cases apply if the holder is the IPO or the Pool - if (operatingCompany.paysOutToTreasury(cert)) { - beneficiary = operatingCompany; + if (operatingCompany.get().paysOutToTreasury(cert)) { + beneficiary = operatingCompany.get(); } return beneficiary; } @@ -1036,9 +1038,9 @@ * @param The revenue amount. */ public void withhold(int amount) { - if (amount > 0) new CashMove(bank, operatingCompany, amount); + if (amount > 0) new CashMove(bank, operatingCompany.get(), amount); // Move the token - operatingCompany.withhold(amount); + operatingCompany.get().withhold(amount); } /** Split a dividend. TODO Optional rounding down the payout @@ -1050,11 +1052,11 @@ if (amount > 0) { // Withhold half of it // For now, hardcode the rule that payout is rounded up. - int numberOfShares = operatingCompany.getNumberOfShares(); + int numberOfShares = operatingCompany.get().getNumberOfShares(); int withheld = (amount / (2 * numberOfShares)) * numberOfShares; - new CashMove(bank, operatingCompany, withheld); - ReportBuffer.add(operatingCompany.getName() + " receives " + Bank.format(withheld)); + new CashMove(bank, operatingCompany.get(), withheld); + ReportBuffer.add(operatingCompany.get().getName() + " receives " + Bank.format(withheld)); // Payout the remainder int payed = amount - withheld; @@ -1084,24 +1086,24 @@ while (true) { // Must be correct company. - if (!companyName.equals(operatingCompany.getName())) { + if (!companyName.equals(operatingCompany.get().getName())) { errMsg = LocalText.getText("WrongCompany", companyName, - operatingCompany.getName() ); + operatingCompany.get().getName() ); break; } // amount is available - if ((amount + operatingCompany.getCash()) < 0) { + if ((amount + operatingCompany.get().getCash()) < 0) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(amount) ); break; } - if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN && operatingCompany.getNumberOfFreeBaseTokens() == 0) { + if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN && operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { errMsg = LocalText.getText("HasNoTokensLeft", companyName); break; @@ -1120,30 +1122,30 @@ if (amount > 0) { // positive amounts: remove cash from cashholder - new CashMove(operatingCompany, bank, amount); + new CashMove(operatingCompany.get(), bank, amount); } else if (amount > 0) { // negative amounts: add cash to cashholder - new CashMove(bank, operatingCompany, -amount); + new CashMove(bank, operatingCompany.get(), -amount); } if (typeOC == OperatingCost.OCType.LAY_TILE) { - operatingCompany.layTileInNoMapMode(amount); + operatingCompany.get().layTileInNoMapMode(amount); ReportBuffer.add(LocalText.getText("OCLayTileExecuted", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); } if (typeOC == OperatingCost.OCType.LAY_BASE_TOKEN) { // move token to Bank - BaseToken token = operatingCompany.getFreeToken(); + BaseToken token = operatingCompany.get().getFreeToken(); if (token == null) { - log.error("Company " + operatingCompany.getName() + " has no free token"); + log.error("Company " + operatingCompany.get().getName() + " has no free token"); return false; } else { token.moveTo(bank.getUnavailable()); } - operatingCompany.layBaseTokenInNoMapMode(amount); + operatingCompany.get().layBaseTokenInNoMapMode(amount); ReportBuffer.add(LocalText.getText("OCLayBaseTokenExecuted", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(amount) )); } @@ -1196,13 +1198,13 @@ log.debug("Step " + step); if (step == GameDef.OrStep.LAY_TOKEN - && operatingCompany.getNumberOfFreeBaseTokens() == 0) { + && operatingCompany.get().getNumberOfFreeBaseTokens() == 0) { continue; } if (step == GameDef.OrStep.CALC_REVENUE) { - if (!operatingCompany.canRunTrains()) { + if (!operatingCompany.get().canRunTrains()) { // No trains, then the revenue is zero. executeSetRevenueAndDividend ( new SetDividend (0, false, new int[] {SetDividend.WITHHOLD})); @@ -1219,8 +1221,8 @@ if (step == GameDef.OrStep.TRADE_SHARES) { // Is company allowed to trade trasury shares? - if (!operatingCompany.mayTradeShares() - || !operatingCompany.hasOperated()) { + if (!operatingCompany.get().mayTradeShares() + || !operatingCompany.get().hasOperated()) { continue; } @@ -1248,23 +1250,23 @@ } protected void initTurn() { - log.debug("Starting turn of "+operatingCompany.getName()); + log.debug("Starting turn of "+operatingCompany.get().getName()); ReportBuffer.add(LocalText.getText("CompanyOperates", - operatingCompany.getName(), - operatingCompany.getPresident().getName())); - setCurrentPlayer(operatingCompany.getPresident()); + operatingCompany.get().getName(), + operatingCompany.get().getPresident().getName())); + setCurrentPlayer(operatingCompany.get().getPresident()); - if (noMapMode && !operatingCompany.hasLaidHomeBaseTokens()){ + if (noMapMode && !operatingCompany.get().hasLaidHomeBaseTokens()){ // Lay base token in noMapMode - BaseToken token = operatingCompany.getFreeToken(); + BaseToken token = operatingCompany.get().getFreeToken(); if (token == null) { - log.error("Company " + operatingCompany.getName() + " has no free token to lay base token"); + log.error("Company " + operatingCompany.get().getName() + " has no free token to lay base token"); } else { - log.debug("Company " + operatingCompany.getName() + " lays base token in nomap mode"); + log.debug("Company " + operatingCompany.get().getName() + " lays base token in nomap mode"); token.moveTo(bank.getUnavailable()); } } - operatingCompany.initTurn(); + operatingCompany.get().initTurn(); trainsBoughtThisTurn.clear(); } @@ -1288,11 +1290,11 @@ protected <T extends SpecialPropertyI> List<T> getSpecialProperties( Class<T> clazz) { List<T> specialProperties = new ArrayList<T>(); - if (!operatingCompany.isClosed()) { + if (!operatingCompany.get().isClosed()) { // OC may have closed itself (e.g. in 1835 when M2 buys 1st 4T and starts PR) - specialProperties.addAll(operatingCompany.getPortfolio().getSpecialProperties( + specialProperties.addAll(operatingCompany.get().getPortfolio().getSpecialProperties( clazz, false)); - specialProperties.addAll(operatingCompany.getPresident().getPortfolio().getSpecialProperties( + specialProperties.addAll(operatingCompany.get().getPresident().getPortfolio().getSpecialProperties( clazz, false)); } return specialProperties; @@ -1311,9 +1313,9 @@ int allowedNumber; for (String colour : tileLaysPerColour.keySet()) { - allowedNumber = operatingCompany.getNumberOfTileLays(colour); + allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); // Replace the null map value with the allowed number of lays - tileLaysPerColour.put(colour, new Integer(allowedNumber)); + new MapChange<String, Integer>(tileLaysPerColour, colour, new Integer(allowedNumber)); } // store state @@ -1346,7 +1348,7 @@ /* Special-property tile lays */ currentSpecialTileLays.clear(); - if (!operatingCompany.canUseSpecialProperties()) return; + if (!operatingCompany.get().canUseSpecialProperties()) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { if (stl.isExtra() || !currentNormalTileLays.isEmpty()) { @@ -1365,7 +1367,7 @@ currentNormalTokenLays.clear(); /* For now, we allow one token of the currently operating company */ - if (operatingCompany.getNumberOfFreeBaseTokens() > 0) { + if (operatingCompany.get().getNumberOfFreeBaseTokens() > 0) { currentNormalTokenLays.add(new LayBaseToken((List<MapHex>) null)); } @@ -1382,13 +1384,13 @@ /* Special-property tile lays */ currentSpecialTokenLays.clear(); - if (!operatingCompany.canUseSpecialProperties()) return; + if (!operatingCompany.get().canUseSpecialProperties()) return; /* * In 1835, this only applies to major companies. TODO: For now, * hardcode this, but it must become configurable later. */ - if (operatingCompany.getType().getName().equals("Minor")) return; + if (operatingCompany.get().getType().getName().equals("Minor")) return; for (SpecialTokenLay stl : getSpecialProperties(SpecialTokenLay.class)) { log.debug("Spec.prop:" + stl); @@ -1443,14 +1445,14 @@ */ public boolean done() { - if (operatingCompany.getPortfolio().getNumberOfTrains() == 0 - && operatingCompany.mustOwnATrain()) { + if (operatingCompany.get().getPortfolio().getNumberOfTrains() == 0 + && operatingCompany.get().mustOwnATrain()) { // FIXME: Need to check for valid route before throwing an // error. /* Check TEMPORARILY disabled errMsg = LocalText.getText("CompanyMustOwnATrain", - operatingCompany.getName()); + operatingCompany.getObject().getName()); setStep(STEP_BUY_TRAIN); DisplayBuffer.add(errMsg); return false; @@ -1470,14 +1472,14 @@ protected void finishTurn() { - if (!operatingCompany.isClosed()) { - operatingCompany.setOperated(); - companiesOperatedThisRound.add(operatingCompany); + if (!operatingCompany.get().isClosed()) { + operatingCompany.get().setOperated(); + companiesOperatedThisRound.add(operatingCompany.get()); // Check if any privates must be closed (now only applies to 1856 W&SR) // Copy list first to avoid concurrent modifications for (PrivateCompanyI priv : - new ArrayList<PrivateCompanyI> (operatingCompany.getPortfolio().getPrivateCompanies())) { + new ArrayList<PrivateCompanyI> (operatingCompany.get().getPortfolio().getPrivateCompanies())) { priv.checkClosingIfExercised(true); } } @@ -1503,31 +1505,30 @@ protected boolean setNextOperatingCompany(boolean initial) { while (true) { - if (initial || operatingCompany == null || operatingCompanyObject == null) { + if (initial || operatingCompany.get() == null || operatingCompany == null) { setOperatingCompany(operatingCompanies.get(0)); initial = false; } else { - int index = operatingCompanies.indexOf(operatingCompany); + int index = operatingCompanies.indexOf(operatingCompany.get()); if (++index >= operatingCompanies.size()) { return false; } setOperatingCompany(operatingCompanies.get(index)); } - if (operatingCompany.isClosed()) continue; + if (operatingCompany.get().isClosed()) continue; return true; } } protected void setOperatingCompany (PublicCompanyI company) { - if (operatingCompanyObject == null) { - operatingCompanyObject = - new GenericState<PublicCompanyI>("OperatingCompanyIndex", company); + if (operatingCompany == null) { + operatingCompany = + new GenericState<PublicCompanyI>("OperatingCompany", company); } else { - operatingCompanyObject.set(company); + operatingCompany.set(company); } - operatingCompany = company; } protected void finishOR() { @@ -1557,7 +1558,7 @@ int price = action.getPricePaid(); int actualPresidentCash = 0; int cashToBeRaisedByPresident = 0; - Player currentPlayer = operatingCompany.getPresident(); + Player currentPlayer = operatingCompany.get().getPresident(); // Dummy loop to enable a quick jump out. while (true) { @@ -1590,7 +1591,7 @@ } // Does the company have room for another train? - int trainLimit = operatingCompany.getCurrentTrainLimit(); + int trainLimit = operatingCompany.get().getCurrentTrainLimit(); if (!canBuyTrainNow() && !action.isForExchange()) { errMsg = LocalText.getText("WouldExceedTrainLimit", @@ -1611,7 +1612,7 @@ } } else if (action.mayPresidentAddCash()) { // From another company - presidentCash = price - operatingCompany.getCash(); + presidentCash = price - operatingCompany.get().getCash(); if (presidentCash > action.getPresidentCashToAdd()) { errMsg = LocalText.getText("PresidentMayNotAddMoreThan", @@ -1627,11 +1628,11 @@ } else { // No forced buy - does the company have the money? - if (price > operatingCompany.getCash()) { + if (price > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", companyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(price) ); break; } @@ -1641,12 +1642,12 @@ if (exchangedTrain == null) { errMsg = LocalText.getText("NoExchangedTrainSpecified"); // TEMPORARY FIX to clean up invalidated saved files - DOES NOT WORK!!?? - //exchangedTrain = operatingCompany.getPortfolio().getTrainList().get(0); + //exchangedTrain = operatingCompany.getObject().getPortfolio().getTrainList().get(0); //action.setExchangedTrain(exchangedTrain); break; - } else if (operatingCompany.getPortfolio().getTrainOfType(exchangedTrain.getType()) == null) { + } else if (operatingCompany.get().getPortfolio().getTrainOfType(exchangedTrain.getType()) == null) { errMsg = LocalText.getText("CompanyDoesNotOwnTrain", - operatingCompany.getName(), + operatingCompany.get().getName(), exchangedTrain.getName()); break; } @@ -1674,21 +1675,21 @@ if (presidentMustSellShares) { savedAction = action; - gameManager.startShareSellingRound(operatingCompany.getPresident(), - cashToBeRaisedByPresident, operatingCompany); + gameManager.startShareSellingRound(operatingCompany.get().getPresident(), + cashToBeRaisedByPresident, operatingCompany.get(), true); return true; } if (actualPresidentCash > 0) { - new CashMove(currentPlayer, operatingCompany, presidentCash); + new CashMove(currentPlayer, operatingCompany.get(), presidentCash); } Portfolio oldHolder = train.getHolder(); if (exchangedTrain != null) { TrainI oldTrain = - operatingCompany.getPortfolio().getTrainOfType( + operatingCompany.get().getPortfolio().getTrainOfType( exchangedTrain.getType()); pool.buyTrain(oldTrain, 0); ReportBuffer.add(LocalText.getText("ExchangesTrain", @@ -1712,7 +1713,7 @@ stb.getOriginalCompany().getName() )); } - operatingCompany.buyTrain(train, price); + operatingCompany.get().buyTrain(train, price); if (oldHolder == ipo) { train.getType().addToBoughtFromIPO(); // Clone the train if infinitely available @@ -1748,7 +1749,7 @@ excessTrainCompanies = new HashMap<Player, List<PublicCompanyI>>(); Player player; - for (PublicCompanyI comp : operatingCompanies) { + for (PublicCompanyI comp : operatingCompanies.viewList()) { if (comp.getPortfolio().getNumberOfTrains() > comp.getTrainLimit(getCurrentPhase().getIndex())) { player = comp.getPresident(); if (!excessTrainCompanies.containsKey(player)) { @@ -1901,29 +1902,29 @@ // Price must be in the allowed range if (price < basePrice - * operatingCompany.getLowerPrivatePriceFactor()) { + * operatingCompany.get().getLowerPrivatePriceFactor()) { errMsg = LocalText.getText("PriceBelowLowerLimit", Bank.format(price), - Bank.format((int) (basePrice * operatingCompany.getLowerPrivatePriceFactor())), + Bank.format((int) (basePrice * operatingCompany.get().getLowerPrivatePriceFactor())), privateCompanyName ); break; } if (price > basePrice - * operatingCompany.getUpperPrivatePriceFactor()) { + * operatingCompany.get().getUpperPrivatePriceFactor()) { errMsg = LocalText.getText("PriceAboveUpperLimit", Bank.format(price), - Bank.format((int) (basePrice * operatingCompany.getUpperPrivatePriceFactor())), + Bank.format((int) (basePrice * operatingCompany.get().getUpperPrivatePriceFactor())), privateCompanyName ); break; } // Does the company have the money? - if (price > operatingCompany.getCash()) { + if (price > operatingCompany.get().getCash()) { errMsg = LocalText.getText("NotEnoughMoney", publicCompanyName, - Bank.format(operatingCompany.getCash()), + Bank.format(operatingCompany.get().getCash()), Bank.format(price) ); break; } @@ -1949,7 +1950,7 @@ moveStack.start(true); - operatingCompany.buyPrivate(privateCompany, player.getPortfolio(), + operatingCompany.get().buyPrivate(privateCompany, player.getPortfolio(), price); return true; @@ -2013,7 +2014,7 @@ // Checks // Is company operating? - if (company != operatingCompany) { + if (company != operatingCompany.get()) { errMsg = LocalText.getText("WrongCompany", companyName, @@ -2046,32 +2047,32 @@ int number = action.getNumberTaken(); int amount = calculateLoanAmount (number); - operatingCompany.addLoans(number); - new CashMove (bank, operatingCompany, amount); + operatingCompany.get().addLoans(number); + new CashMove (bank, operatingCompany.get(), amount); if (number == 1) { ReportBuffer.add(LocalText.getText("CompanyTakesLoan", - operatingCompany.getName(), - Bank.format(operatingCompany.getValuePerLoan()), + operatingCompany.get().getName(), + Bank.format(operatingCompany.get().getValuePerLoan()), Bank.format(amount) )); } else { ReportBuffer.add(LocalText.getText("CompanyTakesLoans", - operatingCompany.getName(), + operatingCompany.get().getName(), number, - Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(operatingCompany.get().getValuePerLoan()), Bank.format(amount) )); } - if (operatingCompany.getMaxLoansPerRound() > 0) { + if (operatingCompany.get().getMaxLoansPerRound() > 0) { int oldLoansThisRound = 0; if (loansThisRound == null) { loansThisRound = new HashMap<PublicCompanyI, Integer>(); - } else if (loansThisRound.containsKey(operatingCompany)){ - oldLoansThisRound = loansThisRound.get(operatingCompany); + } else if (loansThisRound.containsKey(operatingCompany.get())){ + oldLoansThisRound = loansThisRound.get(operatingCompany.get()); } new MapChange<PublicCompanyI, Integer> (loansThisRound, - operatingCompany, + operatingCompany.get(), new Integer (oldLoansThisRound + number)); } } @@ -2099,11 +2100,11 @@ return false; } - int repayment = action.getNumberRepaid() * operatingCompany.getValuePerLoan(); - if (repayment > 0 && repayment > operatingCompany.getCash()) { + int repayment = action.getNumberRepaid() * operatingCompany.get().getValuePerLoan(); + if (repayment > 0 && repayment > operatingCompany.get().getCash()) { // President must contribute - int remainder = repayment - operatingCompany.getCash(); - Player president = operatingCompany.getPresident(); + int remainder = repayment - operatingCompany.get().getCash(); + Player president = operatingCompany.get().getPresident(); int presCash = president.getCash(); if (remainder > presCash) { // Start a share selling round @@ -2113,8 +2114,8 @@ log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added"); savedAction = action; moveStack.start(true); - gameManager.startShareSellingRound(operatingCompany.getPresident(), - cashToBeRaisedByPresident, operatingCompany); + gameManager.startShareSellingRound(operatingCompany.get().getPresident(), + cashToBeRaisedByPresident, operatingCompany.get(), false); return true; } } @@ -2139,37 +2140,37 @@ int payment; int remainder = 0; - operatingCompany.addLoans(-number); - int amount = number * operatingCompany.getValuePerLoan(); - payment = Math.min(amount, operatingCompany.getCash()); + operatingCompany.get().addLoans(-number); + int amount = number * operatingCompany.get().getValuePerLoan(); + payment = Math.min(amount, operatingCompany.get().getCash()); remainder = amount - payment; if (payment > 0) { - new CashMove (operatingCompany, bank, payment); + new CashMove (operatingCompany.get(), bank, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoans", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(payment), Bank.format(amount), number, - Bank.format(operatingCompany.getValuePerLoan()))); + Bank.format(operatingCompany.get().getValuePerLoan()))); } if (remainder > 0) { - Player president = operatingCompany.getPresident(); + Player president = operatingCompany.get().getPresident(); if (president.getCash() >= remainder) { payment = remainder; new CashMove (president, bank, payment); ReportBuffer.add (LocalText.getText("CompanyRepaysLoansWithPresCash", - operatingCompany.getName(), + operatingCompany.get().getName(), Bank.format(payment), Bank.format(amount), number, - Bank.format(operatingCompany.getValuePerLoan()), + Bank.format(operatingCompany.get().getValuePerLoan()), president.getName())); } } } protected int calculateLoanAmount (int numberOfLoans) { - return numberOfLoans * operatingCompany.getValuePerLoan(); + return numberOfLoans * operatingCompany.get().getValuePerLoan(); } /*----- METHODS TO BE CALLED TO SET UP THE NEXT TURN -----*/ @@ -2180,11 +2181,11 @@ * @return The currently operating company object. */ public PublicCompanyI getOperatingCompany() { - return operatingCompanyObject.getObject(); + return operatingCompany.get(); } public List<PublicCompanyI> getOperatingCompanies() { - return operatingCompanies; + return operatingCompanies.viewList(); } /** @@ -2193,7 +2194,7 @@ * @return The number that defines the next action. */ public GameDef.OrStep getStep() { - return (GameDef.OrStep) stepObject.getObject(); + return (GameDef.OrStep) stepObject.get(); } /** @@ -2222,8 +2223,6 @@ @Override public boolean setPossibleActions() { - operatingCompany = getOperatingCompany(); - /* Create a new list of possible actions for the UI */ possibleActions.clear(); selectedAction = null; @@ -2244,10 +2243,10 @@ GameDef.OrStep step = getStep(); if (step == GameDef.OrStep.LAY_TRACK) { - if (!operatingCompany.hasLaidHomeBaseTokens()) { + if (!operatingCompany.get().hasLaidHomeBaseTokens()) { // This can occur if the home hex has two cities and track, // such as the green OO tile #59 - possibleActions.add(new LayBaseToken (operatingCompany.getHomeHex())); + possibleActions.add(new LayBaseToken (operatingCompany.get().getHomeHex())); forced = true; } else { setNormalTileLays(); @@ -2277,11 +2276,11 @@ setBuyableTrains(); // TODO Need route checking here. // TEMPORARILY allow not buying a train if none owned - //if (!operatingCompany.mustOwnATrain() - // || operatingCompany.getPortfolio().getNumberOfTrains() > 0) { + //if (!operatingCompany.getObject().mustOwnATrain() + // || operatingCompany.getObject().getPortfolio().getNumberOfTrains() > 0) { doneAllowed = true; //} - if (noMapMode && (operatingCompany.getLastRevenue() == 0)) + if (noMapMode && (operatingCompany.get().getLastRevenue() == 0)) prepareNoMapActions(); } else if (step == GameDef.OrStep.DISCARD_TRAINS) { @@ -2310,7 +2309,7 @@ if (getCurrentPhase().isPrivateSellingAllowed()) { // Create a list of players with the current one in front - int currentPlayerIndex = operatingCompany.getPresident().getIndex(); + int currentPlayerIndex = operatingCompany.get().getPresident().getIndex(); Player player; int minPrice, maxPrice; List<Player> players = getPlayers(); @@ -2321,16 +2320,16 @@ for (PrivateCompanyI privComp : player.getPortfolio().getPrivateCompanies()) { minPrice = - (int) (privComp.getBasePrice() * operatingCompany.getLowerPrivatePriceFactor()); + (int) (privComp.getBasePrice() * operatingCompany.get().getLowerPrivatePriceFactor()); maxPrice = - (int) (privComp.getBasePrice() * operatingCompany.getUpperPrivatePriceFactor()); + (int) (privComp.getBasePrice() * operatingCompany.get().getUpperPrivatePriceFactor()); possibleActions.add(new BuyPrivate(privComp, minPrice, maxPrice)); } } } - if (operatingCompany.canUseSpecialProperties()) { + if (operatingCompany.get().canUseSpecialProperties()) { // Are there any "common" special properties, // i.e. properties that are available to everyone? @@ -2341,8 +2340,8 @@ if (sp instanceof SellBonusToken) { sbt = (SellBonusToken) sp; // Can't buy if already owned - if (operatingCompany.getBonuses() != null) { - for (Bonus bonus : operatingCompany.getBonuses()) { + if (operatingCompany.get().getBonuses() != null) { + for (Bonus bonus : operatingCompany.get().getBonuses()) { if (bonus.getName().equals(sp.getName())) continue loop; } } @@ -2352,7 +2351,7 @@ } // Are there other step-independent special properties owned by the company? - List<SpecialPropertyI> orsps = operatingCompany.getPortfolio().getAllSpecialProperties(); + List<SpecialPropertyI> orsps = operatingCompany.get().getPortfolio().getAllSpecialProperties(); if (orsps != null) { for (SpecialPropertyI sp : orsps) { if (!sp.isExercised() && sp.isUsableIfOwnedByCompany() @@ -2392,7 +2391,7 @@ for (PossibleAction pa : possibleActions.getList()) { try { - log.debug(operatingCompany.getName() + " may: " + pa.toString()); + log.debug(operatingCompany.get().getName() + " may: " + pa.toString()); } catch (Exception e) { log.error("Error in toString() of " + pa.getClass(), e); } @@ -2404,11 +2403,11 @@ protected void prepareRevenueAndDividendAction () { // There is only revenue if there are any trains - if (operatingCompany.canRunTrains()) { + if (operatingCompany.get().canRunTrains()) { int[] allowedRevenueActions = - operatingCompany.isSplitAlways() + operatingCompany.get().isSplitAlways() ? new int[] { SetDividend.SPLIT } - : operatingCompany.isSplitAllowed() + : operatingCompany.get().isSplitAllowed() ? new int[] { SetDividend.PAYOUT, SetDividend.SPLIT, SetDividend.WITHHOLD } @@ -2416,7 +2415,7 @@ SetDividend.WITHHOLD }; possibleActions.add(new SetDividend( - operatingCompany.getLastRevenue(), true, + operatingCompany.get().getLastRevenue(), true, allowedRevenueActions)); } } @@ -2425,13 +2424,13 @@ // LayTile Actions for (Integer tc: mapManager.getPossibleTileCosts()) { - if (tc <= operatingCompany.getCash()) + if (tc <= operatingCompany.get().getCash()) possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_TILE, tc, false)); } // LayBaseToken Actions - if (operatingCompany.getNumberOfFreeBaseTokens() != 0) { - int[] costsArray = operatingCompany.getBaseTokenLayCosts(); + if (operatingCompany.get().getNumberOfFreeBaseTokens() != 0) { + int[] costsArray = operatingCompany.get().getBaseTokenLayCosts(); // change to set to allow for identity and ordering Set<Integer> costsSet = new TreeSet<Integer>(); @@ -2447,7 +2446,7 @@ } for (int cost : costsSet) { - if (cost <= operatingCompany.getCash()) // distance method returns home base, but in sequence costsSet can be zero + if (cost <= operatingCompany.get().getCash()) // distance method returns home base, but in sequence costsSet can be zero possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, cost, false)); } } @@ -2456,8 +2455,8 @@ // possibleActions.add(new OperatingCost( // OperatingCost.OCType.LAY_TILE, 0, true // )); - // if (operatingCompany.getNumberOfFreeBaseTokens() != 0 - // && operatingCompany.getBaseTokenLayCost(null) != 0) { + // if (operatingCompany.getObject().getNumberOfFreeBaseTokens() != 0 + // && operatingCompany.getObject().getBaseTokenLayCost(null) != 0) { // possibleActions.add(new OperatingCost(OperatingCost.OCType.LAY_BASE_TOKEN, 0, true)); // } @@ -2470,18 +2469,18 @@ */ public void setBuyableTrains() { - if (operatingCompany == null) return; + if (operatingCompany.get() == null) return; TrainManager trainMgr = gameManager.getTrainManager(); - int cash = operatingCompany.getCash(); + int cash = operatingCompany.get().getCash(); int cost; List<TrainI> trains; boolean hasTrains = - operatingCompany.getPortfolio().getNumberOfTrains() > 0; + operatingCompany.get().getPortfolio().getNumberOfTrains() > 0; boolean canBuyTrainNow = canBuyTrainNow(); - boolean presidentMayHelp = !hasTrains && operatingCompany.mustOwnATrain(); + boolean presidentMayHelp = !hasTrains && operatingCompany.get().mustOwnATrain(); TrainI cheapestTrain = null; int costOfCheapestTrain = 0; @@ -2495,7 +2494,7 @@ /* New trains */ trains = trainMgr.getAvailableNewTrains(); for (TrainI train : trains) { - if (!operatingCompany.mayBuyTrainType(train)) continue; + if (!operatingCompany.get().mayBuyTrainType(train)) continue; if (!mayBuyMoreOfEachType && trainsBoughtThisTurn.contains(train.getType())) { continue; @@ -2517,7 +2516,7 @@ cost = train.getType().getExchangeCost(); if (cost <= cash) { ... [truncated message content] |
From: <ev...@us...> - 2010-08-21 19:36:52
|
Revision: 1398 http://rails.svn.sourceforge.net/rails/?rev=1398&view=rev Author: evos Date: 2010-08-21 19:36:46 +0000 (Sat, 21 Aug 2010) Log Message: ----------- Fixed: 18EU FMER did not start correctly if 5-train buyer went bankrupt as prersident of last OR company Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/LocalisedText.properties 2010-08-21 19:36:46 UTC (rev 1398) @@ -125,6 +125,8 @@ ComesWithPresidency=Comes with {0} {1}% presidency certificate Companies=Companies CompanyAlreadyStarted={0} has already been started. +CompanyCloses={0} closes +CompanyClosesAt={0} closes because price token reaches square {1} CompanyDiscardsTrain={0} discards a {1}-train to Pool CompanyDoesNotExist=Company {0} does not exist CompanyDoesNotOwnTrain=Company {0} does not own a {1}-train Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/GameManager.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -356,7 +356,7 @@ if (endOfGameTag != null) { Tag forcedSellingTag = endOfGameTag.getChild("ForcedSelling"); if (forcedSellingTag != null) { - forcedSellingCompanyDump = + forcedSellingCompanyDump = forcedSellingTag.getAttributeAsBoolean("CompanyDump", true); } if (endOfGameTag.getChild("Bankruptcy") != null) { @@ -725,7 +725,7 @@ // check if other companies can be dumped createRound (ShareSellingRound.class, interruptedRound) - .start(player, cashToRaise, cashNeedingCompany, + .start(player, cashToRaise, cashNeedingCompany, !problemDumpOtherCompanies || forcedSellingCompanyDump); // the last parameter indicates if the dump of other companies is allowed, either this is explicit or // the action does not require that check @@ -883,7 +883,7 @@ private boolean processGameActions(GameAction gameAction) { // Process undo/redo centrally boolean result = false; - + int index = gameAction.getmoveStackIndex(); switch (gameAction.getMode()) { case GameAction.SAVE: @@ -916,7 +916,7 @@ return result; } - + /* (non-Javadoc) * @see rails.game.GameManagerI#processOnReload(java.util.List) */ @@ -1132,53 +1132,15 @@ if (gameEndsWithBankruptcy) { finishGame(); } else { - Player player, newPresident; - int numberOfPlayers = getNumberOfPlayers(); - int maxShare; - int share; - - // Assume default case as in 18EU: all assets to Bank/Pool - Player bankrupter = getCurrentPlayer(); - new CashMove (bankrupter, bank, bankrupter.getCash()); - Portfolio bpf = bankrupter.getPortfolio(); - List<PublicCompanyI> presidencies = new ArrayList<PublicCompanyI>(); - for (PublicCertificateI cert : bpf.getCertificates()) { - if (cert.isPresidentShare()) presidencies.add(cert.getCompany()); - } - for (PublicCompanyI company : presidencies) { - // Check if the presidency is dumped on someone - newPresident = null; - maxShare = 0; - for (int index=getCurrentPlayerIndex()+1; - index<getCurrentPlayerIndex()+numberOfPlayers; index++) { - player = getPlayerByIndex(index%numberOfPlayers); - share = player.getPortfolio().getShare(company); - if (share >= company.getPresidentsShare().getShare() - && (share > maxShare)) { - maxShare = share; - newPresident = player; - } - } - if (newPresident != null) { - bankrupter.getPortfolio().swapPresidentCertificate(company, - newPresident.getPortfolio()); - } else { - company.setClosed(); - // TODO: can be restarted (in 18EU) - } - } - // Dump all shares - Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); - - bankrupter.setBankrupt(); - - // Finish the share selling round - if (getCurrentRound() instanceof ShareSellingRound) { - finishShareSellingRound(); - } + processBankruptcy (); } } + protected void processBankruptcy () { + // Currently a stub, don't know if there is any generic handling (EV) + } + + public void registerBrokenBank(){ ReportBuffer.add(LocalText.getText("BankIsBrokenReportText")); String msgContinue; Modified: trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/specific/_18EU/GameManager_18EU.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -1,10 +1,14 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/specific/_18EU/GameManager_18EU.java,v 1.5 2010/01/18 22:51:47 evos Exp $ */ package rails.game.specific._18EU; -import rails.game.GameManager; -import rails.game.Player; -import rails.game.RoundI; +import java.util.ArrayList; +import java.util.List; + +import rails.game.*; +import rails.game.move.CashMove; import rails.game.state.State; +import rails.util.LocalText; +import rails.util.Util; /** * This class manages the playing rounds by supervising all implementations of @@ -12,7 +16,7 @@ */ public class GameManager_18EU extends GameManager { - protected State playerToStartFMERound = + protected State playerToStartFMERound = new State("playerToStartFMERound", Player.class); @Override @@ -20,7 +24,7 @@ if (round instanceof OperatingRound_18EU) { if (playerToStartFMERound.get() != null && relativeORNumber.intValue() == numOfORs.intValue()) { - createRound (FinalMinorExchangeRound.class).start + createRound (FinalMinorExchangeRound.class).start ((Player)playerToStartFMERound.get()); playerToStartFMERound.set(null); } else { @@ -41,7 +45,53 @@ public Player getPlayerToStartFMERound() { return (Player) playerToStartFMERound.get(); } - - + @Override + protected void processBankruptcy () { + Player player, newPresident; + int numberOfPlayers = getNumberOfPlayers(); + int maxShare; + int share; + + // Assume default case as in 18EU: all assets to Bank/Pool + Player bankrupter = getCurrentPlayer(); + new CashMove (bankrupter, bank, bankrupter.getCash()); + Portfolio bpf = bankrupter.getPortfolio(); + List<PublicCompanyI> presidencies = new ArrayList<PublicCompanyI>(); + for (PublicCertificateI cert : bpf.getCertificates()) { + if (cert.isPresidentShare()) presidencies.add(cert.getCompany()); + } + for (PublicCompanyI company : presidencies) { + // Check if the presidency is dumped on someone + newPresident = null; + maxShare = 0; + for (int index=getCurrentPlayerIndex()+1; + index<getCurrentPlayerIndex()+numberOfPlayers; index++) { + player = getPlayerByIndex(index%numberOfPlayers); + share = player.getPortfolio().getShare(company); + if (share >= company.getPresidentsShare().getShare() + && (share > maxShare)) { + maxShare = share; + newPresident = player; + } + } + if (newPresident != null) { + bankrupter.getPortfolio().swapPresidentCertificate(company, + newPresident.getPortfolio()); + } else { + company.setClosed(); + ReportBuffer.add(LocalText.getText("CompanyCloses", company.getName())); + // TODO: can be restarted (in 18EU) + } + } + // Dump all shares + Util.moveObjects(bankrupter.getPortfolio().getCertificates(), bank.getPool()); + + bankrupter.setBankrupt(); + + // Finish the share selling round + if (getCurrentRound() instanceof ShareSellingRound) { + finishShareSellingRound(); + } + } } Modified: trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-21 19:34:52 UTC (rev 1397) +++ trunk/18xx/rails/game/specific/_18EU/OperatingRound_18EU.java 2010-08-21 19:36:46 UTC (rev 1398) @@ -266,7 +266,9 @@ savedAction = null; finishTurn(); } - super.resume(); + if (gameManager.getCurrentRound() == this) { + super.resume(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 15:30:48
|
Revision: 1399 http://rails.svn.sourceforge.net/rails/?rev=1399&view=rev Author: stefanfrey Date: 2010-08-22 15:30:41 +0000 (Sun, 22 Aug 2010) Log Message: ----------- A simplification of the config window before the upcoming release Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/ui/swing/ConfigWindow.java trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/util/Config.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/LocalisedText.properties 2010-08-22 15:30:41 UTC (rev 1399) @@ -71,16 +71,21 @@ CONFIG=Configuration CONFIG_APPLY_MESSAGE=<html>Current changes (will be) applied.<br>Be aware that some changes to be active require <br> UI redraws or a restart of Rails.</html> CONFIG_APPLY_TITLE=Apply confirmation +CONFIG_CURRENT_PATH=Active filepath = {0} CONFIG_CURRENT_PROFILE=Active profile = {0} (based on = {1}) CONFIG_DEFAULT_TITLE=Default profile CONFIG_DEFAULT_MESSAGE=Select a template for settings CONFIG_INFO_TITLE=Info text for {0} +CONFIF_LOAD_ERROR_MESSAGE=An error occurred during load of the file {0}.\nProfile was not loaded. +CONFIG_LOAD_TITLE=Load of profile CONFIG_NEW_MESSAGE=Select a name of the new profile CONFIG_NEW_TITLE=Create profile +CONFIG_PROFILE_ERROR_MESSAGE=An error occurred during save of the profile list in the current working directory.\nCould not store the name and filepath of the new profile. CONFIG_SELECT_PROFILE=Select profile -> CONFIG_SETTINGS=Profile settings -CONFIG_SAVE_MESSAGE=Active profile {0} was saved -CONFIG_SAVE_TITLE=Save confirmation +CONFIG_SAVE_ERROR_MESSAGE=An error occurred during save of active profile {0}.\nProfile was not saved. +CONFIG_SAVE_CONFIRM_MESSAGE=Active profile {0} was saved. +CONFIG_SAVE_TITLE=Save of profile CONFIG_WINDOW_TITLE=Rails Configuration CORRECT_CASH=Cash Correction CORRECT_MAP=Map Correction @@ -296,6 +301,7 @@ HIDE_OPTIONS=Hide Options HoldMoneyInEscrow=The price of {0} is paid to the Bank, which now holds {1} in escrow for {2} HOW_MANY_SHARES=How many shares? +IMPORT=Import INFO=Game Notes Info=Info Insert=Insert @@ -507,6 +513,7 @@ RustsTrains=Rusts {0}-trains SaleNotAllowed=Selling shares of company {0} is not allowed SAVE=Save +SAVE_AND_APPLY=Save/Apply SAVEAS=Save As ... SaveFailed=Save failed, reason: {0} Select=Select Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -6,7 +6,6 @@ import java.awt.GraphicsEnvironment; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -57,16 +56,21 @@ private static final long serialVersionUID = 1L; private static final String CONFIG_EXTENSION = ".rails_config"; - private static final String CONFIG_DESCRIPTION = "Rails configuration files ( *.rails_config )"; + private static final String LEGACY_EXTENSION = ".properties"; + private static final String CONFIG_DESCRIPTION = "Rails configuration files ( *.rails_config, *.properties)"; private JPanel profilePanel; private JTabbedPane configPane; private JPanel buttonPanel; - ConfigWindow() { - // JFrame properties + private boolean fromStatusWindow; + + ConfigWindow(boolean fromStatusWindow) { + // store for handling of close + this.fromStatusWindow = fromStatusWindow; + + // JFrame properties setTitle(LocalText.getText("CONFIG_WINDOW_TITLE")); -// setSize(400,300); // add profile panel profilePanel = new JPanel(); @@ -80,12 +84,13 @@ buttonPanel = new JPanel(); add(buttonPanel, "South"); + // hide on close and inform this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - closeConfig(); + closeConfig(false); } }); } @@ -95,13 +100,12 @@ setupConfigPane(); setupButtonPanel(); this.pack(); + setSize(600,400); } private void setupProfilePanel() { profilePanel.removeAll(); - - profilePanel.setLayout(new GridLayout(0,4)); - + String activeProfile = Config.getActiveProfileName(); String defaultProfile = Config.getDefaultProfileName(); Border etched = BorderFactory.createEtchedBorder(); @@ -134,16 +138,27 @@ buttonPanel.add(newButton); // button to load a new profile - JButton loadButton = new JButton(LocalText.getText("LOAD")); - loadButton.addActionListener( + JButton importButton = new JButton(LocalText.getText("IMPORT")); + importButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - loadProfile(); + importProfile(); } } ); - buttonPanel.add(loadButton); + buttonPanel.add(importButton); + // saveas button +// JButton saveAsButton = new JButton(LocalText.getText("SAVEAS")); +// saveAsButton.addActionListener( +// new ActionListener() { +// public void actionPerformed(ActionEvent arg0) { +// ConfigWindow.this.saveAsConfig(); +// } +// } +// ); +// buttonPanel.add(saveAsButton); + profilePanel.add(buttonPanel); } @@ -322,8 +337,8 @@ int state = fc.showOpenDialog(ConfigWindow.this); if ( state == JFileChooser.APPROVE_OPTION ){ File file = fc.getSelectedFile(); - dirLabel.setText(file.getAbsolutePath()); - item.setNewValue(file.getAbsolutePath()); + dirLabel.setText(file.getPath()); + item.setNewValue(file.getPath()); } } } @@ -430,47 +445,43 @@ private void setupButtonPanel() { buttonPanel.removeAll(); + + String activeFilePath = Config.getActiveFilepath(); + Border etched = BorderFactory.createEtchedBorder(); + Border titled = BorderFactory.createTitledBorder(etched, LocalText.getText("CONFIG_CURRENT_PATH", activeFilePath)); + buttonPanel.setBorder(titled); - // saveas button - JButton saveAsButton = new JButton(LocalText.getText("SAVEAS")); - saveAsButton.addActionListener( + // save button + JButton saveButton = new JButton(LocalText.getText("SAVE_AND_APPLY")); + saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.saveAsConfig(); - } - } - ); - buttonPanel.add(saveAsButton); - - // save button - if (Config.isFilePathDefined()) { - JButton saveButton = new JButton(LocalText.getText("SAVE")); - saveButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent arg0) { + if (Config.isFilePathDefined()) { ConfigWindow.this.saveConfig(); + } else { + ConfigWindow.this.saveAsConfig(); } } - ); - buttonPanel.add(saveButton); - } - - JButton applyButton = new JButton(LocalText.getText("APPLY")); - applyButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.applyConfig(); - } } ); - buttonPanel.add(applyButton); + buttonPanel.add(saveButton); + +// JButton applyButton = new JButton(LocalText.getText("APPLY")); +// applyButton.addActionListener( +// new ActionListener() { +// public void actionPerformed(ActionEvent arg0) { +// ConfigWindow.this.applyConfig(); +// } +// } +// ); +// buttonPanel.add(applyButton); JButton cancelButton = new JButton(LocalText.getText("CANCEL")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { - ConfigWindow.this.closeConfig(); + ConfigWindow.this.closeConfig(true); } } ); @@ -479,8 +490,13 @@ } private void newProfile() { - String newProfile = JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_NEW_MESSAGE"), + List<String> allProfileNames = Config.getAllProfiles(); + String newProfile = null; + do { + newProfile = JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_NEW_MESSAGE"), LocalText.getText("CONFIG_NEW_TITLE"), JOptionPane.QUESTION_MESSAGE); + } while (allProfileNames.contains(newProfile)); + if (Util.hasValue(newProfile)) { String defaultProfile = (String)JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_DEFAULT_MESSAGE"), LocalText.getText("CONFIG_DEFAULT_TITLE"), JOptionPane.QUESTION_MESSAGE, null, @@ -497,7 +513,7 @@ }); } - private void loadProfile() { + private void importProfile() { String directory = Config.get("save.directory"); JFileChooser fc = new JFileChooser(directory); @@ -505,7 +521,9 @@ new FileFilter() { public boolean accept( File f ){ return f.isDirectory() || - f.getName().toLowerCase().endsWith( ".rails_config" ); + f.getName().toLowerCase().endsWith( CONFIG_EXTENSION) || + f.getName().toLowerCase().endsWith( LEGACY_EXTENSION) + ; } public String getDescription() { return CONFIG_DESCRIPTION; @@ -516,8 +534,11 @@ if ( state == JFileChooser.APPROVE_OPTION ) { File file = fc.getSelectedFile(); - if (Config.loadProfileFromFile(file)) { + if (Config.importProfileFromFile(file)) { changeProfile(Config.getActiveProfileName()); + } else { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_LOAD_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_LOAD_TITLE"), JOptionPane.ERROR_MESSAGE); } } } @@ -532,11 +553,17 @@ }); } - private void saveConfig() { - Config.updateProfile(); // transfer the configitem to the active profile - Config.saveActiveProfile(); - JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_MESSAGE", Config.getActiveProfileName()), + private boolean saveConfig() { + Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile + if (Config.saveActiveProfile()) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_CONFIRM_MESSAGE", Config.getActiveProfileName()), LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE); + return true; + } else { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.ERROR_MESSAGE); + return false; + } } private void saveAsConfig() { @@ -561,11 +588,14 @@ } ); int state = fc.showSaveDialog(this); - if ( state == JFileChooser.APPROVE_OPTION ) - { + if ( state == JFileChooser.APPROVE_OPTION ) { File file = fc.getSelectedFile(); - Config.setActiveFilepath(file.getPath()); + if (!Config.setActiveFilepath(file.getPath())) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_PROFILE_ERROR_MESSAGE", Config.getActiveProfileName()), + LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.ERROR_MESSAGE); + } saveConfig(); + // update panel for file path EventQueue.invokeLater(new Runnable() { public void run() { setupButtonPanel(); @@ -576,16 +606,18 @@ } } - private void applyConfig() { - Config.updateProfile(); // transfer the configitem to the active profile - JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), - LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); - } +// private void applyConfig() { +// Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile +// JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), +// LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); +// } - private void closeConfig() { - Config.revertProfile(); - StatusWindow.uncheckMenuItemBox(StatusWindow.CONFIG_CMD); + private void closeConfig(boolean cancel) { + if (cancel) Config.revertProfile(); this.setVisible(false); + if (fromStatusWindow) { + StatusWindow.uncheckMenuItemBox(StatusWindow.CONFIG_CMD); + } } } Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -25,8 +25,8 @@ private static final long serialVersionUID = 1L; GridBagConstraints gc; JPanel gameListPane, playersPane, buttonPane, optionsPane; - JButton newButton, loadButton, recoveryButton, quitButton, optionButton, infoButton; - JButton creditsButton, randomizeButton; + JButton newButton, loadButton, recoveryButton, quitButton, optionButton, infoButton, + creditsButton, randomizeButton, configureButton; JComboBox gameNameBox = new JComboBox(); JComboBox[] playerBoxes = new JComboBox[Player.MAX_PLAYERS]; JTextField[] playerNameFields = new JTextField[Player.MAX_PLAYERS]; @@ -40,6 +40,8 @@ String gameName; Game game; + private ConfigWindow configWindow; + // Used by the player selection combo box. static final int NONE_PLAYER = 0; static final int HUMAN_PLAYER = 1; @@ -71,6 +73,7 @@ optionButton = new JButton(LocalText.getText("OPTIONS")); infoButton = new JButton(LocalText.getText("INFO")); creditsButton = new JButton(LocalText.getText("CREDITS")); + configureButton= new JButton(LocalText.getText("CONFIG")); newButton.setMnemonic(KeyEvent.VK_N); loadButton.setMnemonic(KeyEvent.VK_L); @@ -78,7 +81,8 @@ quitButton.setMnemonic(KeyEvent.VK_Q); optionButton.setMnemonic(KeyEvent.VK_O); infoButton.setMnemonic(KeyEvent.VK_G); - creditsButton.setMnemonic(KeyEvent.VK_C); + creditsButton.setMnemonic(KeyEvent.VK_E); + configureButton.setMnemonic(KeyEvent.VK_C); this.getContentPane().setLayout(new GridBagLayout()); this.setTitle("Rails: New Game"); @@ -87,9 +91,9 @@ populateGameList(GamesInfo.getGameNames(), gameNameBox); gameListPane.add(new JLabel("Available Games:")); - gameListPane.add(new JLabel("")); // empty slot gameListPane.add(gameNameBox); gameListPane.add(optionButton); + gameListPane.add(configureButton); // empty slot gameListPane.setLayout(new GridLayout(2, 2)); gameListPane.setBorder(BorderFactory.createLoweredBevelBorder()); @@ -101,12 +105,13 @@ infoButton.addActionListener(this); creditsButton.addActionListener(this); gameNameBox.addActionListener(this); + configureButton.addActionListener(this); buttonPane.add(newButton); buttonPane.add(loadButton); - if (!Config.get("save.recovery.active", "yes").equalsIgnoreCase("no")) { - buttonPane.add(recoveryButton); - } + recoveryButton.setEnabled(Config.get("save.recovery.active", "no").equalsIgnoreCase("yes")); + buttonPane.add(recoveryButton); + buttonPane.add(infoButton); buttonPane.add(quitButton); buttonPane.add(creditsButton); @@ -212,14 +217,30 @@ } gameUIManager.startLoadedGame(); setVisible(false); + killConfigWindow(); } + private void killConfigWindow() { + if (configWindow == null) return; + configWindow.dispose(); + configWindow = null; + } + public void actionPerformed(ActionEvent arg0) { if (arg0.getSource().equals(newButton)) { startNewGame(); } else if (arg0.getSource().equals(optionButton)) { toggleOptions(); this.pack(); + } else if (arg0.getSource().equals(configureButton)) { + // start configureWindow + if (configWindow == null) { + configWindow = new ConfigWindow(false); + configWindow.init(); + configWindow.setVisible(true); + } else { + configWindow.setVisible(true); + } } else if (arg0.getSource().equals(loadButton)) { String saveDirectory = Config.get("save.directory"); JFileChooser jfc = new JFileChooser(); @@ -421,6 +442,7 @@ this.setVisible(false); // XXX: At some point we should destroy this // XXX: object rather than just making it invisible + killConfigWindow(); } private void startGameUIManager(Game game) { Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -184,7 +184,7 @@ reportWindow.scrollDown(); // define configWindow - configWindow = new ConfigWindow(); + configWindow = new ConfigWindow(true); configWindow.init(); } Modified: trunk/18xx/rails/util/Config.java =================================================================== --- trunk/18xx/rails/util/Config.java 2010-08-21 19:36:46 UTC (rev 1398) +++ trunk/18xx/rails/util/Config.java 2010-08-22 15:30:41 UTC (rev 1399) @@ -133,7 +133,7 @@ /** * updates the profile according to the changes in configitems */ - public static void updateProfile() { + public static void updateProfile(boolean applyInitMethods) { for (List<ConfigItem> items:configSections.values()) { for (ConfigItem item:items) { if (!item.hasNewValue()) continue; @@ -142,7 +142,7 @@ continue; } userProperties.setProperty(item.name, item.getNewValue()); - item.callInitMethod(); + if (applyInitMethods) item.callInitMethod(); log.debug("Changed property name = " + item.name + " to value = " + item.getNewValue()); item.setNewValue(null); } @@ -224,6 +224,7 @@ // add to list of user profiles userProfiles.setProperty(profileName, ""); + // define and load default profile String defaultConfigFile = defaultProfiles.getProperty(defaultProfile); userProperties.setProperty(PROFILENAME_PROPERTY, profileName); @@ -268,6 +269,22 @@ } /** + * get all (visible default + user) profiles + */ + public static List<String> getAllProfiles() { + List<String> profiles = getDefaultProfiles(true); + profiles.addAll(getUserProfiles()); + return profiles; + } + + /** + * checks if profile is default profile + */ + public static boolean isDefaultProfile(String profileName) { + return !(defaultProfiles.get(profileName) == null); + } + + /** * returns name of (active) default profile */ public static String getDefaultProfileName() { @@ -290,6 +307,7 @@ /** * sets filename for an active profile (and store list of profiles) + * @return false if list of profiles cannot be stored */ public static boolean setActiveFilepath(String filepath) { userProfiles.setProperty(selectedProfile, filepath); @@ -423,15 +441,15 @@ * loads an external user profile * defined by the filepath */ - public static boolean loadProfileFromFile(File file) { - String filepath = file.getAbsolutePath(); + public static boolean importProfileFromFile(File file) { + String filepath = file.getPath(); if (loadPropertyFile(userProperties, filepath, false)) { String profile = userProperties.getProperty(PROFILENAME_PROPERTY); if (!Util.hasValue(profile)) { profile = STANDARD_PROFILE_SELECTION; } selectedProfile = profile; - setActiveFilepath(filepath); +// setActiveFilepath(filepath); // do not set filepath on import loadDefaultProfile(); setSaveDirDefaults(); return true; @@ -509,9 +527,8 @@ } properties.load(inFile); } catch (Exception e) { - System.err.println(e + " whilst loading properties file " + log.error(e + " whilst loading properties file " + filepath); -// e.printStackTrace(System.err); result = false; } return result; @@ -531,6 +548,8 @@ properties.store(new FileOutputStream(outFile), "Automatically generated, do not edit"); log.info("Storing properties to file " + filepath); } catch (IOException e) { + log.error(e + " whilst storing properties file " + + filepath); result = false; } return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-08-22 19:53:40
|
Revision: 1403 http://rails.svn.sourceforge.net/rails/?rev=1403&view=rev Author: stefanfrey Date: 2010-08-22 19:53:34 +0000 (Sun, 22 Aug 2010) Log Message: ----------- Final improvements to Gamehistory report window for upcoming release Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/move/MoveStack.java trunk/18xx/rails/ui/swing/AbstractReportWindow.java trunk/18xx/rails/ui/swing/ConfigWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/ui/swing/MessagePanel.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/LocalisedText.properties 2010-08-22 19:53:34 UTC (rev 1403) @@ -494,11 +494,14 @@ RepayLoans=Repay loan(s) RepayLoan=Repay {0} loan(s) of {1} for {2} REPORT=Report Window -REPORT_MOVE_BACKWARD=< -REPORT_MOVE_FORWARD=> REPORT_COMMENT=Comment REPORT_COMMENT_TITLE=Add Comment REPORT_COMMENT_ASK=Add a comment to the previous action +REPORT_MOVE_BACKWARD=< +REPORT_MOVE_FORWARD=> +REPORT_PLAY_FROM_HERE=Play from here +REPORT_LEAVE_TIMEWARP=Leave history +REPORT_TIMEWARP_ACTIVE=<html><center><font color="red"> Game history active <br> (Other windows disabled) </font></center></html> REVENUE=Revenue RevenueBonus=Bonus(es) = {0} RevenueCalculation=support for revenue calculation Modified: trunk/18xx/rails/game/move/MoveStack.java =================================================================== --- trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -178,6 +178,10 @@ } } + public int size() { + return moveStack.size(); + } + /** * undo/redo to a given moveStack index */ Modified: trunk/18xx/rails/ui/swing/AbstractReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -10,6 +10,9 @@ public abstract class AbstractReportWindow extends JFrame { private static final long serialVersionUID = 1L; + + // can be set to false, than it cannot be closed + protected boolean closeable = true; public void init() { setSize(400, 400); @@ -17,13 +20,16 @@ setTitle(LocalText.getText("GameReportTitle")); final JFrame frame = this; + this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { + if (!closeable) return; StatusWindow.uncheckMenuItemBox(StatusWindow.REPORT_CMD); frame.dispose(); } }); + setVisible("yes".equalsIgnoreCase(Config.get("report.window.open"))); } Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -555,6 +555,12 @@ private boolean saveConfig() { Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile + + if (fromStatusWindow) { + JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"), + LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE); + } + if (Config.saveActiveProfile()) { JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_CONFIRM_MESSAGE", Config.getActiveProfileName()), LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE); Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -1,5 +1,7 @@ package rails.ui.swing; +import java.awt.Component; +import java.awt.Container; import java.awt.EventQueue; import java.awt.Font; import java.awt.GraphicsConfiguration; @@ -822,7 +824,26 @@ public boolean getGameParameterAsBoolean (GuiDef.Parm key) { return (Boolean) getGameParameter(key); } + + private void setEnabledWindow(boolean enabled, JFrame window, JFrame exceptionWindow) { + + if (window != null && window != exceptionWindow) { + window.setEnabled(enabled); + } + } + /** + * deactivate all game windows, except the argument one + */ + public void setEnabledAllWindows(boolean enabled, JFrame exceptionWindow) { + setEnabledWindow(enabled, stockChart, exceptionWindow); + setEnabledWindow(enabled, reportWindow, exceptionWindow); + setEnabledWindow(enabled, configWindow, exceptionWindow); + setEnabledWindow(enabled, orWindow, exceptionWindow); + setEnabledWindow(enabled, startRoundWindow, exceptionWindow); + setEnabledWindow(enabled, statusWindow, exceptionWindow); + } + private void updateWindowsLookAndFeel() { SwingUtilities.updateComponentTreeUI(statusWindow); statusWindow.pack(); @@ -843,11 +864,5 @@ Scale.initFromConfiguration(); instance.initFontSettings(); instance.updateWindowsLookAndFeel(); - -// EventQueue.invokeLater(new Runnable() { -// public void run() { -// instance.repaintWindows(); -// } -// }); } } Modified: trunk/18xx/rails/ui/swing/MessagePanel.java =================================================================== --- trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -75,7 +75,7 @@ // display String text = messageText.toString(); int lines = text.split("<[Bb][Rr]>").length + 1; - setLines(lines); +// setLines(lines); message.setText("<html><center>" + text + "</center></html>"); } Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 15:47:27 UTC (rev 1402) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 19:53:34 UTC (rev 1403) @@ -1,7 +1,10 @@ package rails.ui.swing; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Font; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URL; @@ -9,6 +12,7 @@ import javax.swing.JButton; import javax.swing.JEditorPane; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -36,14 +40,20 @@ private GameUIManager gameUIManager; + private JLabel message; + private JScrollPane reportPane; private JEditorPane editorPane; private JPanel buttonPanel; private ActionButton forwardButton; private ActionButton backwardButton; + private JButton returnButton; + private JButton playFromHereButton; private JButton commentButton; + private boolean timeWarpMode; + protected static Logger log = Logger.getLogger(ReportWindowDynamic.class.getPackage().getName()); @@ -54,6 +64,41 @@ } public void init() { + super.init(); + + setLayout(new BorderLayout()); + + JPanel messagePanel = new JPanel(); + messagePanel.setLayout(new BorderLayout()); + + message = new JLabel(); + message.setText( LocalText.getText("REPORT_TIMEWARP_ACTIVE")); + message.setHorizontalAlignment(JLabel.CENTER); + messagePanel.add(message, "North"); + + JPanel timeWarpButtons = new JPanel(); + returnButton = new JButton(LocalText.getText("REPORT_LEAVE_TIMEWARP")); + returnButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + gotoLastIndex(); + } + } + ); + timeWarpButtons.add(returnButton); + + playFromHereButton = new JButton(LocalText.getText("REPORT_PLAY_FROM_HERE")); + playFromHereButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + deactivateTimeWarp(); + } + } + ); + timeWarpButtons.add(playFromHereButton); + messagePanel.add(timeWarpButtons, "South"); + add(messagePanel, "North"); + editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setContentType("text/html"); @@ -74,7 +119,6 @@ buttonPanel = new JPanel(); add(buttonPanel, "South"); - backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD")); backwardButton.addActionListener(this); buttonPanel.add(backwardButton); @@ -83,6 +127,7 @@ forwardButton.addActionListener(this); buttonPanel.add(forwardButton); + commentButton = new JButton(LocalText.getText("REPORT_COMMENT")); commentButton.addActionListener( new ActionListener() { @@ -106,7 +151,6 @@ ); buttonPanel.add(commentButton); - super.init(); } @Override @@ -116,7 +160,9 @@ scrollDown(); forwardButton.setEnabled(false); - backwardButton.setEnabled(true); + backwardButton.setEnabled(false); + + boolean haveRedo = false; List<GameAction> gameActions = PossibleActions.getInstance().getType(GameAction.class); for (GameAction action:gameActions) { switch (action.getMode()) { @@ -128,9 +174,12 @@ case GameAction.REDO: forwardButton.setPossibleAction(action); forwardButton.setEnabled(true); + haveRedo = true; + if (!timeWarpMode) activateTimeWarp(); break; } } + if (!haveRedo) deactivateTimeWarp(); } @Override @@ -168,6 +217,10 @@ } } + private void gotoLastIndex() { + gotoIndex(gameUIManager.getGameManager().getMoveStack().size()); + } + private void gotoIndex(int index) { MoveStack stack = gameUIManager.getGameManager().getMoveStack(); int currentIndex = stack.getIndex(); @@ -182,4 +235,21 @@ } } + private void activateTimeWarp() { + message.setVisible(true); + playFromHereButton.setVisible(true); + returnButton.setVisible(true); + gameUIManager.setEnabledAllWindows(false, this); + timeWarpMode = true; + closeable = false; + } + + private void deactivateTimeWarp() { + gameUIManager.setEnabledAllWindows(true, this); + message.setVisible(false); + playFromHereButton.setVisible(false); + returnButton.setVisible(false); + timeWarpMode = false; + closeable = true; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-09-06 21:20:18
|
Revision: 1413 http://rails.svn.sourceforge.net/rails/?rev=1413&view=rev Author: stefanfrey Date: 2010-09-06 21:20:12 +0000 (Mon, 06 Sep 2010) Log Message: ----------- Fixed several bugs on 1835: - Tile 213 update: fixed - Pr funding money not given : fixed, (was missing and see TODO 1) - PR formation round acts as a stock round (side effect: price increase, wrong round names): fixed (removed call to super.finishRound()) - Undo inside PR formation round creates weird states: fixed (changed to linked moveSets) - Nationalisation does not check certificate limits before action (post-action check was ok): fixed (missing check) - Nationalisation prevents selling of stocks: fixed (removed self-nationalize) - Pr 5% shares only 1/4 of value, 10% shares only 1/2 of value(report window, executed correctly): fixed (fixed currentSellPrice, see TODO 2 and 3, adjusted output) - Closing of OBB not possible: fixed TODO: 1) Implement SharePriceUnits everywhere it is appropriate (e.g. Round method floating()) 2) SellPrices is not a stateful map (=> undo side effects!) 3) Selling PR president is shown as selling two 5 percent shares (which might be correct) but selling those creates all kind of crazy effects Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1835/CompanyManager.xml trunk/18xx/data/1835/TileSet.xml trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java trunk/18xx/rails/game/specific/_1835/StockRound_1835.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/LocalisedText.properties 2010-09-06 21:20:12 UTC (rev 1413) @@ -239,6 +239,7 @@ END_SR=\nAll players have passed, end of SR {0} EndOfExchangeRound=All minors are closed, end of Exchange Round EndOfFormationRound=\nEnd of {0} formation round, resuming {1} +EndOfFormationRoundNoInterrupt=\nEnd of {0} formation round ENTER_PRICE_OR_CANCEL=Enter a valid price or hit Cancel ERROR=Error EXCHANGED=exchanged Modified: trunk/18xx/data/1835/CompanyManager.xml =================================================================== --- trunk/18xx/data/1835/CompanyManager.xml 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/data/1835/CompanyManager.xml 2010-09-06 21:20:12 UTC (rev 1413) @@ -55,6 +55,7 @@ <ClosingConditions> <Phase>5</Phase> <SpecialProperties condition="ifAllExercised"/> + <CloseManually/> <!-- If second tile is laid not via special property --> </ClosingConditions> </Company> <Company name="PfB" longname="Pfalzbahnen" type="Private" basePrice="150" revenue="15"> Modified: trunk/18xx/data/1835/TileSet.xml =================================================================== --- trunk/18xx/data/1835/TileSet.xml 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/data/1835/TileSet.xml 2010-09-06 21:20:12 UTC (rev 1413) @@ -165,7 +165,7 @@ <Upgrade id="218"/> </Tile> <Tile id="213" quantity="1"> - <Upgrade id="218"/> + <Upgrade id="219"/> </Tile> <Tile id="214" quantity="1"> <Upgrade id="219"/> Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/StockRound.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -417,7 +417,9 @@ * original price is still valid */ price = getCurrentSellPrice(company); - price /= company.getShareUnitsForSharePrice(); + + // 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++) { @@ -802,7 +804,7 @@ if (number == 1) { ReportBuffer.add(LocalText.getText("BUY_SHARE_LOG", playerName, - shareUnit, + share, companyName, from.getName(), Bank.format(cost) )); @@ -810,8 +812,8 @@ ReportBuffer.add(LocalText.getText("BUY_SHARES_LOG", playerName, number, - shareUnit, - number * shareUnit, + share, + shares, companyName, from.getName(), Bank.format(cost) )); @@ -1055,17 +1057,17 @@ if (numberSold == 1) { ReportBuffer.add(LocalText.getText("SELL_SHARE_LOG", playerName, - company.getShareUnit(), + company.getShareUnit() * shareUnits, companyName, - Bank.format(numberSold * price) )); + Bank.format(numberSold * price * shareUnits) )); } else { ReportBuffer.add(LocalText.getText("SELL_SHARES_LOG", playerName, numberSold, - company.getShareUnit(), - numberSold * company.getShareUnit(), + company.getShareUnit() * shareUnits, + numberSold * company.getShareUnit() * shareUnits, companyName, - Bank.format(numberSold * price) )); + Bank.format(numberSold * price * shareUnits) )); } // Check if the presidency has changed @@ -1128,8 +1130,10 @@ && GameOption.convertValueToBoolean(getGameOption("SeparateSalesAtSamePrice"))) { price = (sellPrices.get(companyName)).getPrice(); } else { - price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + price = company.getCurrentSpace().getPrice(); } + // stored price is the previous unadjusted price + price = price / company.getShareUnitsForSharePrice(); return price; } Modified: trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/specific/_1835/PrussianFormationRound.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -229,7 +229,8 @@ return false; } - moveStack.start(false); + // all actions linked during formation round to avoid serious undo problems + moveStack.start(false).linkToPreviousMoveSet(); if (folding) executeStartPrussian(false); @@ -246,6 +247,21 @@ ReportBuffer.add(message); if (display) DisplayBuffer.add(message); + // add money from sold shares + // Move cash and shares where required + int capFactor = getSoldPercentage(prussian) / (prussian.getShareUnit() * prussian.getShareUnitsForSharePrice()); + int cash = capFactor * prussian.getIPOPrice(); + + if (cash > 0) { + new CashMove(bank, prussian, cash); + ReportBuffer.add(LocalText.getText("FloatsWithCash", + prussian.getName(), + Bank.format(cash) )); + } else { + ReportBuffer.add(LocalText.getText("Floats", + prussian.getName())); + } + executeExchange (Arrays.asList(new CompanyI[]{m2}), true, false); prussian.setFloated(); } @@ -271,7 +287,8 @@ return false; } - moveStack.start(false); + // all actions linked during formation round to avoid serious undo problems + moveStack.start(false).linkToPreviousMoveSet(); // Execute if (folding) executeExchange (folded, false, false); @@ -415,9 +432,19 @@ @Override protected void finishRound() { + RoundI interruptedRound = gameManager.getInterruptedRound(); + if (interruptedRound != null) { + ReportBuffer.add(LocalText.getText("EndOfFormationRound", PR_ID, + interruptedRound.getRoundName())); + } else { + ReportBuffer.add(LocalText.getText("EndOfFormationRoundNoInterrupt", PR_ID)); + } + if (prussian.hasStarted()) prussian.checkPresidency(); prussian.setOperated(); // To allow immediate share selling - super.finishRound(); + // super.finishRound(); + // Inform GameManager + gameManager.nextRound(this); } public static boolean prussianIsComplete(GameManagerI gameManager) { Modified: trunk/18xx/rails/game/specific/_1835/StockRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-09-06 17:39:47 UTC (rev 1412) +++ trunk/18xx/rails/game/specific/_1835/StockRound_1835.java 2010-09-06 21:20:12 UTC (rev 1413) @@ -45,8 +45,13 @@ otherPlayers.clear(); for (PublicCertificateI cert : company.getCertificates()) { holder = (Portfolio)cert.getHolder(); - owner = holder.getOwner(); - if (owner instanceof Player) { + owner = holder.getOwner(); + /* Would the player exceed the total certificate limit? */ + StockSpaceI stockSpace = company.getCurrentSpace(); + if ((stockSpace == null || !stockSpace.isNoCertLimit()) && !mayPlayerBuyCertificate( + currentPlayer, company, cert.getCertificateCount())) continue; + // only nationalize other players + if (owner instanceof Player && owner != currentPlayer) { otherPlayer = (Player) owner; if (!otherPlayers.contains(otherPlayer)) { price = (int)(1.5 * company.getCurrentPriceModel().getPrice().getPrice()); @@ -88,9 +93,11 @@ if (sellPrices.containsKey(companyName)) { price = (sellPrices.get(companyName)).getPrice(); } else { - price = company.getCurrentSpace().getPrice() / company.getShareUnitsForSharePrice(); + price = company.getCurrentSpace().getPrice(); } - return price; + // stored price is the previous unadjusted price + price = price / company.getShareUnitsForSharePrice(); + return price; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-09-08 21:41:40
|
Revision: 1416 http://rails.svn.sourceforge.net/rails/?rev=1416&view=rev Author: stefanfrey Date: 2010-09-08 21:41:33 +0000 (Wed, 08 Sep 2010) Log Message: ----------- Issues: a) In 1889 the port tile can be laid on a hex already containing a yellow broad curve town tile. b) In 18AL the lumberjack tile can be laid on a hex already containig a yellow broad curve tile. c) In 1830 the D&H allows upgrading to green tiles. Possible Solution: - Special tile lays always increase tile colour number. - Special tile lays always check the allowed tile colour of the current phase. - Add tile="57" to D&H special property Modified Paths: -------------- trunk/18xx/data/1830/CompanyManager.xml trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/ui/swing/UpgradesPanel.java Modified: trunk/18xx/data/1830/CompanyManager.xml =================================================================== --- trunk/18xx/data/1830/CompanyManager.xml 2010-09-07 19:42:01 UTC (rev 1415) +++ trunk/18xx/data/1830/CompanyManager.xml 2010-09-08 21:41:33 UTC (rev 1416) @@ -39,7 +39,7 @@ <Blocking hex="F16"/> <SpecialProperties> <SpecialProperty condition="ifOwnedByCompany" when="tileLayingStep" class="rails.game.special.SpecialTileLay"> - <SpecialTileLay location="F16" extra="no" free="no"/> + <SpecialTileLay location="F16" extra="no" free="no" tile="57" /> </SpecialProperty> <SpecialProperty condition="ifOwnedByCompany" when="tokenLayingStep" class="rails.game.special.SpecialTokenLay"> <SpecialTokenLay location="F16" extra="no" free="yes"/> Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-07 19:42:01 UTC (rev 1415) +++ trunk/18xx/rails/game/OperatingRound.java 2010-09-08 21:41:33 UTC (rev 1416) @@ -1339,11 +1339,11 @@ if (!operatingCompany.get().canUseSpecialProperties()) return; for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { - if (stl.isExtra() || !currentNormalTileLays.isEmpty()) { - /* - * If the special tile lay is not extra, it is only allowed if - * normal tile lays are also (still) allowed - */ + if (getCurrentPhase().isTileColourAllowed(stl.getTile().getColourName()) + // if a tile is specified it must have a tile colour currently available + && (stl.isExtra() || !currentNormalTileLays.isEmpty())) { + // If the special tile lay is not extra, it is only allowed if + // normal tile lays are also (still) allowed currentSpecialTileLays.add(new LayTile(stl)); } } Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-09-07 19:42:01 UTC (rev 1415) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-09-08 21:41:33 UTC (rev 1416) @@ -100,6 +100,9 @@ } } else { for (TileI tile : tiles) { + // special check: does the tile increase the colour number? + // this avoids that a special tile lay down or equalgrades existing tiles + if (tile.getColourNumber() <= uiHex.getCurrentTile().getColourNumber()) continue; if (!orUIManager.tileUpgrades.contains(tile)) orUIManager.tileUpgrades.add(tile); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wak...@us...> - 2010-09-15 15:44:21
|
Revision: 1420 http://rails.svn.sourceforge.net/rails/?rev=1420&view=rev Author: wakko666 Date: 2010-09-15 15:44:14 +0000 (Wed, 15 Sep 2010) Log Message: ----------- Apply 1825 patch from Phil Davies <de...@gm...> Modified Paths: -------------- trunk/18xx/data/1825/CompanyManager.xml trunk/18xx/data/1825/Game.xml trunk/18xx/data/1825/Map.xml trunk/18xx/data/1825/StockMarket.xml trunk/18xx/data/1825/TileSet.xml trunk/18xx/data/1825/Tiles.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/PublicCompany.java trunk/18xx/rails/game/PublicCompanyI.java Added Paths: ----------- trunk/18xx/rails/game/specific/_1825/ trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java trunk/18xx/rails/game/specific/_1825/StartRound_1825.java trunk/18xx/rails/game/specific/_1825/StockRound_1825.java Modified: trunk/18xx/data/1825/CompanyManager.xml =================================================================== --- trunk/18xx/data/1825/CompanyManager.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/CompanyManager.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -2,10 +2,10 @@ <CompanyManager> <CompanyType name="Private" class="rails.game.PrivateCompany"> </CompanyType> - <CompanyType name="Public" class="rails.game.PublicCompany"> - <PoolPaysOut/> + + <CompanyType name="Public" class="rails.game.specific._1825.PublicCompany_1825"> <Float percentage="60"/> - <ShareUnit percentage="10"/> + <StockPrice par="yes"></StockPrice><ShareUnit percentage="10"/> <BaseTokens> <!-- HomeBase lay options: "whenStarted", "whenFloated", "firstOR" (default) --> ` <HomeBase lay="firstOR"/> @@ -14,8 +14,9 @@ </BaseTokens> <Certificate type="President" shares="2"/> <Certificate shares="1" number="8"/> - <Trains number="4,4,3,-1,-1"/> - </CompanyType> + <Trains number="4,4,3"/> + <TileLays> + <Number colour="yellow" number="2" phase="1,2,3,4,5"></Number></TileLays></CompanyType> <Company name="S&M" type="Private" basePrice="30" revenue="5" longname="Swansea and Mumbles"> </Company> <Company name="CHP" type="Private" basePrice="75" revenue="12" @@ -31,39 +32,47 @@ <!-- Note two supported colour specification formats: RGB decimal with commas and RGB hexadecimal without commas --> <Company name="LNWR" type="Public" tokens="6" fgColour="FFFFFF" - bgColour="000000" longname="London & North Western Railway"> + bgColour="000000" longname="London & North Western Railway" startspace="P1"> <Home hex="T16" /> </Company> <Company name="GWR" type="Public" tokens="6" fgColour="FFFFFF" - bgColour="006600" longname="Great Western Railway"> + bgColour="006600" longname="Great Western Railway" available="no" + startspace="O1"> <Home hex="V14" /> </Company> - - + + <Company name="LSWR" type="Public" tokens="5" fgColour="000000" - bgColour="99FF66" longname="London & South Western Railway"> - <Home hex="V20" city="1"/> + bgColour="99FF66" longname="London & South Western Railway" + available="no" startspace="M1"> + <Home hex="V20" city="6" /> </Company> <Company name="GER" type="Public" tokens="5" fgColour="FFFFFF" - bgColour="000066" longname="Great Eastern"> - <Home hex="V20" city="5" /> + bgColour="000066" longname="Great Eastern" available="no" + startspace="M1"> + <Home hex="V20" city="4" /> </Company> - <Company name="SECR" type="Public" tokens="5" fgColour="000000" bgColour="FFFF00" - longname="South Eastern & Chatham Railway"> + <Company name="SECR" type="Public" tokens="5" fgColour="000000" + bgColour="FFFF00" longname="South Eastern & Chatham Railway" + available="no" startspace="L1"> <Home hex="W23"></Home> </Company> <Company name="LBSC" type="Public" tokens="4" fgColour="000000" - bgColour="FF9900" longname="London, Brighton & South Coast Railway"> + bgColour="FF9900" + longname="London, Brighton & South Coast Railway" available="no" + startspace="K1"> <Home hex="X20"></Home> </Company> - - <StartPacket roundClass="rails.game.specific._1851.StartRound_1851"> + + <StartPacket roundClass="rails.game.specific._1825.StartRound_1825"> <Item name="S&M" type="Private" basePrice="30"/> <Item name="CHP" type="Private" basePrice="75"/> <Item name="C&W" type="Private" basePrice="130"/> <Item name="L&M" type="Private" basePrice="210"/> <IfOption name="NumberOfPlayers" value="5"> - <Item name="LNWR" type="Public" president="yes"></Item></IfOption></StartPacket> + <Item name="LNWR" type="Public" president="yes" + basePrice="200"> + </Item></IfOption></StartPacket> <StockRoundRules> <!-- Will probably move later to a GameManager XML--> <NoSaleInFirstSR/> Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/Game.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -15,18 +15,20 @@ <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> - <PlayerShareLimit percentage="100"/> - <BankPoolLimit percentage="100"></BankPoolLimit> <EndOfGame> <Bankruptcy/> - <BankBreaks limit="0" finish="setOfORs"/> + <BankBreaks limit="0" finish="CurrentOR"/> <!-- "Runs out"; when "broken", -1 is the limit --> </EndOfGame> - </Component> + <GameParameters><PlayerShareLimit percentage="100" /><BankPoolShareLimit percentage="100"></BankPoolShareLimit> + <StockRound sequence="SellBuySell" class="rails.game.specific._1825.StockRound_1825"> + <NoSaleInFirstSR></NoSaleInFirstSR></StockRound> + <OperatingRound class="rails.game.specific._1825.OperatingRound_1825"></OperatingRound></GameParameters></Component> <Component name="PlayerManager" class="rails.game.PlayerManager"> - <Players number="3" cash="800" certLimit="20"/> - <Players number="4" cash="630" certLimit="16"/> - <Players number="5" cash="504" certLimit="13"/> + <Players number="2" cash="1200" certLimit="24"/> + <Players number="3" cash="830" certLimit="16"/> + <Players number="4" cash="630" certLimit="12"/> + <Players number="5" cash="504" certLimit="10"/> </Component> <Component name="Bank" class="rails.game.Bank"> <Bank amount="12000"/> @@ -80,10 +82,7 @@ number="3"> </OperatingRounds> </Phase> - <Phase name="4"> - <Tiles colour="yellow,green,brown,grey"/> - </Phase> - <Phase name="5"> - </Phase> </Component> + <Component name="RevenueManager" class="rails.algorithms.RevenueManager"> + </Component> </ComponentManager> Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/Map.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -1,4 +1,16 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> + <!-- The Q row doesn't exist on the board - it is there to facilitate edge tile placement--> + <Hex name="Q9" tile="0"/> + <Hex name="Q11" tile="0"/> + <Hex name="Q13" tile="0"/> + <Hex name="Q15" tile="0"/> + <Hex name="Q17" tile="0"/> + <Hex name="Q19" tile="0"/> + <Hex name="Q21" tile="0"/> + <Hex name="Q23" tile="0"/> + <Hex name="Q25" tile="0"/> + <Hex name="Q27" tile="0"/> + <!-- End of nonexistent Q row --> <Hex name="R8" tile="0"/> <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" /> <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall"/> Modified: trunk/18xx/data/1825/StockMarket.xml =================================================================== --- trunk/18xx/data/1825/StockMarket.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/StockMarket.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -1,38 +1,39 @@ <StockMarket type="linear"> <!-- Note two supported colour specification formats: RGB decimal with commas and RGB hexadecimal without commas --> - - <StockSpace name="A1" price="0"/> - <StockSpace name="B1" price="5"/> - <StockSpace name="C1" price="10"/> - <StockSpace name="D1" price="16"/> - <StockSpace name="E1" price="24"></StockSpace> - <StockSpace name="F1" price="34"/> - <StockSpace name="G1" price="42"/> - <StockSpace name="H1" price="49"/> - <StockSpace name="I1" price="55" /> - <StockSpace name="J1" price="61"></StockSpace> - <StockSpace name="A2" price="67"> - <StartSpace></StartSpace></StockSpace> - <StockSpace name="B2" price="71"> - <StartSpace></StartSpace></StockSpace> - <StockSpace name="C2" price="76"> - <StartSpace></StartSpace></StockSpace> - <StockSpace name="D2" price="82"/> - <StockSpace name="E2" price="90"> - <StartSpace></StartSpace></StockSpace> - <StockSpace name="F2" price="100"> - <StartSpace></StartSpace></StockSpace> - <StockSpace name="G2" price="112"/> - <StockSpace name="H2" price="126" /> - <StockSpace name="I2" price="142" /> - <StockSpace name="A3" price="160"/> - <StockSpace name="B3" price="180"/> - <StockSpace name="C3" price="205"></StockSpace> - <StockSpace name="D3" price="230"/> - <StockSpace name="E3" price="255"/> - <StockSpace name="F3" price="280"/> - <StockSpace name="G3" price="300"/> - <StockSpace name="H3" price="320"/> - <StockSpace name="I3" price="340" /> + <StockSpaceType name="yellow" colour="255,255,0"> + <NoCertLimit/> + </StockSpaceType> + <StockSpace name="A1" price="0" type="yellow"> + <ClosesCompany/> + </StockSpace> + <StockSpace name="B1" price="5" type="yellow"/> + <StockSpace name="C1" price="10" type="yellow"/> + <StockSpace name="D1" price="16" type="yellow"/> + <StockSpace name="E1" price="24" type="yellow"/> + <StockSpace name="F1" price="34" type="yellow"/> + <StockSpace name="G1" price="42" type="yellow"/> + <StockSpace name="H1" price="49" type="yellow"/> + <StockSpace name="I1" price="55"/> + <StockSpace name="J1" price="61"/> + <StockSpace name="K1" price="67"/> + <StockSpace name="L1" price="71"/> + <StockSpace name="M1" price="76"/> + <StockSpace name="N1" price="82"/> + <StockSpace name="O1" price="90"/> + <StockSpace name="P1" price="100"/> + <StockSpace name="Q1" price="112"/> + <StockSpace name="R1" price="126"/> + <StockSpace name="S1" price="142"/> + <StockSpace name="T1" price="160"/> + <StockSpace name="U1" price="180"/> + <StockSpace name="V1" price="205"/> + <StockSpace name="W1" price="230"/> + <StockSpace name="X1" price="255"/> + <StockSpace name="Y1" price="280"/> + <StockSpace name="Z1" price="300"/> + <StockSpace name="[1" price="320"/> + <StockSpace name="\1" price="340"> + <GameOver/> + </StockSpace> </StockMarket> Modified: trunk/18xx/data/1825/TileSet.xml =================================================================== --- trunk/18xx/data/1825/TileSet.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/TileSet.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -13,7 +13,7 @@ <Upgrade id="5,6"/> </Tile> <Tile id="-20"><!-- 2 OO cities --> - <Upgrade id="52" relayBaseTokens="yes"/> + <Upgrade id="1052" relayBaseTokens="yes"/> </Tile> <Tile id="-5"><!--Dover--></Tile> <Tile id="-7"><!--Preprinted tight bend--></Tile> @@ -47,7 +47,7 @@ <Tile id="8" quantity="8" > <Upgrade id="16,19,23,24,25,28,29"></Upgrade></Tile> <Tile id="9" quantity="7" > - <Upgrade id="19,23,24,25,28,29"></Upgrade></Tile> + <Upgrade id="19,20,23,24,26,27"></Upgrade></Tile> <Tile id="55" quantity="1"> <Upgrade id="14"></Upgrade> </Tile> @@ -94,8 +94,8 @@ <Tile id="29" quantity="1"> <Upgrade id="45"></Upgrade> </Tile> - <Tile id="52" quantity="2"> - <Upgrade id="34"></Upgrade> + <Tile id="1052" quantity="2"> + <Upgrade id="64,65,66,67,68"></Upgrade> </Tile> <Tile id="87" quantity="1"> </Tile> Modified: trunk/18xx/data/1825/Tiles.xml =================================================================== --- trunk/18xx/data/1825/Tiles.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/1825/Tiles.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -1,38 +1,27 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<Tiles> - <Tile colour="white" id="0" name="empty"/> - <Tile colour="white" id="-1" name="1 village"> +<?xml version="1.0" encoding="UTF-8" standalone="no"?><Tiles><Tile colour="white" id="0" name="empty"/><Tile colour="white" id="-1" name="1 village"> <Station id="city1" position="002" type="Town"/> - </Tile> - <Tile colour="white" id="-2" name="2 villages"> + </Tile><Tile colour="white" id="-2" name="2 villages"> <Station id="city1" position="102" type="Town"/> <Station id="city2" position="302" type="Town"/> - </Tile> - <Tile colour="white" id="-10" name="1 city"> + </Tile><Tile colour="white" id="-10" name="1 city"> <Station id="city1" position="302" slots="1" type="City"/> - </Tile> - <Tile colour="yellow" id="-20" name="2 cities"> + </Tile><Tile colour="yellow" id="-20" name="2 cities"> <Station id="city1" position="002" slots="1" type="City"/> <Station id="city2" position="302" slots="1" type="City"/> - </Tile> - <Tile colour="fixed" id="-5" name="MF 5"> + </Tile><Tile colour="fixed" id="-5" name="MF 5"> <Station id="city1" position="0" slots="1" type="City" value="20"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side1"/> - </Tile> - <Tile colour="fixed" id="-7" name="MF 7"> + </Tile><Tile colour="fixed" id="-7" name="MF 7"> <Track from="side2" gauge="normal" to="side1"/> - </Tile> - <Tile colour="fixed" id="-41" name="-41"> + </Tile><Tile colour="fixed" id="-41" name="-41"> <Track from="side0" gauge="normal" to="side3"/> <Track from="side4" gauge="normal" to="side0"/> <Track from="side4" gauge="normal" to="side3"/> - </Tile> - <Tile colour="fixed" id="-104" name="MF 104"> + </Tile><Tile colour="fixed" id="-104" name="MF 104"> <Station id="city1" position="0" slots="1" type="City" value="20"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="green" id="-25001" name="London"> + </Tile><Tile colour="green" id="-25001" name="London"> <Station id="city1" position="403" slots="1" type="City" value="50"/> <Station id="city2" position="503" slots="1" type="City" value="50"/> <Station id="city3" position="003" slots="1" type="City" value="50"/> @@ -45,196 +34,160 @@ <Track from="side2" gauge="normal" to="city5"/> <Track from="side1" gauge="normal" to="city4"/> <Track from="side0" gauge="normal" to="city3"/> - </Tile> - <Tile colour="green" id="-25002" name="Birmingham"> + </Tile><Tile colour="green" id="-25002" name="Birmingham"> <Station id="city1" position="402" slots="1" type="City" value="40"/> <Station id="city2" position="002" slots="1" type="City" value="40"/> <Station id="city3" position="202" slots="1" type="City" value="40"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city3" gauge="normal" to="side2"/> <Track from="side0" gauge="normal" to="city2"/> - </Tile> - <Tile colour="green" id="-25003" name="Bristol"> + </Tile><Tile colour="green" id="-25003" name="Bristol"> <Station id="city1" position="0" slots="1" type="City" value="30"/> <Track from="side3" gauge="normal" to="city1"/> <Track from="city1" gauge="normal" to="side1"/> - </Tile> - <Tile colour="fixed" id="-25004" name="Wolverton"> + </Tile><Tile colour="fixed" id="-25004" name="Wolverton"> <Station id="city1" position="0" slots="1" type="City" value="10"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="fixed" id="-25005" name="Swindon"> + </Tile><Tile colour="fixed" id="-25005" name="Swindon"> <Station id="city1" position="0" slots="1" type="City" value="10"/> <Track from="side4" gauge="normal" to="city1"/> <Track from="side5" gauge="normal" to="city1"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="fixed" id="-25006" name="Southend"> + </Tile><Tile colour="fixed" id="-25006" name="Southend"> <Station id="city1" position="102" slots="1" type="City" value="20"/> <Track from="side4" gauge="normal" to="side0"/> <Track from="side4" gauge="normal" to="city1"/> <Track from="side3" gauge="normal" to="side2"/> - </Tile> - <Tile colour="fixed" id="-25007" name="Bournemouth"> + </Tile><Tile colour="fixed" id="-25007" name="Bournemouth"> <Station id="city1" position="0" slots="1" type="City" value="20"/> <Station id="city2" position="0" slots="1" type="City" value="20"/> <Track from="side4" gauge="normal" to="city2"/> <Track from="side5" gauge="normal" to="city2"/> <Track from="side0" gauge="normal" to="city2"/> - </Tile> - <Tile colour="yellow" id="1" name="1"> + </Tile><Tile colour="yellow" id="1" name="1"> <Station id="city1" position="408" type="Town" value="10"/> <Station id="city2" position="108" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city2" gauge="normal" to="side1"/> <Track from="city2" gauge="normal" to="side3"/> - </Tile> - <Tile colour="yellow" id="2" name="2"> + </Tile><Tile colour="yellow" id="2" name="2"> <Station id="city1" position="302" type="Town" value="10"/> <Station id="city2" position="109" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city2" gauge="normal" to="side1"/> <Track from="city2" gauge="normal" to="side2"/> - </Tile> - <Tile colour="yellow" id="3" name="3"> + </Tile><Tile colour="yellow" id="3" name="3"> <Station id="city1" position="352" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side4"/> - </Tile> - <Tile colour="yellow" id="4" name="4"> + </Tile><Tile colour="yellow" id="4" name="4"> <Station id="city1" position="0" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side0"/> - </Tile> - <Tile colour="yellow" id="5" name="5"> + </Tile><Tile colour="yellow" id="5" name="5"> <Station id="city1" position="0" slots="1" type="City" value="20"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="yellow" id="6" name="6"> + </Tile><Tile colour="yellow" id="6" name="6"> <Station id="city1" position="0" slots="1" type="City" value="20"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="yellow" id="7" name="7"> + </Tile><Tile colour="yellow" id="7" name="7"> <Track from="side3" gauge="normal" to="side4"/> - </Tile> - <Tile colour="yellow" id="8" name="8"> + </Tile><Tile colour="yellow" id="8" name="8"> <Track from="side3" gauge="normal" to="side5"/> - </Tile> - <Tile colour="yellow" id="9" name="9"> + </Tile><Tile colour="yellow" id="9" name="9"> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="yellow" id="55" name="55"> + </Tile><Tile colour="yellow" id="55" name="55"> <Station id="city1" position="202" type="Town" value="10"/> <Station id="city2" position="302" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city2" gauge="normal" to="side3"/> <Track from="city2" gauge="normal" to="side0"/> - </Tile> - <Tile colour="yellow" id="56" name="56"> + </Tile><Tile colour="yellow" id="56" name="56"> <Station id="city1" position="407" type="Town" value="10"/> <Station id="city2" position="108" type="Town" value="10"/> <Track from="city2" gauge="normal" to="side1"/> <Track from="city2" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side2"/> - </Tile> - <Tile colour="green" id="12" name="12"> + </Tile><Tile colour="green" id="12" name="12"> <Station id="city1" position="0" slots="1" type="City" value="30"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side3"/> - </Tile> - <Tile colour="green" id="13" name="13"> + </Tile><Tile colour="green" id="13" name="13"> <Station id="city1" position="0" slots="1" type="City" value="30"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side4"/> - </Tile> - <Tile colour="green" id="14" name="14"> + </Tile><Tile colour="green" id="14" name="14"> <Station id="city1" position="0" slots="2" type="City" value="30"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="15" name="15"> + </Tile><Tile colour="green" id="15" name="15"> <Station id="city1" position="0" slots="2" type="City" value="30"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="16" name="16"> + </Tile><Tile colour="green" id="16" name="16"> <Track from="side3" gauge="normal" to="side5"/> <Track from="side4" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="19" name="19"> + </Tile><Tile colour="green" id="19" name="19"> <Track from="side5" gauge="normal" to="side1"/> <Track from="side0" gauge="normal" to="side3"/> - </Tile> - <Tile colour="green" id="20" name="20"> + </Tile><Tile colour="green" id="20" name="20"> <Track from="side1" gauge="normal" to="side4"/> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="23" name="23"> + </Tile><Tile colour="green" id="23" name="23"> <Track from="side4" gauge="normal" to="side0"/> <Track from="side0" gauge="normal" to="side3"/> - </Tile> - <Tile colour="green" id="24" name="24"> + </Tile><Tile colour="green" id="24" name="24"> <Track from="side3" gauge="normal" to="side5"/> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="25" name="25"> + </Tile><Tile colour="green" id="25" name="25"> <Track from="side1" gauge="normal" to="side3"/> <Track from="side3" gauge="normal" to="side5"/> - </Tile> - <Tile colour="green" id="26" name="26"> + </Tile><Tile colour="green" id="26" name="26"> <Track from="side5" gauge="normal" to="side0"/> <Track from="side0" gauge="normal" to="side3"/> - </Tile> - <Tile colour="green" id="27" name="27"> + </Tile><Tile colour="green" id="27" name="27"> <Track from="side3" gauge="normal" to="side4"/> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="green" id="28" name="28"> + </Tile><Tile colour="green" id="28" name="28"> <Track from="side3" gauge="normal" to="side5"/> <Track from="side4" gauge="normal" to="side5"/> - </Tile> - <Tile colour="green" id="29" name="29"> + </Tile><Tile colour="green" id="29" name="29"> <Track from="side3" gauge="normal" to="side4"/> <Track from="side3" gauge="normal" to="side5"/> - </Tile> - <Tile colour="green" id="52" name="52"> - <Station id="city1" position="0" slots="2" type="City" value="30"/> - <Track from="city1" gauge="normal" to="side5"/> - <Track from="city1" gauge="normal" to="side0"/> + </Tile><Tile colour="green" id="1052" name="52"> + <Station id="city1" position="152" slots="1" type="City" value="40"/> + <Station id="city2" position="452" slots="1" type="City" value="40"/> <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side4"/> - </Tile> - <Tile colour="green" id="87" name="87"> + <Track from="city2" gauge="normal" to="side4"/> + </Tile><Tile colour="green" id="87" name="87"> <Station id="city1" position="0" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side5"/> - </Tile> - <Tile colour="green" id="88" name="88"> + </Tile><Tile colour="green" id="88" name="88"> <Station id="city1" position="0" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side5"/> - </Tile> - <Tile colour="brown" id="32" name="32"> + </Tile><Tile colour="brown" id="32" name="32"> <Station id="city1" position="303" slots="1" type="City" value="70"/> <Station id="city2" position="403" slots="1" type="City" value="70"/> <Station id="city3" position="503" slots="1" type="City" value="70"/> @@ -247,8 +200,7 @@ <Track from="city3" gauge="normal" to="side5"/> <Track from="city2" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side3"/> - </Tile> - <Tile colour="brown" id="34" name="34"> + </Tile><Tile colour="brown" id="34" name="34"> <Station id="city1" position="352" slots="1" type="City" value="50"/> <Station id="city2" position="052" slots="1" type="City" value="50"/> <Station id="city3" position="502" slots="1" type="City" value="50"/> @@ -256,80 +208,68 @@ <Track from="city1" gauge="normal" to="side4"/> <Track from="city3" gauge="normal" to="side2"/> <Track from="city3" gauge="normal" to="side5"/> - </Tile> - <Tile colour="brown" id="38" name="38"> + </Tile><Tile colour="brown" id="38" name="38"> <Station id="city1" position="0" slots="2" type="City" value="40"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city1" gauge="normal" to="side2"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side5"/> - </Tile> - <Tile colour="brown" id="41" name="41"> + </Tile><Tile colour="brown" id="41" name="41"> <Track from="side4" gauge="normal" to="side0"/> <Track from="side4" gauge="normal" to="side3"/> <Track from="side0" gauge="normal" to="side3"/> - </Tile> - <Tile colour="brown" id="42" name="42"> + </Tile><Tile colour="brown" id="42" name="42"> <Track from="side3" gauge="normal" to="side5"/> <Track from="side3" gauge="normal" to="side0"/> <Track from="side5" gauge="normal" to="side0"/> - </Tile> - <Tile colour="brown" id="45" name="45"> + </Tile><Tile colour="brown" id="45" name="45"> <Track from="side1" gauge="normal" to="side5"/> <Track from="side1" gauge="normal" to="side3"/> <Track from="side5" gauge="normal" to="side0"/> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="brown" id="46" name="46"> + </Tile><Tile colour="brown" id="46" name="46"> <Track from="side1" gauge="normal" to="side5"/> <Track from="side1" gauge="normal" to="side0"/> <Track from="side3" gauge="normal" to="side5"/> <Track from="side3" gauge="normal" to="side0"/> - </Tile> - <Tile colour="brown" id="47" name="47"> + </Tile><Tile colour="brown" id="47" name="47"> <Track from="side3" gauge="normal" to="side0"/> <Track from="side3" gauge="normal" to="side1"/> <Track from="side4" gauge="normal" to="side0"/> <Track from="side4" gauge="normal" to="side1"/> - </Tile> - <Tile colour="brown" id="64" name="64"> + </Tile><Tile colour="brown" id="64" name="64"> <Station id="city1" position="401" slots="1" type="City" value="50"/> <Station id="city2" position="052" slots="1" type="City" value="50"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city2" gauge="normal" to="side1"/> <Track from="city2" gauge="normal" to="side0"/> - </Tile> - <Tile colour="brown" id="65" name="65"> + </Tile><Tile colour="brown" id="65" name="65"> <Station id="city1" position="501" slots="1" type="City" value="50"/> <Station id="city2" position="252" slots="1" type="City" value="50"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city2" gauge="normal" to="side2"/> <Track from="city2" gauge="normal" to="side3"/> - </Tile> - <Tile colour="brown" id="66" name="66"> + </Tile><Tile colour="brown" id="66" name="66"> <Station id="city1" position="002" slots="1" type="City" value="50"/> <Station id="city2" position="452" slots="1" type="City" value="50"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city1" gauge="normal" to="side0"/> <Track from="city2" gauge="normal" to="side4"/> <Track from="city2" gauge="normal" to="side5"/> - </Tile> - <Tile colour="brown" id="67" name="67"> + </Tile><Tile colour="brown" id="67" name="67"> <Station id="city1" position="307" slots="1" type="City" value="50"/> <Station id="city2" position="502" slots="1" type="City" value="50"/> <Track from="city1" gauge="normal" to="side1"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city2" gauge="normal" to="side5"/> <Track from="city2" gauge="normal" to="side2"/> - </Tile> - <Tile colour="brown" id="68" name="68"> + </Tile><Tile colour="brown" id="68" name="68"> <Station id="city1" position="302" slots="1" type="City" value="50"/> <Station id="city2" position="502" slots="1" type="City" value="50"/> <Track from="city1" gauge="normal" to="side3"/> <Track from="city2" gauge="normal" to="side2"/> <Track from="city2" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side0"/> - </Tile> -</Tiles> \ No newline at end of file + </Tile></Tiles> \ No newline at end of file Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/data/GamesList.xml 2010-09-15 15:44:14 UTC (rev 1420) @@ -201,9 +201,31 @@ (c) 1994 Hartland Trefoil Ltd. Designed by Francis Tresham -Limitation: -- No random assignment of private companies (players should do this off-line and enter the result) - </Description> +Known Issues: +- 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 + sea or the edge of a pre-placed tile with no track on. Currently Rails will not allow some + of these edge placements. The workaround is to use map correction mode to place the tile you want. + ADDITIONAL NOTE: Map correction might still not work, I think route awareness is confused by track going out of the board... + We might need a different fix +- Upgrades to pre-printed tiles are lays, not promotions so you are allowed two of these in a turn. + Rails currently only allows you to lay 2 yellow tiles in a turn. Again, use map correction + for a workaround +- The rule about the two tiles place on your turn not being adjacent is currently not enforced by rails + and must be enforced manually by players +- Revenue Calc: Routes BEGIN and END with large stations, this is currently not checked +- Revenue Calc: Trains may not visit two stations on the same tile, this is currently not checked +- Revenue Calc: 2 2T's can be double headed as a 3T +- The minimum £10 for a train purchase between companies is not enforced +- Money: The boardgame uses company credits, rails does not, as such the bank will potentially break slightly earlier +- Game currently doesn't end when a company reaches the top of the stock market + It needs to end at the end of that companies turn. +- Hexags reserved for certain companies (currently not enforced in EU either) +- Corps that reach the top of the market should end the game at the end of that corps turn +- Not implemented: selling privates back to the bank +- Not implemented: receivership +</Description> <Players minimum="3" maximum="5" /> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> Modified: trunk/18xx/rails/game/PublicCompany.java =================================================================== --- trunk/18xx/rails/game/PublicCompany.java 2010-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/rails/game/PublicCompany.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -269,6 +269,8 @@ 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. @@ -2007,5 +2009,13 @@ public String getExtraShareMarks () { 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-09-10 21:57:19 UTC (rev 1419) +++ trunk/18xx/rails/game/PublicCompanyI.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -358,7 +358,7 @@ public ModelObject getInGameModel (); public ModelObject getIsClosedModel (); - - + public int getFormationOrderIndex (); + public void setFormationOrderIndex (int formationOrderIndex); } Added: trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java (rev 0) +++ trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -0,0 +1,40 @@ +package rails.game.specific._1825; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import rails.game.GameManagerI; +import rails.game.OperatingRound; +import rails.game.PublicCompanyI; + +public class OperatingRound_1825 extends OperatingRound { + + public OperatingRound_1825(GameManagerI gameManager) { + super(gameManager); + } + + @Override + public List<PublicCompanyI> setOperatingCompanies() { + Map<Integer, PublicCompanyI> operatingCompanies = new TreeMap<Integer, PublicCompanyI>(); + int space; + int key; + for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { + if (!canCompanyOperateThisRound(company)) continue; + // Key must put companies in reverse operating order, because sort + // is ascending. + space = company.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); + } + return new ArrayList<PublicCompanyI>(operatingCompanies.values()); + } + +} \ No newline at end of file Property changes on: trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java (rev 0) +++ trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -0,0 +1,48 @@ +package rails.game.specific._1825; + +import rails.game.PublicCompany; +import rails.game.PublicCompanyI; + +public class PublicCompany_1825 extends PublicCompany { + + + @Override + public void payout(int amount) { + if (amount == 0) return; + //Get current price + int curSharePrice = currentPrice.getPrice().getPrice(); + // Move the token + // Work out number of spaces to move by dividing amount by current share price and rounding + // Move stock token a number of times equal to this multiplier + if (hasStockPrice){ + float shareMultiplier = amount/(float)curSharePrice; + if(shareMultiplier<1){ + shareMultiplier = Math.round(shareMultiplier); + }else{ + shareMultiplier = (float)Math.floor(shareMultiplier); + } + + for (int i = 0; i < shareMultiplier && i < 4; i++) { + stockMarket.payOut(this); + } + } + } + + @Override + public void setFloated() { + super.setFloated(); + + //Need to find out if other corps exist at this IPO price + //If so increment formationOrderIndex to control Operating sequence + for (PublicCompanyI company : gameManager.getAllPublicCompanies()) { + if (this.getIPOPrice() == company.getIPOPrice() && (this.getName() != company.getName())){ + //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++; + } + } + + } + } +} Property changes on: trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/18xx/rails/game/specific/_1825/StartRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/StartRound_1825.java (rev 0) +++ trunk/18xx/rails/game/specific/_1825/StartRound_1825.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -0,0 +1,133 @@ +package rails.game.specific._1825; + +import java.util.List; + +import rails.game.*; +import rails.game.action.*; +import rails.util.LocalText; + +public class StartRound_1825 extends StartRound { + + /** + * Constructor, only to be used in dynamic instantiation. + */ + public StartRound_1825(GameManagerI gameManager) { + super(gameManager); + hasBidding = false; + } + + /** + * Start the 1825-style start round. + * + * @param startPacket The startpacket to be sold in this start round. + */ + @Override + public void start() { + super.start(); + + if (!setPossibleActions()) { + /* + * If nobody can do anything, keep executing Operating and Start + * rounds until someone has got enough money to buy one of the + * remaining items. The game mechanism ensures that this will + * ultimately be possible. + */ + finishRound(); + } + + } + + /** + * Get a list + * + * @return An array of start items that can be bought. + */ + + @Override + public boolean setPossibleActions() { + + StartItemAction action; + List<StartItem> startItems = startPacket.getItems(); + boolean itemAvailable = false; + int soldShares = 0; + possibleActions.clear(); + + for (StartItem item : startItems) { + //Do we already have an item available for sale? + if (itemAvailable == false){ + //If not, check whether this has already been sold + if (!item.isSold()){ + item.setStatus(StartItem.BUYABLE); + possibleActions.add(action = + new BuyStartItem(item, item.getBasePrice(), false)); + log.debug(getCurrentPlayer().getName() + " may: " + + action.toString()); + //Found one, no need to find any others + itemAvailable = true; + } + } + } + //Does everyone have at least one private? + //If so, then we're officially into the first share round so passing is allowed + for (StartItem item : startItems) { + if (item.isSold()){ + soldShares++; + } + if (soldShares == playerManager.getPlayers().size()){ + //Enable passing + possibleActions.add(new NullAction(NullAction.PASS)); + } + } + return true; + } + + @Override + public List<StartItem> getStartItems() { + Player currentPlayer = getCurrentPlayer(); + int cashToSpend = currentPlayer.getCash(); + List<StartItem> startItems = startPacket.getItems(); + + for (StartItem item : startItems) { + if (item.isSold()) { + item.setStatus(StartItem.SOLD); + } else if (item.getBasePrice() > cashToSpend) { + item.setStatus(StartItem.UNAVAILABLE); + } else { + item.setStatus(StartItem.BUYABLE); + } + } + return startItems; + } + + @Override + public boolean bid(String playerName, BidStartItem item) { + + DisplayBuffer.add(LocalText.getText("InvalidAction")); + return false; + } + + /** + * Process a player's pass. + * + * @param playerName The name of the current player (for checking purposes). + */ + @Override + public boolean pass(String playerName) { + ReportBuffer.add(LocalText.getText("PASSES", playerName)); + numPasses.add(1); + if (numPasses.intValue() >= numPlayers) { + //Everyone has passed + ReportBuffer.add(LocalText.getText("ALL_PASSED")); + numPasses.set(0); + finishRound(); + } + setNextPlayer(); + return true; + } + + @Override + public String getHelp() { + return "1825 Start Round help text"; + } + +} Property changes on: trunk/18xx/rails/game/specific/_1825/StartRound_1825.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/18xx/rails/game/specific/_1825/StockRound_1825.java =================================================================== --- trunk/18xx/rails/game/specific/_1825/StockRound_1825.java (rev 0) +++ trunk/18xx/rails/game/specific/_1825/StockRound_1825.java 2010-09-15 15:44:14 UTC (rev 1420) @@ -0,0 +1,82 @@ +/** + * This class implements the 1835 rules for making new companies + * being available in the IPO after buying shares of another company. + */ +package rails.game.specific._1825; + +import java.util.ArrayList; +import java.util.List; + +import rails.game.*; + +public class StockRound_1825 extends StockRound { + + protected int[] priceBands = {100,90,82,76,71,67}; + private List<PublicCompanyI> lPublicCompanies = companyManager.getAllPublicCompanies(); + /** + * Constructor with the GameManager, will call super class (StockRound's) Constructor to initialize + * + * @param aGameManager The GameManager Object needed to initialize the Stock Round + * + */ + public StockRound_1825 (GameManagerI aGameManager) { + super (aGameManager); + } + + protected void adjustSharePrice (PublicCompanyI company, int numberSold, boolean soldBefore) { + // Sales do not affect share price, do nothing + } + + /** + * In 1825, whenever a company is sold out, the block of companies with the next lowest price become available. + * + * Hopefully this logic is generic enough to withstand any combination of units for future implementation + * + * @param boughtfrom The portfolio from which a certificate has been bought. + * @param company The company of which a share has been traded. + */ + @Override + protected void gameSpecificChecks (Portfolio boughtFrom, PublicCompanyI company) { + if (boughtFrom != ipo) return; + + int sharesInIPO = ipo.getShare(company); + + // Check for group releases + if (sharesInIPO == 0) { + //Need to release the next block of companies + + //First find out what price band we were just in + //then find out what the next price band is + //then cycle through companies to find ones at that price + //then set them buyable + for (int i = 0; i < priceBands.length; i++) { + if (priceBands[i] == company.getParPriceModel().getPrice().getPrice()) { + //Found the price band we were in + //We had better break out now if it was the last price band or the next loop + //will run infinitely + if (priceBands[i] == priceBands[priceBands.length - 1]) return; + List<PublicCompanyI> lCompaniesToRelease = new ArrayList<PublicCompanyI>(); + while (lCompaniesToRelease.isEmpty()) { + //while loop needed in case we have no corps at the next valid price band + for (int k = 0; k < companyManager.getAllPublicCompanies().size(); k++){ + //for each public company + if (lPublicCompanies.get(k).getIPOPrice() == priceBands[i+1]){ + //this companies IPO matches the next price band value, add it to the list + lCompaniesToRelease.add(lPublicCompanies.get(k)); + } + } + //If we found corps the loop won't repeat, if we didn't we need the next price band + i++; + } + //We should have found some companies to release now, so do that + for (int j = 0; j < lCompaniesToRelease.size(); j++) { + releaseCompanyShares(lCompaniesToRelease.get(j)); + lCompaniesToRelease.get(j).setBuyable(true); + } + } + } + } + + } + +} Property changes on: trunk/18xx/rails/game/specific/_1825/StockRound_1825.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-09-16 21:04:16
|
Revision: 1422 http://rails.svn.sourceforge.net/rails/?rev=1422&view=rev Author: evos Date: 2010-09-16 21:04:10 +0000 (Thu, 16 Sep 2010) Log Message: ----------- 1825: Replaced extra Q row by white tiles. 18EU: used centered city tiles -3007 (Y) and -3008 instead of -10 Modified Paths: -------------- trunk/18xx/data/1825/Map.xml trunk/18xx/data/1825/TileSet.xml trunk/18xx/data/1825/Tiles.xml trunk/18xx/data/18EU/Map.xml trunk/18xx/data/18EU/TileSet.xml trunk/18xx/data/18EU/Tiles.xml trunk/18xx/tiles/Tiles.xml Added Paths: ----------- trunk/18xx/tiles/svg/tile-10000.svg Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/1825/Map.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -1,15 +1,16 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> - <!-- The Q row doesn't exist on the board - it is there to facilitate edge tile placement--> - <Hex name="Q9" tile="0"/> - <Hex name="Q11" tile="0"/> - <Hex name="Q13" tile="0"/> - <Hex name="Q15" tile="0"/> - <Hex name="Q17" tile="0"/> - <Hex name="Q19" tile="0"/> - <Hex name="Q21" tile="0"/> - <Hex name="Q23" tile="0"/> - <Hex name="Q25" tile="0"/> - <Hex name="Q27" tile="0"/> + <!-- The Q row doesn't exist on the board - it is there to facilitate edge tile placement. + The tiles are not upgradable, i.e. no tiles can be laid here--> + <Hex name="Q9" tile="-10000"/> + <Hex name="Q11" tile="-10000"/> + <Hex name="Q13" tile="-10000"/> + <Hex name="Q15" tile="-10000"/> + <Hex name="Q17" tile="-10000"/> + <Hex name="Q19" tile="-10000"/> + <Hex name="Q21" tile="-10000"/> + <Hex name="Q23" tile="-10000"/> + <Hex name="Q25" tile="-10000"/> + <Hex name="Q27" tile="-10000"/> <!-- End of nonexistent Q row --> <Hex name="R8" tile="0"/> <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" /> Modified: trunk/18xx/data/1825/TileSet.xml =================================================================== --- trunk/18xx/data/1825/TileSet.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/1825/TileSet.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -1,8 +1,9 @@ <TileManager tiles="Tiles.xml"> <!-- Preprinted tiles --> <Tile id="0"><!-- Empty space --> - <Upgrade id="7,8,9" hex="-Q9,Q11,Q13,Q15,Q17,Q19,Q21,Q23,Q25,Q27"/> + <Upgrade id="7,8,9"/> </Tile> + <Tile id="-10000"/><!-- Empty space, not upgradeable (for borders between units and kits) --> <Tile id="-1"><!-- 1 town --> <Upgrade id="3,4"/> </Tile> Modified: trunk/18xx/data/1825/Tiles.xml =================================================================== --- trunk/18xx/data/1825/Tiles.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/1825/Tiles.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -1,4 +1,8 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?><Tiles><Tile colour="white" id="0" name="empty"/><Tile colour="white" id="-1" name="1 village"> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Tiles> + <Tile colour="white" id="0" name="empty"/> + <Tile colour="white" id="-10000" name="empty"/> + <Tile colour="white" id="-1" name="1 village"> <Station id="city1" position="002" type="Town"/> </Tile><Tile colour="white" id="-2" name="2 villages"> <Station id="city1" position="102" type="Town"/> Modified: trunk/18xx/data/18EU/Map.xml =================================================================== --- trunk/18xx/data/18EU/Map.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/18EU/Map.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -2,7 +2,7 @@ <!-- Hex name="" tile="" orientation="" value="" impassable="" label="" cost="" value="" port="yes/no" --> <Hex name="A4" port="yes" value="10" tile="-800" orientation="0"/> <Hex name="B7" value="30,50" tile="-939" orientation="1" city="Hamburg"/> - <Hex name="C4" label="Y" tile="-10" city="Amsterdam"/> + <Hex name="C4" label="Y" tile="-3007" city="Amsterdam"/> <Hex name="C6" tile="-1" city="Bremen"/> <Hex name="C8" tile="0" /> <Hex name="C10" tile="0" /> @@ -19,19 +19,19 @@ <Hex name="E14" value="20,30" tile="-901" orientation="2" city="Warsaw"/> <Hex name="F1" value="40,70" tile="-902" orientation="1" city="London"/> <Hex name="F3" tile="-1" city="Antwerp"/> - <Hex name="F5" tile="-10" city="Dortmund"/> + <Hex name="F5" tile="-3008" city="Dortmund"/> <Hex name="F7" tile="-1" city="Hannover"/> <Hex name="F9" tile="0" /> <Hex name="F11" tile="0" /> <Hex name="F13" tile="0" /> <Hex name="G2" tile="-1" city="Lille"/> - <Hex name="G4" tile="-10" city="Cologne"/> + <Hex name="G4" tile="-3008" city="Cologne"/> <Hex name="G6" tile="0" /> <Hex name="G8" tile="-1" city="Magdeburg"/> - <Hex name="G10" label="Y" tile="-10" city="Dresden"/> + <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="-10" city="Brussels"/> + <Hex name="H3" label="Y" tile="-3007" city="Brussels"/> <Hex name="H5" tile="0" /> <Hex name="H7" tile="0" /> <Hex name="H9" tile="-1" city="Leipzig"/> @@ -39,7 +39,7 @@ <Hex name="H13" tile="0" /> <Hex name="I2" tile="0" /> <Hex name="I4" cost="60" tile="0" /> - <Hex name="I6" tile="-10" city="Frankfurt"/> + <Hex name="I6" tile="-3008" city="Frankfurt"/> <Hex name="I8" tile="0" /> <Hex name="I10" cost="60" tile="0" /> <Hex name="I12" cost="60" tile="0" /> @@ -54,17 +54,17 @@ <Hex name="K4" cost="60" tile="0" /> <Hex name="K6" tile="-1" city="Augsburg"/> <Hex name="K8" tile="0" /> - <Hex name="K10" tile="-10" city="Prague"/> + <Hex name="K10" tile="-3008" city="Prague"/> <Hex name="K12" tile="0" /> <Hex name="L1" tile="0" /> <Hex name="L3" tile="0" /> <Hex name="L5" tile="-1" city="Stuttgart"/> - <Hex name="L7" tile="-10" city="Munich"/> + <Hex name="L7" tile="-3007" label="Y" city="Munich"/> <Hex name="L9" cost="60" tile="0" /> <Hex name="L11" tile="-1" city="Brünn"/> <Hex name="L13" tile="0" /> <Hex name="M2" tile="-1" city="Dijon"/> - <Hex name="M4" label="Y" tile="-10" city="Strasbourg"/> + <Hex name="M4" label="Y" tile="-3007" city="Strasbourg"/> <Hex name="M6" tile="0" /> <Hex name="M8" tile="0" /> <Hex name="M10" cost="60" tile="0" /> @@ -91,8 +91,8 @@ <Hex name="P7" cost="60" tile="0" /> <Hex name="P9" cost="120,60" label="M" tile="0" /><!-- Arlberg --> <Hex name="P11" cost="60" label="M" tile="8" orientation="1"/><!-- Semmering --> - <Hex name="P13" label="Y" tile="-10" city="Budapest"/> - <Hex name="Q2" label="Y" tile="-10" city="Lyon"/> + <Hex name="P13" label="Y" tile="-3007" city="Budapest"/> + <Hex name="Q2" label="Y" tile="-3007" city="Lyon"/> <Hex name="Q4" cost="120,60" label="M" tile="0" /><!-- Lotschberg --> <Hex name="Q6" cost="120,60" label="M" tile="0" /><!-- Gotthard --> <Hex name="Q8" cost="120,60" label="M" tile="0" /><!-- Brenner --> @@ -101,18 +101,18 @@ <Hex name="Q14" value="30,50" tile="-901" orientation="3" city="Bucharest"/> <Hex name="R1" tile="0" /> <Hex name="R3" cost="120,60" label="M" tile="0" /><!-- Frejus --> - <Hex name="R5" label="Y" tile="-10" city="Milan"/> + <Hex name="R5" label="Y" tile="-3007" city="Milan"/> <Hex name="R7" cost="120,60" label="M" tile="0" /><!-- Albula --> - <Hex name="R9" tile="-10" orientation="4" city="Trieste"/> + <Hex name="R9" tile="-3008" orientation="4" city="Trieste"/> <Hex name="R11" tile="0" /> - <Hex name="S2" tile="-10" city="Marseille"/> - <Hex name="S4" tile="-10" city="Turin"/> + <Hex name="S2" tile="-3008" city="Marseille"/> + <Hex name="S4" tile="-3008" city="Turin"/> <Hex name="S6" tile="0" /> - <Hex name="S8" label="Y" tile="-10" city="Venice"/> + <Hex name="S8" label="Y" tile="-3007" city="Venice"/> <Hex name="S10" tile="0" /> <Hex name="T1" tile="0" /> <Hex name="T3" cost="60" tile="-1" city="Nice"/> - <Hex name="T5" tile="-10" city="Genoa"/> + <Hex name="T5" tile="-3008" city="Genoa"/> <Hex name="T7" tile="-1" city="Bologna"/> <Hex name="T9" port="yes" value="10" tile="-800" orientation="3"/> <Hex name="U2" port="yes" value="10" tile="-800" orientation="3"/> Modified: trunk/18xx/data/18EU/TileSet.xml =================================================================== --- trunk/18xx/data/18EU/TileSet.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/18EU/TileSet.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -6,10 +6,12 @@ <Tile id="-1"><!-- 1 town --> <Upgrade id="3,4,58"/> </Tile> - <Tile id="-10"><!-- 1 city --> - <Upgrade id="57" hex="F5,G4,I6,K10,R9,S2,S4,T5" /> - <Upgrade id="201,202" hex="C4,G10,H3,L7,M4,P13,Q2,R5,S8" /> + <Tile id="-3008"><!-- 1 city --> + <Upgrade id="57"/> </Tile> + <Tile id="-3007"><!-- 1 Y city --> + <Upgrade id="201,202"/> + </Tile> <Tile id="-3"/> <Tile id="-800"/> <Tile id="-901"/> Modified: trunk/18xx/data/18EU/Tiles.xml =================================================================== --- trunk/18xx/data/18EU/Tiles.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/data/18EU/Tiles.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -4,9 +4,12 @@ <Tile colour="white" id="-1" name="1 village"> <Station id="city1" position="002" type="Town"/> </Tile> - <Tile colour="white" id="-10" name="1 city"> - <Station id="city1" position="302" slots="1" type="City"/> + <Tile colour="white" id="-3007" name="Y city (cent)"> + <Station id="city1" position="0" slots="1" type="City"/> </Tile> + <Tile colour="white" id="-3008" name="city (cent.)"> + <Station id="city1" position="0" slots="1" type="City"/> + </Tile> <Tile colour="fixed" id="-3" name="MF 3"> <Station id="city1" position="252" type="Town" value="10"/> <Track from="city1" gauge="normal" to="side2"/> Modified: trunk/18xx/tiles/Tiles.xml =================================================================== --- trunk/18xx/tiles/Tiles.xml 2010-09-16 20:12:37 UTC (rev 1421) +++ trunk/18xx/tiles/Tiles.xml 2010-09-16 21:04:10 UTC (rev 1422) @@ -62,6 +62,7 @@ <Station id="city1" position="002" type="Town"/> </Tile> <Tile colour="white" id="0" name="empty"/> + <Tile colour="white" id="-10000" name="empty"/> <Tile colour="yellow" id="1" name="1"> <Station id="city1" position="408" type="Town" value="10"/> <Station id="city2" position="108" type="Town" value="10"/> Added: trunk/18xx/tiles/svg/tile-10000.svg =================================================================== --- trunk/18xx/tiles/svg/tile-10000.svg (rev 0) +++ trunk/18xx/tiles/svg/tile-10000.svg 2010-09-16 21:04:10 UTC (rev 1422) @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"> + <path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" + fill="#FFFFFF" stroke="#FFFFFF" stroke-width="1" + stroke-linejoin="round"/> +</svg> \ 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-09-17 22:24:19
|
Revision: 1426 http://rails.svn.sourceforge.net/rails/?rev=1426&view=rev Author: evos Date: 2010-09-17 22:24:13 +0000 (Fri, 17 Sep 2010) Log Message: ----------- Added GameStatus row to display the increase of player worth in th elast complete OR Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/Player.java trunk/18xx/rails/ui/swing/GameStatus.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/LocalisedText.properties 2010-09-17 22:24:13 UTC (rev 1426) @@ -436,6 +436,7 @@ OK=OK OPTIONS=Options OR=or +ORWORTHINCR=OR +/- PAR=Par PASS=Pass PASSES={0} passes. Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/game/OperatingRound.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -10,10 +10,7 @@ import rails.game.move.CashMove; import rails.game.move.MapChange; import rails.game.special.*; -import rails.game.state.ArrayListState; -import rails.game.state.EnumState; -import rails.game.state.GenericState; -import rails.game.state.HashMapState; +import rails.game.state.*; import rails.util.LocalText; import rails.util.SequenceUtil; @@ -41,8 +38,8 @@ protected GenericState<PublicCompanyI> operatingCompany; // do not use a operatingCompany.getObject() as reference - // protected PublicCompanyI operatingCompany.getObject() = null; - + // protected PublicCompanyI operatingCompany.getObject() = null; + // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; @@ -114,6 +111,10 @@ ReportBuffer.add(LocalText.getText("START_OR", thisOrNumber)); + for (Player player : gameManager.getPlayers()) { + player.setWorthAtORStart(); + } + privatesPayOut(); if (operatingCompanies.size() > 0) { @@ -800,7 +801,7 @@ ReportBuffer.add(LocalText.getText("CompanyRevenue", action.getCompanyName(), Bank.format(action.getActualRevenue()))); - + int remainingAmount = checkForDeductions (action); if (remainingAmount < 0) { // A share selling round will be run to raise cash to pay debts @@ -1298,8 +1299,8 @@ * of the tile laying step. */ protected void getNormalTileLays() { - - // duplicate the phase colours + + // duplicate the phase colours Map<String, Integer> newTileColours = new HashMap<String, Integer>(getCurrentPhase().getTileColours()); for (String colour : newTileColours.keySet()) { int allowedNumber = operatingCompany.get().getNumberOfTileLays(colour); @@ -1307,7 +1308,7 @@ newTileColours.put(colour, new Integer(allowedNumber)); } // store to state - tileLaysPerColour.initFromMap(newTileColours); + tileLaysPerColour.initFromMap(newTileColours); } protected void setNormalTileLays() { @@ -1529,6 +1530,11 @@ // priv.checkClosingIfExercised(true); //} + // Update the worth increase per player + for (Player player : gameManager.getPlayers()) { + player.setLastORWorthIncrease(); + } + // OR done. Inform GameManager. ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); finishRound(); Modified: trunk/18xx/rails/game/Player.java =================================================================== --- trunk/18xx/rails/game/Player.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/game/Player.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -3,6 +3,7 @@ import rails.game.model.*; import rails.game.state.BooleanState; +import rails.game.state.IntegerState; /** * Player class holds all player-specific data @@ -26,6 +27,8 @@ private CalculatedMoneyModel freeCash; private CalculatedMoneyModel worth; private BooleanState bankrupt; + private MoneyModel lastORWorthIncrease; + private IntegerState worthAtORStart; private boolean hasBoughtStockThisTurn = false; @@ -42,6 +45,9 @@ worth = new CalculatedMoneyModel(this, "getWorth"); wallet.addDependent(worth); bankrupt = new BooleanState (name+"_isBankrupt", false); + lastORWorthIncrease = new MoneyModel (name+"_lastORIncome"); + lastORWorthIncrease.setOption(MoneyModel.ALLOW_NEGATIVE); + worthAtORStart = new IntegerState (name+"_worthAtORStart"); } /** @@ -88,10 +94,10 @@ int worth; if (bankrupt.booleanValue()) { worth = 0; - } else { + } else { worth = wallet.getCash(); } - + for (PublicCertificateI cert : portfolio.getCertificates()) { worth += cert.getCompany().getGameEndPrice() * cert.getShares(); } @@ -105,6 +111,18 @@ return worth; } + public MoneyModel getLastORWorthIncrease () { + return lastORWorthIncrease; + } + + public void setWorthAtORStart () { + worthAtORStart.set(getWorth()); + } + + public void setLastORWorthIncrease () { + lastORWorthIncrease.set(getWorth() - worthAtORStart.intValue()); + } + public void updateWorth () { worth.update(); } Modified: trunk/18xx/rails/ui/swing/GameStatus.java =================================================================== --- trunk/18xx/rails/ui/swing/GameStatus.java 2010-09-17 21:44:24 UTC (rev 1425) +++ trunk/18xx/rails/ui/swing/GameStatus.java 2010-09-17 22:24:13 UTC (rev 1426) @@ -68,6 +68,8 @@ protected int playerPrivatesXOffset, playerPrivatesYOffset; protected Field playerWorth[]; protected int playerWorthXOffset, playerWorthYOffset; + protected Field playerORWorthIncrease[]; + protected int playerORWorthIncreaseXOffset, playerORWorthIncreaseYOffset; protected Field playerCertCount[]; protected int playerCertCountXOffset, playerCertCountYOffset; protected int certLimitXOffset, certLimitYOffset; @@ -173,6 +175,7 @@ playerCashButton = new ClickField[np]; playerPrivates = new Field[np]; playerWorth = new Field[np]; + playerORWorthIncrease = new Field[np]; playerCertCount = new Field[np]; upperPlayerCaption = new Caption[np]; lowerPlayerCaption = new Caption[np]; @@ -219,6 +222,8 @@ playerPrivatesYOffset = ++lastY; playerWorthXOffset = certPerPlayerXOffset; playerWorthYOffset = ++lastY; + playerORWorthIncreaseXOffset = certPerPlayerXOffset; + playerORWorthIncreaseYOffset = ++lastY; playerCertCountXOffset = certPerPlayerXOffset; playerCertCountYOffset = ++lastY; certLimitXOffset = certInPoolXOffset; @@ -455,6 +460,13 @@ addField(f, playerWorthXOffset + i, playerWorthYOffset, 1, 1, 0, true); } + addField(new Caption(LocalText.getText("ORWORTHINCR")), 0, + playerORWorthIncreaseYOffset, 1, 1, WIDE_RIGHT, true); + for (int i = 0; i < np; i++) { + f = playerORWorthIncrease[i] = new Field(players[i].getLastORWorthIncrease()); + addField(f, playerORWorthIncreaseXOffset + i, playerORWorthIncreaseYOffset, 1, 1, 0, true); + } + addField(new Caption("Certs"), 0, playerCertCountYOffset, 1, 1, WIDE_RIGHT + WIDE_TOP, true); for (int i = 0; i < np; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-09-18 15:20:24
|
Revision: 1427 http://rails.svn.sourceforge.net/rails/?rev=1427&view=rev Author: evos Date: 2010-09-18 15:20:17 +0000 (Sat, 18 Sep 2010) Log Message: ----------- Log player net worth gain/loss per OR in the Report window. Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/OperatingRound.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-17 22:24:13 UTC (rev 1426) +++ trunk/18xx/LocalisedText.properties 2010-09-18 15:20:17 UTC (rev 1427) @@ -437,6 +437,7 @@ OPTIONS=Options OR=or ORWORTHINCR=OR +/- +ORWorthIncrease=Net worth gain/loss of {0} in OR {1} is {2} PAR=Par PASS=Pass PASSES={0} passes. Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-09-17 22:24:13 UTC (rev 1426) +++ trunk/18xx/rails/game/OperatingRound.java 2010-09-18 15:20:17 UTC (rev 1427) @@ -1530,13 +1530,20 @@ // priv.checkClosingIfExercised(true); //} + ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); + // Update the worth increase per player + int orWorthIncrease; for (Player player : gameManager.getPlayers()) { player.setLastORWorthIncrease(); + orWorthIncrease = player.getLastORWorthIncrease().intValue(); + ReportBuffer.add(LocalText.getText("ORWorthIncrease", + player.getName(), + thisOrNumber, + Bank.format(orWorthIncrease))); } // OR done. Inform GameManager. - ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); finishRound(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-09-20 21:31:23
|
Revision: 1429 http://rails.svn.sourceforge.net/rails/?rev=1429&view=rev Author: evos Date: 2010-09-20 21:31:16 +0000 (Mon, 20 Sep 2010) Log Message: ----------- Allow hex sides to be "open", i.e. track can be laid against such sides, even if at a board edge. This is required for 1825. Modified Paths: -------------- trunk/18xx/data/1825/Map.xml trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/ui/swing/hexmap/GUITile.java Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/data/1825/Map.xml 2010-09-20 21:31:16 UTC (rev 1429) @@ -1,43 +1,15 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> - <!-- The tiles numbered -10000 do not exist on the board. - These are there only to enable edge tile placement, - which is allowed where board extensions exist. - The tiles are not upgradable, i.e. no yellow tiles can be laid on these hexes --> - <!-- Edge tiles in case Unit 2 is not used --> - <Hex name="Q9" tile="-10000"/> - <Hex name="Q11" tile="-10000"/> - <Hex name="Q13" tile="-10000"/> - <Hex name="Q15" tile="-10000"/> - <Hex name="Q17" tile="-10000"/> - <Hex name="Q19" tile="-10000"/> - <!-- End of U2 edge tiles --> - <!-- Edge tiles in case kit R3 (North Norfolk) is not used --> - <Hex name="Q23" tile="-10000"/> - <Hex name="Q25" tile="-10000"/> - <!-- End of R3 edge tiles --> - <!-- Edge tiles in case kit R1 (Wales) is not used --> - <Hex name="Q7" tile="-10000"/> - <Hex name="R6" tile="-10000"/> - <Hex name="S7" tile="-10000"/> - <Hex name="T6" tile="-10000"/> - <Hex name="U7" tile="-10000"/> - <Hex name="V6" tile="-10000"/> - <!-- End of R1 edge tiles --> - <!-- Edge tiles in case kit R2 (S/W England) is not used --> - <Hex name="X6" tile="-10000"/> - <Hex name="Y7" tile="-10000"/> - <!-- End of R2 edge tiles --> - <Hex name="R8" tile="0"/> - <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" /> - <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall"/> - <Hex name="R14" tile="0"/> - <Hex name="R16" tile="-10" city="Leicester" /> - <Hex name="R18" tile="0"/> - <Hex name="R20" tile="-1" city="Peterborough" orientation="3" /> - <Hex name="R22" tile="0"/> - <Hex name="R24" tile="-10" city="Norwich" orientation="4" /> - <Hex name="R26" tile="-1" city="Great Yarmouth" orientation="1" /> - <Hex name="S9" tile="0"/> + <Hex name="R8" tile="0" open="0,1,2,3"/> + <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="2,3"/> + <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall" open="2,3"/> + <Hex name="R14" tile="0" open="2,3"/> + <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"/> + <Hex name="R22" tile="0" open="3"/> + <Hex name="R24" tile="-10" city="Norwich" orientation="4" open="2,3"/> + <Hex name="R26" tile="-1" city="Great Yarmouth" orientation="1" open="2"/> + <Hex name="S9" tile="0" open="1"/> <Hex name="S11" tile="0"/> <Hex name="S13" tile="-25002" city="Birmingham" /> <Hex name="S15" tile="-1" city="Northampton" orientation="2" /> @@ -46,7 +18,7 @@ <Hex name="S21" tile="0"/> <Hex name="S23" tile="0"/> <Hex name="S25" tile="0"/> - <Hex name="T8" tile="0" cost="100"></Hex> + <Hex name="T8" tile="0" cost="100" open="0,1,2"></Hex> <Hex name="T10" tile="0"/> <Hex name="T12" tile="0"/> <Hex name="T14" tile="0"/> @@ -55,7 +27,7 @@ <Hex name="T20" tile="-1" city="Cambridge" /> <Hex name="T22" tile="0"/> <Hex name="T24" tile="-1" city="Ipswich" orientation="1" /> - <Hex name="U9" tile="0"/> + <Hex name="U9" tile="0" open="1"/> <Hex name="U11" tile="-1" cost="40" city="Gloucester" orientation="1" ></Hex> <Hex name="U13" tile="0"/> @@ -65,7 +37,7 @@ <Hex name="U21" tile="0"/> <Hex name="U23" tile="-1" city="Colchester" /> <Hex name="U25" tile="-104" orientation="2" city="Harwich"/> - <Hex name="V8" tile="-20" city="Cardiff, Newport" /> + <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"/> @@ -83,7 +55,7 @@ <Hex name="W21" tile="0"/> <Hex name="W23" tile="-10" city="Ashford" orientation="5" /> <Hex name="W25" tile="-5" orientation="2" city="Dover"/> - <Hex name="X8" tile="0"/> + <Hex name="X8" tile="0" open="0,1"/> <Hex name="X10" tile="0"/> <Hex name="X12" tile="0"/> <Hex name="X14" tile="-10" city="Southampton" orientation="5" /> @@ -93,7 +65,7 @@ <Hex name="X20" tile="-10" city="Brighton" orientation="5" /> <Hex name="X22" tile="-1" city="Hastings" orientation="2" /> <Hex name="X24" tile="0"/> - <Hex name="Y9" tile="0"/> + <Hex name="Y9" tile="0" open="1"/> <Hex name="Y11" tile="-1" city="Weymouth" orientation="3" /> <Hex name="Y13" tile="-25007" city="Bournemouth"/> <Hex name="Y17" tile="-7" orientation="4" /> Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/rails/game/MapHex.java 2010-09-20 21:31:16 UTC (rev 1429) @@ -112,6 +112,9 @@ /** Storage of revenueBonus that are bound to the hex */ protected List<RevenueBonusTemplate> revenueBonuses = null; + /** 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 = @@ -207,6 +210,12 @@ revenueBonuses.add(bonus); } } + + // Open sides (as in 1825, track may be laid against some board edges) + for (int side : tag.getAttributeAsIntegerArray("open", new int[0])) { + if (openHexSides == null) openHexSides = new boolean[6]; + openHexSides[side%6] = true; + } } public void finishConfiguration (GameManagerI gameManager) { @@ -258,6 +267,10 @@ return true; } + public boolean isOpenSide (int side) { + return openHexSides != null && openHexSides[side%6]; + } + public int getTileOrientation() { return mapManager.getTileOrientation(); } @@ -1012,15 +1025,15 @@ /** * @return Returns false if no base tokens may yet be laid on this hex and station. - * + * * NOTE: this method currently only checks for prohibitions caused * by the presence of unlaid home base tokens. * It does NOT (yet) check for free space. * * * There are the following cases to check for each company located there - * - * A) City is decided or there is only one city + * + * A) City is decided or there is only one city * => check if the city has a free slot or not * (examples: NYNH in 1830 for a two city tile, NYC for a one city tile) * B) City is not decided (example: Erie in 1830) @@ -1029,14 +1042,14 @@ * - (false): no city of the hex has remaining slots available * C) Or the company does not block its home city at all (example:Pr in 1835) * then isBlockedForTokenLays attribute is used - * + * * NOTE: It now deals with more than one company with a home base on the - * same hex. - * + * same hex. + * * Previously there was only the variable isBlockedForTokenLays * which is set to yes to block the whole hex for the token lays * until the (home) company laid their token - * + * */ public boolean isBlockedForTokenLays(PublicCompanyI company, int cityNumber) { @@ -1071,7 +1084,7 @@ anyBlockCompanies ++; // companies which are located somewhere else } } - log.debug("IsBlockedForTokenLays: allBlockCompanies = " + allBlockCompanies + + log.debug("IsBlockedForTokenLays: allBlockCompanies = " + allBlockCompanies + ", anyBlockCompanies = " + anyBlockCompanies + " , cityBlockCompanies = " + cityBlockCompanies); // check if there are sufficient individual city slots if (allBlockCompanies + cityBlockCompanies + 1 > cityToLay.getTokenSlotsLeft()) { Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-09-20 21:31:16 UTC (rev 1429) @@ -80,7 +80,7 @@ MapHex nHex; boolean connected; - + int fixedRotation = getTile().getFixedOrientation(); if (fixedRotation >= 0) { setRotation (fixedRotation); @@ -102,7 +102,7 @@ if (tile.hasTracks(tempTileSide)) { // If the tile has tracks against that side, but there is no // neighbour, forbid this rotation. - if (!hex.hasNeighbour(j)) { + if (!hex.hasNeighbour(j) && !hex.isOpenSide(j)) { continue rot; } // If the tile must be connected (i.e. not laid on the @@ -111,7 +111,7 @@ // a side of this tile that also has a track. if (mustConnect) { nHex = hex.getNeighbor(j); - if (nHex.getCurrentTile().hasTracks( + if (nHex != null && nHex.getCurrentTile().hasTracks( j + 3 - nHex.getCurrentTileRotation())) { connected = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-09-22 21:38:25
|
Revision: 1431 http://rails.svn.sourceforge.net/rails/?rev=1431&view=rev Author: evos Date: 2010-09-22 21:38:18 +0000 (Wed, 22 Sep 2010) Log Message: ----------- Added parametrized options. Added 1825 Unit 2/3 and R/1/2/3 map (except not yet created special tiles). Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1825/Game.xml trunk/18xx/data/1825/Map.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/GameOption.java trunk/18xx/rails/game/GamesInfo.java trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/hexmap/HexMap.java trunk/18xx/rails/util/Tag.java trunk/18xx/tiles/TileDictionary.18t Property Changed: ---------------- trunk/18xx/test/ Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/LocalisedText.properties 2010-09-22 21:38:18 UTC (rev 1431) @@ -303,6 +303,7 @@ HoldMoneyInEscrow=The price of {0} is paid to the Bank, which now holds {1} in escrow for {2} HOW_MANY_SHARES=How many shares? IMPORT=Import +Include=Include {0} INFO=Game Notes Info=Info Insert=Insert Modified: trunk/18xx/data/1825/Game.xml =================================================================== --- trunk/18xx/data/1825/Game.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/1825/Game.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -12,6 +12,12 @@ - optionally, a default value (only affects a toggle; in a dropdown the first item is always the default). --> + <GameOption name="Include" parm="Unit1" type="toggle" default="yes"/> + <GameOption name="Include" parm="Unit2" type="toggle" default="no"/> + <GameOption name="Include" parm="Unit3" type="toggle" default="no"/> + <GameOption name="Include" parm="R1" type="toggle" default="no"/> + <GameOption name="Include" parm="R2" type="toggle" default="no"/> + <GameOption name="Include" parm="R3" type="toggle" default="no"/> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/1825/Map.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -1,6 +1,96 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> + <IfOption name="Include" parm="Unit3" value="yes"> + <Hex name="B8" tile="-5" orientation="1" city="Inverness"/> + <!--Hex name="B12" tile="-25011" city="Aberdeen"/--> + <Hex name="C7" tile="-1" cost="100" city="Pitlochry" open="1,2"/> + <Hex name="C9" tile="0" cost="100" open="3"/> + <Hex name="C11" tile="0" open="2"/> + <Hex name="D2" tile="0" cost="100"/> + <Hex name="D4" tile="0" cost="100"/> + <Hex name="D6" tile="0" cost="100"/> + <Hex name="D8" tile="0" cost="100"/> + <Hex name="D10" tile="-1" city="Montrose"/> + <Hex name="E1" tile="-5" orientation="5" cost="40" city="Oban"/> + <Hex name="E3" tile="0" cost="100"/> + <Hex name="E5" tile="0" cost="100"/> + <Hex name="E7" tile="-25005" orientation="1" city="Perth"/> + <Hex name="E9" tile="-10" cost="80" city="Dundee"/> + <!--Hex name="F2" tile="-25012" city="Helensburgh, Gourock"/--> + <Hex name="F4" tile="-1" cost="40" city="Dumbarton"/> + <Hex name="F6" tile="-1" city="Stirling"/> + <Hex name="F8" tile="-2" orientation="3" cost="120" city="Dumfermline, Kirkaldy"/> + <!--Hex name="F10" tile="-25013" city="Anstruther"/--> + <Hex name="G3" tile="-10" city="Greenock"/> + <Hex name="G5" tile="-25002" city="Glasgow"/> + <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="H6" tile="-10" city="Motherwell"/> + <Hex name="H8" tile="0" cost="100"/> + <Hex name="H10" tile="0" cost="100"/> + <Hex name="H12" tile="0"/> + <Hex name="H14" tile="0"/> + <Hex name="I3" tile="0" cost="100"/> + <Hex name="I5" tile="0"/> + <Hex name="I7" tile="0" cost="100"/> + <Hex name="I9" tile="0" cost="100"/> + <Hex name="I11" tile="0" cost="100"/> + <Hex name="I13" tile="-2"/> + <Hex name="J2" tile="-10" city="Stranraer"/> + <Hex name="J4" tile="0" cost="100"/> + <Hex name="J6" tile="-10" city="Dumfries"/> + <Hex name="J8" tile="0"/> + <Hex name="J10" tile="-10" ciry="Carlisle"/> + <Hex name="J12" tile="0" cost="100"/> + <Hex name="J14" tile="-20" cost="40" city="Newcastle u/T, Sunderland"/> + <!--Hex name="K7" tile="-25014" orientation="2" city="Maryport"/--> + <Hex name="K9" tile="0" cost="100" open="0,5"/> + <Hex name="K11" tile="0" cost="100" open="0,5"/> + <Hex name="K13" tile="-1" city="Durham" open="0,5"/> + <Hex name="K15" tile="-2" city="Stockton, Middlesbro" open="0,5"/> + </IfOption> + <IfOption name="Include" parm="Unit2" value="yes"> + <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="L16" tile="0" open="2"/> + <Hex name="L18" tile="-1" city="Scarborough"/> + <!--Hex name="M9" tile="-25008" city="Barrow"/--> + <Hex name="M11" tile="0" cost="100"/> + <Hex name="M13" tile="0" cost="100"/> + <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="N12" tile="-2" city="Burnley, Halifax"/> + <Hex name="N14" tile="-20" city="Bradford, Leeds"/> + <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="O13" tile="0" cost="100"/> + <!--Hex name="O15" tile="-25010" city="Barnsley, Doncaster"/--> + <Hex name="O17" tile="0" cost="40"/> + <Hex name="O19" tile="0"/> + <Hex name="P8" tile="-41" orientation="4"/> + <Hex name="P10" tile="0" cost="40"/> + <Hex name="P12" tile="0" cost="100"/> + <Hex name="P14" tile="0" cost="100"/> + <Hex name="P16" tile="-20" city="Sheffield, Rotherham"/> + <Hex name="P18" tile="-1" city="Lincoln"/> + <Hex name="P20" tile="0"/> + <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="Q17" tile="-10" city="Nottingham" open="0,5"/> + <Hex name="Q19" tile="0" open="0,5"/> + </IfOption> + <IfOption name="Include" parm="Unit1" value="yes"> <Hex name="R8" tile="0" open="0,1,2,3"/> - <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="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="R16" tile="-10" city="Leicester" open="2,3"/> @@ -70,5 +160,39 @@ <Hex name="Y13" tile="-25007" city="Bournemouth"/> <Hex name="Y17" tile="-7" orientation="4" /> <Hex name="Y19" tile="-7" orientation="4" /> - + <IfOption name="Include" parm="R1" value="yes"> + <Hex name="P4" tile="-5" city="Holyhead"/> + <Hex name="P6" tile="0" cost="40"/> + <Hex name="Q5" tile="-1" city="Portmadoc"/> + <Hex name="Q7" tile="0" cost="100"/> + <Hex name="R6" tile="0"/> + <Hex name="S5" tile="-1" city="Aberystwyth"/> + <Hex name="S7" tile="0" cost="100"/> + <Hex name="T2" tile="-10" city="Fishguard"/> + <Hex name="T4" tile="0"/> + <Hex name="T6" tile="0" cost="100"/> + <!--Hex name="U1" tile="-25015" city="Milford Haven"/--> + <Hex name="U3" tile="0"/> + <Hex name="U5" tile="0"/> + <Hex name="V8" tile="-25007" orientation="1" city="Swansea"/> + </IfOption> + <IfOption name="Include" parm="R2" value="yes"> + <Hex name="X4" tile="-1" city="Barnstaple"/> + <Hex name="X6" tile="0" cost="100"/> + <Hex name="Y1" tile="0"/> + <Hex name="Y3" tile="0"/> + <Hex name="Y5" tile="0" cost="100"/> + <Hex name="Y7" tile="-10" city="Exeter"/> + <Hex name="Z0" tile="0"/> + <Hex name="Z2" tile="-1" city="Fowey"/> + <Hex name="Z4" tile="-20" city="Devenport, Plymouth"/> + <Hex name="Z6" tile="-1" city="Torquay"/> + <!--Hex name="AA-1" tile="-1" city="Penzance"/> + <Hex name="AA1" tile="-10" city="Falmouth"/--> + </IfOption> + <IfOption name="Include" parm="R3" value="yes"> + <!--Hex name="Q23" tile="-25014" orientation="1" city="Melton Constable"/--> + <Hex name="Q25" tile="0"/> + </IfOption> + </IfOption> </Map> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/data/GamesList.xml 2010-09-22 21:38:18 UTC (rev 1431) @@ -227,6 +227,12 @@ - Not implemented: receivership </Description> <Players minimum="3" maximum="5" /> + <Option name="Include" parm="Unit1" type="toggle" default="yes"/> + <Option name="Include" parm="Unit2" type="toggle" default="no"/> + <Option name="Include" parm="Unit3" type="toggle" default="no"/> + <Option name="Include" parm="R1" type="toggle" default="no"/> + <Option name="Include" parm="R2" type="toggle" default="no"/> + <Option name="Include" parm="R3" type="toggle" default="no"/> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="UnlimitedTiles" type="toggle" default="no"/> Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GameManager.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -233,21 +233,28 @@ GameOption option; String optionName, optionType, optionValues, optionDefault; String optionNameParameters; + String[] optionParameters; List<Tag> optionTags = tag.getChildren("GameOption"); if (optionTags != null) { for (Tag optionTag : optionTags) { optionName = optionTag.getAttributeAsString("name"); if (optionName == null) throw new ConfigurationException("GameOption without name"); + optionParameters = null; + optionNameParameters = + optionTag.getAttributeAsString("parm"); + if (optionNameParameters != null) { + optionParameters = optionNameParameters.split(","); + } + optionName = GameOption.constructParametrisedName ( + optionName, optionParameters); + if (gameOptions.containsKey(optionName)) continue; // Include missing option - option = new GameOption(optionName); + option = new GameOption(optionName, optionParameters); availableGameOptions.add(option); - optionNameParameters = optionTag.getAttributeAsString("parm"); - if (optionNameParameters != null) { - option.setParameters(optionNameParameters.split(",")); - } + optionType = optionTag.getAttributeAsString("type"); if (optionType != null) option.setType(optionType); optionValues = optionTag.getAttributeAsString("values"); Modified: trunk/18xx/rails/game/GameOption.java =================================================================== --- trunk/18xx/rails/game/GameOption.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GameOption.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -8,6 +8,7 @@ public class GameOption { private String name; + private String parametrisedName; private boolean isBoolean = false; private String type; private String defaultValue = null; @@ -22,14 +23,16 @@ // A default option that will always be set public static final String NUMBER_OF_PLAYERS = "NumberOfPlayers"; - + // Some other common game options - public static final String VARIANT = "Variant"; - + public static final String VARIANT = "Variant"; - public GameOption(String name) { - this.name = name; - optionsMap.put(name, this); + + public GameOption(String name, String[] parameters) { + this.name = name; + if (parameters != null) parm = parameters.clone(); + parametrisedName = constructParametrisedName (name, parameters); + optionsMap.put(parametrisedName, this); } public void setType(String type) { @@ -43,7 +46,7 @@ } public String getName() { - return name; + return parametrisedName; } public String getLocalisedName() { @@ -58,14 +61,12 @@ return isBoolean; } + /* public void setParameters(String[] parameters) { parm = parameters.clone(); } + */ - public String[] getParameters() { - return parm; - } - public void setAllowedValues(List<String> values) { allowedValues = values; } @@ -107,7 +108,18 @@ /** Get GameOption Value as Boolean Value */ public static boolean convertValueToBoolean(String value) { - return value != null + return value != null && OPTION_VALUE_YES.equalsIgnoreCase(value); } + + public static String constructParametrisedName (String optionName, + String[] optionNameParameters) { + String parametrisedName = optionName; + if (optionNameParameters != null) { + for (String parameter : optionNameParameters) { + parametrisedName += "_" + parameter; + } + } + return parametrisedName; + } } Modified: trunk/18xx/rails/game/GamesInfo.java =================================================================== --- trunk/18xx/rails/game/GamesInfo.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/GamesInfo.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -129,7 +129,6 @@ // Get the options List<Tag> optionTagList = gameTag.getChildren(OPTION_TAG); List<GameOption> gameOptions = new ArrayList<GameOption>(); - options.put(gameName, gameOptions); if (optionTagList != null) { for (Tag optionTag : optionTagList) { @@ -141,14 +140,16 @@ throw new ConfigurationException("Option name missing in " + GAMES_XML); } - GameOption option = new GameOption(optionName); - gameOptions.add(option); + // Option name parameters (optional) + String[] optionParameters = null; String optionNameParameters = - optionTag.getAttributeAsString("parm"); - if (optionNameParameters != null) { - option.setParameters(optionNameParameters.split(",")); - } + optionTag.getAttributeAsString("parm"); + if (optionNameParameters != null) { + optionParameters = optionNameParameters.split(","); + } + GameOption option = new GameOption(optionName, optionParameters); + gameOptions.add(option); // Option type (optional). // "toggle" means this is a boolean option, @@ -173,6 +174,7 @@ } } } + options.put(gameName, gameOptions); } Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/game/MapHex.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -114,7 +114,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 = @@ -128,16 +128,22 @@ * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { - Pattern namePattern = Pattern.compile("(\\D)(\\d+)"); + Pattern namePattern = Pattern.compile("(\\D+?)(-?\\d+)"); infoText = name = tag.getAttributeAsString("name"); Matcher m = namePattern.matcher(name); if (!m.matches()) { throw new ConfigurationException("Invalid name format: " + name); } - letter = m.group(1).charAt(0); + String letters = m.group(1); + if (letters.length() == 1) { + letter = letters.charAt(0); + } else { // for row 'AA' in 1825U1 + letter = 26 + letters.charAt(1); + } try { number = Integer.parseInt(m.group(2)); + if (number > 90) number -= 100; // For 1825U1 column 99 (= -1) } catch (NumberFormatException e) { // Cannot occur! } @@ -266,7 +272,7 @@ return true; } - + public boolean isOpenSide (int side) { return openHexSides != null && openHexSides[side%6]; } Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -41,7 +41,7 @@ Game game; private ConfigWindow configWindow; - + // Used by the player selection combo box. static final int NONE_PLAYER = 0; static final int HUMAN_PLAYER = 1; @@ -219,13 +219,13 @@ setVisible(false); killConfigWindow(); } - + private void killConfigWindow() { if (configWindow == null) return; configWindow.dispose(); configWindow = null; } - + public void actionPerformed(ActionEvent arg0) { if (arg0.getSource().equals(newButton)) { startNewGame(); @@ -297,14 +297,14 @@ playerNameFields[Integer.parseInt(boxName[1])].setEnabled(false); break; } - } + } } else if (arg0.getSource().equals(randomizeButton)) { // randomize the order of the players - if (playerNameFields.length > 0) { + if (playerNameFields.length > 0) { List<String> playerList = new ArrayList<String>(); for (int i = 0; i < playerNameFields.length; i++) { if (playerNameFields[i] != null - && playerNameFields[i].getText().length() > 0) { + && playerNameFields[i].getText().length() > 0) { playerList.add(playerNameFields[i].getText()); playerNameFields[i].setText(""); } @@ -312,7 +312,7 @@ Collections.shuffle(playerList); for (int i = 0; i < playerList.size(); i++) { playerNameFields[i].setText(playerList.get(i)); - + } } } Modified: trunk/18xx/rails/ui/swing/hexmap/HexMap.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/ui/swing/hexmap/HexMap.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -13,10 +13,9 @@ import rails.game.*; import rails.game.action.*; -import rails.ui.swing.GameUIManager; -import rails.ui.swing.ORUIManager; -import rails.ui.swing.Scale; -import rails.util.*; +import rails.ui.swing.*; +import rails.util.Config; +import rails.util.Util; /** * Base class that stores common info for HexMap independant of Hex @@ -64,10 +63,10 @@ protected Map<MapHex, List<LayToken>> allowedTokensPerHex = null; protected boolean bonusTokenLayingEnabled = false; - + /** list of generalpath elements to indicate train runs */ protected List<GeneralPath> trainPaths; - + private static Color colour1, colour2, colour3, colour4; protected int strokeWidth = 5; protected int strokeCap = BasicStroke.CAP_ROUND; @@ -83,7 +82,7 @@ protected double tileYOffset; protected double coordinateXMargin; protected double coordinateYMargin; - + public static void setRouteColours () { try { colour1 = Util.parseColour(Config.get("route.colour.1", null)); @@ -114,12 +113,12 @@ maxCol = mapManager.getMaxCol(); log.debug("HexMap init: minX="+ minX + ",minY=" + minY + ",maxX=" +maxX + ",maxY=" + maxY); log.debug("HexMap init: minCol="+ minCol + ",minRow=" + minRow + ",maxCol=" +maxCol + ",maxRow=" + maxRow); - + setScale(); setupHexes(); initializeSettings(); - + setRouteColours(); } @@ -143,22 +142,22 @@ } } - - + + protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); hexArray = mapManager.getHexes(); MapHex mh; - + h = new GUIHex[hexArray.length][hexArray[0].length]; for (int i = minX; i < hexArray.length; i++) { for (int j = minY; j < hexArray[0].length; j++) { mh = hexArray[i][j]; - if (mh != null) { - GUIHex hex = new GUIHex(this, calcXCoordinates(mh.getColumn(), tileXOffset), + if (mh != null) { + GUIHex hex = new GUIHex(this, calcXCoordinates(mh.getColumn(), tileXOffset), calcYCoordinates(mh.getRow(), tileYOffset), scale, i-minX+1, j-minY+1); hex.setHexModel(mh); @@ -171,7 +170,7 @@ } setSize(); } - + protected void scaleHexesGUI () { hexArray = mapManager.getHexes(); GUIHex hex; @@ -189,19 +188,33 @@ } protected void drawLabel(Graphics2D g2, int index, int xCoordinate, int yCoordinate, boolean letter) { - String label = letter - ? String.valueOf((char)('@'+index)) - : String.valueOf(index); + String label = letter ? getLetterLabel (index) : getNumberLabel (index); xCoordinate -= 4.0*label.length(); yCoordinate += 4.0; g2.drawString(label, xCoordinate, yCoordinate); - + // log.debug("Draw Label " + label + " for " + index + " at x = " + xCoordinate + ", y = " + yCoordinate); } + private String getLetterLabel (int index) { + if (index > 26) { + return "A" + String.valueOf((char)('@'+(index-26))); // For 1825U1 row "AA" + } else { + return String.valueOf((char)('@'+index)); + } + } + + private String getNumberLabel (int index) { + if (index < 0) { + return String.valueOf(100 + index); // For 1825U1 column "99" + } else { + return String.valueOf(index); + } + } + @Override public void paint(Graphics g) { @@ -214,7 +227,7 @@ int yTop = (int)calcYCoordinates(minRow, - coordinateYMargin); int yBottom = (int)calcYCoordinates(maxRow, coordinateYMargin); - + for (int iCol = minCol; iCol <= maxCol; iCol++) { int xCoordinate = (int)(calcXCoordinates(iCol, 0)); drawLabel(g2, iCol, xCoordinate, yTop, lettersGoHorizontal); @@ -230,7 +243,7 @@ } - + public void setupHexes() { setupHexesGUI(); setupBars(); @@ -293,10 +306,10 @@ hex.paintBars(g); } } - + // paint train paths Graphics2D g2 = (Graphics2D) g; - Stroke trainStroke = + Stroke trainStroke = new BasicStroke((int)(strokeWidth * zoomFactor), strokeCap, strokeJoin); g2.setStroke(trainStroke); @@ -506,7 +519,7 @@ public void setTrainPaths(List<GeneralPath> trainPaths) { this.trainPaths = trainPaths; } - + /** * Off-board tiles must be able to retrieve the current phase. * Modified: trunk/18xx/rails/util/Tag.java =================================================================== --- trunk/18xx/rails/util/Tag.java 2010-09-20 21:32:32 UTC (rev 1430) +++ trunk/18xx/rails/util/Tag.java 2010-09-22 21:38:18 UTC (rev 1431) @@ -287,6 +287,11 @@ "IfOption has no optionName attribute"); name = nameAttr.getNodeValue(); + Node parmAttr = nnp.getNamedItem("parm"); + if (parmAttr != null) { + value = parmAttr.getNodeValue(); + name = GameOption.constructParametrisedName(name, value.split(",")); + } Node valueAttr = nnp.getNamedItem("value"); if (valueAttr == null) throw new ConfigurationException( @@ -301,7 +306,19 @@ } String optionValue = gameOptions.get(name); + + // For backwards compatibility: search for an extended name if (optionValue == null) { + for (String optName : gameOptions.keySet()) { + if (optName.startsWith(name)) { + optionValue = gameOptions.get(optName); + log.warn("Option name "+name+" replaced by "+optName); + break; + } + } + } + + if (optionValue == null) { // Take the default value GameOption go = GameOption.getByName(name); optionValue = go != null ? go.getDefaultValue() : ""; @@ -309,6 +326,7 @@ + " but no assigned value found, assumed "+optionValue); } + if (optionValue.equalsIgnoreCase(value)) { parseSubTags(childElement); } Property changes on: trunk/18xx/test ___________________________________________________________________ Added: svn:ignore + Test.java Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-09-23 23:02:10
|
Revision: 1432 http://rails.svn.sourceforge.net/rails/?rev=1432&view=rev Author: evos Date: 2010-09-23 23:01:59 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Added 1825 special tiles. Fixed map. Modified Paths: -------------- trunk/18xx/data/1825/Map.xml trunk/18xx/data/1825/TileSet.xml trunk/18xx/data/1825/Tiles.xml trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/TileDictionary.xml trunk/18xx/tiles/Tiles.xml trunk/18xx/tiles/svg/tile-102.svg trunk/18xx/tiles/svg/tile-25002.svg trunk/18xx/tiles/svg/tile-25003.svg trunk/18xx/tiles/svg/tile-804.svg Added Paths: ----------- trunk/18xx/tiles/svg/tile-25008.svg trunk/18xx/tiles/svg/tile-25009.svg trunk/18xx/tiles/svg/tile-25010.svg trunk/18xx/tiles/svg/tile-25011.svg trunk/18xx/tiles/svg/tile-25012.svg trunk/18xx/tiles/svg/tile-25013.svg trunk/18xx/tiles/svg/tile-25014.svg trunk/18xx/tiles/svg/tile-25015.svg trunk/18xx/tiles/svg/tile-25016.svg Property Changed: ---------------- trunk/18xx/tiles/ Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-22 21:38:18 UTC (rev 1431) +++ trunk/18xx/data/1825/Map.xml 2010-09-23 23:01:59 UTC (rev 1432) @@ -1,7 +1,7 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> <IfOption name="Include" parm="Unit3" value="yes"> <Hex name="B8" tile="-5" orientation="1" city="Inverness"/> - <!--Hex name="B12" tile="-25011" city="Aberdeen"/--> + <Hex name="B12" tile="-25011" city="Aberdeen"/> <Hex name="C7" tile="-1" cost="100" city="Pitlochry" open="1,2"/> <Hex name="C9" tile="0" cost="100" open="3"/> <Hex name="C11" tile="0" open="2"/> @@ -15,11 +15,11 @@ <Hex name="E5" tile="0" cost="100"/> <Hex name="E7" tile="-25005" orientation="1" city="Perth"/> <Hex name="E9" tile="-10" cost="80" city="Dundee"/> - <!--Hex name="F2" tile="-25012" city="Helensburgh, Gourock"/--> + <Hex name="F2" tile="-25012" city="Helensburgh, Gourock"/> <Hex name="F4" tile="-1" cost="40" city="Dumbarton"/> <Hex name="F6" tile="-1" city="Stirling"/> <Hex name="F8" tile="-2" orientation="3" cost="120" city="Dumfermline, Kirkaldy"/> - <!--Hex name="F10" tile="-25013" city="Anstruther"/--> + <Hex name="F10" tile="-25013" city="Anstruther"/> <Hex name="G3" tile="-10" city="Greenock"/> <Hex name="G5" tile="-25002" city="Glasgow"/> <Hex name="G7" tile="-2" city="Coatbridge, Airdrie"/> @@ -44,7 +44,7 @@ <Hex name="J10" tile="-10" ciry="Carlisle"/> <Hex name="J12" tile="0" cost="100"/> <Hex name="J14" tile="-20" cost="40" city="Newcastle u/T, Sunderland"/> - <!--Hex name="K7" tile="-25014" orientation="2" city="Maryport"/--> + <Hex name="K7" tile="-25014" orientation="2" city="Maryport"/> <Hex name="K9" tile="0" cost="100" open="0,5"/> <Hex name="K11" tile="0" cost="100" open="0,5"/> <Hex name="K13" tile="-1" city="Durham" open="0,5"/> @@ -57,7 +57,7 @@ <Hex name="L14" tile="-10" city="Darlington" open="2,3"/> <Hex name="L16" tile="0" open="2"/> <Hex name="L18" tile="-1" city="Scarborough"/> - <!--Hex name="M9" tile="-25008" city="Barrow"/--> + <Hex name="M9" tile="-25008" city="Barrow"/> <Hex name="M11" tile="0" cost="100"/> <Hex name="M13" tile="0" cost="100"/> <Hex name="M15" tile="-2" city="Harrogate, York"/> @@ -68,10 +68,10 @@ <Hex name="N14" tile="-20" city="Bradford, Leeds"/> <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="O9" tile="-25009" cost="40" city="Liverpool"/> <Hex name="O11" tile="-25002" city="Manchester"/> <Hex name="O13" tile="0" cost="100"/> - <!--Hex name="O15" tile="-25010" city="Barnsley, Doncaster"/--> + <Hex name="O15" tile="-25010" city="Barnsley, Doncaster"/> <Hex name="O17" tile="0" cost="40"/> <Hex name="O19" tile="0"/> <Hex name="P8" tile="-41" orientation="4"/> @@ -135,7 +135,12 @@ <Hex name="V18" tile="0"/> <Hex name="V20" tile="-25001" city="London"/> <Hex name="V22" tile="-25006" value="20" city="Southend"/> - <Hex name="W9" tile="-41" orientation="3" /> + <IfOption name="Include" parm="R2" value="no"> + <Hex name="W9" tile="-41" orientation="3" /> + </IfOption> + <IfOption name="Include" parm="R2" value="yes"> + <Hex name="W9" tile="-25016"/> + </IfOption> <Hex name="W11" tile="-2" city="Bath,Trowbridge" orientation="4" /> <Hex name="W13" tile="0"/> <Hex name="W15" tile="0"/> @@ -171,10 +176,11 @@ <Hex name="T2" tile="-10" city="Fishguard"/> <Hex name="T4" tile="0"/> <Hex name="T6" tile="0" cost="100"/> - <!--Hex name="U1" tile="-25015" city="Milford Haven"/--> + <Hex name="U1" tile="-25015" city="Milford Haven"/> <Hex name="U3" tile="0"/> <Hex name="U5" tile="0"/> - <Hex name="V8" tile="-25007" orientation="1" city="Swansea"/> + <Hex name="U7" tile="-2"/> + <Hex name="V6" tile="-25007" orientation="1" city="Swansea"/> </IfOption> <IfOption name="Include" parm="R2" value="yes"> <Hex name="X4" tile="-1" city="Barnstaple"/> @@ -187,11 +193,11 @@ <Hex name="Z2" tile="-1" city="Fowey"/> <Hex name="Z4" tile="-20" city="Devenport, Plymouth"/> <Hex name="Z6" tile="-1" city="Torquay"/> - <!--Hex name="AA-1" tile="-1" city="Penzance"/> - <Hex name="AA1" tile="-10" city="Falmouth"/--> + <Hex name="AA99" tile="-1" city="Penzance"/> + <Hex name="AA1" tile="-10" city="Falmouth"/> </IfOption> <IfOption name="Include" parm="R3" value="yes"> - <!--Hex name="Q23" tile="-25014" orientation="1" city="Melton Constable"/--> + <Hex name="Q23" tile="-25014" orientation="1" city="Melton Constable"/> <Hex name="Q25" tile="0"/> </IfOption> </IfOption> Modified: trunk/18xx/data/1825/TileSet.xml =================================================================== --- trunk/18xx/data/1825/TileSet.xml 2010-09-22 21:38:18 UTC (rev 1431) +++ trunk/18xx/data/1825/TileSet.xml 2010-09-23 23:01:59 UTC (rev 1432) @@ -27,6 +27,15 @@ <Tile id="-25005"/> <Tile id="-25006"/> <Tile id="-25007"/> + <Tile id="-25008"/> + <Tile id="-25009"><!--Liverpool--><Upgrade id="33"/></Tile> + <Tile id="-25010"/> + <Tile id="-25011"/> + <Tile id="-25012"/> + <Tile id="-25013"/> + <Tile id="-25014"/> + <Tile id="-25015"/> + <Tile id="-25016"/> <!-- Yellow tiles --> <Tile id="1" quantity="1" > <Upgrade id="14"></Upgrade></Tile> @@ -103,6 +112,7 @@ <Tile id="88" quantity="1"></Tile> <!-- Brown tiles --> <Tile id="32" quantity="1" /> + <Tile id="33" quantity="1" /> <Tile id="34" quantity="1" /> <Tile id="38" quantity="2" /> <Tile id="41" quantity="1" /> Modified: trunk/18xx/data/1825/Tiles.xml =================================================================== --- trunk/18xx/data/1825/Tiles.xml 2010-09-22 21:38:18 UTC (rev 1431) +++ trunk/18xx/data/1825/Tiles.xml 2010-09-23 23:01:59 UTC (rev 1432) @@ -1,279 +1,399 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<Tiles> - <Tile colour="white" id="0" name="empty"/> - <!--Tile colour="white" id="-10000" name="empty"/--> - <Tile colour="white" id="-1" name="1 village"> - <Station id="city1" position="002" type="Town"/> - </Tile><Tile colour="white" id="-2" name="2 villages"> - <Station id="city1" position="102" type="Town"/> - <Station id="city2" position="302" type="Town"/> - </Tile><Tile colour="white" id="-10" name="1 city"> - <Station id="city1" position="302" slots="1" type="City"/> - </Tile><Tile colour="yellow" id="-20" name="2 cities"> - <Station id="city1" position="002" slots="1" type="City"/> - <Station id="city2" position="302" slots="1" type="City"/> - </Tile><Tile colour="fixed" id="-5" name="MF 5"> - <Station id="city1" position="0" slots="1" type="City" value="20"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side1"/> - </Tile><Tile colour="fixed" id="-7" name="MF 7"> - <Track from="side2" gauge="normal" to="side1"/> - </Tile><Tile colour="fixed" id="-41" name="-41"> - <Track from="side0" gauge="normal" to="side3"/> - <Track from="side4" gauge="normal" to="side0"/> - <Track from="side4" gauge="normal" to="side3"/> - </Tile><Tile colour="fixed" id="-104" name="MF 104"> - <Station id="city1" position="0" slots="1" type="City" value="20"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="green" id="-25001" name="London"> - <Station id="city1" position="403" slots="1" type="City" value="50"/> - <Station id="city2" position="503" slots="1" type="City" value="50"/> - <Station id="city3" position="003" slots="1" type="City" value="50"/> - <Station id="city4" position="103" slots="1" type="City" value="50"/> - <Station id="city5" position="203" slots="1" type="City" value="50"/> - <Station id="city6" position="303" slots="1" type="City" value="50"/> - <Track from="side5" gauge="normal" to="city2"/> - <Track from="side4" gauge="normal" to="city1"/> - <Track from="side3" gauge="normal" to="city6"/> - <Track from="side2" gauge="normal" to="city5"/> - <Track from="side1" gauge="normal" to="city4"/> - <Track from="side0" gauge="normal" to="city3"/> - </Tile><Tile colour="green" id="-25002" name="Birmingham"> - <Station id="city1" position="402" slots="1" type="City" value="40"/> - <Station id="city2" position="002" slots="1" type="City" value="40"/> - <Station id="city3" position="202" slots="1" type="City" value="40"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city3" gauge="normal" to="side2"/> - <Track from="side0" gauge="normal" to="city2"/> - </Tile><Tile colour="green" id="-25003" name="Bristol"> - <Station id="city1" position="0" slots="1" type="City" value="30"/> - <Track from="side3" gauge="normal" to="city1"/> - <Track from="city1" gauge="normal" to="side1"/> - </Tile><Tile colour="fixed" id="-25004" name="Wolverton"> - <Station id="city1" position="0" slots="1" type="City" value="10"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side5"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="fixed" id="-25005" name="Swindon"> - <Station id="city1" position="0" slots="1" type="City" value="10"/> - <Track from="side4" gauge="normal" to="city1"/> - <Track from="side5" gauge="normal" to="city1"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="fixed" id="-25006" name="Southend"> - <Station id="city1" position="102" slots="1" type="City" value="20"/> - <Track from="side4" gauge="normal" to="side0"/> - <Track from="side4" gauge="normal" to="city1"/> - <Track from="side3" gauge="normal" to="side2"/> - </Tile><Tile colour="fixed" id="-25007" name="Bournemouth"> - <Station id="city1" position="0" slots="1" type="City" value="20"/> - <Station id="city2" position="0" slots="1" type="City" value="20"/> - <Track from="side4" gauge="normal" to="city2"/> - <Track from="side5" gauge="normal" to="city2"/> - <Track from="side0" gauge="normal" to="city2"/> - </Tile><Tile colour="yellow" id="1" name="1"> - <Station id="city1" position="408" type="Town" value="10"/> - <Station id="city2" position="108" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city2" gauge="normal" to="side1"/> - <Track from="city2" gauge="normal" to="side3"/> - </Tile><Tile colour="yellow" id="2" name="2"> - <Station id="city1" position="302" type="Town" value="10"/> - <Station id="city2" position="109" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city2" gauge="normal" to="side1"/> - <Track from="city2" gauge="normal" to="side2"/> - </Tile><Tile colour="yellow" id="3" name="3"> - <Station id="city1" position="352" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side4"/> - </Tile><Tile colour="yellow" id="4" name="4"> - <Station id="city1" position="0" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side0"/> - </Tile><Tile colour="yellow" id="5" name="5"> - <Station id="city1" position="0" slots="1" type="City" value="20"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="yellow" id="6" name="6"> - <Station id="city1" position="0" slots="1" type="City" value="20"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="yellow" id="7" name="7"> - <Track from="side3" gauge="normal" to="side4"/> - </Tile><Tile colour="yellow" id="8" name="8"> - <Track from="side3" gauge="normal" to="side5"/> - </Tile><Tile colour="yellow" id="9" name="9"> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="yellow" id="55" name="55"> - <Station id="city1" position="202" type="Town" value="10"/> - <Station id="city2" position="302" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side5"/> - <Track from="city2" gauge="normal" to="side3"/> - <Track from="city2" gauge="normal" to="side0"/> - </Tile><Tile colour="yellow" id="56" name="56"> - <Station id="city1" position="407" type="Town" value="10"/> - <Station id="city2" position="108" type="Town" value="10"/> - <Track from="city2" gauge="normal" to="side1"/> - <Track from="city2" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side2"/> - </Tile><Tile colour="green" id="12" name="12"> - <Station id="city1" position="0" slots="1" type="City" value="30"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side3"/> - </Tile><Tile colour="green" id="13" name="13"> - <Station id="city1" position="0" slots="1" type="City" value="30"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side4"/> - </Tile><Tile colour="green" id="14" name="14"> - <Station id="city1" position="0" slots="2" type="City" value="30"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="15" name="15"> - <Station id="city1" position="0" slots="2" type="City" value="30"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side5"/> - <Track from="city1" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="16" name="16"> - <Track from="side3" gauge="normal" to="side5"/> - <Track from="side4" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="19" name="19"> - <Track from="side5" gauge="normal" to="side1"/> - <Track from="side0" gauge="normal" to="side3"/> - </Tile><Tile colour="green" id="20" name="20"> - <Track from="side1" gauge="normal" to="side4"/> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="23" name="23"> - <Track from="side4" gauge="normal" to="side0"/> - <Track from="side0" gauge="normal" to="side3"/> - </Tile><Tile colour="green" id="24" name="24"> - <Track from="side3" gauge="normal" to="side5"/> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="25" name="25"> - <Track from="side1" gauge="normal" to="side3"/> - <Track from="side3" gauge="normal" to="side5"/> - </Tile><Tile colour="green" id="26" name="26"> - <Track from="side5" gauge="normal" to="side0"/> - <Track from="side0" gauge="normal" to="side3"/> - </Tile><Tile colour="green" id="27" name="27"> - <Track from="side3" gauge="normal" to="side4"/> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="green" id="28" name="28"> - <Track from="side3" gauge="normal" to="side5"/> - <Track from="side4" gauge="normal" to="side5"/> - </Tile><Tile colour="green" id="29" name="29"> - <Track from="side3" gauge="normal" to="side4"/> - <Track from="side3" gauge="normal" to="side5"/> - </Tile><Tile colour="green" id="1052" name="52"> - <Station id="city1" position="152" slots="1" type="City" value="40"/> - <Station id="city2" position="452" slots="1" type="City" value="40"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city2" gauge="normal" to="side4"/> - </Tile><Tile colour="green" id="87" name="87"> - <Station id="city1" position="0" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side5"/> - </Tile><Tile colour="green" id="88" name="88"> - <Station id="city1" position="0" type="Town" value="10"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side5"/> - </Tile><Tile colour="brown" id="32" name="32"> - <Station id="city1" position="303" slots="1" type="City" value="70"/> - <Station id="city2" position="403" slots="1" type="City" value="70"/> - <Station id="city3" position="503" slots="1" type="City" value="70"/> - <Station id="city4" position="003" slots="1" type="City" value="70"/> - <Station id="city5" position="103" slots="1" type="City" value="70"/> - <Station id="city6" position="203" slots="1" type="City" value="70"/> - <Track from="city6" gauge="normal" to="side2"/> - <Track from="city5" gauge="normal" to="side1"/> - <Track from="city4" gauge="normal" to="side0"/> - <Track from="city3" gauge="normal" to="side5"/> - <Track from="city2" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side3"/> - </Tile><Tile colour="brown" id="34" name="34"> - <Station id="city1" position="352" slots="1" type="City" value="50"/> - <Station id="city2" position="052" slots="1" type="City" value="50"/> - <Station id="city3" position="502" slots="1" type="City" value="50"/> - <Track from="city2" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city3" gauge="normal" to="side2"/> - <Track from="city3" gauge="normal" to="side5"/> - </Tile><Tile colour="brown" id="38" name="38"> - <Station id="city1" position="0" slots="2" type="City" value="40"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city1" gauge="normal" to="side2"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side5"/> - </Tile><Tile colour="brown" id="41" name="41"> - <Track from="side4" gauge="normal" to="side0"/> - <Track from="side4" gauge="normal" to="side3"/> - <Track from="side0" gauge="normal" to="side3"/> - </Tile><Tile colour="brown" id="42" name="42"> - <Track from="side3" gauge="normal" to="side5"/> - <Track from="side3" gauge="normal" to="side0"/> - <Track from="side5" gauge="normal" to="side0"/> - </Tile><Tile colour="brown" id="45" name="45"> - <Track from="side1" gauge="normal" to="side5"/> - <Track from="side1" gauge="normal" to="side3"/> - <Track from="side5" gauge="normal" to="side0"/> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="brown" id="46" name="46"> - <Track from="side1" gauge="normal" to="side5"/> - <Track from="side1" gauge="normal" to="side0"/> - <Track from="side3" gauge="normal" to="side5"/> - <Track from="side3" gauge="normal" to="side0"/> - </Tile><Tile colour="brown" id="47" name="47"> - <Track from="side3" gauge="normal" to="side0"/> - <Track from="side3" gauge="normal" to="side1"/> - <Track from="side4" gauge="normal" to="side0"/> - <Track from="side4" gauge="normal" to="side1"/> - </Tile><Tile colour="brown" id="64" name="64"> - <Station id="city1" position="401" slots="1" type="City" value="50"/> - <Station id="city2" position="052" slots="1" type="City" value="50"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side5"/> - <Track from="city2" gauge="normal" to="side1"/> - <Track from="city2" gauge="normal" to="side0"/> - </Tile><Tile colour="brown" id="65" name="65"> - <Station id="city1" position="501" slots="1" type="City" value="50"/> - <Station id="city2" position="252" slots="1" type="City" value="50"/> - <Track from="city1" gauge="normal" to="side4"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city2" gauge="normal" to="side2"/> - <Track from="city2" gauge="normal" to="side3"/> - </Tile><Tile colour="brown" id="66" name="66"> - <Station id="city1" position="002" slots="1" type="City" value="50"/> - <Station id="city2" position="452" slots="1" type="City" value="50"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city1" gauge="normal" to="side0"/> - <Track from="city2" gauge="normal" to="side4"/> - <Track from="city2" gauge="normal" to="side5"/> - </Tile><Tile colour="brown" id="67" name="67"> - <Station id="city1" position="307" slots="1" type="City" value="50"/> - <Station id="city2" position="502" slots="1" type="City" value="50"/> - <Track from="city1" gauge="normal" to="side1"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city2" gauge="normal" to="side5"/> - <Track from="city2" gauge="normal" to="side2"/> - </Tile><Tile colour="brown" id="68" name="68"> - <Station id="city1" position="302" slots="1" type="City" value="50"/> - <Station id="city2" position="502" slots="1" type="City" value="50"/> - <Track from="city1" gauge="normal" to="side3"/> - <Track from="city2" gauge="normal" to="side2"/> - <Track from="city2" gauge="normal" to="side5"/> - <Track from="city1" gauge="normal" to="side0"/> - </Tile></Tiles> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Tiles> + <Tile colour="white" id="0" name="empty"/> + <Tile colour="white" id="-1" name="1 village"> + <Station id="city1" position="002" type="Town"/> + </Tile> + <Tile colour="white" id="-2" name="2 villages"> + <Station id="city1" position="102" type="Town"/> + <Station id="city2" position="302" type="Town"/> + </Tile> + <Tile colour="white" id="-10" name="1 city"> + <Station id="city1" position="302" slots="1" type="City"/> + </Tile> + <Tile colour="yellow" id="-20" name="2 cities"> + <Station id="city1" position="002" slots="1" type="City"/> + <Station id="city2" position="302" slots="1" type="City"/> + </Tile> + <Tile colour="fixed" id="-5" name="MF 5"> + <Station id="city1" position="0" slots="1" type="City" value="20"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side1"/> + </Tile> + <Tile colour="fixed" id="-7" name="MF 7"> + <Track from="side2" gauge="normal" to="side1"/> + </Tile> + <Tile colour="fixed" id="-41" name="-41"> + <Track from="side0" gauge="normal" to="side3"/> + <Track from="side4" gauge="normal" to="side0"/> + <Track from="side4" gauge="normal" to="side3"/> + </Tile> + <Tile colour="fixed" id="-104" name="MF 104"> + <Station id="city1" position="0" slots="1" type="City" value="20"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="green" id="-25001" name="London"> + <Station id="city1" position="403" slots="1" type="City" value="50"/> + <Station id="city2" position="503" slots="1" type="City" value="50"/> + <Station id="city3" position="003" slots="1" type="City" value="50"/> + <Station id="city4" position="103" slots="1" type="City" value="50"/> + <Station id="city5" position="203" slots="1" type="City" value="50"/> + <Station id="city6" position="303" slots="1" type="City" value="50"/> + <Track from="side5" gauge="normal" to="city2"/> + <Track from="side4" gauge="normal" to="city1"/> + <Track from="side3" gauge="normal" to="city6"/> + <Track from="side2" gauge="normal" to="city5"/> + <Track from="side1" gauge="normal" to="city4"/> + <Track from="side0" gauge="normal" to="city3"/> + </Tile> + <Tile colour="green" id="-25002" name="B/M/G"> + <Station id="city1" position="402" slots="1" type="City" value="40"/> + <Station id="city2" position="002" slots="1" type="City" value="40"/> + <Station id="city3" position="202" slots="1" type="City" value="40"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city3" gauge="normal" to="side2"/> + <Track from="side0" gauge="normal" to="city2"/> + </Tile> + <Tile colour="green" id="-25003" name="Bristol"> + <Station id="city1" position="0" slots="1" type="City" value="30"/> + <Track from="side3" gauge="normal" to="city1"/> + <Track from="city1" gauge="normal" to="side1"/> + </Tile> + <Tile colour="fixed" id="-25004" name="Wolverton"> + <Station id="city1" position="0" slots="1" type="City" value="10"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side5"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="fixed" id="-25005" name="Swindon"> + <Station id="city1" position="0" slots="1" type="City" value="10"/> + <Track from="side4" gauge="normal" to="city1"/> + <Track from="side5" gauge="normal" to="city1"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="fixed" id="-25006" name="Southend"> + <Station id="city1" position="102" slots="1" type="City" value="20"/> + <Track from="side4" gauge="normal" to="side0"/> + <Track from="side4" gauge="normal" to="city1"/> + <Track from="side3" gauge="normal" to="side2"/> + </Tile> + <Tile colour="fixed" id="-25007" name="Bournemouth"> + <Station id="city1" position="0" slots="1" type="City" value="20"/> + <Station id="city2" position="0" slots="1" type="City" value="20"/> + <Track from="side4" gauge="normal" to="city2"/> + <Track from="side5" gauge="normal" to="city2"/> + <Track from="side0" gauge="normal" to="city2"/> + </Tile> + <Tile colour="fixed" id="-25008" name="Barrow"> + <Station id="city1" position="552" slots="1" type="City" value="10"/> + <Station id="city2" position="152" type="Town" value="10"/> + <Track from="side5" gauge="normal" to="city1"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side2"/> + </Tile> + <Tile colour="green" id="-25009" name="Liverpool"> + <Station id="city1" position="002" slots="1" type="City" value="40"/> + <Station id="city2" position="202" slots="1" type="City" value="40"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side2"/> + </Tile> + <Tile colour="fixed" id="-25010" name="Doncaster"> + <Station id="city1" position="351" slots="1" type="City" value="20"/> + <Station id="city2" position="051" slots="1" type="City" value="20"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city2" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side5"/> + </Tile> + <Tile colour="fixed" id="-25011" name="Aberdeen"> + <Station id="city1" position="0" slots="1" type="City" value="30"/> + <Track from="city1" gauge="normal" to="side3"/> + </Tile> + <Tile colour="fixed" id="-25012" name="Helensburgh"> + <Station id="city1" position="202" type="Town" value="10"/> + <Station id="city2" position="102" type="Town" value="10"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="fixed" id="-25013" name="Anstruther"> + <Station id="city1" position="502" type="Town" value="10"/> + <Track from="side2" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side5"/> + </Tile> + <Tile colour="fixed" id="-25014" name="Maryport"> + <Station id="city1" position="051" slots="1" type="City" value="10"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side1"/> + </Tile> + <Tile colour="fixed" id="-25015" name="Milford H."> + <Station id="city1" position="052" slots="1" type="City" value="10"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side1"/> + </Tile> + <Tile colour="fixed" id="-25016" name="Highbridge"> + <Station id="city1" position="151" slots="1" type="City" value="10"/> + <Track from="side0" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="yellow" id="1" name="1"> + <Station id="city1" position="408" type="Town" value="10"/> + <Station id="city2" position="108" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side3"/> + </Tile> + <Tile colour="yellow" id="2" name="2"> + <Station id="city1" position="302" type="Town" value="10"/> + <Station id="city2" position="109" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side2"/> + </Tile> + <Tile colour="yellow" id="3" name="3"> + <Station id="city1" position="352" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side4"/> + </Tile> + <Tile colour="yellow" id="4" name="4"> + <Station id="city1" position="0" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side0"/> + </Tile> + <Tile colour="yellow" id="5" name="5"> + <Station id="city1" position="0" slots="1" type="City" value="20"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="yellow" id="6" name="6"> + <Station id="city1" position="0" slots="1" type="City" value="20"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="yellow" id="7" name="7"> + <Track from="side3" gauge="normal" to="side4"/> + </Tile> + <Tile colour="yellow" id="8" name="8"> + <Track from="side3" gauge="normal" to="side5"/> + </Tile> + <Tile colour="yellow" id="9" name="9"> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="yellow" id="55" name="55"> + <Station id="city1" position="202" type="Town" value="10"/> + <Station id="city2" position="302" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side5"/> + <Track from="city2" gauge="normal" to="side3"/> + <Track from="city2" gauge="normal" to="side0"/> + </Tile> + <Tile colour="yellow" id="56" name="56"> + <Station id="city1" position="407" type="Town" value="10"/> + <Station id="city2" position="108" type="Town" value="10"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side2"/> + </Tile> + <Tile colour="green" id="12" name="12"> + <Station id="city1" position="0" slots="1" type="City" value="30"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side3"/> + </Tile> + <Tile colour="green" id="13" name="13"> + <Station id="city1" position="0" slots="1" type="City" value="30"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side4"/> + </Tile> + <Tile colour="green" id="14" name="14"> + <Station id="city1" position="0" slots="2" type="City" value="30"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="15" name="15"> + <Station id="city1" position="0" slots="2" type="City" value="30"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side5"/> + <Track from="city1" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="16" name="16"> + <Track from="side3" gauge="normal" to="side5"/> + <Track from="side4" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="19" name="19"> + <Track from="side5" gauge="normal" to="side1"/> + <Track from="side0" gauge="normal" to="side3"/> + </Tile> + <Tile colour="green" id="20" name="20"> + <Track from="side1" gauge="normal" to="side4"/> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="23" name="23"> + <Track from="side4" gauge="normal" to="side0"/> + <Track from="side0" gauge="normal" to="side3"/> + </Tile> + <Tile colour="green" id="24" name="24"> + <Track from="side3" gauge="normal" to="side5"/> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="25" name="25"> + <Track from="side1" gauge="normal" to="side3"/> + <Track from="side3" gauge="normal" to="side5"/> + </Tile> + <Tile colour="green" id="26" name="26"> + <Track from="side5" gauge="normal" to="side0"/> + <Track from="side0" gauge="normal" to="side3"/> + </Tile> + <Tile colour="green" id="27" name="27"> + <Track from="side3" gauge="normal" to="side4"/> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="green" id="28" name="28"> + <Track from="side3" gauge="normal" to="side5"/> + <Track from="side4" gauge="normal" to="side5"/> + </Tile> + <Tile colour="green" id="29" name="29"> + <Track from="side3" gauge="normal" to="side4"/> + <Track from="side3" gauge="normal" to="side5"/> + </Tile> + <Tile colour="green" id="1052" name="52"> + <Station id="city1" position="152" slots="1" type="City" value="40"/> + <Station id="city2" position="452" slots="1" type="City" value="40"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city2" gauge="normal" to="side4"/> + </Tile> + <Tile colour="green" id="87" name="87"> + <Station id="city1" position="0" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side5"/> + </Tile> + <Tile colour="green" id="88" name="88"> + <Station id="city1" position="0" type="Town" value="10"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side5"/> + </Tile> + <Tile colour="brown" id="32" name="32"> + <Station id="city1" position="303" slots="1" type="City" value="70"/> + <Station id="city2" position="403" slots="1" type="City" value="70"/> + <Station id="city3" position="503" slots="1" type="City" value="70"/> + <Station id="city4" position="003" slots="1" type="City" value="70"/> + <Station id="city5" position="103" slots="1" type="City" value="70"/> + <Station id="city6" position="203" slots="1" type="City" value="70"/> + <Track from="city6" gauge="normal" to="side2"/> + <Track from="city5" gauge="normal" to="side1"/> + <Track from="city4" gauge="normal" to="side0"/> + <Track from="city3" gauge="normal" to="side5"/> + <Track from="city2" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side3"/> + </Tile> + <Tile colour="brown" id="33" name="33"> + <Station id="city1" position="102" slots="1" type="City" value="50"/> + <Station id="city2" position="302" slots="1" type="City" value="50"/> + <Station id="city3" position="502" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city2" gauge="normal" to="side3"/> + <Track from="city3" gauge="normal" to="side4"/> + </Tile> + <Tile colour="brown" id="34" name="34"> + <Station id="city1" position="352" slots="1" type="City" value="50"/> + <Station id="city2" position="052" slots="1" type="City" value="50"/> + <Station id="city3" position="502" slots="1" type="City" value="50"/> + <Track from="city2" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city3" gauge="normal" to="side2"/> + <Track from="city3" gauge="normal" to="side5"/> + </Tile> + <Tile colour="brown" id="38" name="38"> + <Station id="city1" position="0" slots="2" type="City" value="40"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city1" gauge="normal" to="side2"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side5"/> + </Tile> + <Tile colour="brown" id="41" name="41"> + <Track from="side4" gauge="normal" to="side0"/> + <Track from="side4" gauge="normal" to="side3"/> + <Track from="side0" gauge="normal" to="side3"/> + </Tile> + <Tile colour="brown" id="42" name="42"> + <Track from="side3" gauge="normal" to="side5"/> + <Track from="side3" gauge="normal" to="side0"/> + <Track from="side5" gauge="normal" to="side0"/> + </Tile> + <Tile colour="brown" id="45" name="45"> + <Track from="side1" gauge="normal" to="side5"/> + <Track from="side1" gauge="normal" to="side3"/> + <Track from="side5" gauge="normal" to="side0"/> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="brown" id="46" name="46"> + <Track from="side1" gauge="normal" to="side5"/> + <Track from="side1" gauge="normal" to="side0"/> + <Track from="side3" gauge="normal" to="side5"/> + <Track from="side3" gauge="normal" to="side0"/> + </Tile> + <Tile colour="brown" id="47" name="47"> + <Track from="side3" gauge="normal" to="side0"/> + <Track from="side3" gauge="normal" to="side1"/> + <Track from="side4" gauge="normal" to="side0"/> + <Track from="side4" gauge="normal" to="side1"/> + </Tile> + <Tile colour="brown" id="64" name="64"> + <Station id="city1" position="401" slots="1" type="City" value="50"/> + <Station id="city2" position="052" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side5"/> + <Track from="city2" gauge="normal" to="side1"/> + <Track from="city2" gauge="normal" to="side0"/> + </Tile> + <Tile colour="brown" id="65" name="65"> + <Station id="city1" position="501" slots="1" type="City" value="50"/> + <Station id="city2" position="252" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side4"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side2"/> + <Track from="city2" gauge="normal" to="side3"/> + </Tile> + <Tile colour="brown" id="66" name="66"> + <Station id="city1" position="002" slots="1" type="City" value="50"/> + <Station id="city2" position="452" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city1" gauge="normal" to="side0"/> + <Track from="city2" gauge="normal" to="side4"/> + <Track from="city2" gauge="normal" to="side5"/> + </Tile> + <Tile colour="brown" id="67" name="67"> + <Station id="city1" position="307" slots="1" type="City" value="50"/> + <Station id="city2" position="502" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side1"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city2" gauge="normal" to="side5"/> + <Track from="city2" gauge="normal" to="side2"/> + </Tile> + <Tile colour="brown" id="68" name="68"> + <Station id="city1" position="302" slots="1" type="City" value="50"/> + <Station id="city2" position="502" slots="1" type="City" value="50"/> + <Track from="city1" gauge="normal" to="side3"/> + <Track from="city2" gauge="normal" to="side2"/> + <Track from="city2" gauge="normal" to="side5"/> + <Track from="city1" gauge="normal" to="side0"/> + </Tile> +</Tiles> \ No newline at end of file Property changes on: trunk/18xx/tiles ___________________________________________________________________ Added: svn:ignore + Copy of TileDictionary.18t handmade TDwithID TDwoID xml tileimages.xml Copy (2) of TileDictionary.18t Copy (3) of TileDictionary.18t Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/TileDictionary.xml =================================================================== --- trunk/18xx/tiles/TileDictionary.xml 2010-09-22 21:38:18 UTC (rev 1431) +++ trunk/18xx/tiles/TileDictionary.xml 2010-09-23 23:01:59 UTC (rev 1432) @@ -1,19867 +1,20196 @@ -<?xml version="1.0"?> -<tiles> - <tile> - <ID>-909</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM straight</name> - <junctions/> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp4SideC</position1> - <position2>tp4SideF</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-908</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM wide curve</name> - <junctions/> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp4SideA</position1> - <position2>tp4SideC</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-907</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM tight curve</name> - <junctions/> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp4SideB</position1> - <position2>tp4SideC</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-903</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM 3 way</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCenter</position> - <revenue> - <value>-1</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>tp4SideC</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideB</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-902</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM 2 way</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCenter</position> - <revenue> - <value>-1</value> - <position>tp3CornerA</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideC</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideB</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-901</ID> - <shape>tsHexagon</shape> - <level>tlOffMap</level> - <name>OM 1 way</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCenter</position> - <revenue> - <value>-1</value> - <position>tp3CornerA</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideC</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-102</ID> - <shape>tsHexagon</shape> - <level>tlMapFixed</level> - <name>-102</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tp1CornerD</position> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp1CornerD</position1> - <position2>tp4SideB</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp1CornerD</position1> - <position2>tp4SideD</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp1CornerD</position1> - <position2>tp4SideE</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-101</ID> - <shape>tsHexagon</shape> - <level>tlMapFixed</level> - <name>Philadelphia</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>tp4SideE</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp2CornerD</position1> - <position2>tp4SideB</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp2CornerD</position1> - <position2>tp4SideE</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-21</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToGreen</level> - <name>NY</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tp2SideC</position> - <revenue> - <value>40</value> - <position>tp3SideE</position> - </revenue> - </junction> - <junction> - <junType>jtCity</junType> - <position>tp2SideF</position> - <revenue> - <value>40</value> - <position>tp3SideB</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp2SideC</position1> - <position2>tp4SideC</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp2SideF</position1> - <position2>tp4SideF</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-20</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToGreen</level> - <name>2 cities</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tp2SideA</position> - </junction> - <junction> - <junType>jtCity</junType> - <position>tp2SideD</position> - </junction> - </junctions> - <connections/> - </tile> - <tile> - <ID>-11</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToGreen</level> - <name>B</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tpCenter</position> - <revenue> - <value>30</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>tp4SideD</position2> - </connection> - </connections> - </tile> - <tile> - <ID>-10</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToYellow</level> - <name>1 city</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tp2SideD</position> - </junction> - </junctions> - <connections/> - </tile> - <tile> - <ID>-2</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToYellow</level> - <name>2 villages</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tp2SideB</position> - </junction> - <junction> - <junType>jtWhistlestop</junType> - <position>tp2SideD</position> - </junction> - </junctions> - <connections/> - </tile> - <tile> - <ID>-1</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToYellow</level> - <name>1 village</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tp2SideA</position> - </junction> - </junctions> - <connections/> - </tile> - <tile> - <ID>0</ID> - <shape>tsHexagon</shape> - <level>tlMapUpgradableToYellow</level> - <name>empty</name> - <junctions/> - <connections/> - </tile> - <tile> - <ID>1</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>1</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCurve2LeftE</position> - <revenue> - <value>10</value> - <position>tp3CornerE</position> - </revenue> - </junction> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCurve2LeftB</position> - <revenue> - <value>10</value> - <position>tp3CornerB</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve2LeftE</position1> - <position2>tp4SideA</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve2LeftE</position1> - <position2>tp4SideE</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve2LeftB</position1> - <position2>tp4SideB</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve2LeftB</position1> - <position2>tp4SideD</position2> - </connection> - </connections> - </tile> - <tile> - <ID>2</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>2</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tp2SideD</position> - <revenue> - <value>10</value> - <position>tp3CornerE</position> - </revenue> - </junction> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCurve1LeftB</position> - <revenue> - <value>10</value> - <position>tp3CornerB</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp2SideD</position1> - <position2>tp4SideD</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp2SideD</position1> - <position2>tp4SideA</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve1LeftB</position1> - <position2>tp4SideB</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCurve1LeftB</position1> - <position2>tp4SideC</position2> - </connection> - </connections> - </tile> - <tile> - <ID>3</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>3</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tp2CornerE</position> - <revenue> - <value>10</value> - <position>tp3CornerB</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tp2CornerE</position1> - <position2>tp4SideD</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tp2CornerE</position1> - <position2>tp4SideE</position2> - </connection> - </connections> - </tile> - <tile> - <ID>4</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>4</name> - <junctions> - <junction> - <junType>jtWhistlestop</junType> - <position>tpCenter</position> - <revenue> - <value>10</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>tp4SideA</position2> - </connection> - </connections> - </tile> - <tile> - <ID>5</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>5</name> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tpCenter</position> - <revenue> - <value>20</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> - </connections> - </tile> - <tile> - <ID>1005</ID> - <shape>tsHexagon</shape> - <level>tlYellow</level> - <name>5/1832</name> - <category> - <value>Lille</value> - <position>tp3SideC</position> - </category> - <junctions> - <junction> - <junType>jtCity</junType> - <position>tpCenter</position> - <revenue> - <value>30</value> - <position>tp3CornerA</position> - </revenue> - </junction> - </junctions> - <connections> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideF</position2> - </connection> - <connection> - <conType>ctNormal</conType> - <position1>tpCenter</position1> - <position2>tp4SideE</posi... [truncated message content] |
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-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-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: <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-11-09 15:45:53
|
Revision: 1458 http://rails.svn.sourceforge.net/rails/?rev=1458&view=rev Author: evos Date: 2010-11-09 15:45:47 +0000 (Tue, 09 Nov 2010) Log Message: ----------- Replace bank cash display by "BROKEN" once that is the case. Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/Bank.java trunk/18xx/rails/game/model/CashModel.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/LocalisedText.properties 2010-11-09 15:45:47 UTC (rev 1458) @@ -26,7 +26,8 @@ BID=Bid BID_ITEM_LOG={0} bids {1} on {2}. Remaining free cash {3}. BID_ITEM={0} bids {1} on {2}. -BidMustBeMultipleOf=Invalid bid {0}: must be multiple of {1} +BidMustBeMultipleOf=Invalid bid {0}: must be multiple of {1} +BROKEN=BROKEN BUY=Buy BUY_PRIVATE=Buy Private BUY_SHARE_LOG={0} buys a {1}% share of {2} from {3} for {4}. Modified: trunk/18xx/rails/game/Bank.java =================================================================== --- trunk/18xx/rails/game/Bank.java 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/rails/game/Bank.java 2010-11-09 15:45:47 UTC (rev 1458) @@ -146,6 +146,7 @@ */ if (money.getCash() <= 0 && !broken.booleanValue()) { broken.set(true); + money.setText(LocalText.getText("BROKEN")); GameManager.getInstance().registerBrokenBank(); } } Modified: trunk/18xx/rails/game/model/CashModel.java =================================================================== --- trunk/18xx/rails/game/model/CashModel.java 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/rails/game/model/CashModel.java 2010-11-09 15:45:47 UTC (rev 1458) @@ -2,17 +2,22 @@ package rails.game.model; import rails.game.*; +import rails.game.state.StringState; public class CashModel extends ModelObject { - private int cash; - private CashHolder owner; + protected int cash; + protected CashHolder owner; + /** Text to be displayed instead of the cash amount (if length > 0) */ + protected StringState displayText = new StringState("BankCashDisplayText", ""); + public static final int SUPPRESS_ZERO = 1; public CashModel(CashHolder owner) { cash = 0; this.owner = owner; + displayText.addDependent(this); } public void setCash(int newCash) { @@ -36,7 +41,10 @@ */ @Override public String getText() { - if (cash == 0 && (option & SUPPRESS_ZERO) > 0 + String fixedText = displayText.getText(); + if (!"".equals(fixedText)) { + return fixedText; + } else if (cash == 0 && (option & SUPPRESS_ZERO) > 0 || owner instanceof PublicCompanyI && !((PublicCompanyI) owner).hasStarted()) { return ""; @@ -45,4 +53,7 @@ } } + public void setText (String text) { + displayText.set (text); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-18 12:16:10
|
Revision: 1460 http://rails.svn.sourceforge.net/rails/?rev=1460&view=rev Author: evos Date: 2010-12-18 12:16:04 +0000 (Sat, 18 Dec 2010) Log Message: ----------- 1889 fixes: - replaced tile #440 (had only one slot) - removed optional 3rd 6-train. Modified Paths: -------------- trunk/18xx/data/1889/Game.xml trunk/18xx/data/1889/Tiles.xml trunk/18xx/data/GamesList.xml trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/TileDictionary.xml trunk/18xx/tiles/Tiles.xml trunk/18xx/tiles/svg/tile440.svg Modified: trunk/18xx/data/1889/Game.xml =================================================================== --- trunk/18xx/data/1889/Game.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/1889/Game.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -19,7 +19,6 @@ <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="NoMapMode" type="toggle" default="no" /> <GameOption name="BeginnerGame" type="toggle" default="no" /> - <GameOption name="WithOptional6Train" type="toggle" default="no"/> <GameOption name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <GameOption name="TwoPlayersCertLimit70Percent" type="toggle" default="yes"/> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/data/1889/Tiles.xml =================================================================== --- trunk/18xx/data/1889/Tiles.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/1889/Tiles.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -180,7 +180,7 @@ <Track from="city1" gauge="normal" to="side0"/> </Tile> <Tile colour="green" id="440" name="1889 K5 green"> - <Station id="city1" position="0" slots="1" type="City" value="40"/> + <Station id="city1" position="0" slots="2" type="City" value="40"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side3"/> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/GamesList.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -85,7 +85,6 @@ <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="NoMapMode" type="toggle" default="no" /> <Option name="BeginnerGame" type="toggle" default="no" /> - <Option name="WithOptional6Train" type="toggle" default="no"/> <Option name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <Option name="TwoPlayersCertLimit70Percent" type="toggle" default="no"/> <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/TileDictionary.xml =================================================================== --- trunk/18xx/tiles/TileDictionary.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/TileDictionary.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -19306,7 +19306,7 @@ </category> <junctions> <junction> - <junType>jtCity</junType> + <junType>jtDoubleCity</junType> <position>tpCenter</position> <revenue> <value>40</value> Modified: trunk/18xx/tiles/Tiles.xml =================================================================== --- trunk/18xx/tiles/Tiles.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/Tiles.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -3397,7 +3397,7 @@ <Track from="city1" gauge="normal" to="side0"/> </Tile> <Tile colour="green" id="440" name="1889 Takamatsu green"> - <Station id="city1" position="0" slots="1" type="City" value="40"/> + <Station id="city1" position="0" slots="2" type="City" value="40"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side3"/> Modified: trunk/18xx/tiles/svg/tile440.svg =================================================================== --- trunk/18xx/tiles/svg/tile440.svg 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/svg/tile440.svg 2010-12-18 12:16:04 UTC (rev 1460) @@ -1,2 +1,2 @@ -<?xml version="1.0"?> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#38AC00" stroke="#38AC00" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">440</text><circle cx="196" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><path d="M 196,170 L 49,85" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,85" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><circle cx="196" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><ellipse rx="38" ry="34" cx="123" cy="297" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-linejoin="round"/><text x="123" y="297" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Bookman Old Style" font-size="51">40</text><text x="196" y="43" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="TimpaniHeavy" font-size="51">Takamatsu</text><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#38AC00" stroke="#38AC00" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">440</text><polygon points="145,119 247,119 247,221 145,221" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><circle cx="145" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><circle cx="247" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><path d="M 196,170 L 49,85" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,85" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><polygon points="145,119 247,119 247,221 145,221" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><circle cx="145" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><circle cx="247" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><ellipse rx="38" ry="34" cx="123" cy="297" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-linejoin="round"/><text x="123" y="297" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Bookman Old Style" font-size="51">40</text><text x="196" y="43" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="TimpaniHeavy" font-size="51">Takamatsu</text><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-24 18:59:29
|
Revision: 1464 http://rails.svn.sourceforge.net/rails/?rev=1464&view=rev Author: evos Date: 2010-12-24 18:59:23 +0000 (Fri, 24 Dec 2010) Log Message: ----------- Implemented usage of <TileSet><Tile> pictureID attribute. In 18EU this causes the correct tiles (internally numbered 3081-3083) to be displayed. These tiles have also been replaced, as the original SVG images (from JA Tamplin) had a different orientation. Modified Paths: -------------- trunk/18xx/rails/ui/swing/hexmap/GUITile.java trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/svg/tile3081.svg trunk/18xx/tiles/svg/tile3082.svg trunk/18xx/tiles/svg/tile3083.svg Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-22 20:56:50 UTC (rev 1463) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-24 18:59:23 UTC (rev 1464) @@ -24,6 +24,7 @@ protected TileI tile = null; protected String tileType = null; + protected int picId; protected BufferedImage tileImage = null; protected int rotation = 0; @@ -53,6 +54,7 @@ this.hex = (MapHex)guiHex.getModel(); TileManager tileManager = guiHex.getHexMap().orUIManager.getTileManager(); tile = tileManager.getTile(tileId); + picId = tile.getPictureId(); if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; @@ -250,7 +252,7 @@ int zoomStep = guiHex.getHexMap().getZoomStep(); - tileImage = imageLoader.getTile(tileId, zoomStep); + tileImage = imageLoader.getTile(picId, zoomStep); if (tileImage != null) { Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3081.svg =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3082.svg =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3083.svg =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-24 20:24:07
|
Revision: 1465 http://rails.svn.sourceforge.net/rails/?rev=1465&view=rev Author: evos Date: 2010-12-24 20:24:00 +0000 (Fri, 24 Dec 2010) Log Message: ----------- Implemented usage of <TileSet><Tile> pictureID attribute. In 18EU this causes the correct green and brown plain track tiles (internally numbered 3080-3083 and 3544-3546) to be displayed. Modified Paths: -------------- trunk/18xx/data/18EU/TileSet.xml trunk/18xx/rails/ui/swing/RemainingTilesWindow.java trunk/18xx/rails/ui/swing/UpgradesPanel.java trunk/18xx/tiles/svg/tile3080.svg Added Paths: ----------- trunk/18xx/tiles/svg/tile3544.svg trunk/18xx/tiles/svg/tile3545.svg trunk/18xx/tiles/svg/tile3546.svg Modified: trunk/18xx/data/18EU/TileSet.xml =================================================================== --- trunk/18xx/data/18EU/TileSet.xml 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/data/18EU/TileSet.xml 2010-12-24 20:24:00 UTC (rev 1465) @@ -112,9 +112,9 @@ <Tile id="145" quantity="4" /> <Tile id="146" quantity="5" /> <Tile id="147" quantity="4" /> - <Tile id="544" quantity="3" /> - <Tile id="545" quantity="3" /> - <Tile id="546" quantity="3" /> + <Tile id="544" pic="3544" quantity="3" /> + <Tile id="545" pic="3545" quantity="3" /> + <Tile id="546" pic="3546" quantity="3" /> <Tile id="582" quantity="9" /> <Tile id="583" quantity="1"> <AllowsMultipleBasesOfOneCompany/> Modified: trunk/18xx/rails/ui/swing/RemainingTilesWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/RemainingTilesWindow.java 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/rails/ui/swing/RemainingTilesWindow.java 2010-12-24 20:24:00 UTC (rev 1465) @@ -62,6 +62,7 @@ Field label; BufferedImage hexImage; ImageIcon hexIcon; + int picId; // Build the grid with tiles in the sequence as // these have been defined in Tiles.xml @@ -72,8 +73,9 @@ if (tileId <= 0) continue; tile = tmgr.getTile(tileId); + picId = tile.getPictureId(); - hexImage = GameUIManager.getImageLoader().getTile(tileId, 10); + hexImage = GameUIManager.getImageLoader().getTile(picId, 10); hexIcon = new ImageIcon(hexImage); hexIcon.setImage(hexIcon.getImage().getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-24 20:24:00 UTC (rev 1465) @@ -174,7 +174,7 @@ orUIManager.setMessage(LocalText.getText("NoTiles")); } else { for (TileI tile : orUIManager.tileUpgrades) { - BufferedImage hexImage = getHexImage(tile.getId()); + BufferedImage hexImage = getHexImage(tile.getPictureId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. Modified: trunk/18xx/tiles/svg/tile3080.svg =================================================================== (Binary files differ) Added: trunk/18xx/tiles/svg/tile3544.svg =================================================================== --- trunk/18xx/tiles/svg/tile3544.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3544.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">544</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> Added: trunk/18xx/tiles/svg/tile3545.svg =================================================================== --- trunk/18xx/tiles/svg/tile3545.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3545.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">545</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,255 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,255 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> Added: trunk/18xx/tiles/svg/tile3546.svg =================================================================== --- trunk/18xx/tiles/svg/tile3546.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3546.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">546</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-25 21:12:46
|
Revision: 1466 http://rails.svn.sourceforge.net/rails/?rev=1466&view=rev Author: evos Date: 2010-12-25 21:12:39 +0000 (Sat, 25 Dec 2010) Log Message: ----------- Main windows keep their location and size across program restarts. The bounds per window and per game are saved in a file named like "settings_xxxx.rails_ini", where xxxx is the game name. This file is stored in the save directory (as does ConfigWindow), but I'm open to any other suggestions. For some reason that is beyond me, the ReportWindow refuses to register its bounds, so it doesn't work there yet. Modified Paths: -------------- trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/ui/swing/ORWindow.java trunk/18xx/rails/ui/swing/ReportWindow.java trunk/18xx/rails/ui/swing/StartRoundWindow.java trunk/18xx/rails/ui/swing/StatusWindow.java trunk/18xx/rails/ui/swing/StockChart.java trunk/18xx/tiles/TileDictionary.18t Added Paths: ----------- trunk/18xx/rails/ui/swing/WindowSettings.java Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -1,12 +1,6 @@ package rails.ui.swing; -import java.awt.Component; -import java.awt.Container; -import java.awt.EventQueue; import java.awt.Font; -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; @@ -72,6 +66,8 @@ protected SimpleDateFormat saveDateTimeFormat; protected File lastFile, lastDirectory; + protected WindowSettings windowSettings; + protected boolean configuredStockChartVisibility = false; protected boolean previousStockChartVisibilityHint; @@ -93,13 +89,29 @@ this.gameManager = gameManager; uiHints = gameManager.getUIHints(); + initWindowSettings(); initSaveSettings(); initFontSettings(); - + configuredStockChartVisibility = "yes".equalsIgnoreCase(Config.get("stockchart.window.open")); } - + + private void initWindowSettings () { + + windowSettings = new WindowSettings (gameManager.getGameName()); + windowSettings.load(); + } + + public void terminate () { + getWindowSettings ().save(); + System.exit(0); + } + + public WindowSettings getWindowSettings () { + return windowSettings; + } + private void initSaveSettings() { saveDirectory = Config.get("save.directory"); if (!Util.hasValue(saveDirectory)) { @@ -126,7 +138,7 @@ } private void initFontSettings() { - + // font settings, can be game specific String fontType = Config.getGameSpecific("font.ui.name"); Font font = null; @@ -149,14 +161,14 @@ log.debug("Change text fonts to relative scale " + Scale.getFontScale()); changeGlobalFont(font, Scale.getFontScale()); } - + public void gameUIInit(boolean newGame) { imageLoader = new ImageLoader(); stockChart = new StockChart(this); if (Config.get("report.window.type").equalsIgnoreCase("static")) { - reportWindow = new ReportWindow(gameManager); + reportWindow = new ReportWindow(this); } else { reportWindow = new ReportWindowDynamic(this); } @@ -174,7 +186,7 @@ // GraphicsDevice[] gs = ge.getScreenDevices(); // log.debug("ScreenDevices = " + Arrays.toString(gs)); // statusWindow = statusWindowClass.getConstructor(GraphicsConfiguration.class).newInstance(gs[1].getDefaultConfiguration()); - + statusWindow.init(this); } catch (Exception e) { log.fatal("Cannot instantiate class " + statusWindowClassName, e); @@ -312,7 +324,7 @@ /* close current dialog */ setCurrentDialog(null, null); - + if (StockRound.class.isAssignableFrom(previousRoundType)) { log.debug("UI leaving Stock Round "+previousRoundName); statusWindow.finishRound(); @@ -454,7 +466,7 @@ } updateStatus(activeWindow); - + } /** Stub, to be overridden in subclasses for special round types */ @@ -708,7 +720,7 @@ File proposedFile = new File(filename); jfc.setSelectedFile(proposedFile); - + if (jfc.showSaveDialog(statusWindow) == JFileChooser.APPROVE_OPTION) { File selectedFile = jfc.getSelectedFile(); String filepath = selectedFile.getPath(); @@ -760,7 +772,7 @@ saveAction.setFilepath(filepath); processOnServer(saveAction); } - + } public void setSaveDirectory(String saveDirectory) { @@ -838,14 +850,14 @@ public boolean getGameParameterAsBoolean (GuiDef.Parm key) { return (Boolean) getGameParameter(key); } - + private void setEnabledWindow(boolean enabled, JFrame window, JFrame exceptionWindow) { - + if (window != null && window != exceptionWindow) { window.setEnabled(enabled); } } - /** + /** * deactivate all game windows, except the argument one */ public void setEnabledAllWindows(boolean enabled, JFrame exceptionWindow) { @@ -856,8 +868,8 @@ setEnabledWindow(enabled, startRoundWindow, exceptionWindow); setEnabledWindow(enabled, statusWindow, exceptionWindow); } - - + + private void updateWindowsLookAndFeel() { SwingUtilities.updateComponentTreeUI(statusWindow); statusWindow.pack(); @@ -870,7 +882,7 @@ SwingUtilities.updateComponentTreeUI(stockChart); stockChart.pack(); } - + /** update fonts settings * (after configuration changes) */ Modified: trunk/18xx/rails/ui/swing/ORWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ORWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/ORWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -3,8 +3,7 @@ import java.awt.BorderLayout; import java.awt.Rectangle; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -67,7 +66,7 @@ mapPanel = new MapPanel(gameUIManager); getContentPane().add(mapPanel, BorderLayout.CENTER); - + upgradePanel = new UpgradesPanel(orUIManager); getContentPane().add(upgradePanel, BorderLayout.WEST); addMouseListener(upgradePanel); @@ -93,6 +92,7 @@ log.debug("OrWindow size = " + this.getSize()); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { @@ -100,7 +100,25 @@ frame.dispose(); } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); + gameUIManager.reportWindow.updateLog(); } Modified: trunk/18xx/rails/ui/swing/ReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -3,12 +3,7 @@ import java.awt.*; import java.awt.event.*; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import javax.swing.*; @@ -17,9 +12,7 @@ import rails.game.GameManagerI; import rails.game.ReportBuffer; import rails.ui.swing.elements.ActionMenuItem; -import rails.util.Config; -import rails.util.LocalText; -import rails.util.Util; +import rails.util.*; /** * This is the UI for the LogWindow. It displays logged messages to the user @@ -38,11 +31,12 @@ private JMenuItem saveItem, loadItem, printItem; private JMenuItem findItem, findBackItem, findNextItem, findPrevItem; + private GameUIManager gameUIManager; private GameManagerI gameManager; - + private String reportDirectory = Config.get("report.directory"); private String reportFile; - + private boolean editable = "yes".equalsIgnoreCase(Config.get("report.window.editable")); protected static final String SAVE_CMD = "Save"; @@ -52,14 +46,15 @@ protected static final String FIND_BACK_CMD = "FindBack"; protected static final String FIND_NEXT_CMD = "FindNext"; protected static final String FIND_PREV_CMD = "FindPrev"; - + protected static Logger log = Logger.getLogger(ReportWindow.class.getPackage().getName()); - - public ReportWindow(GameManagerI gameManager) { + + public ReportWindow(GameUIManager gameUIManager) { messageWindow = this; - this.gameManager = gameManager; + this.gameUIManager = gameUIManager; + this.gameManager = gameUIManager.getGameManager(); reportText = new JTextArea(); reportText.setEditable(editable); @@ -79,13 +74,13 @@ gbc.weightx = gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; messagePanel.add(messageScroller, gbc); - + menuBar = new JMenuBar(); fileMenu = new JMenu(LocalText.getText("FILE")); fileMenu.setMnemonic(KeyEvent.VK_F); editMenu = new JMenu(LocalText.getText("EDIT")); editMenu.setMnemonic(KeyEvent.VK_E); - + loadItem = new ActionMenuItem(LocalText.getText("LOAD")); loadItem.setActionCommand(LOAD_CMD); loadItem.setMnemonic(KeyEvent.VK_L); @@ -151,20 +146,40 @@ menuBar.add(fileMenu); menuBar.add(editMenu); - + setJMenuBar(menuBar); - + setContentPane(messagePanel); addKeyListener(this); - + // default report window settings super.init(); + + final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } /* (non-Javadoc) * @see rails.ui.swing.ReportWindowI#updateLog() */ + @Override public void updateLog() { String newText = ReportBuffer.get(); if (newText.length() > 0) { @@ -173,6 +188,7 @@ } } + @Override public void scrollDown () { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -197,7 +213,7 @@ findNext(true); } } - + private void loadReportFile() { JFileChooser jfc = new JFileChooser(); @@ -212,7 +228,7 @@ } else { return; } - + try { BufferedReader in = new BufferedReader (new FileReader(selectedFile)); String line; @@ -226,9 +242,9 @@ e.getMessage(), "", JOptionPane.ERROR_MESSAGE); } } - + private void saveReportFile () { - + JFileChooser jfc = new JFileChooser(); if (Util.hasValue(reportDirectory)) { jfc.setCurrentDirectory(new File(reportDirectory)); @@ -243,7 +259,7 @@ if (!selectedFile.getName().equalsIgnoreCase(reportFile)) { reportFile = filepath; } - + try { PrintWriter out = new PrintWriter (new FileWriter (new File (reportFile))); out.print(reportText.getText()); @@ -255,40 +271,40 @@ } } } - + private void findText(boolean backwards) { - + String text = reportText.getText(); - String target = JOptionPane.showInputDialog(reportText, + String target = JOptionPane.showInputDialog(reportText, LocalText.getText("EnterSearch")); if (!Util.hasValue(target)) return; - - int startPos = editable - ? reportText.getCaretPosition() + + int startPos = editable + ? reportText.getCaretPosition() : backwards ? text.length() : 0; int foundPos = backwards ? text.lastIndexOf(target, startPos) : text.indexOf(target, startPos); if (foundPos < 0) return; - + reportText.select(foundPos, foundPos + target.length()); } - + private void findNext(boolean backwards) { - + String text = reportText.getText(); String target = reportText.getSelectedText(); if (!Util.hasValue(target)) return; - + int startPos = reportText.getSelectionStart(); int foundPos = backwards ? text.lastIndexOf(target, startPos-1) : text.indexOf(target, startPos+1); if (foundPos < 0) return; - + reportText.select(foundPos, foundPos + target.length()); } - + public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { HelpWindow.displayHelp(gameManager.getHelp()); Modified: trunk/18xx/rails/ui/swing/StartRoundWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -186,8 +186,38 @@ addKeyListener(this); + // set closing behavior and listener + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE ); + final JFrame thisFrame = this; + final GameUIManager guiMgr = gameUIManager; + addWindowListener(new WindowAdapter () { + @Override + public void windowClosing(WindowEvent e) { + if (JOptionPane.showConfirmDialog(thisFrame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) + == JOptionPane.OK_OPTION) { + thisFrame.dispose(); + guiMgr.terminate(); + } + } + }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(thisFrame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(thisFrame); + } + }); pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(thisFrame); } private void init() { @@ -321,19 +351,6 @@ dummyButton = new ClickField("", "", "", this, itemGroup); - // set closing behavior and listener - setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE ); - final JFrame thisFrame = this; - addWindowListener(new WindowAdapter () { - @Override - public void windowClosing(WindowEvent e) { - if (JOptionPane.showConfirmDialog(thisFrame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) - == JOptionPane.OK_OPTION) { - thisFrame.dispose(); - System.exit(0); - } - } - }); } private void addField(JComponent comp, int x, int y, int width, int height, Modified: trunk/18xx/rails/ui/swing/StatusWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StatusWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StatusWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -1,10 +1,10 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/StatusWindow.java,v 1.46 2010/06/15 20:16:54 evos Exp $*/ package rails.ui.swing; -import java.awt.BorderLayout; -import java.awt.Color; +import java.awt.*; import java.awt.event.*; import java.util.*; +import java.util.List; import javax.swing.*; @@ -256,11 +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")); @@ -299,19 +299,35 @@ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE ); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter () { @Override public void windowClosing(WindowEvent e) { if (JOptionPane.showConfirmDialog(frame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { frame.dispose(); - System.exit(0); + guiMgr.terminate(); } } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + pack(); - pack(); + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } public void setGameActions() { @@ -596,7 +612,7 @@ process(executedAction); } else if (command.equals(QUIT_CMD)) { - System.exit(0); + gameUIManager.terminate(); } else if (command.equals(REPORT_CMD)) { gameUIManager.reportWindow.setVisible(((JMenuItem) actor.getSource()).isSelected()); gameUIManager.reportWindow.scrollDown(); Modified: trunk/18xx/rails/ui/swing/StockChart.java =================================================================== --- trunk/18xx/rails/ui/swing/StockChart.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StockChart.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -33,6 +33,7 @@ stockPanel.setBackground(Color.LIGHT_GRAY); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { @@ -40,8 +41,24 @@ frame.dispose(); } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); addKeyListener(this); pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } private void initialize() { Added: trunk/18xx/rails/ui/swing/WindowSettings.java =================================================================== --- trunk/18xx/rails/ui/swing/WindowSettings.java (rev 0) +++ trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -0,0 +1,114 @@ +package rails.ui.swing; + +import java.awt.Rectangle; +import java.io.*; +import java.util.*; + +import javax.swing.JFrame; + +import org.apache.log4j.Logger; + +import rails.util.Config; + +public class WindowSettings { + + private Map<String, Rectangle> settings = new HashMap<String, Rectangle>(); + private String filepath; + + private static final String settingsfilename = "settings_xxxx.rails_ini"; + + protected static Logger log = + Logger.getLogger(WindowSettings.class.getPackage().getName()); + + public WindowSettings (String gameName) { + String directory = Config.get("save.directory"); + filepath = directory + File.separator + settingsfilename.replace("xxxx", gameName); + } + + private Rectangle rectangle (String windowName) { + + if (settings.containsKey(windowName)) { + return settings.get(windowName); + } else { + Rectangle r = new Rectangle(-1, -1, -1, -1); + settings.put(windowName, r); + return r; + } + } + + public Rectangle getBounds (JFrame w) { + return rectangle (w.getClass().getSimpleName()); + } + + public void load () { + + BufferedReader in; + try { + in = new BufferedReader (new FileReader (filepath)); + String line; + String[] fields; + int v; + Rectangle r; + while ((line = in.readLine()) != null) { + fields = line.split("[\\.=]"); + if (fields.length < 3) continue; + v = Integer.parseInt(fields[2]); + r = rectangle(fields[0]); + switch (fields[1].charAt(0)) { + case 'X': r.x = v; break; + case 'Y': r.y = v; break; + case 'W': r.width = v; break; + case 'H': r.height = v; break; + } + } + in.close(); + } catch (FileNotFoundException e) { + // No problem + return; + } catch (Exception e) { + log.error ("Error while loading "+filepath, e); + } + + } + + public void set(JFrame window) { + + if (window != null) { + + // Save one window's settings + String name = window.getClass().getSimpleName(); + Rectangle r = rectangle (name); + r.x = window.getX(); + r.y = window.getY(); + r.width = window.getWidth(); + r.height = window.getHeight(); + log.debug("+++ Set "+name+" bounds to "+r.x+","+r.y+"/"+r.width+","+r.height); + } + return; + } + + public void save () { + + // Save all settings to file + log.debug("=== Saving all window settings"); + try { + PrintWriter out = new PrintWriter (new FileWriter (new File (filepath))); + Rectangle r; + Set<String> keys = new TreeSet<String> (settings.keySet()); + for (String name : keys) { + r = settings.get(name); + out.println(name+".X="+r.x); + out.println(name+".Y="+r.y); + out.println(name+".W="+r.width); + out.println(name+".H="+r.height); + } + out.close(); + } catch (Exception e) { + + } + + } + + +} + Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-28 19:47:57
|
Revision: 1474 http://rails.svn.sourceforge.net/rails/?rev=1474&view=rev Author: evos Date: 2011-01-28 19:47:51 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Added "Version" option to 18Kaas with values "v1" (includes Gouda on map) and "v2" (no Gouda, default). Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/GamesList.xml Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2011-01-28 19:44:46 UTC (rev 1473) +++ trunk/18xx/LocalisedText.properties 2011-01-28 19:47:51 UTC (rev 1474) @@ -643,6 +643,7 @@ USING_SP=using {0} Variant=Variant VariantIs=Variant is {0}. +Version=Version WantToReplaceToken=Do you want to replace the {0} home token with one of {1}? WarningNeedCash=Warning: {0} will be deducted from the company revenue or from your personal cash WHICH_PRICE=Which price? Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2011-01-28 19:44:46 UTC (rev 1473) +++ trunk/18xx/data/GamesList.xml 2011-01-28 19:47:51 UTC (rev 1474) @@ -139,6 +139,7 @@ Should work, but has not been extensively tested. Limitations as with 1830. </Description> + <Option name="Version" values="v1,v2" default="v2" /> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="18KaasRuhrgebiedDoublesOnlyMajors" type="toggle" default="yes" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |