mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
added showAndWait method to InputSyncronizedBase - it holds the long chain of calls to reach Control's input queue.
This commit is contained in:
@@ -80,15 +80,7 @@ public class InputQueue extends Observable {
|
||||
return inputStack.toString();
|
||||
}
|
||||
|
||||
public void setInputAndWait(InputSynchronized input) {
|
||||
this.inputStack.push(input);
|
||||
syncPoint();
|
||||
this.updateObservers();
|
||||
|
||||
input.awaitLatchRelease();
|
||||
}
|
||||
|
||||
void setInput(InputSynchronized input) {
|
||||
public void setInput(InputSynchronized input) {
|
||||
this.inputStack.push(input);
|
||||
syncPoint();
|
||||
this.updateObservers();
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
@@ -34,7 +33,7 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
if (controller.isHuman()) {
|
||||
InputProliferate inp = new InputProliferate();
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if ( inp.hasCancelled() )
|
||||
return;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
@@ -83,7 +82,7 @@ public class UntapEffect extends SpellAbilityEffect {
|
||||
|
||||
if (p.isHuman()) {
|
||||
InputSelectCards sc = new InputSelectCardsFromList(0, num, list);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(sc);
|
||||
sc.showAndWait();
|
||||
if( !sc.hasCancelled() )
|
||||
for( Card c : sc.getSelected() )
|
||||
c.untap();
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
@@ -2859,7 +2858,7 @@ public class CardFactoryUtil {
|
||||
if (card.getController().isHuman()) {
|
||||
final InputSelectCards target = new InputSelectCardsFromList(1, 1, creats);
|
||||
target.setMessage("Choose target creature to haunt.");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(target);
|
||||
target.showAndWait();
|
||||
toHaunt = target.getSelected().get(0);
|
||||
} else {
|
||||
// AI choosing what to haunt
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.AiController;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -221,7 +220,7 @@ public class CostDiscard extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, handList);
|
||||
inp.setMessage("Select one of the cards with the same name to discard. Already chosen: " + discarded);
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled()) {
|
||||
return false;
|
||||
}
|
||||
@@ -252,7 +251,7 @@ public class CostDiscard extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, handList);
|
||||
inp.setMessage("Select %d more " + getDescriptiveType() + " to discard.");
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled() || inp.getSelected().size() != c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -270,7 +269,7 @@ public class CostExile extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, list);
|
||||
inp.setMessage("Exile %d card(s) from your" + from);
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return !inp.hasCancelled() && executePayment(ability, inp.getSelected());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.game.cost;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import forge.Singletons;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
@@ -110,7 +109,7 @@ public class CostGainControl extends CostPartWithList {
|
||||
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards);
|
||||
inp.setMessage("Gain control of %d " + desc);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.cost;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaCost;
|
||||
@@ -135,7 +134,7 @@ public class CostPartMana extends CostPart {
|
||||
}
|
||||
if (!toPay.isPaid()) {
|
||||
inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inpPayment);
|
||||
inpPayment.showAndWait();
|
||||
if (!inpPayment.isPaid()) {
|
||||
return handleOfferingAndConvoke(ability, true, false);
|
||||
}
|
||||
@@ -147,7 +146,7 @@ public class CostPartMana extends CostPart {
|
||||
if (!ability.isAnnouncing("X") && !xWasBilled) {
|
||||
source.setXManaCostPaid(0);
|
||||
inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0());
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inpPayment);
|
||||
inpPayment.showAndWait();
|
||||
if (!inpPayment.isPaid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.game.cost;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -238,7 +237,7 @@ public class CostPutCardToLib extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, list);
|
||||
inp.setMessage("Put %d card(s) from your " + from );
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return !inp.hasCancelled() && executePayment(ability, inp.getSelected());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -271,8 +270,8 @@ public class CostPutCounter extends CostPartWithList {
|
||||
InputSelectCardToPutCounter inp = new InputSelectCardToPutCounter(c, typeList);
|
||||
inp.setMessage("Put %d " + getCounter().getName() + " counter on " + getDescriptiveType());
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
|
||||
inp.showAndWait();
|
||||
|
||||
if(inp.hasCancelled())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -133,7 +132,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, list);
|
||||
inp.setMessage("Select " + this.getDescriptiveType() + " to remove a counter");
|
||||
inp.setCancelAllowed(false);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
Card selected = inp.getSelected().get(0);
|
||||
final Map<CounterType, Integer> tgtCounters = selected.getCounters();
|
||||
final ArrayList<CounterType> typeChoices = new ArrayList<CounterType>();
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
@@ -164,7 +163,7 @@ public class CostRemoveCounter extends CostPartWithList {
|
||||
final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(cntRemoved, getCounter(), validCards);
|
||||
inp.setMessage("Remove %d " + getCounter().getName() + " counters from " + getDescriptiveType());
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if(inp.hasCancelled())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.game.cost;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -147,7 +146,7 @@ public class CostReturn extends CostPartWithList {
|
||||
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards);
|
||||
inp.setMessage("Return %d " + this.getType() + " " + this.getType() + " card(s) to hand");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.AiController;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -195,7 +194,7 @@ public class CostReveal extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, handList);
|
||||
inp.setMessage("Select one of cards to reveal. Already chosen:" + revealed);
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled())
|
||||
return false;
|
||||
final Card first = inp.getSelected().get(0);
|
||||
@@ -222,7 +221,7 @@ public class CostReveal extends CostPartWithList {
|
||||
if ( num == 0 ) return true;
|
||||
InputSelectCards inp = new InputSelectCardsFromList(num, num, handList);
|
||||
inp.setMessage("Select %d more " + getDescriptiveType() + " card(s) to reveal.");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if ( inp.hasCancelled() )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.game.cost;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -166,7 +165,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, list);
|
||||
inp.setMessage("Select a " + this.getDescriptiveType() + " to sacrifice (%d left)");
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if ( inp.hasCancelled() )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -225,7 +224,7 @@ public class CostTapType extends CostPartWithList {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, typeList);
|
||||
inp.setMessage("Select one of the cards to tap. Already chosen: " + tapped);
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled())
|
||||
return false;
|
||||
final Card first = inp.getSelected().get(0);
|
||||
@@ -248,7 +247,7 @@ public class CostTapType extends CostPartWithList {
|
||||
inp.setMessage("Select a card to tap.");
|
||||
inp.setUnselectAllowed(true);
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
|
||||
if (inp.hasCancelled() || CardLists.getTotalPower(inp.getSelected()) < i) {
|
||||
return false;
|
||||
@@ -259,7 +258,7 @@ public class CostTapType extends CostPartWithList {
|
||||
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList);
|
||||
inp.setMessage("Select a " + getDescriptiveType() + " to tap (%d left)");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if ( inp.hasCancelled() )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package forge.game.cost;
|
||||
|
||||
import java.util.List;
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -153,7 +152,7 @@ public class CostUntapType extends CostPartWithList {
|
||||
}
|
||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList);
|
||||
inp.setMessage("Select a " + getDescriptiveType() + " to untap (%d left)");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if( inp.hasCancelled() || inp.getSelected().size() != c )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
@@ -216,7 +215,7 @@ public class Untap extends Phase {
|
||||
} else {
|
||||
final InputSelectCards target = new InputSelectCardsFromList(1,1, landList);
|
||||
target.setMessage("Select one tapped land to untap");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(target);
|
||||
target.showAndWait();
|
||||
if( !target.hasCancelled() && !target.getSelected().isEmpty())
|
||||
toUntap = target.getSelected().get(0);
|
||||
}
|
||||
@@ -233,7 +232,7 @@ public class Untap extends Phase {
|
||||
} else {
|
||||
final InputSelectCards target = new InputSelectCardsFromList(1,1, artList);
|
||||
target.setMessage("Select one tapped artifact to untap");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(target);
|
||||
target.showAndWait();
|
||||
if( !target.hasCancelled() && !target.getSelected().isEmpty())
|
||||
target.getSelected().get(0).untap();
|
||||
}
|
||||
@@ -247,7 +246,7 @@ public class Untap extends Phase {
|
||||
} else {
|
||||
final InputSelectCards target = new InputSelectCardsFromList(1, 1, creatures);
|
||||
target.setMessage("Select one creature to untap");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(target);
|
||||
target.showAndWait();
|
||||
if( !target.hasCancelled() && !target.getSelected().isEmpty())
|
||||
target.getSelected().get(0).untap();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.Game;
|
||||
@@ -164,7 +163,7 @@ public class HumanPlay {
|
||||
|
||||
if (!isPaid) {
|
||||
InputPayMana inputPay = new InputPayManaSimple(p.getGame(), sa, manaCost);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inputPay);
|
||||
inputPay.showAndWait();
|
||||
isPaid = inputPay.isPaid();
|
||||
}
|
||||
return isPaid;
|
||||
@@ -440,7 +439,7 @@ public class HumanPlay {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, list);
|
||||
inp.setMessage("Select a card to add a counter to");
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled()) {
|
||||
continue;
|
||||
}
|
||||
@@ -492,7 +491,7 @@ public class HumanPlay {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, list);
|
||||
inp.setMessage("Select a card to remove a counter");
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled()) {
|
||||
continue;
|
||||
}
|
||||
@@ -680,7 +679,7 @@ public class HumanPlay {
|
||||
prompt = source + "\n" + promptCurrent;
|
||||
}
|
||||
InputPayMana toSet = new InputPayManaExecuteCommands(source, p, prompt, cost.getCostMana().getManaToPay());
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(toSet);
|
||||
toSet.showAndWait();
|
||||
return toSet.isPaid();
|
||||
}
|
||||
|
||||
@@ -691,7 +690,7 @@ public class HumanPlay {
|
||||
inp.setMessage("Select %d " + cpl.getDescriptiveType() + " card(s) to " + actionName);
|
||||
inp.setCancelAllowed(true);
|
||||
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled() || inp.getSelected().size() != amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(min == 0 ? 1 : min, max, valid);
|
||||
inp.setMessage(outerMessage);
|
||||
inp.setCancelAllowed(min == 0);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.hasCancelled() ? Lists.<Card>newArrayList() : inp.getSelected();
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
InputSelectCardsFromList input = new InputSelectCardsFromList(isOptional ? 0 : 1, 1, options);
|
||||
input.setCancelAllowed(isOptional);
|
||||
input.setMessage(title);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(input);
|
||||
input.showAndWait();
|
||||
return Iterables.getFirst(input.getSelected(), null);
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public boolean getWillPlayOnFirstTurn(boolean isFirstGame) {
|
||||
InputPlayOrDraw inp = new InputPlayOrDraw(player, isFirstGame);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.isPlayingFirst();
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
InputSelectCards inp = new InputSelectCardsFromList(min, max, valid);
|
||||
inp.setMessage(sa.hasParam("AnyNumber") ? "Discard up to %d card(s)" : "Discard %d card(s)");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.getSelected();
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
};
|
||||
target.setMessage("Select %d card(s) to discard, unless you discard a " + uType + ".");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(target);
|
||||
target.showAndWait();
|
||||
return target.getSelected();
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer) {
|
||||
final InputConfirmMulligan inp = new InputConfirmMulligan(player, firstPlayer, isCommander);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.isKeepHand() ? null : isCommander ? inp.getSelectedCards() : player.getCardsIn(ZoneType.Hand);
|
||||
}
|
||||
|
||||
@@ -663,14 +663,14 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public void declareAttackers(Player attacker, Combat combat) {
|
||||
// This input should not modify combat object itself, but should return user choice
|
||||
InputAttack inpAttack = new InputAttack(attacker, player, combat);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inpAttack);
|
||||
inpAttack.showAndWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareBlockers(Player defender, Combat combat) {
|
||||
// This input should not modify combat object itself, but should return user choice
|
||||
InputBlock inpBlock = new InputBlock(player, defender, combat);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inpBlock);
|
||||
inpBlock.showAndWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -691,7 +691,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (game.isGameOver()) { return; } //don't wait to pass priority if player conceded while in middle of playing a spell/ability
|
||||
}
|
||||
InputPassPriority defaultInput = new InputPassPriority(player);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(defaultInput);
|
||||
defaultInput.showAndWait();
|
||||
chosenSa = defaultInput.getChosenSa();
|
||||
} while (chosenSa != null);
|
||||
}
|
||||
@@ -706,7 +706,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
String message = String.format(msgFmt, max, n, nDiscard);
|
||||
inp.setMessage(message);
|
||||
inp.setCancelAllowed(false);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.getSelected();
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
min = Math.min(min, max);
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(min, max, valid);
|
||||
inp.setMessage("Choose Which Cards to Reveal");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.getSelected();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.card.Card;
|
||||
@@ -108,7 +107,7 @@ public class TargetSelection {
|
||||
List<Card> validTargets = this.getValidCardsToTarget();
|
||||
if (zone.size() == 1 && (zone.get(0) == ZoneType.Battlefield || zone.get(0) == ZoneType.Hand)) {
|
||||
InputSelectTargets inp = new InputSelectTargets(validTargets, ability, mandatory);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
choiceResult = !inp.hasCancelled();
|
||||
bTargetingDone = inp.hasPressedOk();
|
||||
} else {
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.card.mana.ManaCost;
|
||||
@@ -633,7 +632,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
if (source.getController().isHuman()) {
|
||||
final InputSelectCards targetHaunted = new InputSelectCardsFromList(1,1, creats);
|
||||
targetHaunted.setMessage("Choose target creature to haunt.");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(targetHaunted);
|
||||
targetHaunted.showAndWait();
|
||||
targetCard = targetHaunted.getSelected().get(0);
|
||||
} else {
|
||||
// AI choosing what to haunt
|
||||
|
||||
@@ -295,7 +295,7 @@ public final class GuiDisplayUtil {
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, untapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to tap");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if( !inp.hasCancelled() )
|
||||
for(Card c : inp.getSelected())
|
||||
c.tap();
|
||||
@@ -322,7 +322,7 @@ public final class GuiDisplayUtil {
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, tapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to untap");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
if( !inp.hasCancelled() )
|
||||
for(Card c : inp.getSelected())
|
||||
c.untap();
|
||||
|
||||
@@ -40,6 +40,8 @@ public class InputPlayOrDraw extends InputSyncronizedBase {
|
||||
firstGame = isFirstGame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void showMessage() {
|
||||
|
||||
@@ -27,6 +27,12 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
cdlDone.countDown();
|
||||
}
|
||||
|
||||
|
||||
public void showAndWait() {
|
||||
Singletons.getControl().getInputQueue().setInput(this);
|
||||
awaitLatchRelease();
|
||||
}
|
||||
|
||||
protected final void stop() {
|
||||
onStop();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
package forge.gui.input;
|
||||
|
||||
import forge.Singletons;
|
||||
|
||||
import forge.view.ButtonUtil;
|
||||
/**
|
||||
* <p>
|
||||
@@ -41,7 +41,7 @@ public class InputYesOrNo extends InputSyncronizedBase {
|
||||
}
|
||||
public static boolean ask(String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) {
|
||||
InputYesOrNo inp = new InputYesOrNo(message0, yesButtonText0, noButtonText0, defaultYes0);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
inp.showAndWait();
|
||||
return inp.getResult();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user