mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +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.RegisteredPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.PlayerZone;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class RestartGameEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -37,6 +37,7 @@ import forge.Constant.Preferences;
|
||||
import forge.Singletons;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.GuiDialog;
|
||||
@@ -63,6 +64,7 @@ import forge.gui.toolbox.FSkin;
|
||||
import forge.net.NetServer;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.io.QuestDataIO;
|
||||
import forge.sound.SoundSystem;
|
||||
@@ -404,6 +406,16 @@ public enum FControl {
|
||||
public void attachToGame(Game game0) {
|
||||
// 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();
|
||||
|
||||
this.game = game0;
|
||||
|
||||
@@ -12,7 +12,6 @@ import forge.game.event.GameEventAnteCardsSelected;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.QuestController;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -79,21 +78,16 @@ public class Match {
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
*/
|
||||
public void startRound() {
|
||||
|
||||
public Game createGame() {
|
||||
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;
|
||||
GameNew.newGame(currentGame, canRandomFoil, this.useAnte);
|
||||
|
||||
|
||||
@@ -169,7 +169,8 @@ public class GauntletMini {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -127,7 +127,8 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -118,7 +118,8 @@ public enum CSubmenuGauntletLoad implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -152,7 +152,8 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -444,7 +444,8 @@ public class SSubmenuQuestUtil {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
// no overlays here?
|
||||
}
|
||||
});
|
||||
|
||||
@@ -127,7 +127,8 @@ public enum CSubmenuConstructed implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -140,7 +140,8 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -238,7 +238,8 @@ public enum CSubmenuArchenemy implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -219,7 +219,8 @@ public enum CSubmenuPlanechase implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -181,7 +181,8 @@ public enum CSubmenuVanguard implements ICDoc {
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mc.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -78,7 +78,8 @@ public class ControlWinLose {
|
||||
executeAnte();
|
||||
}
|
||||
|
||||
match.startRound();
|
||||
Singletons.getControl().attachToGame(match.createGame());
|
||||
match.startGame();
|
||||
}
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
@@ -86,7 +87,8 @@ public class ControlWinLose {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
match.clearGamesPlayed();
|
||||
match.startRound();
|
||||
Singletons.getControl().attachToGame(match.createGame());
|
||||
match.startGame();
|
||||
}
|
||||
|
||||
/** 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(aiDeck).setPlayer(lobby.getAiPlayer()));
|
||||
|
||||
Match newMatch = new Match(GameType.Gauntlet, players);
|
||||
Match mc = new Match(GameType.Gauntlet, players);
|
||||
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
newMatch.startRound();
|
||||
Singletons.getControl().attachToGame(mc.createGame());
|
||||
mc.startGame();
|
||||
} else {
|
||||
super.actionOnContinue();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class Main {
|
||||
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
|
||||
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
||||
|
||||
boolean isHeadlessMode = false;
|
||||
boolean isHeadlessMode = !true;
|
||||
|
||||
// Start splash screen first, then data models, then controller.
|
||||
if(!isHeadlessMode)
|
||||
@@ -48,6 +48,8 @@ public final class Main {
|
||||
|
||||
// ok, done with possible interactive startup
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user