mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
untied dependencies in newGame, made input field in match final
This commit is contained in:
@@ -106,6 +106,7 @@ public class FThreads {
|
||||
}
|
||||
|
||||
public static final void setInputAndWait(Input inp, CountDownLatch cdl) {
|
||||
checkEDT("FThreads.setInputAndWait", false);
|
||||
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
|
||||
try {
|
||||
cdl.await();
|
||||
|
||||
@@ -42,17 +42,6 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
|
||||
private final Stack<Input> inputStack = new Stack<Input>();
|
||||
|
||||
private final transient GameState game;
|
||||
/**
|
||||
* TODO Write javadoc for Constructor.
|
||||
*
|
||||
* @param fModel
|
||||
* the f model
|
||||
*/
|
||||
public InputControl(final GameState game0) {
|
||||
this.game = game0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>input</code>.
|
||||
@@ -126,7 +115,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
*
|
||||
* @return a {@link forge.control.input.Input} object.
|
||||
*/
|
||||
public final Input getActualInput() {
|
||||
public final Input getActualInput(GameState game) {
|
||||
if ( !game.hasMulliganned() )
|
||||
return new InputMulligan();
|
||||
|
||||
@@ -146,7 +135,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
if (handler.hasPhaseEffects()) {
|
||||
// Handle begin phase stuff, then start back from the top
|
||||
handler.handleBeginPhase();
|
||||
return this.getActualInput();
|
||||
return this.getActualInput(game);
|
||||
}
|
||||
|
||||
// If the Phase we're in doesn't allow for Priority, return null to move
|
||||
@@ -196,7 +185,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
// priority
|
||||
|
||||
boolean prioritySkip = pc.mayAutoPass(phase) || pc.isUiSetToSkipPhase(playerTurn, phase);
|
||||
if (this.game.getStack().isEmpty() && prioritySkip) {
|
||||
if (game.getStack().isEmpty() && prioritySkip) {
|
||||
pc.passPriority();
|
||||
return null;
|
||||
} else
|
||||
@@ -208,7 +197,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
public final void setNewInput(GameState game) {
|
||||
PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
final Input tmp = getActualInput();
|
||||
final Input tmp = getActualInput(game);
|
||||
String message = String.format("%s's %s, priority of %s [%sP] input is %s \t stack:%s", ph.getPlayerTurn(), ph.getPhase(), ph.getPriorityPlayer(), ph.isPlayerPriorityAllowed() ? "+" : "-", tmp == null ? "null" : tmp.getClass().getSimpleName(), inputStack);
|
||||
System.out.println(message);
|
||||
|
||||
|
||||
@@ -40,15 +40,12 @@ import forge.gui.GuiChoose;
|
||||
public class GameActionPlay {
|
||||
|
||||
private final GameState game;
|
||||
private InputControl matchInput;
|
||||
private final InputControl matchInput;
|
||||
|
||||
|
||||
public GameActionPlay(final GameState game0) {
|
||||
public GameActionPlay(final GameState game0, InputControl input) {
|
||||
game = game0;
|
||||
}
|
||||
|
||||
void setMatchInput(InputControl input) {
|
||||
this.matchInput = input; // TODO: Add 0 to parameter's name.
|
||||
this.matchInput = input;
|
||||
}
|
||||
|
||||
public final void playCardWithoutManaCost(final Card c, Player player) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.control.input.InputControl;
|
||||
import forge.game.phase.Cleanup;
|
||||
import forge.game.phase.Combat;
|
||||
import forge.game.phase.EndOfCombat;
|
||||
@@ -95,8 +96,9 @@ public class GameState {
|
||||
* Constructor.
|
||||
* @param players2
|
||||
* @param match0
|
||||
* @param input
|
||||
*/
|
||||
public GameState(Iterable<LobbyPlayer> players2, GameType t, MatchController match0) { /* no more zones to map here */
|
||||
public GameState(Iterable<LobbyPlayer> players2, GameType t, MatchController match0, InputControl input) { /* no more zones to map here */
|
||||
type = t;
|
||||
List<Player> players = new ArrayList<Player>();
|
||||
for (LobbyPlayer p : players2) {
|
||||
@@ -108,7 +110,7 @@ public class GameState {
|
||||
allPlayers = Collections.unmodifiableList(players);
|
||||
roIngamePlayers = Collections.unmodifiableList(ingamePlayers);
|
||||
action = new GameAction(this);
|
||||
actionPlay = new GameActionPlay(this);
|
||||
actionPlay = new GameActionPlay(this, input);
|
||||
stack = new MagicStack(this);
|
||||
phaseHandler = new PhaseHandler(this);
|
||||
|
||||
|
||||
@@ -129,10 +129,8 @@ public class MatchController {
|
||||
public void startRound() {
|
||||
|
||||
// Deal with circular dependencies here
|
||||
currentGame = Singletons.getModel().newGame(players.keySet(),gameType, this);
|
||||
input = new InputControl(currentGame);
|
||||
currentGame.getActionPlay().setMatchInput(input);
|
||||
|
||||
input = new InputControl();
|
||||
currentGame = Singletons.getModel().newGame(players.keySet(),gameType, this, input);
|
||||
|
||||
Map<Player, PlayerStartConditions> startConditions = new HashMap<Player, PlayerStartConditions>();
|
||||
for (Player p : currentGame.getPlayers()) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.card.EditionCollection;
|
||||
import forge.card.FatPackData;
|
||||
import forge.card.FormatCollection;
|
||||
import forge.card.cardfactory.CardStorageReader;
|
||||
import forge.control.input.InputControl;
|
||||
import forge.deck.CardCollections;
|
||||
import forge.error.BugReporter;
|
||||
import forge.error.ExceptionHandler;
|
||||
@@ -401,9 +402,10 @@ public enum FModel {
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param players
|
||||
* @param input
|
||||
*/
|
||||
public GameState newGame(Iterable<LobbyPlayer> players, GameType type, final MatchController match0) {
|
||||
gameState = new GameState(players,type, match0);
|
||||
public GameState newGame(Iterable<LobbyPlayer> players, GameType type, final MatchController match0, InputControl input) {
|
||||
gameState = new GameState(players,type, match0, input);
|
||||
return gameState;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user