From: <ste...@us...> - 2010-07-10 17:02:45
|
Revision: 1334 http://rails.svn.sourceforge.net/rails/?rev=1334&view=rev Author: stefanfrey Date: 2010-07-10 17:02:39 +0000 (Sat, 10 Jul 2010) Log Message: ----------- Fixed the following bugs/requests: 18EU minor company initial sale problem - ID: 3021157 - Renamed pass to decline to bid Autopass during minor auction in 18EU - ID: 2899354 - General autopass in GameManager if only Pass Action is available Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/action/NullAction.java trunk/18xx/rails/game/action/PossibleActions.java trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java trunk/18xx/rails/ui/swing/StartRoundWindow.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/LocalisedText.properties 2010-07-10 17:02:39 UTC (rev 1334) @@ -157,6 +157,7 @@ CorrectionModeActivate={1} activated by {0} CorrectionModeDeactivate={1} deactivated by {0} CREDITS=Credits +DeclineToBid=Decline to Bid DestinationReachedByToken={0} gains {1} by laying a token on its destination {2} DestinationReached={0} has reached its destination hex {1} DestinationsReached=Destinations reached @@ -385,6 +386,7 @@ PRICE_STAYS_LOG={0} price stays at {1}({2}). PRIVATES=Privates PaysLoanInterest={0} pays {1} interest for outstanding loans +Pass=Pass PhaseClosesAllPrivates=Close all privates PhaseNumberOfORs=Number of ORs: {0} PhaseOffBoardStep=Off-board revenue step: {0} Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/rails/game/GameManager.java 2010-07-10 17:02:39 UTC (rev 1334) @@ -808,6 +808,11 @@ possibleActions.clear(); getCurrentRound().setPossibleActions(); + // only pass available => execute automatically + if (!isGameOver() && possibleActions.containsOnlyPass()) { + result = process(possibleActions.getList().get(0)); + } + // moveStack closing is done here to allow state changes to occur // when setting possible actions if (action != null) { Modified: trunk/18xx/rails/game/action/NullAction.java =================================================================== --- trunk/18xx/rails/game/action/NullAction.java 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/rails/game/action/NullAction.java 2010-07-10 17:02:39 UTC (rev 1334) @@ -10,9 +10,12 @@ public static final int START_GAME = 4; // For use after loading public static final int MAX_MODE = 4; + // optional label that is returned on toString instead of the standard labels defined below + private String optionalLabel = null; + + // standard labels defined private static String[] name = new String[] { "Done", "Pass", "Skip", "Autopass", "StartGame" }; - protected int mode = -1; public static final long serialVersionUID = 2L; @@ -26,6 +29,12 @@ public int getMode() { return mode; } + + /** returns the NullAction itself */ + public NullAction setLabel(String label) { + this.optionalLabel = label; + return this; + } @Override public boolean equals(PossibleAction action) { @@ -36,6 +45,8 @@ @Override public String toString() { + if (optionalLabel != null) return optionalLabel; return name[mode]; } + } Modified: trunk/18xx/rails/game/action/PossibleActions.java =================================================================== --- trunk/18xx/rails/game/action/PossibleActions.java 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/rails/game/action/PossibleActions.java 2010-07-10 17:02:39 UTC (rev 1334) @@ -82,6 +82,16 @@ public boolean isEmpty() { return possibleActions.isEmpty(); } + + public boolean containsOnlyPass() { + if (possibleActions.size() != 1) return false; + PossibleAction action = possibleActions.get(0); + if (action instanceof NullAction && ((NullAction)action).getMode() == NullAction.PASS) { + return true; + } else { + return false; + } + } /** Check if a given action exists in the current list of possible actions */ public boolean validate(PossibleAction checkedAction) { Modified: trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java =================================================================== --- trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/rails/game/specific/_18EU/StartRound_18EU.java 2010-07-10 17:02:39 UTC (rev 1334) @@ -56,7 +56,6 @@ public boolean setPossibleActions() { possibleActions.clear(); - boolean passAllowed = false; // Refresh player, may have been reset by Undo/Redo currentPlayer = getCurrentPlayer(); @@ -81,31 +80,33 @@ } } break; - case BUY_STEP: - - possibleActions.add(new BuyStartItem( - (StartItem) currentAuctionItem.getObject(), - currentBuyPrice.intValue(), true)); - passAllowed = true; - + // only offer buy if enough money + if (currentBuyPrice.intValue() <= currentPlayer.getFreeCash()) { + possibleActions.add(new BuyStartItem( + (StartItem) currentAuctionItem.getObject(), + currentBuyPrice.intValue(), true)); + } + possibleActions.add(new NullAction(NullAction.PASS)); break; - case OPEN_STEP: case BID_STEP: - StartItem item = (StartItem) currentAuctionItem.getObject(); - BidStartItem possibleAction = + // only offer if enough money + if (item.getMinimumBid() <= currentPlayer.getFreeCash()) { + BidStartItem possibleAction = new BidStartItem(item, item.getMinimumBid(), startPacket.getModulus(), true); - possibleActions.add(possibleAction); - passAllowed = true; - + possibleActions.add(possibleAction); + } + if (getStep() == OPEN_STEP) { + possibleActions.add(new NullAction(NullAction.PASS).setLabel("DeclineToBid")); + } else { + possibleActions.add(new NullAction(NullAction.PASS)); + } break; } - if (passAllowed) possibleActions.add(new NullAction(NullAction.PASS)); - return true; } Modified: trunk/18xx/rails/ui/swing/StartRoundWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-07-05 18:02:13 UTC (rev 1333) +++ trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-07-10 17:02:39 UTC (rev 1334) @@ -103,7 +103,7 @@ private final boolean includeBidding; private final boolean showBasePrices; - private boolean repacked = false; +// private boolean repacked = false; protected static Logger log = Logger.getLogger(StartRoundWindow.class.getPackage().getName()); @@ -464,18 +464,14 @@ List<NullAction> inactiveItems = possibleActions.getType(NullAction.class); - if (inactiveItems != null) { - - for (NullAction na : inactiveItems) { - switch (na.getMode()) { - case NullAction.PASS: - passButton.setText(LocalText.getText("PASS")); - passAllowed = true; - passButton.setPossibleAction(na); - passButton.setMnemonic(KeyEvent.VK_P); - break; - } - } + if (inactiveItems != null && !inactiveItems.isEmpty()) { + // only one NullAction is allowed + NullAction na = inactiveItems.get(0); + // nullActions differ in text to display + passButton.setText(LocalText.getText(na.toString())); + passAllowed = true; + passButton.setPossibleAction(na); + passButton.setMnemonic(KeyEvent.VK_P); } buyButton.setEnabled(buyAllowed); @@ -485,6 +481,7 @@ } passButton.setEnabled(passAllowed); + pack(); // to avoid not displaying after label size changes requestFocus(); } @@ -538,10 +535,10 @@ passButton.setEnabled(true); passButton.setText(LocalText.getText("SelectNoBid")); passButton.setVisible(true); - if (!repacked) { +// if (!repacked) { pack(); - repacked = true; - } +// repacked = true; +// } } if (includeBidding) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |