mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Necromancer's Magemark - Fixed replacement effect that was coded as triggered ability.
This commit is contained in:
parent
b0d5a9312a
commit
507ddd8711
3 changed files with 119 additions and 24 deletions
|
@ -29,11 +29,9 @@ package mage.sets.guildpact;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesCreatureTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostAllEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -46,6 +44,11 @@ import mage.constants.Zone;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.filter.predicate.permanent.EnchantedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
@ -55,7 +58,8 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class NecromancersMagemark extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures you control that are enchanted");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control that are enchanted");
|
||||
|
||||
static {
|
||||
filter.add(new EnchantedPredicate());
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
|
@ -72,13 +76,13 @@ public class NecromancersMagemark extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// Creatures you control that are enchanted get +1/+1.
|
||||
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false));
|
||||
this.addAbility(ability);
|
||||
|
||||
// If a creature you control that's enchanted would die, return it to its owner's hand instead.
|
||||
Effect effect = new ReturnToHandSourceEffect();
|
||||
ability = new DiesCreatureTriggeredAbility(effect,false);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NecromancersMagemarkEffect()));
|
||||
}
|
||||
|
||||
public NecromancersMagemark(final NecromancersMagemark card) {
|
||||
|
@ -90,3 +94,61 @@ public class NecromancersMagemark extends CardImpl {
|
|||
return new NecromancersMagemark(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NecromancersMagemarkEffect extends ReplacementEffectImpl {
|
||||
|
||||
public NecromancersMagemarkEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "If a creature you control that's enchanted would die, return it to its owner's hand instead";
|
||||
}
|
||||
|
||||
public NecromancersMagemarkEffect(final NecromancersMagemarkEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NecromancersMagemarkEffect copy() {
|
||||
return new NecromancersMagemarkEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null) {
|
||||
controller.moveCards(permanent, Zone.HAND, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.ZONE_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) {
|
||||
for (UUID attachmentId : permanent.getAttachments()) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(attachmentId);
|
||||
if (attachment != null && attachment.getSubtype(game).contains("Aura")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ class KalitasTraitorOfGhetEffect extends ReplacementEffectImpl {
|
|||
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null) {
|
||||
controller.moveCardToExileWithInfo(permanent, null, null, source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
controller.moveCards(permanent, Zone.EXILED, source, game);
|
||||
new CreateTokenEffect(new ZombieToken()).apply(game, source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,4 +52,37 @@ public class KalitasTraitorOfGhetTest extends CardTestPlayerBase {
|
|||
assertExileCount("Kalitas, Traitor of Ghet", 0); // player controlled, not opponent so not exiled
|
||||
assertPermanentCount(playerA, "Zombie", 3); // 3 tokens generated from exiling 3 opponent's creatures
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDamnationGraveyard() {
|
||||
|
||||
/*
|
||||
Kalitas, Traitor of Ghet {2}{B}{B} 3/4 lifelink - Legendary Vampire
|
||||
If a nontoken creature an opponent controls would die, instead exile that card and put a 2/2 black Zombie creature token onto the battlefield.
|
||||
*/
|
||||
addCard(Zone.GRAVEYARD, playerA, "Kalitas, Traitor of Ghet", 1);
|
||||
/*
|
||||
Damnation {2}{B}{B} - Sorcery
|
||||
Destroy all creatures. They can't be regenerated.
|
||||
*/
|
||||
addCard(Zone.HAND, playerA, "Damnation", 1);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Bronze Sable", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Wall of Roots", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Sigiled Starfish", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Damnation");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Kalitas, Traitor of Ghet", 1);
|
||||
assertGraveyardCount(playerA, "Damnation", 1);
|
||||
assertGraveyardCount(playerB, "Bronze Sable", 1);
|
||||
assertGraveyardCount(playerB, "Wall of Roots", 1);
|
||||
assertGraveyardCount(playerB, "Sigiled Starfish", 1);
|
||||
assertPermanentCount(playerA, "Zombie", 0); // 3 tokens generated from exiling 3 opponent's creatures
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue