Replace more custom effects with SavedDamageValue

This commit is contained in:
Alex W. Jackson 2022-04-02 02:11:12 -04:00
parent ca9b2ea135
commit 081b2f2f39
48 changed files with 318 additions and 1226 deletions

View file

@ -5,7 +5,7 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsDamageAttachedTriggeredAbility; import mage.abilities.common.DealsDamageAttachedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
@ -44,7 +44,7 @@ public final class ArmadilloCloak extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Whenever enchanted creature deals damage, you gain that much life. // Whenever enchanted creature deals damage, you gain that much life.
this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false));
} }

View file

@ -1,10 +1,8 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageAttachedControllerEffect; import mage.abilities.effects.common.DamageAttachedControllerEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -32,11 +30,10 @@ public final class Backfire extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature deals damage to you, Backfire deals that much damage to that creature's controller. // Whenever enchanted creature deals damage to you, Backfire deals that much damage to that creature's controller.
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DamageAttachedControllerEffect(new NumericSetToEffectValues("that much", "damage")), "enchanted creature", false, true, false, TargetController.YOU)); this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DamageAttachedControllerEffect(SavedDamageValue.MUCH), "enchanted creature", false, true, false, TargetController.YOU));
} }
private Backfire(final Backfire card) { private Backfire(final Backfire card) {

View file

@ -1,21 +1,15 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageAllControlledTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -31,9 +25,12 @@ public final class BalefireDragon extends CardImpl {
this.toughness = new MageInt(6); this.toughness = new MageInt(6);
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Whenever Balefire Dragon deals combat damage to a player, it deals that much damage to each creature that player controls.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new BalefireDragonEffect(), false, true));
// Whenever Balefire Dragon deals combat damage to a player,
// it deals that much damage to each creature that player controls.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DamageAllControlledTargetEffect(SavedDamageValue.MUCH, "it"),
false, true));
} }
private BalefireDragon(final BalefireDragon card) { private BalefireDragon(final BalefireDragon card) {
@ -45,36 +42,3 @@ public final class BalefireDragon extends CardImpl {
return new BalefireDragon(this); return new BalefireDragon(this);
} }
} }
class BalefireDragonEffect extends OneShotEffect {
public BalefireDragonEffect() {
super(Outcome.Damage);
staticText = "it deals that much damage to each creature that player controls";
}
public BalefireDragonEffect(final BalefireDragonEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
creature.damage(amount, source.getSourceId(), source, game, false, true);
}
}
return true;
}
return false;
}
@Override
public BalefireDragonEffect copy() {
return new BalefireDragonEffect(this);
}
}

View file

