[TDM] change Mistrise Village effect duration to end of turn and add discard logic

* effect now has end of turn duration and is discarded after resolving the next spell
This commit is contained in:
jmlundeen 2025-08-14 13:03:44 -05:00
parent b8504d56f2
commit ec2c7e6ad6
2 changed files with 58 additions and 34 deletions

View file

@ -1,25 +1,22 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.common.CantBeCounteredSourceAbility;
import mage.abilities.common.EntersBattlefieldTappedUnlessAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.common.YouControlPermanentCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddContinuousEffectToGame;
import mage.abilities.mana.BlueManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.*;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.watchers.common.SpellsCastWatcher;
@ -43,7 +40,7 @@ public final class MistriseVillage extends CardImpl {
public MistriseVillage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
// This land enters tapped unless you control a Mountain or a Forest.
this.addAbility(new EntersBattlefieldTappedUnlessAbility(condition).addHint(condition.getHint()));
@ -68,12 +65,12 @@ public final class MistriseVillage extends CardImpl {
}
}
class MistriseCantBeCounteredEffect extends ContinuousRuleModifyingEffectImpl {
class MistriseCantBeCounteredEffect extends ContinuousEffectImpl {
private int spellsCastThisTurn;
public MistriseCantBeCounteredEffect() {
super(Duration.OneUse, Outcome.Benefit, false, true);
super(Duration.EndOfTurn, Layer.RulesEffects, SubLayer.NA, Outcome.Benefit);
staticText = "the next spell you cast this turn can't be countered";
}
@ -87,11 +84,6 @@ class MistriseCantBeCounteredEffect extends ContinuousRuleModifyingEffectImpl {
return new MistriseCantBeCounteredEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER;
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
@ -102,27 +94,27 @@ class MistriseCantBeCounteredEffect extends ContinuousRuleModifyingEffectImpl {
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
StackObject targetObject = game.getStack().getStackObject(event.getTargetId());
if (sourceObject != null && targetObject != null) {
return targetObject.getName() + " cannot be countered by " + sourceObject.getName();
}
return staticText;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Spell spell = game.getStack().getSpell(event.getTargetId());
public boolean apply(Game game, Ability source) {
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
if (spell == null || !spell.isControlledBy(source.getControllerId()) || watcher == null) {
if (watcher == null) {
return false;
}
List<Spell> spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId());
for (int i = 0; i < spellsCast.size(); i++) {
if (i == spellsCastThisTurn && spellsCast.get(i).getId().equals(spell.getId())) {
discard();
return true;
if (game.getStack().isEmpty() && watcher.getSpellsCastThisTurn(source.getControllerId()).size() >= spellsCastThisTurn + 1) {
discard();
return false;
}
for (StackObject stackObject : game.getStack()) {
if (!(stackObject instanceof Spell) || !stackObject.isControlledBy(source.getControllerId())) {
continue;
}
Spell spell = (Spell) stackObject;
List<Spell> spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId());
for (int i = 0; i < spellsCast.size(); i++) {
if (i == spellsCastThisTurn && spellsCast.get(i).getId().equals(spell.getId())) {
game.getState().addOtherAbility(spell.getCard(), new CantBeCounteredSourceAbility());
return true;
}
}
}
return false;

View file

@ -137,7 +137,7 @@ public class MistriseVillageTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, AETHER_SPELLBOMB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, FORCE_OF_NEGATION, AETHER_SPELLBOMB); // Successful counter
setStopAt(1, PhaseStep.END_TURN);
setStopAt(2, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, NARSET_PARTER_OF_VEILS, 1);
@ -162,7 +162,6 @@ public class MistriseVillageTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, NARSET_PARTER_OF_VEILS);
checkPlayableAbility("cast force", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Force", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, FORCE_OF_NEGATION, NARSET_PARTER_OF_VEILS); // Fail to counter
setChoice(playerB, "Cast with no alternative cost");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
@ -182,4 +181,37 @@ public class MistriseVillageTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, FORCE_OF_NEGATION, 2);
assertPermanentCount(playerA, AETHER_SPELLBOMB, 1);
}
@Test
public void testCastingMultipleSpells() {
setStrictChooseMode(true);
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, MISTRISE,2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 13);
addCard(Zone.HAND, playerA, NARSET_PARTER_OF_VEILS);
addCard(Zone.HAND, playerA, "Hieroglyphic Illumination");
addCard(Zone.BATTLEFIELD, playerB, "Island", 6);
addCard(Zone.HAND, playerB, FORCE_OF_NEGATION, 2);
addCard(Zone.LIBRARY, playerA, AETHER_SPELLBOMB);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{U}, {T}"); // Activate mistrise
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, NARSET_PARTER_OF_VEILS);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hieroglyphic Illumination");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, FORCE_OF_NEGATION, NARSET_PARTER_OF_VEILS); // Fail to counter
setChoice(playerB, "Cast with no alternative cost");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, AETHER_SPELLBOMB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, FORCE_OF_NEGATION, AETHER_SPELLBOMB); // Successful counter
setStopAt(2, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, NARSET_PARTER_OF_VEILS, 1);
assertGraveyardCount(playerB, FORCE_OF_NEGATION, 2);
assertExileCount(playerA, AETHER_SPELLBOMB, 1);
}
}