Distinguish "blocks or becomes blocked" triggered abilities from "blocks or becomes blocked by a creature". Fixes #9347

This commit is contained in:
Alex W. Jackson 2022-09-25 02:53:07 -04:00
parent 8e67386628
commit c8c663b976
56 changed files with 431 additions and 753 deletions

View file

@ -1,10 +1,9 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -39,7 +38,7 @@ public final class Abomination extends CardImpl {
// Whenever Abomination blocks or becomes blocked by a green or white creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, filter, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter));
}
private Abomination(final Abomination card) {

View file

@ -1,11 +1,9 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
@ -29,8 +27,7 @@ public final class AislingLeprechaun extends CardImpl {
// Whenever Aisling Leprechaun blocks or becomes blocked by a creature, that creature becomes green.
Effect effect = new BecomesColorTargetEffect(ObjectColor.GREEN, Duration.EndOfGame);
effect.setText("that creature becomes green");
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false);
this.addAbility(ability);
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private AislingLeprechaun(final AislingLeprechaun card) {

View file

@ -1,41 +1,43 @@
package mage.cards.a;
import java.util.Objects;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DestroySourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
/**
*
* @author jeffwadsworth
* @author awjackson
*/
public final class ArrogantBloodlord extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power 1 or less");
static {
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 2));
}
public ArrogantBloodlord(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.subtype.add(SubType.VAMPIRE);
this.subtype.add(SubType.KNIGHT);
this.subtype.add(SubType.VAMPIRE, SubType.KNIGHT);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Whenever Arrogant Bloodlord blocks or becomes blocked by a creature with power 1 or less, destroy Arrogant Bloodlord at end of combat.
this.addAbility(new ArrogantBloodlordTriggeredAbility());
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroySourceEffect()));
effect.setText("destroy {this} at end of combat");
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter));
}
private ArrogantBloodlord(final ArrogantBloodlord card) {
@ -47,72 +49,3 @@ public final class ArrogantBloodlord extends CardImpl {
return new ArrogantBloodlord(this);
}
}
class ArrogantBloodlordTriggeredAbility extends TriggeredAbilityImpl {
ArrogantBloodlordTriggeredAbility() {
super(Zone.BATTLEFIELD, new ArrogantBloodlordEffect());
}
ArrogantBloodlordTriggeredAbility(final ArrogantBloodlordTriggeredAbility ability) {
super(ability);
}
@Override
public ArrogantBloodlordTriggeredAbility copy() {
return new ArrogantBloodlordTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent blocker = game.getPermanent(event.getSourceId());
Permanent blocked = game.getPermanent(event.getTargetId());
Permanent arrogantBloodlord = game.getPermanent(sourceId);
if (blocker != null && !Objects.equals(blocker, arrogantBloodlord)
&& blocker.getPower().getValue() < 2
&& Objects.equals(blocked, arrogantBloodlord)) {
return true;
}
return blocker != null && Objects.equals(blocker, arrogantBloodlord)
&& game.getPermanent(event.getTargetId()).getPower().getValue() < 2;
}
@Override
public String getRule() {
return "Whenever {this} blocks or becomes blocked by a creature with power 1 or less, destroy {this} at end of combat.";
}
}
class ArrogantBloodlordEffect extends OneShotEffect {
ArrogantBloodlordEffect() {
super(Outcome.Detriment);
staticText = "Destroy {this} at the end of combat";
}
ArrogantBloodlordEffect(final ArrogantBloodlordEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect());
delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
@Override
public ArrogantBloodlordEffect copy() {
return new ArrogantBloodlordEffect(this);
}
}

View file

@ -1,9 +1,8 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -18,14 +17,13 @@ public final class AshmouthHound extends CardImpl {
public AshmouthHound(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.DOG);
this.subtype.add(SubType.ELEMENTAL, SubType.DOG);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// Whenever Ashmouth Hound blocks or becomes blocked by a creature, Ashmouth Hound deals 1 damage to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(1, true, "that creature"), false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(1, true, "that creature")));
}
private AshmouthHound(final AshmouthHound card) {

View file

@ -1,11 +1,9 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
@ -27,12 +25,8 @@ public final class AssembledAlphas extends CardImpl {
this.toughness = new MageInt(5);
// Whenever Assembled Alphas blocks or becomes blocked by a creature, Assembled Alphas deals 3 damage to that creature and 3 damage to that creature's controller.
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(
new DamageTargetEffect(3, true, "that creature"), StaticFilters.FILTER_PERMANENT_CREATURE, false, null, true);
Effect effect = new DamageTargetControllerEffect(3);
effect.setText("and 3 damage to that creature's controller");
ability.addEffect(effect);
Ability ability = new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(3, true, "that creature"));
ability.addEffect(new DamageTargetControllerEffect(3).setText("and 3 damage to that creature's controller"));
this.addAbility(ability);
}

View file

