update remaining confirm action for human decision

- to show relevant card and fix message title (removing "\n").
This commit is contained in:
Anthony Calosa
2022-07-31 19:02:34 +08:00
parent 37354d3aa7
commit 44997b55cd
2 changed files with 153 additions and 216 deletions

View File

@@ -87,7 +87,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (discardType.equals("Hand")) {
if (!mandatory && !confirmAction(Localizer.getInstance().getMessage("lblDoYouWantDiscardYourHand"))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblDoYouWantDiscardYourHand"), ability)*/) {
if (!mandatory && !confirmAction(Localizer.getInstance().getMessage("lblDoYouWantDiscardYourHand"))) {
return null;
}
if (hand.size() > 1 && ability.getActivatingPlayer() != null) {
@@ -131,16 +131,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final String type = TextUtil.fastReplace(discardType, "+WithSameName", "");
hand = CardLists.getValidCards(hand, type.split(";"), player, source, ability);
final CardCollectionView landList2 = hand;
hand = CardLists.filter(hand, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
for (final Card card : landList2) {
if (!card.equals(c) && card.getName().equals(c.getName())) {
return true;
}
hand = CardLists.filter(hand, c1 -> {
for (final Card card : landList2) {
if (!card.equals(c1) && card.getName().equals(c1.getName())) {
return true;
}
return false;
}
return false;
});
if (c == 0) {
return PaymentDecision.card(new CardCollection());
@@ -182,7 +179,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
public PaymentDecision visit(final CostDamage cost) {
int c = cost.getAbilityAmount(ability);
if (confirmAction(Localizer.getInstance().getMessage("lblDoYouWantCardDealNDamageToYou", CardTranslation.getTranslatedName(source.getName()), String.valueOf(c)))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblDoYouWantCardDealNDamageToYou", CardTranslation.getTranslatedName(source.getName()), String.valueOf(c)), ability)*/) {
if (confirmAction(Localizer.getInstance().getMessage("lblDoYouWantCardDealNDamageToYou", CardTranslation.getTranslatedName(source.getName()), String.valueOf(c)))) {
return PaymentDecision.number(c);
}
return null;
@@ -209,7 +206,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
message = Localizer.getInstance().getMessage("lblDrawNCardsConfirm", String.valueOf(c));
}
if (!confirmAction(message)/*controller.confirmPayment(cost, message, ability)*/) {
if (!confirmAction(message)) {
return null;
}
@@ -244,7 +241,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (cost.payCostFromSource()) {
return source.getZone() == player.getZone(cost.from) && confirmAction(Localizer.getInstance().getMessage("lblExileConfirm", CardTranslation.getTranslatedName(source.getName())))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblExileConfirm", CardTranslation.getTranslatedName(source.getName())), ability)*/ ? PaymentDecision.card(source) : null;
return source.getZone() == player.getZone(cost.from) && confirmAction(Localizer.getInstance().getMessage("lblExileConfirm", CardTranslation.getTranslatedName(source.getName()))) ? PaymentDecision.card(source) : null;
}
if (type.equals("All")) {
@@ -373,7 +370,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
private PaymentDecision exileFromTop(final CostExile cost, final SpellAbility sa, final Player player, final int nNeeded) {
final CardCollectionView list = player.getCardsIn(ZoneType.Library, nNeeded);
if (list.size() > nNeeded || !confirmAction(Localizer.getInstance().getMessage("lblExileNCardFromYourTopLibraryConfirm"))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblExileNCardFromYourTopLibraryConfirm"), ability)*/) {
if (list.size() > nNeeded || !confirmAction(Localizer.getInstance().getMessage("lblExileNCardFromYourTopLibraryConfirm"))) {
return null;
}
return PaymentDecision.card(list);
@@ -439,7 +436,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (cost.payCostFromSource()) {
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
return confirmAction(Localizer.getInstance().getMessage("lblExertCardConfirm", CardTranslation.getTranslatedName(source.getName())))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblExertCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability)*/ ? PaymentDecision.card(source) : null;
return confirmAction(Localizer.getInstance().getMessage("lblExertCardConfirm", CardTranslation.getTranslatedName(source.getName()))) ? PaymentDecision.card(source) : null;
}
return null;
}
@@ -467,7 +464,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
public PaymentDecision visit(final CostFlipCoin cost) {
Integer c = cost.getAbilityAmount(ability);
if (!confirmAction(Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinAction", String.valueOf(c)))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinAction", String.valueOf(c)), ability)*/) {
if (!confirmAction(Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinAction", String.valueOf(c)))) {
return null;
}
@@ -478,7 +475,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
public PaymentDecision visit(final CostRollDice cost) {
int c = cost.getAbilityAmount(ability);
if (!confirmAction(Localizer.getInstance().getMessage("lblDoYouWantRollNDiceAction", String.valueOf(c), "d" + cost.getType()))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblDoYouWantRollNDiceAction", String.valueOf(c), "d" + cost.getType()), ability)*/) {
if (!confirmAction(Localizer.getInstance().getMessage("lblDoYouWantRollNDiceAction", String.valueOf(c), "d" + cost.getType()))) {
return null;
}
@@ -536,7 +533,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
message = Localizer.getInstance().getMessage("lblMillNCardsFromYourLibraryConfirm", String.valueOf(c));
}
if (!confirmAction(message)/*controller.confirmPayment(cost, message, ability)*/) {
if (!confirmAction(message)) {
return null;
}
return PaymentDecision.number(c);
@@ -558,7 +555,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
// for costs declared mandatory, this is only reachable with a valid amount
if (player.canPayLife(c, isEffect(), ability) && confirmAction(message)/*controller.confirmPayment(cost, message, ability)*/) {
if (player.canPayLife(c, isEffect(), ability) && confirmAction(message)) {
//force mandatory if paylife is paid.. todo add check if all can be paid
mandatory = true;
return PaymentDecision.number(c);
@@ -571,7 +568,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
Integer c = cost.getAbilityAmount(ability);
if (player.canPayEnergy(c) &&
confirmAction(Localizer.getInstance().getMessage("lblPayEnergyConfirm", cost.toString(), String.valueOf(player.getCounters(CounterEnumType.ENERGY)), "{E}"))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblPayEnergyConfirm", cost.toString(), String.valueOf(player.getCounters(CounterEnumType.ENERGY)), "{E}"), ability)*/) {
confirmAction(Localizer.getInstance().getMessage("lblPayEnergyConfirm", cost.toString(), String.valueOf(player.getCounters(CounterEnumType.ENERGY)), "{E}"))) {
return PaymentDecision.number(c);
}
return null;
@@ -591,7 +588,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
player.getCardsIn(cost.getFrom()), cost.getType().split(";"), player, source, ability);
if (cost.payCostFromSource()) {
return source.getZone() == player.getZone(cost.from) && confirmAction(Localizer.getInstance().getMessage("lblPutCardToLibraryConfirm", CardTranslation.getTranslatedName(source.getName())))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblPutCardToLibraryConfirm", CardTranslation.getTranslatedName(source.getName())), ability)*/ ? PaymentDecision.card(source) : null;
return source.getZone() == player.getZone(cost.from) && confirmAction(Localizer.getInstance().getMessage("lblPutCardToLibraryConfirm", CardTranslation.getTranslatedName(source.getName()))) ? PaymentDecision.card(source) : null;
}
if (cost.from == ZoneType.Hand) {
@@ -671,7 +668,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (cost.payCostFromSource()) {
// UnlessCost so player might not want to pay (Fabricate)
if (ability.hasParam("UnlessCost") && !confirmAction(Localizer.getInstance().getMessage("lblPutNTypeCounterOnTarget", String.valueOf(c), cost.getCounter().getName(), ability.getHostCard().getName()))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblPutNTypeCounterOnTarget", String.valueOf(c), cost.getCounter().getName(), ability.getHostCard().getName()), ability)*/) {
if (ability.hasParam("UnlessCost") && !confirmAction(Localizer.getInstance().getMessage("lblPutNTypeCounterOnTarget", String.valueOf(c), cost.getCounter().getName(), ability.getHostCard().getName()))) {
return null;
}
cost.setLastPaidAmount(c);
@@ -701,7 +698,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final Card card = ability.getHostCard();
if (card.getController() == player && card.isInPlay()) {
final CardView view = CardView.get(card);
return confirmAction(Localizer.getInstance().getMessage("lblReturnCardToHandConfirm", CardTranslation.getTranslatedName(view.getName())))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblReturnCardToHandConfirm", CardTranslation.getTranslatedName(view.getName())), ability)*/ ? PaymentDecision.card(card) : null;
return confirmAction(Localizer.getInstance().getMessage("lblReturnCardToHandConfirm", CardTranslation.getTranslatedName(view.getName()))) ? PaymentDecision.card(card) : null;
}
} else {
final CardCollectionView validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield),
@@ -732,16 +729,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final Integer num = cost.getAbilityAmount(ability);
CardCollectionView hand = player.getCardsIn(cost.getRevealFrom());
final CardCollectionView hand2 = hand;
hand = CardLists.filter(hand, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
for (final Card card : hand2) {
if (!card.equals(c) && card.sharesColorWith(c)) {
return true;
}
hand = CardLists.filter(hand, c -> {
for (final Card card : hand2) {
if (!card.equals(c) && card.sharesColorWith(c)) {
return true;
}
return false;
}
return false;
});
if (num == 0) {
return PaymentDecision.number(0);
@@ -944,7 +938,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (maxCounters < cntRemoved) {
return null;
}
if (!confirmAction(Localizer.getInstance().getMessage("lblRemoveNTargetCounterFromCardPayCostConfirm", amount, cost.counter.getName().toLowerCase(), CardTranslation.getTranslatedName(source.getName())))/*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblRemoveNTargetCounterFromCardPayCostConfirm", amount, cost.counter.getName().toLowerCase(), CardTranslation.getTranslatedName(source.getName())), ability)*/) {
if (!confirmAction(Localizer.getInstance().getMessage("lblRemoveNTargetCounterFromCardPayCostConfirm", amount, cost.counter.getName().toLowerCase(), CardTranslation.getTranslatedName(source.getName())))) {
return null;
}
}
@@ -1000,7 +994,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (cost.payCostFromSource()) {
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
return mandatory || confirmAction(Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(source.getName()))) /*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability)*/ ? PaymentDecision.card(source) : null;
return mandatory || confirmAction(Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(source.getName()))) ? PaymentDecision.card(source) : null;
}
return null;
}
@@ -1008,7 +1002,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (type.equals("OriginalHost")) {
Card host = ability.getOriginalHost();
if (host.getController() == ability.getActivatingPlayer() && host.isInPlay()) {
return confirmAction(Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(host.getName()))) /*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(host.getName())), ability)*/ ? PaymentDecision.card(host) : null;
return confirmAction(Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(host.getName()))) ? PaymentDecision.card(host) : null;
}
return null;
}
@@ -1081,16 +1075,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (sameType) {
final CardCollection list2 = typeList;
typeList = CardLists.filter(typeList, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
for (final Card card : list2) {
if (!card.equals(c) && card.sharesCreatureTypeWith(c)) {
return true;
}
typeList = CardLists.filter(typeList, c12 -> {
for (final Card card : list2) {
if (!card.equals(c12) && card.sharesCreatureTypeWith(c12)) {
return true;
}
return false;
}
return false;
});
final CardCollection tapped = new CardCollection();
@@ -1104,12 +1095,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
final Card first = inp.getFirstSelected();
tapped.add(first);
typeList = CardLists.filter(typeList, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
return c.sharesCreatureTypeWith(first);
}
});
typeList = CardLists.filter(typeList, c1 -> c1.sharesCreatureTypeWith(first));
typeList.remove(first);
c--;
}
@@ -1171,7 +1157,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
@Override
public PaymentDecision visit(final CostUnattach cost) {
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
if (cardToUnattach != null && confirmAction(Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName()))) /*controller.confirmPayment(cost, Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName())), ability)*/) {
if (cardToUnattach != null && confirmAction(Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName())))) {
return PaymentDecision.card(cardToUnattach);
}
return null;
@@ -1188,6 +1174,6 @@ public class HumanCostDecision extends CostDecisionMakerBase {
cardView = CardView.getCardForUi(ImageUtil.getPaperCardFromImageKey(cardView.getImprintedCards().get(0).getCurrentState().getImageKey()));
else if (ability.getTargets() != null && ability.getTargets().isTargetingAnyCard() && ability.getTargets().size() == 1)
cardView = CardView.get(ability.getTargetCard());
return controller.getGui().confirm(cardView, message);
return controller.getGui().confirm(cardView, message.replaceAll("\n", " "));
}
}

View File

@@ -810,10 +810,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
buildQuestion.append("\n").append(localizer.getMessage("lblTriggeredby")).append(": ").append(tos.get(AbilityKey.Card));
}
}
final InputConfirm inp = new InputConfirm(this, buildQuestion.toString(), wrapper);
inp.showAndWait();
return inp.getResult();
return this.getGui().confirm(wrapper.getView().getHostCard(), buildQuestion.toString().replaceAll("\n", " "));
}
@Override
@@ -1344,11 +1341,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// create sorted list from map from least to most frequent
List<Entry<String, Integer>> sortedList = Lists.newArrayList(typesInDeck.entrySet());
Collections.sort(sortedList, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
Collections.sort(sortedList, (o1, o2) -> o1.getValue().compareTo(o2.getValue()));
// loop through sorted list and move each type to the front of the
// validTypes collection
@@ -1377,9 +1370,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public boolean confirmReplacementEffect(final ReplacementEffect replacementEffect, final SpellAbility effectSA,
GameEntity affected, final String question) {
final InputConfirm inp = new InputConfirm(this, question, effectSA);
inp.showAndWait();
return inp.getResult();
return this.getGui().confirm(effectSA.getView().getHostCard(), question.replaceAll("\n", " "));
}
@Override
@@ -1781,9 +1772,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public boolean confirmPayment(final CostPart costPart, final String question, SpellAbility sa) {
final InputConfirm inp = new InputConfirm(this, question, sa);
inp.showAndWait();
return inp.getResult();
return this.getGui().confirm(sa.getView().getHostCard(), question.replaceAll("\n", " "));
}
@Override
@@ -2229,11 +2218,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
inp.selectButtonOK();
} else {
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public final void run() {
// getGui().message("Cannot pass priority at this time.");
}
FThreads.invokeInEdtNowOrLater(() -> {
// getGui().message("Cannot pass priority at this time.");
});
}
}
@@ -2352,12 +2338,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final Map<String, String> produced = Maps.newHashMap();
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
abMana.produceMana(null);
}
});
getGame().getAction().invoke(() -> abMana.produceMana(null));
}
@Override
@@ -2470,12 +2451,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return;
}
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
getGame().getAction().moveToHand(card, null);
}
});
getGame().getAction().invoke(() -> getGame().getAction().moveToHand(card, null));
}
/*
@@ -2510,12 +2486,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final Card card = gameCacheCounters.get(cv);
final ImmutableList<CounterType> counters = subtract ? ImmutableList.copyOf(card.getCounters().keySet())
: ImmutableList.copyOf(Collections2.transform(CounterEnumType.values, new Function<CounterEnumType, CounterType>() {
@Override
public CounterType apply(CounterEnumType input) {
return CounterType.get(input);
}
}));
: ImmutableList.copyOf(Collections2.transform(CounterEnumType.values, input -> CounterType.get(input)));
final CounterType counter = getGui().oneOrNone(localizer.getMessage("lblWhichTypeofCounter"), counters);
if (counter == null) {
@@ -2541,20 +2512,17 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void tapPermanents() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
final CardCollectionView untapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
Predicates.not(CardPredicates.Presets.TAPPED));
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, untapped);
inp.setCancelAllowed(true);
inp.setMessage(localizer.getMessage("lblChoosePermanentstoTap"));
inp.showAndWait();
if (!inp.hasCancelled()) {
for (final Card c : inp.getSelected()) {
c.tap(true);
}
getGame().getAction().invoke(() -> {
final CardCollectionView untapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
Predicates.not(CardPredicates.Presets.TAPPED));
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, untapped);
inp.setCancelAllowed(true);
inp.setMessage(localizer.getMessage("lblChoosePermanentstoTap"));
inp.showAndWait();
if (!inp.hasCancelled()) {
for (final Card c : inp.getSelected()) {
c.tap(true);
}
}
});
@@ -2567,20 +2535,17 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void untapPermanents() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
final CardCollectionView tapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
CardPredicates.Presets.TAPPED);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, tapped);
inp.setCancelAllowed(true);
inp.setMessage(localizer.getMessage("lblChoosePermanentstoUntap"));
inp.showAndWait();
if (!inp.hasCancelled()) {
for (final Card c : inp.getSelected()) {
c.untap(true);
}
getGame().getAction().invoke(() -> {
final CardCollectionView tapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
CardPredicates.Presets.TAPPED);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, tapped);
inp.setCancelAllowed(true);
inp.setMessage(localizer.getMessage("lblChoosePermanentstoUntap"));
inp.showAndWait();
if (!inp.hasCancelled()) {
for (final Card c : inp.getSelected()) {
c.untap(true);
}
}
});
@@ -2759,91 +2724,88 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
forgeCard.setTimestamp(getGame().getNextTimestamp());
PaperCard finalC = c;
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
if (targetZone == ZoneType.Battlefield) {
if (!forgeCard.getName().equals(f.getName())) {
forgeCard.changeToState(CardStateName.Flipped);
forgeCard.changeToState(CardStateName.Transformed);
forgeCard.changeToState(CardStateName.Modal);
}
if (noTriggers) {
if (forgeCard.isPermanent() && !forgeCard.isAura()) {
if (forgeCard.isCreature()) {
if (!repeatLast) {
if (forgeCard.hasKeyword(Keyword.HASTE)) {
lastSummoningSickness = true;
} else {
lastSummoningSickness = getGui().confirm(forgeCard.getView(),
localizer.getMessage("lblCardShouldBeSummoningSicknessConfirm", CardTranslation.getTranslatedName(forgeCard.getName())));
}
}
}
getGame().getAction().moveTo(targetZone, forgeCard, null, AbilityKey.newMap());
if (forgeCard.isCreature()) {
forgeCard.setSickness(lastSummoningSickness);
}
} else {
getGui().message(localizer.getMessage("lblChosenCardNotPermanentorCantExistIndependentlyontheBattleground"), localizer.getMessage("lblError"));
return;
}
} else {
if (finalC.getRules().getType().isLand()) {
// this is needed to ensure land abilities fire
getGame().getAction().moveToHand(forgeCard, null);
getGame().getAction().moveToPlay(forgeCard, null, null);
// ensure triggered abilities fire
getGame().getTriggerHandler().runWaitingTriggers();
} else {
final FCollectionView<SpellAbility> choices = forgeCard.getBasicSpells();
if (choices.isEmpty()) {
return; // when would it happen?
}
final SpellAbility sa;
if (choices.size() == 1) {
sa = choices.iterator().next();
} else {
sa = repeatLast ? lastAddedSA : getGui().oneOrNone(localizer.getMessage("lblChoose"), (FCollection<SpellAbility>) choices);
}
if (sa == null) {
return; // happens if cancelled
}
lastAddedSA = sa;
// this is really needed (for rollbacks at least)
getGame().getAction().moveToHand(forgeCard, null);
// Human player is choosing targets for an ability
// controlled by chosen player.
sa.setActivatingPlayer(p);
sa.setSVar("IsCastFromPlayEffect", "True");
HumanPlay.playSaWithoutPayingManaCost(PlayerControllerHuman.this, getGame(), sa, true);
}
// playSa could fire some triggers
getGame().getStack().addAllTriggeredAbilitiesToStack();
}
} else if (targetZone == ZoneType.Library) {
if (!repeatLast) {
lastTopOfTheLibrary = getGui().confirm(forgeCard.getView(), localizer.getMessage("lblCardShouldBeAddedToLibraryTopOrBottom", CardTranslation.getTranslatedName(forgeCard.getName())),
true, Arrays.asList(localizer.getMessage("lblTop"), localizer.getMessage("lblBottom")));
}
if (lastTopOfTheLibrary) {
getGame().getAction().moveToLibrary(forgeCard, null);
} else {
getGame().getAction().moveToBottomOfLibrary(forgeCard, null);
}
} else {
getGame().getAction().moveTo(targetZone, forgeCard, null, AbilityKey.newMap());
getGame().getAction().invoke(() -> {
if (targetZone == ZoneType.Battlefield) {
if (!forgeCard.getName().equals(f.getName())) {
forgeCard.changeToState(CardStateName.Flipped);
forgeCard.changeToState(CardStateName.Transformed);
forgeCard.changeToState(CardStateName.Modal);
}
lastAdded = f;
lastAddedZone = targetZone;
lastAddedPlayer = p;
lastTrigs = noTriggers;
if (noTriggers) {
if (forgeCard.isPermanent() && !forgeCard.isAura()) {
if (forgeCard.isCreature()) {
if (!repeatLast) {
if (forgeCard.hasKeyword(Keyword.HASTE)) {
lastSummoningSickness = true;
} else {
lastSummoningSickness = getGui().confirm(forgeCard.getView(),
localizer.getMessage("lblCardShouldBeSummoningSicknessConfirm", CardTranslation.getTranslatedName(forgeCard.getName())));
}
}
}
getGame().getAction().moveTo(targetZone, forgeCard, null, AbilityKey.newMap());
if (forgeCard.isCreature()) {
forgeCard.setSickness(lastSummoningSickness);
}
} else {
getGui().message(localizer.getMessage("lblChosenCardNotPermanentorCantExistIndependentlyontheBattleground"), localizer.getMessage("lblError"));
return;
}
} else {
if (finalC.getRules().getType().isLand()) {
// this is needed to ensure land abilities fire
getGame().getAction().moveToHand(forgeCard, null);
getGame().getAction().moveToPlay(forgeCard, null, null);
// ensure triggered abilities fire
getGame().getTriggerHandler().runWaitingTriggers();
} else {
final FCollectionView<SpellAbility> choices1 = forgeCard.getBasicSpells();
if (choices1.isEmpty()) {
return; // when would it happen?
}
final SpellAbility sa;
if (choices1.size() == 1) {
sa = choices1.iterator().next();
} else {
sa = repeatLast ? lastAddedSA : getGui().oneOrNone(localizer.getMessage("lblChoose"), (FCollection<SpellAbility>) choices1);
}
if (sa == null) {
return; // happens if cancelled
}
lastAddedSA = sa;
// this is really needed (for rollbacks at least)
getGame().getAction().moveToHand(forgeCard, null);
// Human player is choosing targets for an ability
// controlled by chosen player.
sa.setActivatingPlayer(p);
sa.setSVar("IsCastFromPlayEffect", "True");
HumanPlay.playSaWithoutPayingManaCost(PlayerControllerHuman.this, getGame(), sa, true);
}
// playSa could fire some triggers
getGame().getStack().addAllTriggeredAbilitiesToStack();
}
} else if (targetZone == ZoneType.Library) {
if (!repeatLast) {
lastTopOfTheLibrary = getGui().confirm(forgeCard.getView(), localizer.getMessage("lblCardShouldBeAddedToLibraryTopOrBottom", CardTranslation.getTranslatedName(forgeCard.getName())),
true, Arrays.asList(localizer.getMessage("lblTop"), localizer.getMessage("lblBottom")));
}
if (lastTopOfTheLibrary) {
getGame().getAction().moveToLibrary(forgeCard, null);
} else {
getGame().getAction().moveToBottomOfLibrary(forgeCard, null);
}
} else {
getGame().getAction().moveTo(targetZone, forgeCard, null, AbilityKey.newMap());
}
lastAdded = f;
lastAddedZone = targetZone;
lastAddedPlayer = p;
lastTrigs = noTriggers;
});
}
@@ -2986,12 +2948,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
System.out.println("Rigging planar dice roll: " + res.toString());
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
PlanarDice.roll(player, res);
}
});
getGame().getAction().invoke(() -> PlanarDice.roll(player, res));
}
/*
@@ -3022,24 +2979,18 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final Card forgeCard = Card.fromPaperCard(c, p);
forgeCard.setOwner(p);
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
getGame().getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0, null);
PlanarDice.roll(p, PlanarDice.Planeswalk);
}
getGame().getAction().invoke(() -> {
getGame().getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0, null);
PlanarDice.roll(p, PlanarDice.Planeswalk);
});
}
public void askAI() {
PlayerControllerAi ai = new PlayerControllerAi(player.getGame(), player, player.getOriginalLobbyPlayer());
player.runWithController(new Runnable() {
@Override
public void run() {
List<SpellAbility> sas = ai.chooseSpellAbilityToPlay();
SpellAbility chosen = sas == null ? null : sas.get(0);
getGui().message(chosen == null ? "AI doesn't want to play anything right now" : chosen.getHostCard().toString(), "AI Play Suggestion");
}
player.runWithController(() -> {
List<SpellAbility> sas = ai.chooseSpellAbilityToPlay();
SpellAbility chosen = sas == null ? null : sas.get(0);
getGui().message(chosen == null ? "AI doesn't want to play anything right now" : chosen.getHostCard().toString(), "AI Play Suggestion");
}, ai);
}
}