@ -1,13 +1,10 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DealtDamageAttachedTriggeredAbility; import mage.abilities.common.DealtDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageAttachedControllerEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -29,12 +26,10 @@ public final class BindingAgony extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature is dealt damage, Binding Agony deals that much damage to that creature's controller. // Whenever enchanted creature is dealt damage, Binding Agony deals that much damage to that creature's controller.
Effect effect = new DamageTargetEffect(new NumericSetToEffectValues("that much", "damage")); this.addAbility(new DealtDamageAttachedTriggeredAbility(new DamageAttachedControllerEffect(SavedDamageValue.MUCH), false));
effect.setText("{this} deals that much damage to that creature's controller");
this.addAbility(new DealtDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, effect, false, SetTargetPointer.PLAYER));
} }
private BindingAgony(final BindingAgony card) { private BindingAgony(final BindingAgony card) {

View file

@ -1,4 +1,3 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
@ -6,15 +5,12 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageAllControlledTargetEffect;
import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.common.FilterAttackingOrBlockingCreature; import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
/** /**
@ -35,10 +31,11 @@ public final class BrigidHeroOfKinsbaile extends CardImpl {
this.addAbility(FirstStrikeAbility.getInstance()); this.addAbility(FirstStrikeAbility.getInstance());
// {T}: Brigid, Hero of Kinsbaile deals 2 damage to each attacking or blocking creature target player controls. // {T}: Brigid, Hero of Kinsbaile deals 2 damage to each attacking or blocking creature target player controls.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BrigidHeroOfKinsbaileEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(
new DamageAllControlledTargetEffect(2, StaticFilters.FILTER_ATTACKING_OR_BLOCKING_CREATURE),
new TapSourceCost());
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());
this.addAbility(ability); this.addAbility(ability);
} }
private BrigidHeroOfKinsbaile(final BrigidHeroOfKinsbaile card) { private BrigidHeroOfKinsbaile(final BrigidHeroOfKinsbaile card) {
@ -50,32 +47,3 @@ public final class BrigidHeroOfKinsbaile extends CardImpl {
return new BrigidHeroOfKinsbaile(this); return new BrigidHeroOfKinsbaile(this);
} }
} }
class BrigidHeroOfKinsbaileEffect extends OneShotEffect {
public BrigidHeroOfKinsbaileEffect() {
super(Outcome.Damage);
staticText = "{this} deals 2 damage to each attacking or blocking creature target player controls";
}
public BrigidHeroOfKinsbaileEffect(final BrigidHeroOfKinsbaileEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterAttackingOrBlockingCreature(), targetPlayer.getId(), game)) {
creature.damage(2, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
@Override
public BrigidHeroOfKinsbaileEffect copy() {
return new BrigidHeroOfKinsbaileEffect(this);
}
}

View file

@ -1,19 +1,15 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.IslandwalkAbility; import mage.abilities.keyword.IslandwalkAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -31,9 +27,11 @@ public final class ColdEyedSelkie extends CardImpl {
// Islandwalk // Islandwalk
this.addAbility(new IslandwalkAbility()); this.addAbility(new IslandwalkAbility());
// Whenever Cold-Eyed Selkie deals combat damage to a player, you may draw that many cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ColdEyeSelkieEffect(), true, true));
// Whenever Cold-Eyed Selkie deals combat damage to a player, you may draw that many cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DrawCardSourceControllerEffect(SavedDamageValue.MANY),
true, true));
} }
private ColdEyedSelkie(final ColdEyedSelkie card) { private ColdEyedSelkie(final ColdEyedSelkie card) {
@ -45,33 +43,3 @@ public final class ColdEyedSelkie extends CardImpl {
return new ColdEyedSelkie(this); return new ColdEyedSelkie(this);
} }
} }
class ColdEyeSelkieEffect extends OneShotEffect {
public ColdEyeSelkieEffect() {
super(Outcome.DrawCard);
this.staticText = "draw that many cards";
}
public ColdEyeSelkieEffect(final ColdEyeSelkieEffect effect) {
super(effect);
}
@Override
public ColdEyeSelkieEffect copy() {
return new ColdEyeSelkieEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(amount, source, game);
return true;
}
}
return false;
}
}

View file

@ -1,10 +1,10 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DiesAttachedTriggeredAbility; import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.AttachedPermanentToughnessValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageAttachedControllerEffect; import mage.abilities.effects.common.DamageAttachedControllerEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -13,6 +13,9 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -24,18 +27,19 @@ public final class CreatureBond extends CardImpl {
public CreatureBond(UUID ownerId, CardSetInfo setInfo) { public CreatureBond(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature // Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// When enchanted creature dies, Creature Bond deals damage equal to that creature's toughness to the creature's controller. // When enchanted creature dies, Creature Bond deals damage equal to that creature's toughness to the creature's controller.
this.addAbility( new DiesAttachedTriggeredAbility(new DamageAttachedControllerEffect(AttachedPermanentToughnessValue.instance), "enchanted creature")); Effect effect = new DamageAttachedControllerEffect(CreatureBondValue.instance);
effect.setText("{this} deals damage equal to that creature's toughness to the creature's controller");
this.addAbility(new DiesAttachedTriggeredAbility(effect, "enchanted creature"));
} }
private CreatureBond(final CreatureBond card) { private CreatureBond(final CreatureBond card) {
@ -47,3 +51,32 @@ public final class CreatureBond extends CardImpl {
return new CreatureBond(this); return new CreatureBond(this);
} }
} }
enum CreatureBondValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId());
}
if (enchantment == null) {
return 0;
}
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
return enchanted.getToughness().getValue();
}
@Override
public CreatureBondValue copy() {
return instance;
}
@Override
public String getMessage() {
return "that creature's toughness";
}
}

View file

@ -5,9 +5,8 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect; import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -18,8 +17,6 @@ import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTargets; import mage.target.targetpointer.FixedTargets;
@ -38,7 +35,9 @@ public final class DreamPillager extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Whenever Dream Pillager deals combat damage to a player, exile that many cards from the top of your library. Until end of turn, you may cast nonland cards from among those exiled cards. // Whenever Dream Pillager deals combat damage to a player, exile that many cards from the top of your library. Until end of turn, you may cast nonland cards from among those exiled cards.
this.addAbility(new DreamPillagerTriggeredAbility()); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DreamPillagerEffect(),
false, true));
} }
private DreamPillager(final DreamPillager card) { private DreamPillager(final DreamPillager card) {
@ -51,48 +50,11 @@ public final class DreamPillager extends CardImpl {
} }
} }
class DreamPillagerTriggeredAbility extends TriggeredAbilityImpl {
public DreamPillagerTriggeredAbility() {
super(Zone.BATTLEFIELD, new DreamPillagerEffect(), false);
}
public DreamPillagerTriggeredAbility(final DreamPillagerTriggeredAbility ability) {
super(ability);
}
@Override
public DreamPillagerTriggeredAbility copy() {
return new DreamPillagerTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
for (Effect effect : getEffects()) {
effect.setValue("damage", event.getAmount());
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever {this} deals combat damage to a player, exile that many cards from the top of your library. Until end of turn, you may cast spells from among those exiled cards.";
}
}
class DreamPillagerEffect extends OneShotEffect { class DreamPillagerEffect extends OneShotEffect {
public DreamPillagerEffect() { public DreamPillagerEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "exile that many cards from the top of your library. Until end of turn, you may cast nonland cards from among those exiled cards"; this.staticText = "exile that many cards from the top of your library. Until end of turn, you may cast spells from among those exiled cards";
} }
public DreamPillagerEffect(final DreamPillagerEffect effect) { public DreamPillagerEffect(final DreamPillagerEffect effect) {

View file

@ -1,21 +1,17 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.keyword.EternalizeAbility; import mage.abilities.keyword.EternalizeAbility;
import mage.abilities.keyword.MenaceAbility; import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -34,12 +30,13 @@ public final class Dreamstealer extends CardImpl {
// Menace // Menace
this.addAbility(new MenaceAbility(false)); this.addAbility(new MenaceAbility(false));
// When Dreamstealer deals combat damage to a player, that player discards that many cards. // Whenever Dreamstealer deals combat damage to a player, that player discards that many cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DreamstealerDiscardEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DiscardTargetEffect(SavedDamageValue.MANY),
false, true));
// Eternalize {4}{B}{B} // Eternalize {4}{B}{B}
this.addAbility(new EternalizeAbility(new ManaCostsImpl("{4}{B}{B}"), this)); this.addAbility(new EternalizeAbility(new ManaCostsImpl("{4}{B}{B}"), this));
} }
private Dreamstealer(final Dreamstealer card) { private Dreamstealer(final Dreamstealer card) {
@ -51,33 +48,3 @@ public final class Dreamstealer extends CardImpl {
return new Dreamstealer(this); return new Dreamstealer(this);
} }
} }
class DreamstealerDiscardEffect extends OneShotEffect {
public DreamstealerDiscardEffect() {
super(Outcome.Discard);
this.staticText = "that player discards that many cards";
}
public DreamstealerDiscardEffect(final DreamstealerDiscardEffect effect) {
super(effect);
}
@Override
public DreamstealerDiscardEffect copy() {
return new DreamstealerDiscardEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
int damage = (Integer) getValue("damage");
targetPlayer.discard(damage, false, false, source, game);
game.informPlayers(targetPlayer.getLogName() + "discards " + damage + " card(s)");
return true;
}
return false;
}
}

View file

@ -1,10 +1,8 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DealtDamageAttachedTriggeredAbility; import mage.abilities.common.DealtDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect; import mage.abilities.effects.common.CreateTokenTargetEffect;
@ -30,16 +28,14 @@ public final class DruidsCall extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature // Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature is dealt damage, its controller creates that many 1/1 green Squirrel creature tokens. // Whenever enchanted creature is dealt damage, its controller creates that many 1/1 green Squirrel creature tokens.
Effect effect = new CreateTokenTargetEffect(new SquirrelToken(), new NumericSetToEffectValues("that much", "damage")); Effect effect = new CreateTokenTargetEffect(new SquirrelToken(), SavedDamageValue.MANY);
effect.setText("its controller creates that many 1/1 green Squirrel creature tokens"); effect.setText("its controller creates that many 1/1 green Squirrel creature tokens");
this.addAbility(new DealtDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, effect, false, SetTargetPointer.PLAYER)); this.addAbility(new DealtDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, effect, false, SetTargetPointer.PLAYER));
} }

View file

@ -1,11 +1,9 @@
package mage.cards.e; package mage.cards.e;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect; import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
@ -13,9 +11,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -35,7 +30,10 @@ public final class EmpyrealVoyager extends CardImpl {
// Trample // Trample
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// Whenever Empyreal Voyager deals combat damage to a player you get that many {E} // Whenever Empyreal Voyager deals combat damage to a player you get that many {E}
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new EmpyrealVoyagerEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new GetEnergyCountersControllerEffect(SavedDamageValue.MANY)
.setText("you get that many {E} <i>(energy counters)</i>."),
false, true));
} }
private EmpyrealVoyager(final EmpyrealVoyager card) { private EmpyrealVoyager(final EmpyrealVoyager card) {
@ -47,32 +45,3 @@ public final class EmpyrealVoyager extends CardImpl {
return new EmpyrealVoyager(this); return new EmpyrealVoyager(this);
} }
} }
class EmpyrealVoyagerEffect extends OneShotEffect {
public EmpyrealVoyagerEffect() {
super(Outcome.Benefit);
this.staticText = "you get that many {E}";
}
public EmpyrealVoyagerEffect(final EmpyrealVoyagerEffect effect) {
super(effect);
}
@Override
public EmpyrealVoyagerEffect copy() {
return new EmpyrealVoyagerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return new GetEnergyCountersControllerEffect(amount).apply(game, source);
}
}
return false;
}
}

View file

@ -5,15 +5,12 @@ import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageControllerEffect; import mage.abilities.effects.common.DamageControllerEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -31,12 +28,11 @@ public final class FiredrinkerSatyr extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Whenever Firedrinker Satyr is dealt damage, it deals that much damage to you. // Whenever Firedrinker Satyr is dealt damage, it deals that much damage to you.
this.addAbility(new DealtDamageToSourceTriggeredAbility(new FiredrinkerSatyrDealDamageEffect(), false, false)); this.addAbility(new DealtDamageToSourceTriggeredAbility(
new DamageControllerEffect(SavedDamageValue.MUCH, "it"), false));
// {1}{R}: Firedrinker Satyr gets +1/+0 until end of turn and deals 1 damage to you. // {1}{R}: Firedrinker Satyr gets +1/+0 until end of turn and deals 1 damage to you.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{1}{R}")); Ability ability = new SimpleActivatedAbility(new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl<>("{1}{R}"));
Effect effect = new DamageControllerEffect(1); ability.addEffect(new DamageControllerEffect(1, "and"));
effect.setText("and deals 1 damage to you");
ability.addEffect(effect);
this.addAbility(ability); this.addAbility(ability);
} }
@ -49,33 +45,3 @@ public final class FiredrinkerSatyr extends CardImpl {
return new FiredrinkerSatyr(this); return new FiredrinkerSatyr(this);
} }
} }
class FiredrinkerSatyrDealDamageEffect extends OneShotEffect {
public FiredrinkerSatyrDealDamageEffect() {
super(Outcome.Damage);
this.staticText = "it deals that much damage to you";
}
public FiredrinkerSatyrDealDamageEffect(final FiredrinkerSatyrDealDamageEffect effect) {
super(effect);
}
@Override
public FiredrinkerSatyrDealDamageEffect copy() {
return new FiredrinkerSatyrDealDamageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
return true;
}
}
return false;
}
}

View file

@ -5,17 +5,13 @@ import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToACreatureTriggeredAbility; import mage.abilities.common.DealsCombatDamageToACreatureTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.abilities.effects.common.RegenerateSourceEffect; import mage.abilities.effects.common.RegenerateSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -32,10 +28,13 @@ public final class FlayedNim extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever Flayed Nim deals combat damage to a creature, that creature's controller loses that much life. // Whenever Flayed Nim deals combat damage to a creature, that creature's controller loses that much life.
this.addAbility(new DealsCombatDamageToACreatureTriggeredAbility(new FlayedNimEffect(), false, true)); this.addAbility(new DealsCombatDamageToACreatureTriggeredAbility(
new LoseLifeTargetControllerEffect(SavedDamageValue.MUCH)
.setText("that creature's controller loses that much life"),
false, true));
// {2}{B}: Regenerate Flayed Nim. // {2}{B}: Regenerate Flayed Nim.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{2}{B}"))); this.addAbility(new SimpleActivatedAbility(new RegenerateSourceEffect(), new ManaCostsImpl("{2}{B}")));
} }
private FlayedNim(final FlayedNim card) { private FlayedNim(final FlayedNim card) {
@ -47,35 +46,3 @@ public final class FlayedNim extends CardImpl {
return new FlayedNim(this); return new FlayedNim(this);
} }
} }
class FlayedNimEffect extends OneShotEffect {
FlayedNimEffect() {
super(Outcome.Benefit);
this.staticText = "that creature's controller loses that much life";
}
FlayedNimEffect(final FlayedNimEffect effect) {
super(effect);
}
@Override
public FlayedNimEffect copy() {
return new FlayedNimEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (creature == null) {
return false;
}
Player player = game.getPlayer(creature.getControllerId());
if (player == null) {
return false;
}
int damage = (int) this.getValue("damage");
player.loseLife(damage, game, source, false);
return true;
}
}

View file

@ -1,19 +1,17 @@
package mage.cards.f; package mage.cards.f;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -47,7 +45,7 @@ public final class FleshReaver extends CardImpl {
class FleshReaverTriggeredAbility extends TriggeredAbilityImpl { class FleshReaverTriggeredAbility extends TriggeredAbilityImpl {
FleshReaverTriggeredAbility() { FleshReaverTriggeredAbility() {
super(Zone.BATTLEFIELD, new FleshReaverEffect()); super(Zone.BATTLEFIELD, new DamageControllerEffect(SavedDamageValue.MUCH));
} }
private FleshReaverTriggeredAbility(final FleshReaverTriggeredAbility effect) { private FleshReaverTriggeredAbility(final FleshReaverTriggeredAbility effect) {
@ -80,39 +78,7 @@ class FleshReaverTriggeredAbility extends TriggeredAbilityImpl {
} }
@Override @Override
public String getRule() { public String getTriggerPhrase() {
return "Whenever {this} deals damage to a creature or opponent, {this} deals that much damage to you."; return "Whenever {this} deals damage to a creature or opponent, ";
}
}
class FleshReaverEffect extends OneShotEffect {
FleshReaverEffect() {
super(Outcome.Detriment);
this.staticText = "{this} deals that much damage to you.";
}
private FleshReaverEffect(final FleshReaverEffect effect) {
super(effect);
}
@Override
public FleshReaverEffect copy() {
return new FleshReaverEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent creature = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (creature == null || controller == null) {
return false;
}
int damageToDeal = (Integer) getValue("damage");
if (damageToDeal > 0) {
controller.damage(damageToDeal, source.getSourceId(), source, game);
}
return true;
} }
} }

View file

@ -1,4 +1,3 @@
package mage.cards.g; package mage.cards.g;
import java.util.UUID; import java.util.UUID;
@ -8,7 +7,8 @@ import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardCardCost; import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -16,9 +16,6 @@ import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/** /**
* @author fenhl * @author fenhl
@ -33,10 +30,12 @@ public final class GlintEyeNephilim extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever Glint-Eye Nephilim deals combat damage to a player, draw that many cards. // Whenever Glint-Eye Nephilim deals combat damage to a player, draw that many cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new GlintEyeNephilimEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DrawCardSourceControllerEffect(SavedDamageValue.MANY),
false, true));
// {1}, Discard a card: Glint-Eye Nephilim gets +1/+1 until end of turn. // {1}, Discard a card: Glint-Eye Nephilim gets +1/+1 until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 1, Duration.EndOfTurn), new GenericManaCost(1)); Ability ability = new SimpleActivatedAbility(new BoostSourceEffect(1, 1, Duration.EndOfTurn), new GenericManaCost(1));
ability.addCost(new DiscardCardCost()); ability.addCost(new DiscardCardCost());
this.addAbility(ability); this.addAbility(ability);
@ -51,33 +50,3 @@ public final class GlintEyeNephilim extends CardImpl {
return new GlintEyeNephilim(this); return new GlintEyeNephilim(this);
} }
} }
class GlintEyeNephilimEffect extends OneShotEffect {
public GlintEyeNephilimEffect() {
super(Outcome.DrawCard);
this.staticText = "draw that many cards";
}
public GlintEyeNephilimEffect(final GlintEyeNephilimEffect effect) {
super(effect);
}
@Override
public GlintEyeNephilimEffect copy() {
return new GlintEyeNephilimEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(amount, source, game);
return true;
}
}
return false;
}
}

View file

@ -1,11 +1,11 @@
package mage.cards.h; package mage.cards.h;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
@ -13,9 +13,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -27,15 +24,15 @@ public final class HuntersProwess extends CardImpl {
public HuntersProwess(UUID ownerId, CardSetInfo setInfo) { public HuntersProwess(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{G}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{G}");
// Until end of turn, target creature gets +3/+3 and gains trample and "Whenever this creature deals combat damage to a player, draw that many cards." // Until end of turn, target creature gets +3/+3 and gains trample and "Whenever this creature deals combat damage to a player, draw that many cards."
Effect effect = new BoostTargetEffect(3,3, Duration.EndOfTurn); Effect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
effect.setText("Until end of turn, target creature gets +3/+3"); effect.setText("Until end of turn, target creature gets +3/+3");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setText("and gains trample"); effect.setText("and gains trample");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
Ability grantedAbility = new DealsCombatDamageToAPlayerTriggeredAbility(new HuntersProwessDrawEffect(), false, true); Ability grantedAbility = new DealsCombatDamageToAPlayerTriggeredAbility(
new DrawCardSourceControllerEffect(SavedDamageValue.MANY), false, true);
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(grantedAbility, Duration.EndOfTurn, this.getSpellAbility().addEffect(new GainAbilityTargetEffect(grantedAbility, Duration.EndOfTurn,
"and \"Whenever this creature deals combat damage to a player, draw that many cards.\"")); "and \"Whenever this creature deals combat damage to a player, draw that many cards.\""));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -50,35 +47,3 @@ public final class HuntersProwess extends CardImpl {
return new HuntersProwess(this); return new HuntersProwess(this);
} }
} }
class HuntersProwessDrawEffect extends OneShotEffect {
public HuntersProwessDrawEffect() {
super(Outcome.Benefit);
this.staticText = "draw that many cards";
}
public HuntersProwessDrawEffect(final HuntersProwessDrawEffect effect) {
super(effect);
}
@Override
public HuntersProwessDrawEffect copy() {
return new HuntersProwessDrawEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int damage = (Integer) this.getValue("damage");
if (damage > 0) {
controller.drawCards(damage, source, game);
}
return true;
}
return false;
}
}

View file

@ -1,16 +1,13 @@
package mage.cards.j; package mage.cards.j;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -27,8 +24,8 @@ public final class JackalPup extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Whenever Jackal Pup is dealt damage, it deals that much damage to you. // Whenever Jackal Pup is dealt damage, it deals that much damage to you.
this.addAbility(new DealtDamageToSourceTriggeredAbility(new JackalPupEffect(), false, false)); this.addAbility(new DealtDamageToSourceTriggeredAbility(
new DamageControllerEffect(SavedDamageValue.MUCH, "it"), false));
} }
private JackalPup(final JackalPup card) { private JackalPup(final JackalPup card) {
@ -40,30 +37,3 @@ public final class JackalPup extends CardImpl {
return new JackalPup(this); return new JackalPup(this);
} }
} }
class JackalPupEffect extends OneShotEffect {
public JackalPupEffect() {
super(Outcome.Damage);
staticText = "it deals that much damage to you";
}
public JackalPupEffect(final JackalPupEffect effect) {
super(effect);
}
@Override
public JackalPupEffect copy() {
return new JackalPupEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
you.damage((Integer) this.getValue("damage"), source.getSourceId(), source, game);
}
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.j; package mage.cards.j;
import java.util.UUID; import java.util.UUID;
@ -8,15 +7,14 @@ import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.condition.common.HellbentCondition; import mage.abilities.condition.common.HellbentCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.AbilityWord; import mage.constants.AbilityWord;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -33,16 +31,15 @@ public final class JaggedPoppet extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever Jagged Poppet is dealt damage, discard that many cards. // Whenever Jagged Poppet is dealt damage, discard that many cards.
this.addAbility(new DealtDamageToSourceTriggeredAbility(new JaggedPoppetDealtDamageEffect(), false, false)); this.addAbility(new DealtDamageToSourceTriggeredAbility(new DiscardControllerEffect(SavedDamageValue.MANY), false));
// Hellbent - Whenever Jagged Poppet deals combat damage to a player, if you have no cards in hand, that player discards cards equal to the damage. // Hellbent - Whenever Jagged Poppet deals combat damage to a player, if you have no cards in hand, that player discards cards equal to the damage.
Ability hellbentAbility = new ConditionalInterveningIfTriggeredAbility( Ability hellbentAbility = new ConditionalInterveningIfTriggeredAbility(
new DealsCombatDamageToAPlayerTriggeredAbility(new JaggedPoppetDealsDamageEffect(), false, true), new DealsCombatDamageToAPlayerTriggeredAbility(new DiscardTargetEffect(SavedDamageValue.MANY), false, true),
HellbentCondition.instance, HellbentCondition.instance,
"Whenever {this} deals combat damage to a player, if you have no cards in hand, that player discards cards equal to the damage."); "Whenever {this} deals combat damage to a player, if you have no cards in hand, that player discards cards equal to the damage.");
hellbentAbility.setAbilityWord(AbilityWord.HELLBENT); hellbentAbility.setAbilityWord(AbilityWord.HELLBENT);
this.addAbility(hellbentAbility); this.addAbility(hellbentAbility);
} }
private JaggedPoppet(final JaggedPoppet card) { private JaggedPoppet(final JaggedPoppet card) {
@ -54,73 +51,3 @@ public final class JaggedPoppet extends CardImpl {
return new JaggedPoppet(this); return new JaggedPoppet(this);
} }
} }
class JaggedPoppetDealsDamageEffect extends OneShotEffect {
public JaggedPoppetDealsDamageEffect() {
super(Outcome.Discard);
//staticText = "it deals that much damage to each creature that player controls";
}
public JaggedPoppetDealsDamageEffect(final JaggedPoppetDealsDamageEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
//According to the Balefire Dragon code, This statement gets the player that was dealt the combat damage
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
//Call the getValue method of the Effect class to retrieve the amount of damage
int amount = (Integer) getValue("damage");
if (amount > 0) {
//Call the player discard function discarding cards equal to damage
player.discard(amount, false, false, source, game);
}
return true;
}
return false;
}
@Override
public JaggedPoppetDealsDamageEffect copy() {
return new JaggedPoppetDealsDamageEffect(this);
}
}
class JaggedPoppetDealtDamageEffect extends OneShotEffect {
public JaggedPoppetDealtDamageEffect() {
super(Outcome.Discard);
staticText = "discard that many cards";
}
public JaggedPoppetDealtDamageEffect(final JaggedPoppetDealtDamageEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
//According to the Firedrinker Satyr code, This statement gets the player that controls Jagged Poppet
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
//Call the getValue method of the Effect class to retrieve the amount of damage
int amount = (Integer) getValue("damage");
if (amount > 0) {
//Call the player discard function discarding cards equal to damage
player.discard(amount, false, false, source, game);
}
return true;
}
return false;
}
@Override
public JaggedPoppetDealtDamageEffect copy() {
return new JaggedPoppetDealtDamageEffect(this);
}
}

View file

@ -1,21 +1,16 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.token.InsectToken; import mage.game.permanent.token.InsectToken;
import mage.players.Player;
/** /**
* *
@ -33,7 +28,8 @@ public final class LivingHive extends CardImpl {
// Trample // Trample
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// Whenever Living Hive deals combat damage to a player, create that many 1/1 green Insect creature tokens. // Whenever Living Hive deals combat damage to a player, create that many 1/1 green Insect creature tokens.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new LivingHiveEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new CreateTokenEffect(new InsectToken(), SavedDamageValue.MANY), false, true));
} }
private LivingHive(final LivingHive card) { private LivingHive(final LivingHive card) {
@ -45,33 +41,3 @@ public final class LivingHive extends CardImpl {
return new LivingHive(this); return new LivingHive(this);
} }
} }
class LivingHiveEffect extends OneShotEffect {
public LivingHiveEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "create that many 1/1 green Insect creature tokens";
}
public LivingHiveEffect(final LivingHiveEffect effect) {
super(effect);
}
@Override
public LivingHiveEffect copy() {
return new LivingHiveEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int amount = (Integer)getValue("damage");
if (amount > 0) {
return new CreateTokenEffect(new InsectToken(), amount).apply(game, source);
}
return true;
}
return false;
}
}

View file

@ -1,20 +1,17 @@
package mage.cards.n; package mage.cards.n;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.WitherAbility; import mage.abilities.keyword.WitherAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -31,13 +28,14 @@ public final class NeedleSpecter extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Wither // Wither
this.addAbility(WitherAbility.getInstance()); this.addAbility(WitherAbility.getInstance());
// Whenever Needle Specter deals combat damage to a player, that player discards that many cards. // Whenever Needle Specter deals combat damage to a player, that player discards that many cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new NeedleSpecterEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DiscardTargetEffect(SavedDamageValue.MANY),
false, true));
} }
private NeedleSpecter(final NeedleSpecter card) { private NeedleSpecter(final NeedleSpecter card) {
@ -49,33 +47,3 @@ public final class NeedleSpecter extends CardImpl {
return new NeedleSpecter(this); return new NeedleSpecter(this);
} }
} }
class NeedleSpecterEffect extends OneShotEffect {
public NeedleSpecterEffect() {
super(Outcome.Discard);
this.staticText = "that player discards that many cards";
}
public NeedleSpecterEffect(final NeedleSpecterEffect effect) {
super(effect);
}
@Override
public NeedleSpecterEffect copy() {
return new NeedleSpecterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
int damage = (Integer)getValue("damage");
targetPlayer.discard(damage, false, false, source, game);
game.informPlayers(targetPlayer.getLogName() + "discards " + damage + " card(s)");
return true;
}
return false;
}
}

View file

@ -2,10 +2,8 @@ package mage.cards.o;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.constants.SetTargetPointer; import mage.constants.SetTargetPointer;
import mage.constants.SubType; import mage.constants.SubType;
@ -15,7 +13,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.token.TreasureToken; import mage.game.permanent.token.TreasureToken;
/** /**
@ -37,7 +34,7 @@ public final class OldGnawbone extends CardImpl {
// Whenever a creature you control deals combat damage to a player, create that many Treasure tokens. // Whenever a creature you control deals combat damage to a player, create that many Treasure tokens.
this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility( this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(
new CreateTokenEffect(new TreasureToken(), OldGnawboneValue.instance), new CreateTokenEffect(new TreasureToken(), SavedDamageValue.MANY),
StaticFilters.FILTER_CONTROLLED_A_CREATURE, StaticFilters.FILTER_CONTROLLED_A_CREATURE,
false, SetTargetPointer.NONE, true false, SetTargetPointer.NONE, true
)); ));
@ -52,31 +49,3 @@ public final class OldGnawbone extends CardImpl {
return new OldGnawbone(this); return new OldGnawbone(this);
} }
} }
enum OldGnawboneValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Integer damage = (Integer) effect.getValue("damage");
if (damage != null) {
return damage;
}
return 0;
}
@Override
public String toString() {
return "that many";
}
@Override
public String getMessage() {
return "";
}
@Override
public OldGnawboneValue copy() {
return OldGnawboneValue.instance;
}
}

View file

@ -7,20 +7,19 @@ import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.DealsDamageGainLifeSourceTriggeredAbility; import mage.abilities.common.DealsDamageGainLifeSourceTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.keyword.ForecastAbility; import mage.abilities.keyword.ForecastAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.SubType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -59,13 +58,12 @@ public final class PaladinOfPrahv extends CardImpl {
class PaladinOfPrahvTriggeredAbility extends DelayedTriggeredAbility { class PaladinOfPrahvTriggeredAbility extends DelayedTriggeredAbility {
public PaladinOfPrahvTriggeredAbility() { public PaladinOfPrahvTriggeredAbility() {
super(new PaladinOfPrahvEffect(), Duration.EndOfTurn, false); super(new GainLifeEffect(SavedDamageValue.MUCH), Duration.EndOfTurn, false);
} }
public PaladinOfPrahvTriggeredAbility(final PaladinOfPrahvTriggeredAbility ability) { public PaladinOfPrahvTriggeredAbility(final PaladinOfPrahvTriggeredAbility ability) {
super(ability); super(ability);
} }
@Override @Override
public PaladinOfPrahvTriggeredAbility copy() { public PaladinOfPrahvTriggeredAbility copy() {
@ -93,40 +91,9 @@ class PaladinOfPrahvTriggeredAbility extends DelayedTriggeredAbility {
} }
return false; return false;
} }
@Override @Override
public String getTriggerPhrase() { public String getTriggerPhrase() {
return "Whenever target creature deals damage this turn, " ; return "Whenever target creature deals damage this turn, " ;
} }
} }
class PaladinOfPrahvEffect extends OneShotEffect {
public PaladinOfPrahvEffect() {
super(Outcome.GainLife);
this.staticText = "you gain that much life";
}
public PaladinOfPrahvEffect(final PaladinOfPrahvEffect effect) {
super(effect);
}
@Override
public PaladinOfPrahvEffect copy() {
return new PaladinOfPrahvEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
controller.gainLife(amount, game, source);
return true;
}
return true;
}
return false;
}
}

View file

@ -1,13 +1,10 @@
package mage.cards.r; package mage.cards.r;
import java.util.UUID; import java.util.UUID;
import mage.abilities.common.DealtDamageAttachedTriggeredAbility; import mage.abilities.common.DealtDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlashAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -15,8 +12,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -30,7 +25,6 @@ public final class RaggedVeins extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}"); super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Flash // Flash
this.addAbility(FlashAbility.getInstance()); this.addAbility(FlashAbility.getInstance());
@ -41,9 +35,10 @@ public final class RaggedVeins extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName())); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted creature is dealt damage, its controller loses that much life. // Whenever enchanted creature is dealt damage, its controller loses that much life.
Effect effect = new LoseLifeTargetEffect(new NumericSetToEffectValues("that much", "damage")); this.addAbility(new DealtDamageAttachedTriggeredAbility(
effect.setText("its controller loses that much life"); new LoseLifeControllerAttachedEffect(SavedDamageValue.MUCH),
this.addAbility(new DealtDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, effect, false, SetTargetPointer.PLAYER)); false
));
} }
private RaggedVeins(final RaggedVeins card) { private RaggedVeins(final RaggedVeins card) {

View file

@ -1,16 +1,13 @@
package mage.cards.s; package mage.cards.s;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -28,7 +25,8 @@ public final class ShinkaGatekeeper extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever Shinka Gatekeeper is dealt damage, it deals that much damage to you. // Whenever Shinka Gatekeeper is dealt damage, it deals that much damage to you.
this.addAbility(new DealtDamageToSourceTriggeredAbility(new ShinkaGatekeeperDealDamageEffect(), false, false)); this.addAbility(new DealtDamageToSourceTriggeredAbility(
new DamageControllerEffect(SavedDamageValue.MUCH, "it"), false));
} }
private ShinkaGatekeeper(final ShinkaGatekeeper card) { private ShinkaGatekeeper(final ShinkaGatekeeper card) {
@ -40,33 +38,3 @@ public final class ShinkaGatekeeper extends CardImpl {
return new ShinkaGatekeeper(this); return new ShinkaGatekeeper(this);
} }
} }
class ShinkaGatekeeperDealDamageEffect extends OneShotEffect {
public ShinkaGatekeeperDealDamageEffect() {
super(Outcome.Damage);
this.staticText = "it deals that much damage to you";
}
public ShinkaGatekeeperDealDamageEffect(final ShinkaGatekeeperDealDamageEffect effect) {
super(effect);
}
@Override
public ShinkaGatekeeperDealDamageEffect copy() {
return new ShinkaGatekeeperDealDamageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
return true;
}
}
return false;
}
}

View file

@ -2,19 +2,13 @@ package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageAllControlledTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -31,8 +25,11 @@ public final class ShockmawDragon extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Whenever Shockmaw Dragon deals combat damage to a player, it deals 1 damage to each creature that player controls. // Whenever Shockmaw Dragon deals combat damage to a player,
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ShockmawDragonEffect(), false, true)); // it deals 1 damage to each creature that player controls.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DamageAllControlledTargetEffect(1, "it"),
false, true));
} }
private ShockmawDragon(final ShockmawDragon card) { private ShockmawDragon(final ShockmawDragon card) {
@ -44,36 +41,3 @@ public final class ShockmawDragon extends CardImpl {
return new ShockmawDragon(this); return new ShockmawDragon(this);
} }
} }
class ShockmawDragonEffect extends OneShotEffect {
public ShockmawDragonEffect() {
super(Outcome.Damage);
staticText = "it deals 1 damage to each creature that player controls";
}
public ShockmawDragonEffect(final ShockmawDragonEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
creature.damage(1, source.getSourceId(), source, game, false, true);
}
}
return true;
}
return false;
}
@Override
public ShockmawDragonEffect copy() {
return new ShockmawDragonEffect(this);
}
}

View file

@ -1,11 +1,9 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageAttachedTriggeredAbility; import mage.abilities.common.DealsDamageAttachedTriggeredAbility;
import mage.abilities.common.DealtDamageAttachedTriggeredAbility; import mage.abilities.common.DealtDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -32,13 +30,13 @@ public final class SoulLink extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature deals damage, you gain that much life. // Whenever enchanted creature deals damage, you gain that much life.
this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD,
new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); new GainLifeEffect(SavedDamageValue.MUCH), false));
// Whenever enchanted creature is dealt damage, you gain that much life. // Whenever enchanted creature is dealt damage, you gain that much life.
this.addAbility(new DealtDamageAttachedTriggeredAbility(new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); this.addAbility(new DealtDamageAttachedTriggeredAbility(new GainLifeEffect(SavedDamageValue.MUCH), false));
} }
private SoulLink(final SoulLink card) { private SoulLink(final SoulLink card) {

View file

@ -1,10 +1,9 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsDamageAttachedTriggeredAbility; import mage.abilities.common.DealsDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -31,11 +30,10 @@ public final class SpiritLink extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature deals damage, you gain that much life. // Whenever enchanted creature deals damage, you gain that much life.
this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false));
} }
private SpiritLink(final SpiritLink card) { private SpiritLink(final SpiritLink card) {

View file

@ -1,11 +1,9 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageAttachedTriggeredAbility; import mage.abilities.common.DealsDamageAttachedTriggeredAbility;
import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect;
@ -32,15 +30,13 @@ public final class SpiritLoop extends CardImpl {
TargetPermanent auraTarget = new TargetControlledCreaturePermanent(); TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature deals damage, you gain that much life. // Whenever enchanted creature deals damage, you gain that much life.
this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false));
// When Spirit Loop is put into a graveyard from the battlefield, return Spirit Loop to its owner's hand. // When Spirit Loop is put into a graveyard from the battlefield, return Spirit Loop to its owner's hand.
this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect()));
} }
private SpiritLoop(final SpiritLoop card) { private SpiritLoop(final SpiritLoop card) {
@ -51,4 +47,4 @@ public final class SpiritLoop extends CardImpl {
public SpiritLoop copy() { public SpiritLoop copy() {
return new SpiritLoop(this); return new SpiritLoop(this);
} }
} }

View file

@ -1,23 +1,21 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -50,7 +48,7 @@ public final class Spiritualize extends CardImpl {
class SpiritualizeTriggeredAbility extends DelayedTriggeredAbility { class SpiritualizeTriggeredAbility extends DelayedTriggeredAbility {
public SpiritualizeTriggeredAbility() { public SpiritualizeTriggeredAbility() {
super(new SpiritualizeEffect(), Duration.EndOfTurn, false); super(new GainLifeEffect(SavedDamageValue.MUCH), Duration.EndOfTurn, false);
} }
public SpiritualizeTriggeredAbility(final SpiritualizeTriggeredAbility ability) { public SpiritualizeTriggeredAbility(final SpiritualizeTriggeredAbility ability) {
@ -85,33 +83,3 @@ class SpiritualizeTriggeredAbility extends DelayedTriggeredAbility {
return "Whenever target creature deals damage, " ; return "Whenever target creature deals damage, " ;
} }
} }
class SpiritualizeEffect extends OneShotEffect {
public SpiritualizeEffect() {
super(Outcome.GainLife);
this.staticText = "you gain that much life";
}
public SpiritualizeEffect(final SpiritualizeEffect effect) {
super(effect);
}
@Override
public SpiritualizeEffect copy() {
return new SpiritualizeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(amount, game, source);
return true;
}
}
return false;
}
}

View file

@ -4,15 +4,14 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.target.common.TargetPlayerOrPlaneswalker;
import mage.target.TargetPlayer;
import java.util.UUID; import java.util.UUID;
@ -29,13 +28,11 @@ public final class SpitefulSliver extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Sliver creatures you control have "Whenever this creature is dealt damage, it deals that much damage to target player or planeswalker." // Sliver creatures you control have "Whenever this creature is dealt damage, it deals that much damage to target player or planeswalker."
Ability ability = new DealtDamageToSourceTriggeredAbility( Ability ability = new DealtDamageToSourceTriggeredAbility(new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false);
new SpitefulSliverEffect(), ability.addTarget(new TargetPlayerOrPlaneswalker());
false, false
);
ability.addTarget(new TargetPlayer());
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
ability, Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_ALL_SLIVERS ability, Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_SLIVERS
).setText("Sliver creatures you control have \"Whenever this creature is dealt damage, " + ).setText("Sliver creatures you control have \"Whenever this creature is dealt damage, " +
"it deals that much damage to target player or planeswalker.\"") "it deals that much damage to target player or planeswalker.\"")
)); ));
@ -50,26 +47,3 @@ public final class SpitefulSliver extends CardImpl {
return new SpitefulSliver(this); return new SpitefulSliver(this);
} }
} }
class SpitefulSliverEffect extends OneShotEffect {
SpitefulSliverEffect() {
super(Outcome.Damage);
this.staticText = "it deals that much damage to target player or planeswalker";
}
private SpitefulSliverEffect(final SpitefulSliverEffect effect) {
super(effect);
}
@Override
public SpitefulSliverEffect copy() {
return new SpitefulSliverEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
return new DamageTargetEffect(amount).apply(game, source);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.t; package mage.cards.t;
import java.util.UUID; import java.util.UUID;
@ -6,7 +5,7 @@ import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -31,7 +30,7 @@ public final class Tamanoa extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever a noncreature source you control deals damage, you gain that much life. // Whenever a noncreature source you control deals damage, you gain that much life.
Ability ability = new TamanoaDealsDamageTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false); Ability ability = new TamanoaDealsDamageTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false);
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -1,11 +1,9 @@
package mage.cards.t; package mage.cards.t;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.PartnerAbility; import mage.abilities.keyword.PartnerAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
@ -13,11 +11,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.game.Game;
import mage.game.permanent.token.SaprolingToken; import mage.game.permanent.token.SaprolingToken;
import mage.players.Player;
/** /**
* *
@ -36,8 +31,10 @@ public final class TanaTheBloodsower extends CardImpl {
// Trample // Trample
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// Whenever Tana, the Bloodsower deals combat damage to a player, create that many 1/1 green Saproling creature tokens. // Whenever Tana, the Bloodsower deals combat damage to a player, create that many 1/1 green Saproling creature tokens.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new TanaTheBloodsowerEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new CreateTokenEffect(new SaprolingToken(), SavedDamageValue.MANY), false, true));
// Partner // Partner
this.addAbility(PartnerAbility.getInstance()); this.addAbility(PartnerAbility.getInstance());
@ -52,33 +49,3 @@ public final class TanaTheBloodsower extends CardImpl {
return new TanaTheBloodsower(this); return new TanaTheBloodsower(this);
} }
} }
class TanaTheBloodsowerEffect extends OneShotEffect {
public TanaTheBloodsowerEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "create that many 1/1 green Saproling creature tokens";
}
public TanaTheBloodsowerEffect(final TanaTheBloodsowerEffect effect) {
super(effect);
}
@Override
public TanaTheBloodsowerEffect copy() {
return new TanaTheBloodsowerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int amount = (Integer)getValue("damage");
if (amount > 0) {
return new CreateTokenEffect(new SaprolingToken(), amount).apply(game, source);
}
return true;
}
return false;
}
}

View file

@ -1,10 +1,9 @@
package mage.cards.v; package mage.cards.v;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsDamageAttachedTriggeredAbility; import mage.abilities.common.DealsDamageAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -30,12 +29,11 @@ public final class VampiricLink extends CardImpl {
// Enchant creature // Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Whenever enchanted creature deals damage, you gain that much life. // Whenever enchanted creature deals damage, you gain that much life.
this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(new NumericSetToEffectValues("that much", "damage")), false)); this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false));
} }
private VampiricLink(final VampiricLink card) { private VampiricLink(final VampiricLink card) {

View file

@ -1,17 +1,16 @@
package mage.cards.w; package mage.cards.w;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.DamagedEvent; import mage.game.events.DamagedEvent;
@ -33,7 +32,7 @@ public final class WallOfSouls extends CardImpl {
// Defender // Defender
this.addAbility(DefenderAbility.getInstance()); this.addAbility(DefenderAbility.getInstance());
// Whenever Wall of Souls is dealt combat damage, it deals that much damage to target opponent. // Whenever Wall of Souls is dealt combat damage, it deals that much damage to target opponent or planeswalker.
Ability ability = new WallOfSoulsTriggeredAbility(); Ability ability = new WallOfSoulsTriggeredAbility();
ability.addTarget(new TargetOpponentOrPlaneswalker()); ability.addTarget(new TargetOpponentOrPlaneswalker());
this.addAbility(ability); this.addAbility(ability);
@ -52,7 +51,7 @@ public final class WallOfSouls extends CardImpl {
class WallOfSoulsTriggeredAbility extends TriggeredAbilityImpl { class WallOfSoulsTriggeredAbility extends TriggeredAbilityImpl {
public WallOfSoulsTriggeredAbility() { public WallOfSoulsTriggeredAbility() {
super(Zone.BATTLEFIELD, new WallOfSoulsDealDamageEffect()); super(Zone.BATTLEFIELD, new DamageTargetEffect(SavedDamageValue.MUCH, "it"));
} }
public WallOfSoulsTriggeredAbility(final WallOfSoulsTriggeredAbility effect) { public WallOfSoulsTriggeredAbility(final WallOfSoulsTriggeredAbility effect) {
@ -72,7 +71,7 @@ class WallOfSoulsTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage()) { if (event.getTargetId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage()) {
this.getEffects().get(0).setValue("damage", event.getAmount()); this.getEffects().setValue("damage", event.getAmount());
return true; return true;
} }
return false; return false;
@ -83,29 +82,3 @@ class WallOfSoulsTriggeredAbility extends TriggeredAbilityImpl {
return "Whenever {this} is dealt combat damage, " ; return "Whenever {this} is dealt combat damage, " ;
} }
} }
class WallOfSoulsDealDamageEffect extends OneShotEffect {
public WallOfSoulsDealDamageEffect() {
super(Outcome.Damage);
this.staticText = "it deals that much damage to target opponent or planeswalker";
}
public WallOfSoulsDealDamageEffect(final WallOfSoulsDealDamageEffect effect) {
super(effect);
}
@Override
public WallOfSoulsDealDamageEffect copy() {
return new WallOfSoulsDealDamageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
return game.damagePlayerOrPlaneswalker(source.getFirstTarget(), amount, source.getSourceId(), source, game, false, true) > 0;
}
return false;
}
}

View file

@ -3,8 +3,9 @@ package mage.cards.w;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility; import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.DeathtouchAbility; import mage.abilities.keyword.DeathtouchAbility;
@ -13,7 +14,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.token.ZombieToken; import mage.game.permanent.token.ZombieToken;
import java.util.UUID; import java.util.UUID;
@ -44,12 +44,12 @@ public final class WandOfOrcus extends CardImpl {
// Whenever equipped creature deals combat damage to a player, create that many // Whenever equipped creature deals combat damage to a player, create that many
// 2/2 black Zombie creature tokens. // 2/2 black Zombie creature tokens.
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility( this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(
new WandOfOrcusZombieEffect(), "equipped creature", new CreateTokenEffect(new ZombieToken(), SavedDamageValue.MANY),
false, true "equipped creature",
)); false));
// Equip {3} // Equip {3}
this.addAbility(new EquipAbility(Outcome.AddAbility, new ManaCostsImpl<>("{3}"))); this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3)));
} }
private WandOfOrcus(final WandOfOrcus card) { private WandOfOrcus(final WandOfOrcus card) {
@ -61,29 +61,3 @@ public final class WandOfOrcus extends CardImpl {
return new WandOfOrcus(this); return new WandOfOrcus(this);
} }
} }
class WandOfOrcusZombieEffect extends OneShotEffect {
public WandOfOrcusZombieEffect() {
super(Outcome.Benefit);
this.staticText = "create that many 2/2 black Zombie creature tokens";
}
public WandOfOrcusZombieEffect(final WandOfOrcusZombieEffect effect) {
super(effect);
}
@Override
public WandOfOrcusZombieEffect copy() {
return new WandOfOrcusZombieEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Integer damage = (Integer) this.getValue("damage");
if (damage != null) {
return new ZombieToken().putOntoBattlefield(damage, game, source, source.getControllerId());
}
return false;
}
}

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.dynamicvalue; package org.mage.test.cards.dynamicvalue;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
@ -11,8 +10,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* @author LevelX2 * @author LevelX2
*/ */
public class NumericSetToEffectValueTest extends CardTestPlayerBase { public class SavedDamageValueTest extends CardTestPlayerBase {
/** /**
* Check that the dealt damage is added to life * Check that the dealt damage is added to life
@ -40,7 +38,5 @@ public class NumericSetToEffectValueTest extends CardTestPlayerBase {
assertLife(playerA, 24); assertLife(playerA, 24);
assertLife(playerB, 16); assertLife(playerB, 16);
} }
}
}

View file

@ -1,16 +1,12 @@
package mage.abilities.common; package mage.abilities.common;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.dynamicvalue.common.SavedDamageValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player;
/** /**
* *
@ -20,7 +16,7 @@ import mage.players.Player;
public class DealsDamageGainLifeSourceTriggeredAbility extends TriggeredAbilityImpl { public class DealsDamageGainLifeSourceTriggeredAbility extends TriggeredAbilityImpl {
public DealsDamageGainLifeSourceTriggeredAbility() { public DealsDamageGainLifeSourceTriggeredAbility() {
super(Zone.BATTLEFIELD, new GainThatMuchLifeEffect(), false); super(Zone.BATTLEFIELD, new GainLifeEffect(SavedDamageValue.MUCH), false);
} }
public DealsDamageGainLifeSourceTriggeredAbility(final DealsDamageGainLifeSourceTriggeredAbility ability) { public DealsDamageGainLifeSourceTriggeredAbility(final DealsDamageGainLifeSourceTriggeredAbility ability) {
@ -53,34 +49,3 @@ public class DealsDamageGainLifeSourceTriggeredAbility extends TriggeredAbilityI
return "Whenever {this} deals damage, " ; return "Whenever {this} deals damage, " ;
} }
} }
class GainThatMuchLifeEffect extends OneShotEffect {
public GainThatMuchLifeEffect() {
super(Outcome.GainLife);
this.staticText = "you gain that much life";
}
public GainThatMuchLifeEffect(final GainThatMuchLifeEffect effect) {
super(effect);
}
@Override
public GainThatMuchLifeEffect copy() {
return new GainThatMuchLifeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
controller.gainLife(amount, game, source);
}
return true;
}
return false;
}
}

View file

@ -1,45 +0,0 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author MTGfan
*/
public enum AttachedPermanentToughnessValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId());
}
if (enchantment == null) {
return 0;
}
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
return enchanted.getToughness().getValue();
}
@Override
public AttachedPermanentToughnessValue copy() {
return AttachedPermanentToughnessValue.instance;
}
@Override
public String toString() {
return "equal to";
}
@Override
public String getMessage() {
return "that creature's toughness";
}
}