@ -1,11 +1,11 @@
package mage.cards.b;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DestroyAllAttachedEquipmentEffect;
import mage.abilities.effects.common.DestroyAllAttachedToTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.StaticFilters;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
@ -19,10 +19,9 @@ public final class BlastfireBolt extends CardImpl {
public BlastfireBolt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{5}{R}");
// Blastfire Bolt deals 5 damage to target creature. Destroy all Equipment attached to that creature.
this.getSpellAbility().addEffect(new DamageTargetEffect(5));
this.getSpellAbility().addEffect(new DestroyAllAttachedEquipmentEffect());
this.getSpellAbility().addEffect(new DestroyAllAttachedToTargetEffect(StaticFilters.FILTER_PERMANENT_EQUIPMENT, "that creature"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}

View file

@ -1,9 +1,8 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -24,7 +23,7 @@ public final class Brushwagg extends CardImpl {
this.toughness = new MageInt(2);
// Whenever Brushwagg blocks or becomes blocked, it gets -2/+2 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(-2, 2, Duration.EndOfTurn), false));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(-2, 2, Duration.EndOfTurn, "it")));
}
private Brushwagg(final Brushwagg card) {

View file

@ -1,11 +1,8 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -22,14 +19,12 @@ public final class ChubToad extends CardImpl {
public ChubToad(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}");
this.subtype.add(SubType.FROG);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Whenever Chub Toad blocks or becomes blocked, it gets +2/+2 until end of turn.
Effect effect = new BoostSourceEffect(+2, +2, Duration.EndOfTurn);
effect.setText("it gets +2/+2 until end of turn");
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false);
this.addAbility(ability);
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn, "it")));
}
private ChubToad(final ChubToad card) {

View file

@ -1,9 +1,8 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -37,11 +36,11 @@ public final class Cockatrice extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever Cockatrice blocks or becomes blocked by a non-Wall creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, filter, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter));
}
private Cockatrice(final Cockatrice card) {

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -44,7 +44,7 @@ public final class CorrosiveOoze extends CardImpl {
// Whenever Corrosive Ooze blocks or becomes blocked by an equipped creature, destroy all Equipment attached to that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new CorrosiveOozeEffect()), true);
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, filter, false), new CorrosiveOozeCombatWatcher());
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter), new CorrosiveOozeCombatWatcher());
}
private CorrosiveOoze(final CorrosiveOoze card) {

View file

@ -2,7 +2,7 @@ package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -29,8 +29,7 @@ public final class Deathgazer extends CardImpl {
// Whenever Deathgazer blocks or becomes blocked by a nonblack creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK));
}
private Deathgazer(final Deathgazer card) {

View file

@ -2,7 +2,7 @@ package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -28,7 +28,7 @@ public final class DreadSpecter extends CardImpl {
// Whenever Dread Specter blocks or becomes blocked by a nonblack creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK));
}
private DreadSpecter(final DreadSpecter card) {

View file

@ -2,14 +2,13 @@ package mage.cards.d;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.PhaseOutSourceEffect;
import mage.abilities.effects.common.PhaseOutTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import java.util.UUID;
@ -27,12 +26,8 @@ public final class DreamFighter extends CardImpl {
this.toughness = new MageInt(1);
// Whenever Dream Fighter blocks or becomes blocked by a creature, Dream Fighter and that creature phase out.
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(
new PhaseOutSourceEffect(), StaticFilters.FILTER_PERMANENT_CREATURE,
false, "Whenever {this} blocks or becomes blocked by a creature, " +
"{this} and that creature phase out.", true
);
ability.addEffect(new PhaseOutTargetEffect());
Ability ability = new BlocksOrBlockedByCreatureSourceTriggeredAbility(new PhaseOutSourceEffect().setText("{this}"));
ability.addEffect(new PhaseOutTargetEffect().setText("and that creature phase out"));
this.addAbility(ability);
}

View file

@ -1,9 +1,8 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -13,7 +12,7 @@ import mage.constants.SubType;
/**
*
* @author Backfir3
* @author awjackson
*/
public final class Dromosaur extends CardImpl {
@ -24,8 +23,8 @@ public final class Dromosaur extends CardImpl {
this.power = new MageInt(2);
this.toughness = new MageInt(3);
// Whenever Dromosaur blocks or becomes blocked by a creature, it gets +2/-2 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(2, -2, Duration.EndOfTurn), false));
// Whenever Dromosaur blocks or becomes blocked, it gets +2/-2 until end of turn.
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(2, -2, Duration.EndOfTurn, "it")));
}
private Dromosaur(final Dromosaur card) {

View file

@ -4,7 +4,7 @@ package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
@ -30,7 +30,7 @@ public final class EngulfingSlagwurm extends CardImpl {
this.toughness = new MageInt(7);
// Whenever Engulfing Slagwurm blocks or becomes blocked by a creature, destroy that creature. You gain life equal to that creature's toughness.
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(new DestroyTargetEffect(), false);
Ability ability = new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DestroyTargetEffect());
ability.addEffect(new EngulfingSlagwurmEffect());
this.addAbility(ability);
}

View file

@ -1,9 +1,8 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
@ -27,7 +26,7 @@ public final class EscapedNull extends CardImpl {
this.toughness = new MageInt(2);
this.addAbility(LifelinkAbility.getInstance());
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(5, 0, Duration.EndOfTurn).setText("it gets +5/+0 until end of turn"), false, false));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(5, 0, Duration.EndOfTurn, "it")));
}
private EscapedNull(final EscapedNull card) {

View file

@ -1,27 +1,22 @@
package mage.cards.f;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BlocksOrBlockedAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.counter.AddCountersAttachedEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author TheElk801
* @author awjackson
*/
public final class Ferocity extends CardImpl {
@ -34,11 +29,13 @@ public final class Ferocity extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted creature blocks or becomes blocked, you may put a +1/+1 counter on it.
this.addAbility(new FerocityTriggeredAbility());
this.addAbility(new BlocksOrBlockedAttachedTriggeredAbility(
new AddCountersTargetEffect(CounterType.P1P1.createInstance()).setText("put a +1/+1 counter on it"),
true
));
}
private Ferocity(final Ferocity card) {
@ -50,47 +47,3 @@ public final class Ferocity extends CardImpl {
return new Ferocity(this);
}
}
class FerocityTriggeredAbility extends TriggeredAbilityImpl {
public FerocityTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), "it"), true);
}
public FerocityTriggeredAbility(final FerocityTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent aura = game.getPermanent(sourceId);
if (aura == null || aura.getAttachedTo() == null) {
return false;
}
if (event.getSourceId().equals(aura.getAttachedTo())) {
Permanent blocks = game.getPermanent(event.getTargetId());
return blocks != null;
}
if (event.getTargetId().equals(aura.getAttachedTo())) {
Permanent blockedBy = game.getPermanent(event.getSourceId());
return blockedBy != null;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted creature blocks or becomes blocked, "
+ "you may put a +1/+1 counter on it";
}
@Override
public FerocityTriggeredAbility copy() {
return new FerocityTriggeredAbility(this);
}
}

