Fix so Gauntlet game screen closed after continuing to next match

This commit is contained in:
drdev
2015-04-19 20:16:58 +00:00
parent 8f28c6f78a
commit 42cfec383f
3 changed files with 23 additions and 26 deletions

View File

@@ -1,15 +1,12 @@
package forge.screens.home.gauntlet;
import forge.GuiBase;
import forge.UiCommand;
import forge.deck.DeckType;
import forge.game.GameType;
import forge.game.player.RegisteredPlayer;
import forge.gauntlet.GauntletData;
import forge.gauntlet.GauntletUtil;
import forge.gui.SOverlayUtils;
import forge.gui.framework.ICDoc;
import forge.match.HostedMatch;
import forge.player.GamePlayerUtil;
import javax.swing.*;
@@ -83,8 +80,7 @@ public enum CSubmenuGauntletQuick implements ICDoc {
starter.add(human);
starter.add(new RegisteredPlayer(gd.getDecks().get(gd.getCompleted())).setPlayer(GamePlayerUtil.createAiPlayer()));
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
hostedMatch.startMatch(GameType.Gauntlet, null, starter, human, GuiBase.getInterface().getNewGuiGame());
gd.startRound(starter, human);
SwingUtilities.invokeLater(new Runnable() {
@Override

View File

@@ -2,7 +2,11 @@ package forge.gauntlet;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import forge.GuiBase;
import forge.deck.Deck;
import forge.game.GameType;
import forge.game.player.RegisteredPlayer;
import forge.match.HostedMatch;
import forge.properties.ForgeConstants;
import java.io.File;
@@ -21,7 +25,9 @@ import java.util.List;
public final class GauntletData {
@XStreamOmitField
private String name; // set based on the the filename on load
private transient HostedMatch hostedMatch = null;
private int completed;
private String timestamp;
private List<String> eventRecords = new ArrayList<String>();
@@ -29,23 +35,13 @@ public final class GauntletData {
private Deck userDeck;
private List<Deck> decks;
/** Constructor. */
public GauntletData() {
}
//========== Mutator / accessor methods
public void setName(String name0) {
name = name0;
}
/**
* Rename this gauntlet.
*
* @param newName
* the new name to set
*/
public void rename(final String newName) {
File newpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, newName + ".dat");
File oldpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, name + ".dat");
@@ -134,6 +130,20 @@ public final class GauntletData {
return decks;
}
public void startRound(final List<RegisteredPlayer> players, final RegisteredPlayer human) {
hostedMatch = GuiBase.getInterface().hostMatch();
hostedMatch.startMatch(GameType.Gauntlet, null, players, human, GuiBase.getInterface().getNewGuiGame());
}
public void nextRound(final List<RegisteredPlayer> players, final RegisteredPlayer human) {
if (hostedMatch == null) {
throw new IllegalStateException("Cannot advance round when no match has been hosted.");
}
hostedMatch.endCurrentGame();
startRound(players, human);
}
@Override
public String toString() {
String str = getDisplayName();

View File

@@ -4,21 +4,17 @@ import java.util.List;
import com.google.common.collect.Lists;
import forge.GuiBase;
import forge.LobbyPlayer;
import forge.assets.FSkinProp;
import forge.deck.Deck;
import forge.game.GameType;
import forge.game.GameView;
import forge.game.player.RegisteredPlayer;
import forge.interfaces.IButton;
import forge.interfaces.IWinLoseView;
import forge.match.HostedMatch;
import forge.model.FModel;
import forge.player.GamePlayerUtil;
public abstract class GauntletWinLoseController {
private HostedMatch hostedMatch = null;
private final IWinLoseView<? extends IButton> view;
private final GameView lastGame;
@@ -122,12 +118,7 @@ public abstract class GauntletWinLoseController {
view.hide();
saveOptions();
if (hostedMatch != null) {
hostedMatch.endCurrentGame();
}
hostedMatch = GuiBase.getInterface().hostMatch();
hostedMatch.startMatch(GameType.Gauntlet, null, players, human, GuiBase.getInterface().getNewGuiGame());
gd.nextRound(players, human);
return true;
}
return false;