View file

@ -15,7 +15,7 @@ public enum SavedDamageValue implements DynamicValue {
private final String message; private final String message;
SavedDamageValue(String message) { SavedDamageValue(String message) {
this.message = message; this.message = "that " + message;
} }
@Override @Override
@ -30,7 +30,7 @@ public enum SavedDamageValue implements DynamicValue {
@Override @Override
public String toString() { public String toString() {
return "that " + message; return message;
} }
@Override @Override

View file

@ -1,10 +1,13 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -15,20 +18,43 @@ import mage.players.Player;
*/ */
public class DamageAllControlledTargetEffect extends OneShotEffect { public class DamageAllControlledTargetEffect extends OneShotEffect {
private FilterPermanent filter; private final DynamicValue amount;
private int amount; private final FilterPermanent filter;
private String sourceName = "{this}";
public DamageAllControlledTargetEffect(int amount) {
this(amount, StaticFilters.FILTER_PERMANENT_CREATURE);
}
public DamageAllControlledTargetEffect(int amount, String whoDealDamageName) {
this(amount, StaticFilters.FILTER_PERMANENT_CREATURE);
this.sourceName = whoDealDamageName;
}
public DamageAllControlledTargetEffect(DynamicValue amount) {
this(amount, StaticFilters.FILTER_PERMANENT_CREATURE);
}
public DamageAllControlledTargetEffect(DynamicValue amount, String whoDealDamageName) {
this(amount, StaticFilters.FILTER_PERMANENT_CREATURE);
this.sourceName = whoDealDamageName;
}
public DamageAllControlledTargetEffect(int amount, FilterPermanent filter) { public DamageAllControlledTargetEffect(int amount, FilterPermanent filter) {
this(StaticValue.get(amount), filter);
}
public DamageAllControlledTargetEffect(DynamicValue amount, FilterPermanent filter) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.filter = filter; this.filter = filter;
getText();
} }
public DamageAllControlledTargetEffect(final DamageAllControlledTargetEffect effect) { public DamageAllControlledTargetEffect(final DamageAllControlledTargetEffect effect) {
super(effect); super(effect);
this.amount = effect.amount; this.amount = effect.amount.copy();
this.filter = effect.filter.copy(); this.filter = effect.filter.copy();
this.sourceName = effect.sourceName;
} }
@Override @Override
@ -38,19 +64,29 @@ public class DamageAllControlledTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget()); Player player = game.getPlayerOrPlaneswalkerController(targetPointer.getFirst(game, source));
if (player == null) { if (player == null) {
return false; return false;
} }
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
permanent.damage(amount, source.getSourceId(), source, game, false, true); permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
} }
return true; return true;
} }
private void getText() { @Override
StringBuilder sb = new StringBuilder("{this} deals "); public String getText(Mode mode) {
sb.append(amount).append(" damage to each ").append(filter.getMessage()).append(" controlled by target player"); if (staticText != null && !staticText.isEmpty()) {
staticText = sb.toString(); return staticText;
}
StringBuilder sb = new StringBuilder(sourceName);
sb.append(" deals ").append(amount).append(" damage to each ").append(filter.getMessage());
if (mode.getTargets().isEmpty()) {
sb.append(" that player");
} else {
sb.append(" target ").append(mode.getTargets().get(0).getTargetName());
}
sb.append(" controls");
return sb.toString();
} }
} }