View file

@ -1,10 +1,8 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.keyword.FlyingAbility;
@ -13,7 +11,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.filter.StaticFilters;
/**
*
@ -32,8 +29,7 @@ public final class FlailingDrake extends CardImpl {
// Whenever Flailing Drake blocks or becomes blocked by a creature, that creature gets +1/+1 until end of turn.
Effect effect = new BoostTargetEffect(+1, +1, Duration.EndOfTurn);
effect.setText("that creature gets +1/+1 until end of turn");
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_A_CREATURE, false, null, true);
this.addAbility(ability);
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private FlailingDrake(final FlailingDrake card) {

View file

@ -1,14 +1,13 @@
package mage.cards.f;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.WerewolfBackTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import java.util.UUID;
@ -28,8 +27,7 @@ public final class FlameheartWerewolf extends CardImpl {
this.nightCard = true;
// Whenever Flameheart Werewolf blocks or becomes blocked by a creature, Flameheart Werewolf deals 2 damage to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(2, true, "that creature"),
StaticFilters.FILTER_PERMANENT_CREATURE, false, null, true));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(2, true, "that creature")));
// At the beginning of each upkeep, if a player cast two or more spells last turn, transform Flameheart Werewolf.
this.addAbility(new WerewolfBackTriggeredAbility());

View file

@ -1,10 +1,9 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.VigilanceAbility;
@ -40,8 +39,7 @@ public final class GhostHounds extends CardImpl {
this.addAbility(VigilanceAbility.getInstance());
// Whenever Ghost Hounds blocks or becomes blocked by a white creature, Ghost Hounds gains first strike until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), filter, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), filter));
}
private GhostHounds(final GhostHounds card) {

View file

@ -2,7 +2,7 @@ package mage.cards.g;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.SacrificeSourceEffect;
@ -43,7 +43,7 @@ public final class GiantShark extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(filter)));
// Whenever Giant Shark blocks or becomes blocked by a creature that has been dealt damage this turn, Giant Shark gets +2/+0 and gains trample until end of turn.
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(2, 0, Duration.EndOfTurn).setText("{this} gets +2/+0"), filter2, false);
Ability ability = new BlocksOrBlockedByCreatureSourceTriggeredAbility(new BoostSourceEffect(2, 0, Duration.EndOfTurn).setText("{this} gets +2/+0"), filter2);
ability.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn).setText("and gains trample until end of turn"));
this.addAbility(ability);

View file

@ -1,16 +1,16 @@
package mage.cards.g;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBlockedAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -28,12 +28,14 @@ public final class GiftOfTheWoods extends CardImpl {
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
this.getSpellAbility().addTarget(auraTarget);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted creature blocks or becomes blocked, it gets +0/+3 until end of turn and you gain 1 life.
this.addAbility(new GiftOfTheWoodsTriggeredAbility());
Ability ability = new BlocksOrBlockedAttachedTriggeredAbility(new BoostTargetEffect(0, 3).setText("it gets +0/+3 until end of turn"));
ability.addEffect(new GainLifeEffect(1).concatBy("and"));
this.addAbility(ability);
}
private GiftOfTheWoods(final GiftOfTheWoods card) {
@ -45,39 +47,3 @@ public final class GiftOfTheWoods extends CardImpl {
return new GiftOfTheWoods(this);
}
}
class GiftOfTheWoodsTriggeredAbility extends TriggeredAbilityImpl {
GiftOfTheWoodsTriggeredAbility() {
super(Zone.BATTLEFIELD, new BoostEnchantedEffect(0, 3, Duration.EndOfTurn));
this.addEffect(new GainLifeEffect(1));
}
private GiftOfTheWoodsTriggeredAbility(final GiftOfTheWoodsTriggeredAbility ability) {
super(ability);
}
@Override
public GiftOfTheWoodsTriggeredAbility copy() {
return new GiftOfTheWoodsTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = getSourcePermanentIfItStillExists(game);
return permanent != null && permanent.getAttachedTo() != null
&& (event.getSourceId().equals(permanent.getAttachedTo())
|| event.getTargetId().equals(permanent.getAttachedTo()));
}
@Override
public String getRule() {
return "Whenever enchanted creature blocks or becomes blocked, " +
"it gets +0/+3 until end of turn and you gain 1 life.";
}
}

View file

@ -1,10 +1,9 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -27,7 +26,7 @@ public final class GoblinCadets extends CardImpl {
this.toughness = new MageInt(1);
// Whenever Goblin Cadets blocks or becomes blocked, target opponent gains control of it.
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(new GoblinCadetsChangeControlEffect(), false);
Ability ability = new BlocksOrBlockedSourceTriggeredAbility(new GoblinCadetsChangeControlEffect());
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
@ -47,7 +46,7 @@ class GoblinCadetsChangeControlEffect extends ContinuousEffectImpl {
public GoblinCadetsChangeControlEffect() {
super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
staticText = "target opponent gains control of {this}";
staticText = "target opponent gains control of it. <i>(This removes {this} from combat.)</i>";
}
public GoblinCadetsChangeControlEffect(final GoblinCadetsChangeControlEffect effect) {
@ -69,5 +68,4 @@ class GoblinCadetsChangeControlEffect extends ContinuousEffectImpl {
}
return false;
}
}

View file

@ -1,9 +1,8 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -24,7 +23,7 @@ public final class GoblinEliteInfantry extends CardImpl {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(-1, -1, Duration.EndOfTurn), false));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(-1, -1, Duration.EndOfTurn, "it")));
}
private GoblinEliteInfantry(final GoblinEliteInfantry card) {

View file

@ -3,7 +3,7 @@ package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DoUnlessControllerPaysEffect;
@ -37,7 +37,7 @@ public final class GoblinFlotilla extends CardImpl {
// At the beginning of each combat, unless you pay {R}, whenever Goblin Flotilla blocks or becomes blocked by a creature this combat, that creature gains first strike until end of turn.
Effect effect = new DoUnlessControllerPaysEffect(
new GainAbilitySourceEffect(
new BlocksOrBecomesBlockedSourceTriggeredAbility(
new BlocksOrBlockedByCreatureSourceTriggeredAbility(
new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(),
Duration.EndOfTurn,
"Blocks or Blocked by Goblin Flotilla"),

View file

@ -2,7 +2,7 @@ package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
@ -30,7 +30,7 @@ public final class GorgonRecluse extends CardImpl {
// Whenever Gorgon Recluse blocks or becomes blocked by a nonblack creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK));
// Madness {B}{B}
this.addAbility(new MadnessAbility(new ManaCostsImpl<>("{B}{B}")));

View file

@ -1,9 +1,8 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -24,7 +23,7 @@ public final class InfernoElemental extends CardImpl {
this.toughness = new MageInt(4);
// Whenever Inferno Elemental blocks or becomes blocked by a creature, Inferno Elemental deals 3 damage to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(3, true, "that creature"), false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(3, true, "that creature")));
}
private InfernoElemental(final InfernoElemental card) {

View file

@ -1,7 +1,7 @@
package mage.cards.j;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -25,11 +25,7 @@ public final class JukaiTrainee extends CardImpl {
this.toughness = new MageInt(2);
// Whenever Jukai Trainee blocks or becomes blocked, it gets +1/+1 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(
new BoostSourceEffect(1, 1, Duration.EndOfTurn)
.setText("it gets +1/+1 until end of turn"),
false, false
));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(1, 1, Duration.EndOfTurn, "it")));
}
private JukaiTrainee(final JukaiTrainee card) {

View file

@ -1,10 +1,9 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
@ -38,7 +37,7 @@ public final class KarnSilverGolem extends CardImpl {
this.toughness = new MageInt(4);
// Whenever Karn, Silver Golem blocks or becomes blocked, it gets -4/+4 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(-4, +4, Duration.EndOfTurn), false));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(-4, +4, Duration.EndOfTurn, "it")));
// {1}: Target noncreature artifact becomes an artifact creature with power and toughness each equal to its converted mana cost until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new KarnSilverGolemEffect(), new ManaCostsImpl<>("{1}"));

View file

@ -1,7 +1,7 @@
package mage.cards.k;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.WerewolfFrontTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.TransformAbility;
@ -20,22 +20,18 @@ public final class KessigForgemaster extends CardImpl {
public KessigForgemaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SHAMAN);
this.subtype.add(SubType.WEREWOLF);
this.subtype.add(SubType.HUMAN, SubType.SHAMAN, SubType.WEREWOLF);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
this.secondSideCardClazz = mage.cards.f.FlameheartWerewolf.class;
// Whenever Kessig Forgemaster blocks or becomes blocked by a creature, Kessig Forgemaster deals 1 damage to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(1, true, "that creature"),
StaticFilters.FILTER_PERMANENT_CREATURE, false, null, true));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(1, true, "that creature")));
// At the beginning of each upkeep, if no spells were cast last turn, transform Kessig Forgemaster.
this.addAbility(new TransformAbility());
this.addAbility(new WerewolfFrontTriggeredAbility());
}
private KessigForgemaster(final KessigForgemaster card) {

View file

@ -2,7 +2,7 @@ package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.CantBeRegeneratedTargetEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
@ -25,13 +25,10 @@ public final class LimDulsCohort extends CardImpl {
this.toughness = new MageInt(3);
// Whenever Lim-Dûl's Cohort blocks or becomes blocked by a creature, that creature can't be regenerated this turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(
new CantBeRegeneratedTargetEffect(Duration.EndOfTurn),
new FilterCreaturePermanent(),
false,
"Whenever {this} blocks or becomes blocked by a creature, that creature can't be regenerated this turn.",
true));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(
new CantBeRegeneratedTargetEffect(Duration.EndOfTurn)
.setText("that creature can't be regenerated this turn")
));
}
private LimDulsCohort(final LimDulsCohort card) {

View file

@ -2,7 +2,7 @@ package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
@ -12,13 +12,7 @@ import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -44,7 +38,7 @@ public final class MammothHarness extends CardImpl {
this.addAbility(ability);
// Enchanted creature loses flying.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LoseAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA)));
this.addAbility(new SimpleStaticAbility(new LoseAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA)));
// Whenever enchanted creature blocks or becomes blocked by a creature, the other creature gains first strike until end of turn.
this.addAbility(new MammothHarnessTriggeredAbility());
@ -60,38 +54,38 @@ public final class MammothHarness extends CardImpl {
}
}
class MammothHarnessTriggeredAbility extends BlocksOrBecomesBlockedSourceTriggeredAbility {
class MammothHarnessTriggeredAbility extends TriggeredAbilityImpl {
public MammothHarnessTriggeredAbility() {
super(new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), StaticFilters.FILTER_PERMANENT_CREATURE, false, null, false);
super(Zone.BATTLEFIELD, new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), false);
}
public MammothHarnessTriggeredAbility(final MammothHarnessTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (sourcePermanent != null) {
Permanent attachedTo = game.getPermanentOrLKIBattlefield(sourcePermanent.getAttachedTo());
if (event.getSourceId().equals(attachedTo.getId())) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocked != null && filter.match(blocked, game)) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;
}
}
if (event.getTargetId().equals(attachedTo.getId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (blocker != null) {
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
return true;
}
}
Permanent aura = getSourcePermanentIfItStillExists(game);
if (aura == null) {
return false;
}
return false;
Permanent otherCreature = null;
if (event.getSourceId().equals(aura.getAttachedTo())) {
otherCreature = game.getPermanent(event.getTargetId());
} else if (event.getTargetId().equals(aura.getAttachedTo())) {
otherCreature = game.getPermanent(event.getSourceId());
}
if (otherCreature == null) {
return false;
}
getEffects().setTargetPointer(new FixedTarget(otherCreature, game));
return true;
}
@Override

View file

@ -1,7 +1,7 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
@ -25,14 +25,14 @@ import java.util.UUID;
*/
public final class MirrorShield extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent();
private static final FilterPermanent filter = new FilterCreaturePermanent("creature with deathtouch");
static {
filter.add(new AbilityPredicate(DeathtouchAbility.class));
}
private static final String rule
= "Whenever a creature with deathtouch blocks or becomes blocked by this creature, destroy that creature.";
private static final String triggerPhrase
= "Whenever a creature with deathtouch blocks or becomes blocked by this creature, ";
public MirrorShield(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
@ -40,13 +40,14 @@ public final class MirrorShield extends CardImpl {
this.subtype.add(SubType.EQUIPMENT);
// Equipped creature gets +0/+2 and has hexproof and "Whenever a creature with deathtouch blocks or becomes blocked by this creature, destroy that creature."
Ability gainedAbility = new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DestroyTargetEffect(), filter).setTriggerPhrase(triggerPhrase);
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(0, 2));
ability.addEffect(new GainAbilityAttachedEffect(
HexproofAbility.getInstance(), AttachmentType.EQUIPMENT
).setText("and has hexproof"));
ability.addEffect(new GainAbilityAttachedEffect(new BlocksOrBecomesBlockedSourceTriggeredAbility(
new DestroyTargetEffect(), filter, false, rule + "", true
), AttachmentType.EQUIPMENT).setText("and \"" + rule + "\""));
ability.addEffect(new GainAbilityAttachedEffect(
gainedAbility, AttachmentType.EQUIPMENT
).setText("and \"" + triggerPhrase + "destroy that creature.\""));
this.addAbility(ability);
// Equip {2}

