diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletQuick.java b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletQuick.java index a301f314b55..fa7808626b7 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletQuick.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletQuick.java @@ -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 diff --git a/forge-gui/src/main/java/forge/gauntlet/GauntletData.java b/forge-gui/src/main/java/forge/gauntlet/GauntletData.java index 33637c43856..54506fb5c21 100644 --- a/forge-gui/src/main/java/forge/gauntlet/GauntletData.java +++ b/forge-gui/src/main/java/forge/gauntlet/GauntletData.java @@ -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 eventRecords = new ArrayList(); @@ -29,23 +35,13 @@ public final class GauntletData { private Deck userDeck; private List 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 players, final RegisteredPlayer human) { + hostedMatch = GuiBase.getInterface().hostMatch(); + hostedMatch.startMatch(GameType.Gauntlet, null, players, human, GuiBase.getInterface().getNewGuiGame()); + } + + public void nextRound(final List 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(); diff --git a/forge-gui/src/main/java/forge/gauntlet/GauntletWinLoseController.java b/forge-gui/src/main/java/forge/gauntlet/GauntletWinLoseController.java index cc2da1ad0f3..72bd6347e22 100644 --- a/forge-gui/src/main/java/forge/gauntlet/GauntletWinLoseController.java +++ b/forge-gui/src/main/java/forge/gauntlet/GauntletWinLoseController.java @@ -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 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;