View file

@ -19,13 +19,13 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
protected DynamicValue amount; protected DynamicValue amount;
public DamageAttachedControllerEffect(int amount) { public DamageAttachedControllerEffect(int amount) {
super(Outcome.Damage); this(StaticValue.get(amount));
this.amount = StaticValue.get(amount);
} }
public DamageAttachedControllerEffect(DynamicValue amount) { public DamageAttachedControllerEffect(DynamicValue amount) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.staticText = "{this} deals " + amount + " damage to that creature's controller";
} }
public DamageAttachedControllerEffect(final DamageAttachedControllerEffect effect) { public DamageAttachedControllerEffect(final DamageAttachedControllerEffect effect) {
@ -60,15 +60,4 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
} }
return false; return false;
} }
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
if ("equal to".equals(amount.toString())) {
return "{this} deals damage " + amount + " that creatures toughness to that creature's controller";
}
return "{this} deals " + amount + " damage to that creature's controller";
}
} }

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -19,27 +17,28 @@ import mage.game.permanent.Permanent;
public class DamageAttachedEffect extends OneShotEffect { public class DamageAttachedEffect extends OneShotEffect {
protected DynamicValue amount; protected DynamicValue amount;
private String sourceName = "{this}";
public DamageAttachedEffect(int amount) { public DamageAttachedEffect(int amount) {
super(Outcome.Damage); this(StaticValue.get(amount), "{this}");
this.amount = StaticValue.get(amount);
} }
public DamageAttachedEffect(int amount, String whoDealDamageName) { public DamageAttachedEffect(int amount, String whoDealDamageName) {
this(amount); this(StaticValue.get(amount), whoDealDamageName);
this.sourceName = whoDealDamageName;
} }
public DamageAttachedEffect(DynamicValue amount) { public DamageAttachedEffect(DynamicValue amount) {
this(amount, "{this}");
}
public DamageAttachedEffect(DynamicValue amount, String whoDealDamageName) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.staticText = whoDealDamageName + " deals " + amount + " damage to enchanted creature";
} }
public DamageAttachedEffect(final DamageAttachedEffect effect) { public DamageAttachedEffect(final DamageAttachedEffect effect) {
super(effect); super(effect);
this.amount = effect.amount; this.amount = effect.amount;
this.sourceName = effect.sourceName;
} }
@Override @Override
@ -65,23 +64,4 @@ public class DamageAttachedEffect extends OneShotEffect {
enchanted.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true); enchanted.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
return true; return true;
} }
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
if ("equal to".equals(amount.toString())) {
return this.sourceName + " deals damage " + amount + " that creatures toughness to enchanted creature";
}
return this.sourceName + " deals " + amount + " damage to enchanted creature";
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
} }

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -21,39 +19,35 @@ public class DamageControllerEffect extends OneShotEffect {
protected boolean preventable; protected boolean preventable;
private String sourceName = "{this}"; private String sourceName = "{this}";
public DamageControllerEffect(int amount, String whoDealDamageName) {
this(amount, true, whoDealDamageName);
}
public DamageControllerEffect(int amount) { public DamageControllerEffect(int amount) {
this(amount, true); this(amount, true);
} }
public DamageControllerEffect(int amount, boolean preventable, String whoDealDamageName) { public DamageControllerEffect(int amount, boolean preventable) {
super(Outcome.Damage); this(amount, preventable, "{this}");
this.amount = StaticValue.get(amount);
this.preventable = preventable;
this.sourceName = whoDealDamageName;
} }
public DamageControllerEffect(int amount, boolean preventable) { public DamageControllerEffect(int amount, String whoDealDamageName) {
super(Outcome.Damage); this(amount, true, whoDealDamageName);
this.amount = StaticValue.get(amount); }
this.preventable = preventable;
public DamageControllerEffect(int amount, boolean preventable, String whoDealDamageName) {
this(StaticValue.get(amount), preventable, whoDealDamageName);
} }
public DamageControllerEffect(DynamicValue amount) { public DamageControllerEffect(DynamicValue amount) {
this(amount, "{this}");
}
public DamageControllerEffect(DynamicValue amount, String whoDealDamageName) {
this(amount, true, whoDealDamageName);
}
public DamageControllerEffect(DynamicValue amount, boolean preventable, String whoDealDamageName) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.preventable = true; this.preventable = preventable;
} this.sourceName = whoDealDamageName;
public int getAmount() {
if (amount instanceof StaticValue) {
return amount.calculate(null, null, this);
} else {
return 0;
}
} }
public DamageControllerEffect(final DamageControllerEffect effect) { public DamageControllerEffect(final DamageControllerEffect effect) {
@ -77,7 +71,7 @@ public class DamageControllerEffect extends OneShotEffect {
} }
return false; return false;
} }
@Override @Override
public String getText(Mode mode) { public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) { if (staticText != null && !staticText.isEmpty()) {
@ -107,12 +101,4 @@ public class DamageControllerEffect extends OneShotEffect {
} }
return sb.toString(); return sb.toString();
} }
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
} }