View file

@ -2,7 +2,7 @@ package mage.cards.o;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
@ -24,9 +24,7 @@ public final class OrneryGoblin extends CardImpl {
this.toughness = new MageInt(1);
// Whenever Ornery Goblin blocks or becomes blocked by a creature, Ornery Goblin deals 1 damage to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(
new DamageTargetEffect(1, true, "that creature"), false
));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new DamageTargetEffect(1, true, "that creature")));
}
private OrneryGoblin(final OrneryGoblin card) {

View file

@ -1,9 +1,8 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -24,7 +23,7 @@ public final class RagingGorilla extends CardImpl {
this.toughness = new MageInt(3);
// Whenever Raging Gorilla blocks or becomes blocked, it gets +2/-2 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(2, -2, Duration.EndOfTurn), false));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(2, -2, Duration.EndOfTurn, "it")));
}
private RagingGorilla(final RagingGorilla card) {

View file

@ -1,9 +1,8 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -38,7 +37,7 @@ public final class RockBasilisk extends CardImpl {
Effect effect = new CreateDelayedTriggeredAbilityEffect(
new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, filter, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter));
}
private RockBasilisk(final RockBasilisk card) {

View file

@ -3,7 +3,7 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -26,10 +26,9 @@ public final class SawtoothOgre extends CardImpl {
this.toughness = new MageInt(3);
// Whenever Sawtooth Ogre blocks or becomes blocked by a creature, Sawtooth Ogre deals 1 damage to that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(
new DamageTargetEffect(1)), true)
.setText("{this} deals 1 damage to that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false));
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DamageTargetEffect(1)), true);
effect.setText("{this} deals 1 damage to that creature at end of combat");
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private SawtoothOgre(final SawtoothOgre card) {

View file

@ -4,7 +4,7 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
@ -37,7 +37,7 @@ public final class ShapeStealer extends CardImpl {
// each one in succession. The first trigger put on the stack will be the last to resolve,
// so that will set Shape Stealer's final power and toughness.
// Whenever Shape Stealer blocks or becomes blocked by a creature, change Shape Stealer's base power and toughness to that creature's power and toughness until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new ShapeStealerEffect(), false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(new ShapeStealerEffect()));
}
private ShapeStealer(final ShapeStealer card) {

View file

@ -1,9 +1,8 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.WitherAbility;
import mage.cards.CardImpl;
@ -28,7 +27,7 @@ public final class SlinkingGiant extends CardImpl {
this.addAbility(WitherAbility.getInstance());
// Whenever Slinking Giant blocks or becomes blocked, it gets -3/-0 until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(-3, 0, Duration.EndOfTurn).setText("it gets -3/-0 until end of turn"), false).setTriggerPhrase("Whenever {this} blocks or becomes blocked, "));
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(new BoostSourceEffect(-3, 0, Duration.EndOfTurn, "it")));
}
private SlinkingGiant(final SlinkingGiant card) {

View file

@ -1,30 +1,21 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.BlockedByIdPredicate;
import mage.filter.predicate.permanent.BlockingAttackerIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate;
/**
*
@ -32,6 +23,12 @@ import mage.target.targetpointer.FixedTarget;
*/
public final class SpittingSlug extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("each creature blocking or blocked by {this}");
static {
filter.add(BlockingOrBlockedBySourcePredicate.EITHER);
}
public SpittingSlug(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}");
this.subtype.add(SubType.SLUG);
@ -39,9 +36,10 @@ public final class SpittingSlug extends CardImpl {
this.toughness = new MageInt(4);
// Whenever Spitting Slug blocks or becomes blocked, you may pay {1}{G}. If you do, Spitting Slug gains first strike until end of turn. Otherwise, each creature blocking or blocked by Spitting Slug gains first strike until end of turn.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(
new DoIfCostPaid(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn),
new SpittingSlugEffect(),
this.addAbility(new BlocksOrBlockedSourceTriggeredAbility(
new DoIfCostPaid(
new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn),
new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filter),
new ManaCostsImpl<>("{1}{G}")).setText("you may pay {1}{G}. If you do, {this} gains first strike until end of turn. Otherwise, each creature blocking or blocked by {this} gains first strike until end of turn"),
false));
}
@ -55,35 +53,3 @@ public final class SpittingSlug extends CardImpl {
return new SpittingSlug(this);
}
}
class SpittingSlugEffect extends OneShotEffect {
public SpittingSlugEffect() {
super(Outcome.Detriment);
}
public SpittingSlugEffect(final SpittingSlugEffect effect) {
super(effect);
}
@Override
public SpittingSlugEffect copy() {
return new SpittingSlugEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(Predicates.or(new BlockedByIdPredicate(sourcePermanent.getId()), new BlockingAttackerIdPredicate(sourcePermanent.getId())));
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
}

View file

@ -1,35 +1,34 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyAllAttachedToTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author jeffwadsworth
* @author awjackson
*
*/
public final class StripBare extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Auras and Equipment");
static {
filter.add(Predicates.or(SubType.AURA.getPredicate(), SubType.EQUIPMENT.getPredicate()));
}
public StripBare(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}");
// Destroy all Auras and Equipment attached to target creature.
this.getSpellAbility().addEffect(new StripBareEffect());
this.getSpellAbility().addEffect(new DestroyAllAttachedToTargetEffect(filter, "target creature"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
private StripBare(final StripBare card) {
@ -41,39 +40,3 @@ public final class StripBare extends CardImpl {
return new StripBare(this);
}
}
class StripBareEffect extends OneShotEffect {
public StripBareEffect() {
super(Outcome.GainLife);
this.staticText = "Destroy all Auras and Equipment attached to target creature";
}
public StripBareEffect(final StripBareEffect effect) {
super(effect);
}
@Override
public StripBareEffect copy() {
return new StripBareEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(SubType.EQUIPMENT.getPredicate(),
SubType.AURA.getPredicate()));
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null
&& !targetCreature.getAttachments().isEmpty()) {
for (Permanent attachment : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (attachment != null
&& targetCreature.getAttachments().contains(attachment.getId())) {
applied = attachment.destroy(source, game, false);
}
}
}
return applied;
}
}

View file

@ -1,9 +1,8 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect;
import mage.abilities.keyword.FirstStrikeAbility;
@ -31,7 +30,7 @@ public final class TalruumChampion extends CardImpl {
// Whenever Talruum Champion blocks or becomes blocked by a creature, that creature loses first strike until end of turn.
Effect effect = new LoseAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
effect.setText("that creature loses first strike until end of turn");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private TalruumChampion(final TalruumChampion card) {

View file

@ -1,9 +1,8 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -30,7 +29,7 @@ public final class TangleAsp extends CardImpl {
// Whenever Tangle Asp blocks or becomes blocked by a creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private TangleAsp(final TangleAsp card) {

View file

@ -1,9 +1,8 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -37,7 +36,7 @@ public final class ThicketBasilisk extends CardImpl {
// Whenever Thicket Basilisk blocks or becomes blocked by a non-Wall creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, filter, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect, filter));
}
private ThicketBasilisk(final ThicketBasilisk card) {

View file

@ -1,20 +1,14 @@
package mage.cards.t;
import java.util.LinkedList;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.effects.common.DestroyAllAttachedToTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.filter.StaticFilters;
/**
*
@ -30,7 +24,9 @@ public final class TreefolkMystic extends CardImpl {
this.toughness = new MageInt(4);
// Whenever Treefolk Mystic blocks or becomes blocked by a creature, destroy all Auras attached to that creature.
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(new TreefolkMysticEffect(), false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(
new DestroyAllAttachedToTargetEffect(StaticFilters.FILTER_PERMANENT_AURAS, "that creature")
));
}
private TreefolkMystic(final TreefolkMystic card) {
@ -42,36 +38,3 @@ public final class TreefolkMystic extends CardImpl {
return new TreefolkMystic(this);
}
}
class TreefolkMysticEffect extends OneShotEffect {
public TreefolkMysticEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "destroy all Auras attached to that creature";
}
public TreefolkMysticEffect(final TreefolkMysticEffect effect) {
super(effect);
}
@Override
public TreefolkMysticEffect copy() {
return new TreefolkMysticEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
LinkedList<UUID> attachments = new LinkedList();
attachments.addAll(permanent.getAttachments());
for (UUID uuid : attachments) {
Permanent aura = game.getPermanent(uuid);
if (aura != null && aura.hasSubtype(SubType.AURA, game)) {
aura.destroy(source, game, false);
}
}
}
return false;
}
}

View file

@ -1,31 +1,27 @@
package mage.cards.t;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DestroyAllAttachedToTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.filter.StaticFilters;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Loki
* @author awjackson
*/
public final class TurnToSlag extends CardImpl {
public TurnToSlag (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{R}{R}");
this.getSpellAbility().addEffect(new TurnToSlagEffect());
// Turn To Slag deals 5 damage to target creature. Destroy all Equipment attached to that creature.
this.getSpellAbility().addEffect(new DamageTargetEffect(5));
this.getSpellAbility().addEffect(new DestroyAllAttachedToTargetEffect(StaticFilters.FILTER_PERMANENT_EQUIPMENT, "that creature"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
@ -38,41 +34,3 @@ public final class TurnToSlag extends CardImpl {
return new TurnToSlag(this);
}
}
class TurnToSlagEffect extends OneShotEffect {
public TurnToSlagEffect() {
super(Outcome.DestroyPermanent);
staticText = "{this} deals 5 damage to target creature. Destroy all Equipment attached to that creature";
}
public TurnToSlagEffect(final TurnToSlagEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
List<Permanent> attachments = new ArrayList<>();
for (UUID uuid : target.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached.hasSubtype(SubType.EQUIPMENT, game)) {
attachments.add(attached);
}
}
for (Permanent p : attachments) {
p.destroy(source, game, false);
}
target.damage(5, source.getSourceId(), source, game, false, false);
return true;
}
return false;
}
@Override
public TurnToSlagEffect copy() {
return new TurnToSlagEffect(this);
}
}

View file

@ -1,9 +1,8 @@
package mage.cards.v;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
@ -30,9 +29,9 @@ public final class VenomousDragonfly extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// Whenever Venomous Dragonfly blocks or becomes blocked by a creature, destroy that creature at end of combat.
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()));
Effect effect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect()), true);
effect.setText("destroy that creature at end of combat");
this.addAbility(new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, false));
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
}
private VenomousDragonfly(final VenomousDragonfly card) {

View file

@ -3,8 +3,7 @@ package mage.cards.w;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility;
import mage.abilities.common.BlocksOrBlockedByCreatureSourceTriggeredAbility;
import mage.abilities.common.DealsDamageToOpponentTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RemoveAllCountersSourceEffect;
@ -34,8 +33,7 @@ public final class WitherscaleWurm extends CardImpl {
// Whenever Witherscale Wurm blocks or becomes blocked by a creature, that creature gains wither until end of turn.
Effect effect = new GainAbilityTargetEffect(WitherAbility.getInstance(), Duration.EndOfTurn);
effect.setText("that creature gains wither until end of turn");
Ability ability = new BlocksOrBecomesBlockedSourceTriggeredAbility(effect, StaticFilters.FILTER_PERMANENT_CREATURE, false, null, true);
this.addAbility(ability);
this.addAbility(new BlocksOrBlockedByCreatureSourceTriggeredAbility(effect));
// Whenever Witherscale Wurm deals damage to an opponent, remove all -1/-1 counters from it.
this.addAbility(new DealsDamageToOpponentTriggeredAbility(new RemoveAllCountersSourceEffect(CounterType.M1M1), false));

View file

@ -1,91 +0,0 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
* @author North, Loki
*/
public class BlocksOrBecomesBlockedSourceTriggeredAbility extends TriggeredAbilityImpl {
protected FilterPermanent filter;
protected String rule;
protected boolean setTargetPointer;
public BlocksOrBecomesBlockedSourceTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, true);
}
public BlocksOrBecomesBlockedSourceTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
this(effect, StaticFilters.FILTER_PERMANENT_CREATURE, optional, null, setTargetPointer);
}
public BlocksOrBecomesBlockedSourceTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional) {
this(effect, filter, optional, null, true);
}
public BlocksOrBecomesBlockedSourceTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional, String rule) {
this(effect, filter, optional, rule, true);
}
public BlocksOrBecomesBlockedSourceTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional, String rule, boolean setTargetPointer) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
this.rule = rule;
this.setTargetPointer = setTargetPointer;
setTriggerPhrase("Whenever {this} blocks or becomes blocked" + (setTargetPointer ? " by a " + filter.getMessage() : "") + ", ");
}
public BlocksOrBecomesBlockedSourceTriggeredAbility(final BlocksOrBecomesBlockedSourceTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.rule = ability.rule;
this.setTargetPointer = ability.setTargetPointer;
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId())) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (filter.match(blocked, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
}
return true;
}
}
if (event.getTargetId().equals(this.getSourceId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (filter.match(blocker, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
}
return true;
}
}
return false;
}
@Override
public String getRule() {
return rule != null ? rule : super.getRule();
}
@Override
public BlocksOrBecomesBlockedSourceTriggeredAbility copy() {
return new BlocksOrBecomesBlockedSourceTriggeredAbility(this);
}
}

