Skip to content

Commit

Permalink
Primordial Mist - Fixed selection of face down targets (fixes #7045).
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelX2 committed Sep 8, 2020
1 parent ce4073d commit 8e465ac
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/s/SerratedArrows.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SerratedArrows(UUID ownerId, CardSetInfo setInfo) {
effect = new ConditionalOneShotEffect(new SacrificeSourceEffect(), new SourceHasCounterCondition(CounterType.ARROWHEAD, 0, 0),
"if there are no arrowhead counters on {this}, sacrifice it");
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false, false));
// {tap}, Remove an arrowhead counter from Serrated Arrows: Put a -1/-1 counter on target creature.
// {T}, Remove an arrowhead counter from Serrated Arrows: Put a -1/-1 counter on target creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new AddCountersTargetEffect(CounterType.M1M1.createInstance()),
new TapSourceCost());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.mage.test.cards.facedown;

import mage.constants.EmptyNames;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

/**
*
* @author LevelX2
*/
public class PrimordialMistTest extends CardTestPlayerBase {

/**
* I have Brine Elemental played face down as a morph, an artifact which has
* been manifested and Kadena which has been turned face by Ixidron. I can't
* seem to activate Primordial Mist's second ability for any of these kinds
* of face down creatures:
*/
@Test
public void test_ExileAndCastMorphFaceDownCard() {
setStrictChooseMode(true);

// At the beginning of your end step, you may manifest the top card of your library.
// Exile a face-down permanent you control face-up: You may play that card this turn
addCard(Zone.BATTLEFIELD, playerA, "Primordial Mist");
// Morph {5}{U}{U}
// When Brine Elemental is turned face up, each opponent skips their next untap step.
addCard(Zone.HAND, playerA, "Brine Elemental"); // Creature {5}{U}{U} (5/4)
addCard(Zone.BATTLEFIELD, playerA, "Island", 9);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Brine Elemental");
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature

waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);

activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Exile a face-down permanent you control");
setChoice(playerA, EmptyNames.FACE_DOWN_CREATURE.toString());

castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Brine Elemental");
setChoice(playerA, "No"); // cast it face down as 2/2 creature

setChoice(playerA, "Yes");

setStopAt(1, PhaseStep.END_TURN);
execute();

assertAllCommandsUsed();

assertExileCount(playerA, 0);

assertPowerToughness(playerA, "Brine Elemental", 5, 4);

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package mage.filter.predicate.other;

import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.permanent.Permanent;

/**
* @author North
Expand All @@ -14,15 +12,7 @@ public enum FaceDownPredicate implements Predicate<Card> {

@Override
public boolean apply(Card input, Game game) {
if (game.inCheckPlayableState()) {
// Check for cost reduction of possible face down spell to cast
if (input != null && !(input instanceof Permanent)) {
return input.getAbilities().containsClass(MorphAbility.class);
}
return false;
} else {
return input.isFaceDown(game);
}
return input.isFaceDown(game);
}

@Override
Expand Down
13 changes: 3 additions & 10 deletions Mage/src/main/java/mage/players/PlayerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3100,15 +3100,6 @@ protected boolean canPlay(ActivatedAbility ability, ManaOptions availableMana, M
}
}

// ALTERNATIVE COST from source card (AlternativeCostSourceAbility)
for (Ability objectAbility : sourceObject.getAbilities()) {
if (objectAbility instanceof AlternativeCostSourceAbility) {
if (objectAbility.getCosts().canPay(copy, copy.getSourceId(), playerId, game)) {
return true;
}
}
}

// ALTERNATIVE COST FROM dynamic effects
if (getCastSourceIdWithAlternateMana().contains(copy.getSourceId())) {
ManaCosts alternateCosts = getCastSourceIdManaCosts().get(copy.getSourceId());
Expand All @@ -3128,7 +3119,9 @@ protected boolean canPlay(ActivatedAbility ability, ManaOptions availableMana, M
}

// ALTERNATIVE COST from source card (any AlternativeSourceCosts)
return canPlayCardByAlternateCost(game.getCard(ability.getSourceId()), availableMana, copy, game);
if (AbilityType.SPELL.equals(ability.getAbilityType())) {
return canPlayCardByAlternateCost(game.getCard(ability.getSourceId()), availableMana, copy, game);
}
}
return false;
}
Expand Down

0 comments on commit 8e465ac

Please sign in to comment.