View file

@ -60,13 +60,11 @@ public class GainLifeEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String message = life.getMessage(); String message = life.getMessage();
sb.append("you gain "); sb.append("you gain ");
if (message.startsWith("that")) { if (message.isEmpty() || !life.toString().equals("1")) {
sb.append(message).append(' ');
} else if (message.isEmpty() || !life.toString().equals("1")) {
sb.append(life).append(' '); sb.append(life).append(' ');
} }
sb.append("life"); sb.append("life");
if (!message.isEmpty() && !message.startsWith("that")) { if (!message.isEmpty()) {
sb.append(life.toString().equals("1") ? " equal to the number of " : " for each "); sb.append(life.toString().equals("1") ? " equal to the number of " : " for each ");
sb.append(message); sb.append(message);
} }

View file

@ -1,12 +1,13 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
@ -18,9 +19,13 @@ import mage.players.Player;
*/ */
public class LoseLifeTargetControllerEffect extends OneShotEffect { public class LoseLifeTargetControllerEffect extends OneShotEffect {
protected int amount; private final DynamicValue amount;
public LoseLifeTargetControllerEffect(int amount) { public LoseLifeTargetControllerEffect(int amount) {
this(StaticValue.get(amount));
}
public LoseLifeTargetControllerEffect(DynamicValue amount) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
staticText = "Its controller loses " + amount + " life"; staticText = "Its controller loses " + amount + " life";
@ -28,7 +33,7 @@ public class LoseLifeTargetControllerEffect extends OneShotEffect {
public LoseLifeTargetControllerEffect(final LoseLifeTargetControllerEffect effect) { public LoseLifeTargetControllerEffect(final LoseLifeTargetControllerEffect effect) {
super(effect); super(effect);
this.amount = effect.amount; this.amount = effect.amount.copy();
} }
@Override @Override
@ -38,16 +43,11 @@ public class LoseLifeTargetControllerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
MageObject targetCard = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); MageObject targetCard = targetPointer.getFirstTargetPermanentOrLKI(game, source);
// if target is a countered spell
if ( targetCard == null ) { if ( targetCard == null ) {
MageObject obj = game.getObject(targetPointer.getFirst(game, source)); targetCard = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK);
if ( obj instanceof Card ) {
targetCard = (Card)obj;
} else {
// if target is a countered spell
targetCard = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK);
}
} }
if ( targetCard != null ) { if ( targetCard != null ) {
@ -65,11 +65,10 @@ public class LoseLifeTargetControllerEffect extends OneShotEffect {
} }
if ( controller != null ) { if ( controller != null ) {
controller.loseLife(amount, game, source, false); controller.loseLife(amount.calculate(game, source, this), game, source, false);
return true; return true;
} }
} }
return false; return false;
} }
} }