View file

@ -0,0 +1,48 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
* @author awjackson
*/
public class BlocksOrBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl {
public BlocksOrBlockedAttachedTriggeredAbility(Effect effect) {
this(effect, false);
}
public BlocksOrBlockedAttachedTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever enchanted creature blocks or becomes blocked, ");
}
public BlocksOrBlockedAttachedTriggeredAbility(final BlocksOrBlockedAttachedTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CREATURE_BLOCKS
|| event.getType() == GameEvent.EventType.CREATURE_BLOCKED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent creature = game.getPermanent(event.getTargetId());
if (creature == null || !creature.getAttachments().contains(getSourceId())) {
return false;
}
getEffects().setTargetPointer(new FixedTarget(creature, game));
return true;
}
@Override
public BlocksOrBlockedAttachedTriggeredAbility copy() {
return new BlocksOrBlockedAttachedTriggeredAbility(this);
}
}

View file

@ -0,0 +1,70 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
* @author awjackson
*/
public class BlocksOrBlockedByCreatureSourceTriggeredAbility extends TriggeredAbilityImpl {
private final FilterPermanent filter;
public BlocksOrBlockedByCreatureSourceTriggeredAbility(Effect effect) {
this(effect, false);
}
public BlocksOrBlockedByCreatureSourceTriggeredAbility(Effect effect, FilterPermanent filter) {
this(effect, filter, false);
}
public BlocksOrBlockedByCreatureSourceTriggeredAbility(Effect effect, boolean optional) {
this(effect, StaticFilters.FILTER_PERMANENT_CREATURE, optional);
}
public BlocksOrBlockedByCreatureSourceTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
setTriggerPhrase("Whenever {this} blocks or becomes blocked by " + CardUtil.addArticle(filter.getMessage()) + ", ");
}
public BlocksOrBlockedByCreatureSourceTriggeredAbility(final BlocksOrBlockedByCreatureSourceTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent otherCreature = null;
if (this.getSourceId().equals(event.getSourceId())) {
otherCreature = game.getPermanent(event.getTargetId());
} else if (this.getSourceId().equals(event.getTargetId())) {
otherCreature = game.getPermanent(event.getSourceId());
} else {
return false;
}
if (!filter.match(otherCreature, getControllerId(), this, game)) {
return false;
}
getEffects().setTargetPointer(new FixedTarget(otherCreature, game));
return true;
}
@Override
public BlocksOrBlockedByCreatureSourceTriggeredAbility copy() {
return new BlocksOrBlockedByCreatureSourceTriggeredAbility(this);
}
}

