From 190db26ebdf0bd6f029923377a33b34bc928777c Mon Sep 17 00:00:00 2001 From: Hanmac Date: Mon, 16 Apr 2018 16:46:41 +0200 Subject: [PATCH] MayPlay: fixed Bestow and MorphDown Effects --- .../main/java/forge/game/GameActionUtil.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/forge-game/src/main/java/forge/game/GameActionUtil.java b/forge-game/src/main/java/forge/game/GameActionUtil.java index f4743f3d384..fc87dddfa2a 100644 --- a/forge-game/src/main/java/forge/game/GameActionUtil.java +++ b/forge-game/src/main/java/forge/game/GameActionUtil.java @@ -20,6 +20,9 @@ package forge.game; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import forge.card.CardStateName; import forge.card.MagicColor; import forge.card.mana.ManaCostParser; import forge.game.ability.AbilityFactory; @@ -119,9 +122,32 @@ public final class GameActionUtil { public static final List getAlternativeCosts(final SpellAbility sa, final Player activator) { final List alternatives = Lists.newArrayList(); - final Card source = sa.getHostCard(); + Card source = sa.getHostCard(); + final Game game = source.getGame(); if (sa.isSpell()) { + boolean lkicheck = false; + if (sa.hasParam("Bestow") && !source.isBestowed() && !source.isInZone(ZoneType.Battlefield)) { + if (!source.isLKI()) { + source = CardUtil.getLKICopy(source); + } + + source.animateBestow(false); + lkicheck = true; + } else if (((Spell) sa).isCastFaceDown()) { + // need a copy of the card to turn facedown without trigger anything + if (!source.isLKI()) { + source = CardUtil.getLKICopy(source); + } + source.setState(CardStateName.FaceDown, false); + lkicheck = true; + } + + if (lkicheck) { + CardCollection preList = new CardCollection(source); + game.getAction().checkStaticAbilities(false, Sets.newHashSet(source), preList); + } + for (CardPlayOption o : source.mayPlay(activator)) { // non basic are only allowed if PayManaCost is yes if (!sa.isBasicSpell() && o.getPayManaCost() == PayManaCost.NO) { @@ -186,6 +212,11 @@ public final class GameActionUtil { newSA.setDescription(sb.toString()); alternatives.add(newSA); } + + // reset static abilities + if (lkicheck) { + game.getAction().checkStaticAbilities(false, Sets.newHashSet(), CardCollection.EMPTY); + } } if (!sa.isBasicSpell()) {