mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix so Gauntlet game screen closed after continuing to next match
This commit is contained in:
@@ -1,15 +1,12 @@
|
|||||||
package forge.screens.home.gauntlet;
|
package forge.screens.home.gauntlet;
|
||||||
|
|
||||||
import forge.GuiBase;
|
|
||||||
import forge.UiCommand;
|
import forge.UiCommand;
|
||||||
import forge.deck.DeckType;
|
import forge.deck.DeckType;
|
||||||
import forge.game.GameType;
|
|
||||||
import forge.game.player.RegisteredPlayer;
|
import forge.game.player.RegisteredPlayer;
|
||||||
import forge.gauntlet.GauntletData;
|
import forge.gauntlet.GauntletData;
|
||||||
import forge.gauntlet.GauntletUtil;
|
import forge.gauntlet.GauntletUtil;
|
||||||
import forge.gui.SOverlayUtils;
|
import forge.gui.SOverlayUtils;
|
||||||
import forge.gui.framework.ICDoc;
|
import forge.gui.framework.ICDoc;
|
||||||
import forge.match.HostedMatch;
|
|
||||||
import forge.player.GamePlayerUtil;
|
import forge.player.GamePlayerUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -83,8 +80,7 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
|||||||
starter.add(human);
|
starter.add(human);
|
||||||
starter.add(new RegisteredPlayer(gd.getDecks().get(gd.getCompleted())).setPlayer(GamePlayerUtil.createAiPlayer()));
|
starter.add(new RegisteredPlayer(gd.getDecks().get(gd.getCompleted())).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||||
|
|
||||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
gd.startRound(starter, human);
|
||||||
hostedMatch.startMatch(GameType.Gauntlet, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package forge.gauntlet;
|
|||||||
|
|
||||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||||
|
|
||||||
|
import forge.GuiBase;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
|
import forge.game.GameType;
|
||||||
|
import forge.game.player.RegisteredPlayer;
|
||||||
|
import forge.match.HostedMatch;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -21,7 +25,9 @@ import java.util.List;
|
|||||||
public final class GauntletData {
|
public final class GauntletData {
|
||||||
@XStreamOmitField
|
@XStreamOmitField
|
||||||
private String name; // set based on the the filename on load
|
private String name; // set based on the the filename on load
|
||||||
|
|
||||||
|
private transient HostedMatch hostedMatch = null;
|
||||||
|
|
||||||
private int completed;
|
private int completed;
|
||||||
private String timestamp;
|
private String timestamp;
|
||||||
private List<String> eventRecords = new ArrayList<String>();
|
private List<String> eventRecords = new ArrayList<String>();
|
||||||
@@ -29,23 +35,13 @@ public final class GauntletData {
|
|||||||
private Deck userDeck;
|
private Deck userDeck;
|
||||||
private List<Deck> decks;
|
private List<Deck> decks;
|
||||||
|
|
||||||
|
|
||||||
/** Constructor. */
|
|
||||||
public GauntletData() {
|
public GauntletData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//========== Mutator / accessor methods
|
|
||||||
|
|
||||||
public void setName(String name0) {
|
public void setName(String name0) {
|
||||||
name = name0;
|
name = name0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Rename this gauntlet.
|
|
||||||
*
|
|
||||||
* @param newName
|
|
||||||
* the new name to set
|
|
||||||
*/
|
|
||||||
public void rename(final String newName) {
|
public void rename(final String newName) {
|
||||||
File newpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, newName + ".dat");
|
File newpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, newName + ".dat");
|
||||||
File oldpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, name + ".dat");
|
File oldpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, name + ".dat");
|
||||||
@@ -134,6 +130,20 @@ public final class GauntletData {
|
|||||||
return decks;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String str = getDisplayName();
|
String str = getDisplayName();
|
||||||
|
|||||||
@@ -4,21 +4,17 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.GuiBase;
|
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
import forge.assets.FSkinProp;
|
import forge.assets.FSkinProp;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.GameType;
|
|
||||||
import forge.game.GameView;
|
import forge.game.GameView;
|
||||||
import forge.game.player.RegisteredPlayer;
|
import forge.game.player.RegisteredPlayer;
|
||||||
import forge.interfaces.IButton;
|
import forge.interfaces.IButton;
|
||||||
import forge.interfaces.IWinLoseView;
|
import forge.interfaces.IWinLoseView;
|
||||||
import forge.match.HostedMatch;
|
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.player.GamePlayerUtil;
|
import forge.player.GamePlayerUtil;
|
||||||
|
|
||||||
public abstract class GauntletWinLoseController {
|
public abstract class GauntletWinLoseController {
|
||||||
private HostedMatch hostedMatch = null;
|
|
||||||
private final IWinLoseView<? extends IButton> view;
|
private final IWinLoseView<? extends IButton> view;
|
||||||
private final GameView lastGame;
|
private final GameView lastGame;
|
||||||
|
|
||||||
@@ -122,12 +118,7 @@ public abstract class GauntletWinLoseController {
|
|||||||
|
|
||||||
view.hide();
|
view.hide();
|
||||||
saveOptions();
|
saveOptions();
|
||||||
if (hostedMatch != null) {
|
gd.nextRound(players, human);
|
||||||
hostedMatch.endCurrentGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
hostedMatch = GuiBase.getInterface().hostMatch();
|
|
||||||
hostedMatch.startMatch(GameType.Gauntlet, null, players, human, GuiBase.getInterface().getNewGuiGame());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user