View file

@ -0,0 +1,41 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
* @author awjackson
*/
public class BlocksOrBlockedSourceTriggeredAbility extends TriggeredAbilityImpl {
public BlocksOrBlockedSourceTriggeredAbility(Effect effect) {
this(effect, false);
}
public BlocksOrBlockedSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever {this} blocks or becomes blocked, ");
}
public BlocksOrBlockedSourceTriggeredAbility(final BlocksOrBlockedSourceTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CREATURE_BLOCKS
|| event.getType() == GameEvent.EventType.CREATURE_BLOCKED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getTargetId().equals(getSourceId());
}
@Override
public BlocksOrBlockedSourceTriggeredAbility copy() {
return new BlocksOrBlockedSourceTriggeredAbility(this);
}
}

View file

@ -1,53 +0,0 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author Quercitron
*/
public class DestroyAllAttachedEquipmentEffect extends OneShotEffect {
public DestroyAllAttachedEquipmentEffect() {
super(Outcome.Benefit);
this.staticText = "Destroy all Equipment attached to that creature";
}
public DestroyAllAttachedEquipmentEffect(final DestroyAllAttachedEquipmentEffect effect) {
super(effect);
}
@Override
public DestroyAllAttachedEquipmentEffect copy() {
return new DestroyAllAttachedEquipmentEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetPermanent != null) {
List<UUID> attachments = new ArrayList<>(targetPermanent.getAttachments());
for (UUID attachmentId : attachments) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && attachment.hasSubtype(SubType.EQUIPMENT, game)) {
attachment.destroy(source, game, false);
}
}
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,52 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.filter.FilterPermanent;
/**
*
* @author awjackson
*/
public class DestroyAllAttachedToTargetEffect extends OneShotEffect {
private final FilterPermanent filter;
public DestroyAllAttachedToTargetEffect(FilterPermanent filter, String description) {
super(Outcome.DestroyPermanent);
this.filter = filter;
this.staticText = "destroy all " + filter.getMessage() + " attached to " + description;
}
public DestroyAllAttachedToTargetEffect(final DestroyAllAttachedToTargetEffect effect) {
super(effect);
this.filter = effect.filter;
}
@Override
public DestroyAllAttachedToTargetEffect copy() {
return new DestroyAllAttachedToTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (targetPermanent != null) {
List<UUID> attachments = new ArrayList<>(targetPermanent.getAttachments());
for (UUID attachmentId : attachments) {
Permanent attachment = game.getPermanent(attachmentId);
if (filter.match(attachment, source.getControllerId(), source, game)) {
attachment.destroy(source, game, false);
}
}
}
return true;
}
}

