Merge pull request #10059 from Grath/grath/fix-mari-the-killing-quill

[NCC] Fix Mari, the Killing Quill
This commit is contained in:
Grath 2023-03-28 15:11:24 -04:00 committed by GitHub
commit 30c49de105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,17 +2,18 @@ package mage.cards.m;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.RemoveCounterCost; import mage.abilities.costs.common.RemoveCounterCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.DeathtouchAbility; import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -26,11 +27,10 @@ import mage.filter.predicate.card.OwnerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.TreasureToken; import mage.game.permanent.token.TreasureToken;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -58,7 +58,7 @@ public class MariTheKillingQuill extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever a creature an opponent controls dies, exile it with a hit counter on it. // Whenever a creature an opponent controls dies, exile it with a hit counter on it.
this.addAbility(new SimpleStaticAbility(new MariTheKillingQuillReplacementEffect())); this.addAbility(new MariTheKillingQuillCreatureDiesAbility());
// Assassins, Mercenaries, and Rogues you control have deathtouch and // Assassins, Mercenaries, and Rogues you control have deathtouch and
// "Whenever this creature deals combat damage to a player, you may remove a hit counter from a card that player owns in exile. // "Whenever this creature deals combat damage to a player, you may remove a hit counter from a card that player owns in exile.
@ -158,46 +158,79 @@ class MariTheKillingQuillDrawAndTokenEffect extends OneShotEffect {
} }
} }
// Based on Draugr Necromancer // Based on Patron of the Vein
class MariTheKillingQuillReplacementEffect extends ReplacementEffectImpl { class MariTheKillingQuillCreatureDiesAbility extends TriggeredAbilityImpl {
MariTheKillingQuillReplacementEffect() { public MariTheKillingQuillCreatureDiesAbility() {
super(Duration.WhileOnBattlefield, Outcome.Exile); super(Zone.BATTLEFIELD, new MariTheKillingQuillExileCreatureEffect(), false);
staticText = "Whenever a creature an opponent controls dies, exile it with a hit counter on it.";
} }
private MariTheKillingQuillReplacementEffect(final MariTheKillingQuillReplacementEffect effect) { public MariTheKillingQuillCreatureDiesAbility(final MariTheKillingQuillCreatureDiesAbility ability) {
super(effect); super(ability);
} }
@Override @Override
public MariTheKillingQuillReplacementEffect copy() { public MariTheKillingQuillCreatureDiesAbility copy() {
return new MariTheKillingQuillReplacementEffect(this); return new MariTheKillingQuillCreatureDiesAbility(this);
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean checkEventType(GameEvent event, Game game) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null
|| permanent == null
|| !controller.hasOpponent(permanent.getControllerId(), game)) {
return false;
}
return CardUtil.moveCardWithCounter(game, source, controller, permanent, Zone.EXILED, CounterType.HIT.createInstance());
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE; return event.getType() == GameEvent.EventType.ZONE_CHANGE;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zce = (ZoneChangeEvent) event; if (((ZoneChangeEvent) event).isDiesEvent()) {
return zce.isDiesEvent() if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
&& zce.getTarget().isCreature(game) Card creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
&& !(zce.getTarget() instanceof PermanentToken); if (creature != null
&& creature.isCreature(game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
}
return true;
}
}
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature an opponent controls dies, exile it with a hit counter on it.";
}
}
class MariTheKillingQuillExileCreatureEffect extends OneShotEffect {
public MariTheKillingQuillExileCreatureEffect() {
super(Outcome.Benefit);
this.staticText = "exile it with a hit counter on it";
}
public MariTheKillingQuillExileCreatureEffect(final MariTheKillingQuillExileCreatureEffect effect) {
super(effect);
}
@Override
public MariTheKillingQuillExileCreatureEffect copy() {
return new MariTheKillingQuillExileCreatureEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
if (card != null) {
return CardUtil.moveCardWithCounter(game, source, controller, card, Zone.EXILED, CounterType.HIT.createInstance());
}
return false;
} }
} }