mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Moved quest game initialization to fcontrol, since quest was a bad dependence from game
separated createGame and tartGame to make Fcontrol.attach optinal and called from UI code that starts a game
This commit is contained in:
@@ -19,7 +19,6 @@ import forge.game.GameNew;
|
|||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.RegisteredPlayer;
|
import forge.game.RegisteredPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.PlayerZone;
|
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
public class RestartGameEffect extends SpellAbilityEffect {
|
public class RestartGameEffect extends SpellAbilityEffect {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import forge.Constant.Preferences;
|
|||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.control.KeyboardShortcuts.Shortcut;
|
import forge.control.KeyboardShortcuts.Shortcut;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
|
import forge.game.GameType;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.gui.GuiDialog;
|
import forge.gui.GuiDialog;
|
||||||
@@ -63,6 +64,7 @@ import forge.gui.toolbox.FSkin;
|
|||||||
import forge.net.NetServer;
|
import forge.net.NetServer;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.QuestController;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.io.QuestDataIO;
|
import forge.quest.io.QuestDataIO;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
@@ -404,6 +406,16 @@ public enum FControl {
|
|||||||
public void attachToGame(Game game0) {
|
public void attachToGame(Game game0) {
|
||||||
// TODO: Detach from other game we might be looking at
|
// TODO: Detach from other game we might be looking at
|
||||||
|
|
||||||
|
|
||||||
|
if ( game0.getType() == GameType.Quest) {
|
||||||
|
QuestController qc = Singletons.getModel().getQuest();
|
||||||
|
// Reset new list when the Match round starts, not when each game starts
|
||||||
|
if (game0.getMatch().getPlayedGames().isEmpty()) {
|
||||||
|
qc.getCards().resetNewList();
|
||||||
|
}
|
||||||
|
game0.subscribeToEvents(qc); // this one listens to player's mulligans ATM
|
||||||
|
}
|
||||||
|
|
||||||
inputQueue = new InputQueue();
|
inputQueue = new InputQueue();
|
||||||
|
|
||||||
this.game = game0;
|
this.game = game0;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import forge.game.event.GameEventAnteCardsSelected;
|
|||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.quest.QuestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -79,21 +78,16 @@ public class Match {
|
|||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
*/
|
*/
|
||||||
public void startRound() {
|
public Game createGame() {
|
||||||
|
|
||||||
currentGame = new Game(players, gameType, this);
|
currentGame = new Game(players, gameType, this);
|
||||||
|
return currentGame;
|
||||||
|
|
||||||
if ( getGameType() == GameType.Quest) {
|
|
||||||
QuestController qc = Singletons.getModel().getQuest();
|
|
||||||
// Reset new list when the Match round starts, not when each game starts
|
|
||||||
if (this.getPlayedGames().isEmpty()) {
|
|
||||||
qc.getCards().resetNewList();
|
|
||||||
}
|
|
||||||
currentGame.subscribeToEvents(qc); // this one listens to player's mulligans ATM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Singletons.getControl().attachToGame(currentGame);
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
*/
|
||||||
|
public void startGame() {
|
||||||
final boolean canRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL) && gameType == GameType.Constructed;
|
final boolean canRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL) && gameType == GameType.Constructed;
|
||||||
GameNew.newGame(currentGame, canRandomFoil, this.useAnte);
|
GameNew.newGame(currentGame, canRandomFoil, this.useAnte);
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ public class GauntletMini {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ public enum CSubmenuGauntletLoad implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -444,7 +444,8 @@ public class SSubmenuQuestUtil {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
// no overlays here?
|
// no overlays here?
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ public enum CSubmenuConstructed implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ public enum CSubmenuDraft implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -238,7 +238,8 @@ public enum CSubmenuArchenemy implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -219,7 +219,8 @@ public enum CSubmenuPlanechase implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -181,7 +181,8 @@ public enum CSubmenuVanguard implements ICDoc {
|
|||||||
FThreads.invokeInEdtLater(new Runnable(){
|
FThreads.invokeInEdtLater(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mc.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ public class ControlWinLose {
|
|||||||
executeAnte();
|
executeAnte();
|
||||||
}
|
}
|
||||||
|
|
||||||
match.startRound();
|
Singletons.getControl().attachToGame(match.createGame());
|
||||||
|
match.startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||||
@@ -86,7 +87,8 @@ public class ControlWinLose {
|
|||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
saveOptions();
|
saveOptions();
|
||||||
match.clearGamesPlayed();
|
match.clearGamesPlayed();
|
||||||
match.startRound();
|
Singletons.getControl().attachToGame(match.createGame());
|
||||||
|
match.startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||||
|
|||||||
@@ -202,11 +202,12 @@ public class GauntletWinLose extends ControlWinLose {
|
|||||||
players.add(RegisteredPlayer.fromDeck(gd.getUserDeck()).setPlayer(lobby.getGuiPlayer()));
|
players.add(RegisteredPlayer.fromDeck(gd.getUserDeck()).setPlayer(lobby.getGuiPlayer()));
|
||||||
players.add(RegisteredPlayer.fromDeck(aiDeck).setPlayer(lobby.getAiPlayer()));
|
players.add(RegisteredPlayer.fromDeck(aiDeck).setPlayer(lobby.getAiPlayer()));
|
||||||
|
|
||||||
Match newMatch = new Match(GameType.Gauntlet, players);
|
Match mc = new Match(GameType.Gauntlet, players);
|
||||||
|
|
||||||
SOverlayUtils.hideOverlay();
|
SOverlayUtils.hideOverlay();
|
||||||
saveOptions();
|
saveOptions();
|
||||||
newMatch.startRound();
|
Singletons.getControl().attachToGame(mc.createGame());
|
||||||
|
mc.startGame();
|
||||||
} else {
|
} else {
|
||||||
super.actionOnContinue();
|
super.actionOnContinue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public final class Main {
|
|||||||
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
|
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
|
||||||
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
||||||
|
|
||||||
boolean isHeadlessMode = false;
|
boolean isHeadlessMode = !true;
|
||||||
|
|
||||||
// Start splash screen first, then data models, then controller.
|
// Start splash screen first, then data models, then controller.
|
||||||
if(!isHeadlessMode)
|
if(!isHeadlessMode)
|
||||||
@@ -48,6 +48,8 @@ public final class Main {
|
|||||||
|
|
||||||
// ok, done with possible interactive startup
|
// ok, done with possible interactive startup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user