View file

@ -1,8 +1,7 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
@ -10,26 +9,27 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
public class BushidoAbility extends TriggeredAbilityImpl {
/**
* @author awjackson
*/
public class BushidoAbility extends BlocksOrBlockedSourceTriggeredAbility {
private DynamicValue value;
private String rulesText = null;
private final DynamicValue value;
private final String rule;
public BushidoAbility(int value) {
this(StaticValue.get(value));
rulesText = "Bushido " + value + getReminder(Integer.toString(value));
}
public BushidoAbility(DynamicValue value) {
super(Zone.BATTLEFIELD, new BoostSourceEffect(value, value, Duration.EndOfTurn, true), false);
if (!(value instanceof StaticValue)) {
rulesText = "{this} has bushido X, where X is " + value.getMessage() + getReminder(value.toString());
}
super(new BoostSourceEffect(value, value, Duration.EndOfTurn, true));
this.value = value;
rule = (
value instanceof StaticValue ?
"Bushido " + value.toString() :
"{this} has bushido X, where X is " + value.getMessage()
) + getReminder(value.toString());
}
static String getReminder(String xValue) {
@ -39,28 +39,7 @@ public class BushidoAbility extends TriggeredAbilityImpl {
public BushidoAbility(final BushidoAbility ability) {
super(ability);
this.value = ability.value;
this.rulesText = ability.rulesText;
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARE_BLOCKERS_STEP;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent source = game.getPermanent(getSourceId());
if (source != null) {
if (source.isBlocked(game)) {
return true;
}
for (CombatGroup group : game.getCombat().getGroups()) {
if (group.getBlockers().contains(getSourceId())) {
return true;
}
}
}
return false;
this.rule = ability.rule;
}
@Override
@ -74,6 +53,6 @@ public class BushidoAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return rulesText;
return rule;
}
}

View file

@ -952,12 +952,11 @@ public final class StaticFilters {
FILTER_BLOCKING_CREATURES.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_AURA = new FilterPermanent();
public static final FilterPermanent FILTER_PERMANENT_AURAS = new FilterEnchantmentPermanent("Auras");
static {
FILTER_PERMANENT_AURA.add(CardType.ENCHANTMENT.getPredicate());
FILTER_PERMANENT_AURA.add(SubType.AURA.getPredicate());
FILTER_PERMANENT_AURA.setLockedFilter(true);
FILTER_PERMANENT_AURAS.add(SubType.AURA.getPredicate());
FILTER_PERMANENT_AURAS.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_EQUIPMENT = new FilterEquipmentPermanent();