View file

@ -55,18 +55,10 @@ public class DiscardControllerEffect extends OneShotEffect {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder("discard "); StringBuilder sb = new StringBuilder("discard ");
if (amount.toString().equals("1")) { if (amount.toString().equals("1") || amount.toString().equals("a")) {
sb.append('a'); sb.append("a card");
} else { } else {
sb.append(CardUtil.numberToText(amount.toString())); sb.append(CardUtil.numberToText(amount.toString())).append(" cards");
}
sb.append(" card");
try {
if (Integer.parseInt(amount.toString()) > 1) {
sb.append('s');
}
} catch (Exception e) {
sb.append('s');
} }
if (randomDiscard) { if (randomDiscard) {
sb.append(" at random"); sb.append(" at random");

View file

@ -875,6 +875,12 @@ public final class StaticFilters {
FILTER_ATTACKING_CREATURES.setLockedFilter(true); FILTER_ATTACKING_CREATURES.setLockedFilter(true);
} }
public static final FilterAttackingOrBlockingCreature FILTER_ATTACKING_OR_BLOCKING_CREATURE = new FilterAttackingOrBlockingCreature();
static {
FILTER_ATTACKING_OR_BLOCKING_CREATURE.setLockedFilter(true);
}
public static final FilterAttackingOrBlockingCreature FILTER_ATTACKING_OR_BLOCKING_CREATURES = new FilterAttackingOrBlockingCreature("attacking or blocking creatures"); public static final FilterAttackingOrBlockingCreature FILTER_ATTACKING_OR_BLOCKING_CREATURES = new FilterAttackingOrBlockingCreature("attacking or blocking creatures");
static { static {

View file

@ -1,7 +1,6 @@
package mage.target.common; package mage.target.common;
import mage.filter.StaticFilters;
import mage.filter.common.FilterAttackingOrBlockingCreature; import mage.filter.common.FilterAttackingOrBlockingCreature;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
@ -12,11 +11,11 @@ import mage.target.TargetPermanent;
public class TargetAttackingOrBlockingCreature extends TargetPermanent { public class TargetAttackingOrBlockingCreature extends TargetPermanent {
public TargetAttackingOrBlockingCreature() { public TargetAttackingOrBlockingCreature() {
this(1, 1, new FilterAttackingOrBlockingCreature(), false); this(1, 1, StaticFilters.FILTER_ATTACKING_OR_BLOCKING_CREATURE, false);
} }
public TargetAttackingOrBlockingCreature(int numTargets) { public TargetAttackingOrBlockingCreature(int numTargets) {
this(numTargets, numTargets, new FilterAttackingOrBlockingCreature(), false); this(numTargets, numTargets, StaticFilters.FILTER_ATTACKING_OR_BLOCKING_CREATURE, false);
} }
public TargetAttackingOrBlockingCreature(int minNumTargets, int maxNumTargets, FilterAttackingOrBlockingCreature filter, boolean notTarget) { public TargetAttackingOrBlockingCreature(int minNumTargets, int maxNumTargets, FilterAttackingOrBlockingCreature filter, boolean notTarget) {