Reset game in menu.
parent
b48b69c625
commit
e9591c8355
|
@ -38,7 +38,6 @@ Release 1.12 (April 17, 2011)
|
|||
- added selectable avatar sets in preferences, separate from theme
|
||||
- added unlimited undo support
|
||||
- added "Reset game" in menu, undoing all moves
|
||||
- added counter for number of games played in startup screen
|
||||
- added M key as additional shortcut for messages
|
||||
|
||||
Release 1.11 (April 11, 2011)
|
||||
|
|
|
@ -41,12 +41,7 @@ public class CubeDefinitions {
|
|||
cubeDefinitions.add(new MagicCubeDefinition(cubeName));
|
||||
}
|
||||
}
|
||||
|
||||
public String getCardText() {
|
||||
|
||||
return cubeDefinitions.get(0).size()+" / "+cubeDefinitions.get(1).size()+" cards";
|
||||
}
|
||||
|
||||
|
||||
public String[] getCubeNames() {
|
||||
|
||||
final String names[]=new String[cubeDefinitions.size()];
|
||||
|
|
|
@ -44,6 +44,7 @@ public class GameController {
|
|||
private boolean undoClicked=false;
|
||||
private boolean actionClicked=false;
|
||||
private boolean combatChoice=false;
|
||||
private boolean resetGame=false;
|
||||
private Object choiceClicked=null;
|
||||
private MagicCardDefinition sourceCardDefinition;
|
||||
|
||||
|
@ -359,13 +360,21 @@ public class GameController {
|
|||
return;
|
||||
}
|
||||
if (choiceResults==MagicChoice.UNDO_CHOICE_RESULTS) {
|
||||
game.gotoLastUndoPoint();
|
||||
performUndo();
|
||||
return;
|
||||
}
|
||||
}
|
||||
game.executeNextEvent(choiceResults);
|
||||
}
|
||||
|
||||
public synchronized void resetGame() {
|
||||
|
||||
if (game.hasUndoPoints()) {
|
||||
resetGame=true;
|
||||
undoClicked();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void concede() {
|
||||
|
||||
if (!gameConceded&&!game.isFinished()) {
|
||||
|
@ -376,6 +385,19 @@ public class GameController {
|
|||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void performUndo() {
|
||||
|
||||
if (resetGame) {
|
||||
resetGame=false;
|
||||
while (game.hasUndoPoints()) {
|
||||
|
||||
game.gotoLastUndoPoint();
|
||||
}
|
||||
} else {
|
||||
game.gotoLastUndoPoint();
|
||||
}
|
||||
}
|
||||
|
||||
public void haltGame() {
|
||||
|
||||
|
@ -400,7 +422,7 @@ public class GameController {
|
|||
showMessage(null,"{L} "+game.getLosingPlayer()+" "+(gameConceded?"conceded":"lost")+" the game.|Press {f} to continue.");
|
||||
enableForwardButton();
|
||||
if (waitForInputOrUndo()) {
|
||||
game.gotoLastUndoPoint();
|
||||
performUndo();
|
||||
update();
|
||||
continue;
|
||||
} else {
|
||||
|
@ -434,4 +456,4 @@ public class GameController {
|
|||
}
|
||||
running.set(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
private static final String SAVE_DECK_ITEM="SaveDeck";
|
||||
private static final String SWAP_DECKS_ITEM="Swap";
|
||||
private static final String PLAY_GAME_ITEM="Play";
|
||||
private static final String RESET_GAME_ITEM="Reset";
|
||||
private static final String CONCEDE_GAME_ITEM="Concede";
|
||||
private static final String CARD_EXPLORER_ITEM="Explorer";
|
||||
private static final String KEYWORDS_ITEM="Keywords";
|
||||
|
@ -55,6 +56,7 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
private JMenuItem saveDeckItem;
|
||||
private JMenuItem swapDecksItem;
|
||||
private JMenuItem playGameItem;
|
||||
private JMenuItem resetGameItem;
|
||||
private JMenuItem concedeGameItem;
|
||||
private JMenuItem preferencesItem;
|
||||
private JMenuItem quitItem;
|
||||
|
@ -127,13 +129,15 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
swapDecksItem.setEnabled(enabled);
|
||||
} else if (PLAY_GAME_ITEM.equals(item)) {
|
||||
playGameItem.setEnabled(enabled);
|
||||
} else if (RESET_GAME_ITEM.equals(item)) {
|
||||
resetGameItem.setEnabled(enabled);
|
||||
} else if (CONCEDE_GAME_ITEM.equals(item)) {
|
||||
concedeGameItem.setEnabled(enabled);
|
||||
} else if (CARD_EXPLORER_ITEM.equals(item)) {
|
||||
cardExplorerItem.setEnabled(enabled);
|
||||
} else if (KEYWORDS_ITEM.equals(item)) {
|
||||
keywordsItem.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setInitialContent() {
|
||||
|
@ -172,6 +176,7 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
enableMenuItem(SAVE_DECK_ITEM,false);
|
||||
enableMenuItem(SWAP_DECKS_ITEM,false);
|
||||
enableMenuItem(PLAY_GAME_ITEM,false);
|
||||
enableMenuItem(RESET_GAME_ITEM,false);
|
||||
enableMenuItem(CONCEDE_GAME_ITEM,false);
|
||||
enableMenuItem(CARD_EXPLORER_ITEM,true);
|
||||
enableMenuItem(KEYWORDS_ITEM,true);
|
||||
|
@ -223,6 +228,10 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
playGameItem.addActionListener(this);
|
||||
tournamentMenu.add(playGameItem);
|
||||
|
||||
resetGameItem=new JMenuItem("Reset game");
|
||||
resetGameItem.addActionListener(this);
|
||||
tournamentMenu.add(resetGameItem);
|
||||
|
||||
concedeGameItem=new JMenuItem("Concede game");
|
||||
concedeGameItem.addActionListener(this);
|
||||
tournamentMenu.add(concedeGameItem);
|
||||
|
@ -362,13 +371,20 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void resetGame() {
|
||||
|
||||
if (gamePanel!=null) {
|
||||
gamePanel.getController().resetGame();
|
||||
}
|
||||
}
|
||||
|
||||
public void concedeGame() {
|
||||
|
||||
if (gamePanel!=null) {
|
||||
gamePanel.getController().concede();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void nextGame() {
|
||||
|
||||
tournament.updateDifficulty();
|
||||
|
@ -383,6 +399,7 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
final GameLayeredPane gamePane=new GameLayeredPane(gamePanel,backgroundLabel);
|
||||
setContent(gamePane);
|
||||
gamePanel.requestFocus();
|
||||
enableMenuItem(RESET_GAME_ITEM,true);
|
||||
enableMenuItem(CONCEDE_GAME_ITEM,true);
|
||||
}
|
||||
|
||||
|
@ -443,6 +460,8 @@ public class MagicFrame extends JFrame implements ActionListener {
|
|||
swapDecks();
|
||||
} else if (source==playGameItem) {
|
||||
nextGame();
|
||||
} else if (source==resetGameItem) {
|
||||
resetGame();
|
||||
} else if (source==concedeGameItem) {
|
||||
concedeGame();
|
||||
} else if (source==preferencesItem) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import javax.swing.JPanel;
|
|||
import javax.swing.border.Border;
|
||||
|
||||
import magic.data.CardDefinitions;
|
||||
import magic.data.CubeDefinitions;
|
||||
import magic.data.IconImages;
|
||||
import magic.model.MagicCardDefinition;
|
||||
import magic.model.MagicRandom;
|
||||
|
@ -30,9 +29,7 @@ public class VersionPanel extends JPanel implements ActionListener {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String VERSION = "1.12";
|
||||
private static final String CARDS = CubeDefinitions.getInstance().getCardText();
|
||||
private static final String SPACING = " ";
|
||||
private static final String VERSION_TEXT = "Magarena Limited Edition "+VERSION+SPACING+"by ubeefx"+SPACING+CARDS;
|
||||
private static final String VERSION_TEXT = "Magarena Limited Edition "+VERSION+" by ubeefx";
|
||||
|
||||
private static final Border LOGO_BORDER=BorderFactory.createMatteBorder(2,2,2,2,new Color(0x8C,0x78,0x53));
|
||||
|
||||
|
|
Loading…
Reference in New Issue