forked from External/mage
[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:
parent
b8504d56f2
commit
ec2c7e6ad6
2 changed files with 58 additions and 34 deletions
|
|
@ -1,25 +1,22 @@
|
||||||
package mage.cards.m;
|
package mage.cards.m;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.CantBeCounteredSourceAbility;
|
||||||
import mage.abilities.common.EntersBattlefieldTappedUnlessAbility;
|
import mage.abilities.common.EntersBattlefieldTappedUnlessAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.condition.common.YouControlPermanentCondition;
|
import mage.abilities.condition.common.YouControlPermanentCondition;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
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.Effect;
|
||||||
import mage.abilities.effects.common.AddContinuousEffectToGame;
|
import mage.abilities.effects.common.AddContinuousEffectToGame;
|
||||||
import mage.abilities.mana.BlueManaAbility;
|
import mage.abilities.mana.BlueManaAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.filter.common.FilterLandPermanent;
|
import mage.filter.common.FilterLandPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackObject;
|
import mage.game.stack.StackObject;
|
||||||
import mage.watchers.common.SpellsCastWatcher;
|
import mage.watchers.common.SpellsCastWatcher;
|
||||||
|
|
@ -43,7 +40,7 @@ public final class MistriseVillage extends CardImpl {
|
||||||
|
|
||||||
public MistriseVillage(UUID ownerId, CardSetInfo setInfo) {
|
public MistriseVillage(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||||
|
|
||||||
|
|
||||||
// This land enters tapped unless you control a Mountain or a Forest.
|
// This land enters tapped unless you control a Mountain or a Forest.
|
||||||
this.addAbility(new EntersBattlefieldTappedUnlessAbility(condition).addHint(condition.getHint()));
|
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;
|
private int spellsCastThisTurn;
|
||||||
|
|
||||||
public MistriseCantBeCounteredEffect() {
|
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";
|
staticText = "the next spell you cast this turn can't be countered";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,11 +84,6 @@ class MistriseCantBeCounteredEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
return new MistriseCantBeCounteredEffect(this);
|
return new MistriseCantBeCounteredEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.COUNTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
|
|
@ -102,27 +94,27 @@ class MistriseCantBeCounteredEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInfoMessage(Ability source, GameEvent event, Game game) {
|
public boolean apply(Game game, Ability source) {
|
||||||
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());
|
|
||||||
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
||||||
if (spell == null || !spell.isControlledBy(source.getControllerId()) || watcher == null) {
|
if (watcher == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
List<Spell> spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId());
|
if (game.getStack().isEmpty() && watcher.getSpellsCastThisTurn(source.getControllerId()).size() >= spellsCastThisTurn + 1) {
|
||||||
for (int i = 0; i < spellsCast.size(); i++) {
|
discard();
|
||||||
if (i == spellsCastThisTurn && spellsCast.get(i).getId().equals(spell.getId())) {
|
return false;
|
||||||
discard();
|
}
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ public class MistriseVillageTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, AETHER_SPELLBOMB);
|
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, AETHER_SPELLBOMB);
|
||||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, FORCE_OF_NEGATION, AETHER_SPELLBOMB); // Successful counter
|
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, FORCE_OF_NEGATION, AETHER_SPELLBOMB); // Successful counter
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertPermanentCount(playerA, NARSET_PARTER_OF_VEILS, 1);
|
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);
|
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
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, FORCE_OF_NEGATION, NARSET_PARTER_OF_VEILS); // Fail to counter
|
||||||
setChoice(playerB, "Cast with no alternative cost");
|
setChoice(playerB, "Cast with no alternative cost");
|
||||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||||
|
|
@ -182,4 +181,37 @@ public class MistriseVillageTest extends CardTestPlayerBase {
|
||||||
assertGraveyardCount(playerB, FORCE_OF_NEGATION, 2);
|
assertGraveyardCount(playerB, FORCE_OF_NEGATION, 2);
|
||||||
assertPermanentCount(playerA, AETHER_SPELLBOMB, 1);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue