From 6ca93d1936906a6c1eb3cb0ab2e0e4a33ecfd135 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Thu, 31 Mar 2022 08:56:12 -0400 Subject: [PATCH] [VOW] Fix Howlpack Avenger; replace various custom abilities with SavedDamageValue --- .../src/mage/cards/b/BodyOfKnowledge.java | 40 +++----------- Mage.Sets/src/mage/cards/b/BorosReckoner.java | 4 +- Mage.Sets/src/mage/cards/b/BrashTaunter.java | 47 +++------------- .../src/mage/cards/b/BroodhatchNantuko.java | 38 +------------ .../src/mage/cards/c/CoalhaulerSwine.java | 3 +- Mage.Sets/src/mage/cards/h/HornetNest.java | 38 +------------ .../src/mage/cards/h/HowlpackAvenger.java | 8 +-- .../src/mage/cards/i/IllTemperedLoner.java | 4 +- .../src/mage/cards/i/IllusoryAmbusher.java | 41 ++------------ .../mage/cards/l/LathrilBladeOfTheElves.java | 5 +- Mage.Sets/src/mage/cards/m/MoggManiac.java | 38 ++----------- Mage.Sets/src/mage/cards/s/SaberAnts.java | 37 +------------ .../src/mage/cards/t/TruefireCaptain.java | 33 +---------- .../cards/v/VarchildBetrayerOfKjeldor.java | 55 ++----------------- .../dynamicvalue/common/SavedDamageValue.java | 16 +++++- 15 files changed, 66 insertions(+), 341 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BodyOfKnowledge.java b/Mage.Sets/src/mage/cards/b/BodyOfKnowledge.java index b28e836ac1..1f82d8433a 100644 --- a/Mage.Sets/src/mage/cards/b/BodyOfKnowledge.java +++ b/Mage.Sets/src/mage/cards/b/BodyOfKnowledge.java @@ -1,18 +1,19 @@ package mage.cards.b; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.common.CardsInControllerHandCount; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect; import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.game.Game; -import mage.players.Player; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.Zone; import java.util.UUID; @@ -44,8 +45,7 @@ public final class BodyOfKnowledge extends CardImpl { // Whenever Body of Knowledge is dealt damage, draw that many cards. this.addAbility(new DealtDamageToSourceTriggeredAbility( - new BodyOfKnowledgeEffect(), false, false - )); + new DrawCardSourceControllerEffect(SavedDamageValue.MANY), false)); } private BodyOfKnowledge(final BodyOfKnowledge card) { @@ -57,29 +57,3 @@ public final class BodyOfKnowledge extends CardImpl { return new BodyOfKnowledge(this); } } - -class BodyOfKnowledgeEffect extends OneShotEffect { - - BodyOfKnowledgeEffect() { - super(Outcome.Benefit); - staticText = "draw that many cards"; - } - - private BodyOfKnowledgeEffect(final BodyOfKnowledgeEffect effect) { - super(effect); - } - - @Override - public BodyOfKnowledgeEffect copy() { - return new BodyOfKnowledgeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = (Integer) getValue("damage"); - Player player = game.getPlayer(source.getControllerId()); - return player != null - && amount > 0 - && player.drawCards(amount, source, game) > 0; - } -} diff --git a/Mage.Sets/src/mage/cards/b/BorosReckoner.java b/Mage.Sets/src/mage/cards/b/BorosReckoner.java index bc3a19a925..1d20671065 100644 --- a/Mage.Sets/src/mage/cards/b/BorosReckoner.java +++ b/Mage.Sets/src/mage/cards/b/BorosReckoner.java @@ -31,8 +31,8 @@ public final class BorosReckoner extends CardImpl { this.toughness = new MageInt(3); // Whenever Boros Reckoner is dealt damage, it deals that much damage to any target. - Ability ability = new DealtDamageToSourceTriggeredAbility(new DamageTargetEffect(SavedDamageValue.instance) - .setText("it deals that much damage to any target"), false, false); + Ability ability = new DealtDamageToSourceTriggeredAbility( + new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false); ability.addTarget(new TargetAnyTarget()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/b/BrashTaunter.java b/Mage.Sets/src/mage/cards/b/BrashTaunter.java index ca83be0f18..56703a2d80 100644 --- a/Mage.Sets/src/mage/cards/b/BrashTaunter.java +++ b/Mage.Sets/src/mage/cards/b/BrashTaunter.java @@ -6,20 +6,17 @@ import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.FightTargetSourceEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AnotherPredicate; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetOpponent; @@ -48,15 +45,15 @@ public final class BrashTaunter extends CardImpl { this.addAbility(IndestructibleAbility.getInstance()); // Whenever Brash Taunter is dealt damage, it deals that much damage to target opponent. - Ability ability = new DealtDamageToSourceTriggeredAbility(new BrashTaunterEffect(), false, false); + Ability ability = new DealtDamageToSourceTriggeredAbility(new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false); ability.addTarget(new TargetOpponent()); this.addAbility(ability); // {2}{R}, {T}: Brash Taunter fights another target creature. - Ability ability1 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new FightTargetSourceEffect(), new ManaCostsImpl("{2}{R}")); - ability1.addCost(new TapSourceCost()); - ability1.addTarget(new TargetPermanent(filter)); - this.addAbility(ability1); + ability = new SimpleActivatedAbility(new FightTargetSourceEffect(), new ManaCostsImpl("{2}{R}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); } private BrashTaunter(final BrashTaunter card) { @@ -68,33 +65,3 @@ public final class BrashTaunter extends CardImpl { return new BrashTaunter(this); } } - -class BrashTaunterEffect extends OneShotEffect { - - public BrashTaunterEffect() { - super(Outcome.Damage); - this.staticText = "it deals that much damage to target opponent"; - } - - public BrashTaunterEffect(final BrashTaunterEffect effect) { - super(effect); - } - - @Override - public BrashTaunterEffect copy() { - return new BrashTaunterEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = (Integer) getValue("damage"); - if (amount > 0) { - Player player = game.getPlayer(targetPointer.getFirst(game, source)); - if (player != null) { - player.damage(amount, source.getSourceId(), source, game); - return true; - } - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/b/BroodhatchNantuko.java b/Mage.Sets/src/mage/cards/b/BroodhatchNantuko.java index 3bd8e8e4a4..4bf877e161 100644 --- a/Mage.Sets/src/mage/cards/b/BroodhatchNantuko.java +++ b/Mage.Sets/src/mage/cards/b/BroodhatchNantuko.java @@ -1,22 +1,17 @@ - package mage.cards.b; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.MorphAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.game.Game; import mage.game.permanent.token.InsectToken; -import mage.players.Player; /** * @@ -31,7 +26,8 @@ public final class BroodhatchNantuko extends CardImpl { this.toughness = new MageInt(1); // Whenever Broodhatch Nantuko is dealt damage, you may create that many 1/1 green Insect creature tokens. - this.addAbility(new DealtDamageToSourceTriggeredAbility(new BroodhatchNantukoDealDamageEffect(), true, false)); + this.addAbility(new DealtDamageToSourceTriggeredAbility( + new CreateTokenEffect(new InsectToken(), SavedDamageValue.MANY), true)); // Morph {2}{G} this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{2}{G}"))); @@ -46,31 +42,3 @@ public final class BroodhatchNantuko extends CardImpl { return new BroodhatchNantuko(this); } } - -class BroodhatchNantukoDealDamageEffect extends OneShotEffect { - - public BroodhatchNantukoDealDamageEffect() { - super(Outcome.Damage); - this.staticText = "create that many 1/1 green Insect creature tokens"; - } - - public BroodhatchNantukoDealDamageEffect(final BroodhatchNantukoDealDamageEffect effect) { - super(effect); - } - - @Override - public BroodhatchNantukoDealDamageEffect copy() { - return new BroodhatchNantukoDealDamageEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { return false; } - - int amount = (Integer) getValue("damage"); - if (amount <= 0) { return false; } - - return new CreateTokenEffect(new InsectToken(), amount).apply(game, source); - } -} diff --git a/Mage.Sets/src/mage/cards/c/CoalhaulerSwine.java b/Mage.Sets/src/mage/cards/c/CoalhaulerSwine.java index 87acbeb4bf..fb9fbb57ff 100644 --- a/Mage.Sets/src/mage/cards/c/CoalhaulerSwine.java +++ b/Mage.Sets/src/mage/cards/c/CoalhaulerSwine.java @@ -28,8 +28,7 @@ public final class CoalhaulerSwine extends CardImpl { // Whenever Coalhauler Swine is dealt damage, it deals that much damage to each player. this.addAbility(new DealtDamageToSourceTriggeredAbility(new DamagePlayersEffect( - Outcome.Neutral, SavedDamageValue.instance, TargetController.ANY, "it" - ), false, false)); + Outcome.Damage, SavedDamageValue.MUCH, TargetController.ANY, "it"), false)); } private CoalhaulerSwine(final CoalhaulerSwine card) { diff --git a/Mage.Sets/src/mage/cards/h/HornetNest.java b/Mage.Sets/src/mage/cards/h/HornetNest.java index 83b448036e..87c4f6a269 100644 --- a/Mage.Sets/src/mage/cards/h/HornetNest.java +++ b/Mage.Sets/src/mage/cards/h/HornetNest.java @@ -1,19 +1,15 @@ package mage.cards.h; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.DefenderAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.game.Game; import mage.game.permanent.token.InsectDeathToken; -import mage.players.Player; import java.util.UUID; @@ -33,7 +29,8 @@ public final class HornetNest extends CardImpl { this.addAbility(DefenderAbility.getInstance()); // Whenever Hornet Nest is dealt damage, create that many 1/1 green Insect creature tokens with flying and deathtouch. - this.addAbility(new DealtDamageToSourceTriggeredAbility(new HornetNestDealDamageEffect(), false, false)); + this.addAbility(new DealtDamageToSourceTriggeredAbility( + new CreateTokenEffect(new InsectDeathToken(), SavedDamageValue.MANY), false)); } private HornetNest(final HornetNest card) { @@ -45,32 +42,3 @@ public final class HornetNest extends CardImpl { return new HornetNest(this); } } - -class HornetNestDealDamageEffect extends OneShotEffect { - - public HornetNestDealDamageEffect() { - super(Outcome.Damage); - this.staticText = "create that many 1/1 green Insect creature tokens with flying and deathtouch"; - } - - public HornetNestDealDamageEffect(final HornetNestDealDamageEffect effect) { - super(effect); - } - - @Override - public HornetNestDealDamageEffect copy() { - return new HornetNestDealDamageEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - int amount = (Integer) getValue("damage"); - if (amount > 0) { - return new CreateTokenEffect(new InsectDeathToken(), amount).apply(game, source); - } - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/h/HowlpackAvenger.java b/Mage.Sets/src/mage/cards/h/HowlpackAvenger.java index 047490e4b7..77d011f058 100644 --- a/Mage.Sets/src/mage/cards/h/HowlpackAvenger.java +++ b/Mage.Sets/src/mage/cards/h/HowlpackAvenger.java @@ -60,7 +60,7 @@ public final class HowlpackAvenger extends CardImpl { class HowlpackAvengerTriggeredAbility extends TriggeredAbilityImpl { HowlpackAvengerTriggeredAbility() { - super(Zone.BATTLEFIELD, new DamageTargetEffect(SavedDamageValue.instance)); + super(Zone.BATTLEFIELD, new DamageTargetEffect(SavedDamageValue.MUCH)); this.addTarget(new TargetAnyTarget()); } @@ -91,11 +91,11 @@ class HowlpackAvengerTriggeredAbility extends TriggeredAbilityImpl { return false; } this.getEffects().setValue("damage", damage); - return false; + return true; } @Override - public String getRule() { - return "Whenever a permanent you control is dealt damage, {this} deals that much damage to any target."; + public String getTriggerPhrase() { + return "Whenever a permanent you control is dealt damage, "; } } diff --git a/Mage.Sets/src/mage/cards/i/IllTemperedLoner.java b/Mage.Sets/src/mage/cards/i/IllTemperedLoner.java index 0381d93903..08b861d29d 100644 --- a/Mage.Sets/src/mage/cards/i/IllTemperedLoner.java +++ b/Mage.Sets/src/mage/cards/i/IllTemperedLoner.java @@ -33,8 +33,8 @@ public final class IllTemperedLoner extends CardImpl { this.secondSideCardClazz = mage.cards.h.HowlpackAvenger.class; // Whenever Ill-Tempered Loner is dealt damage, it deals that much damage to any target. - Ability ability = new DealtDamageToSourceTriggeredAbility(new DamageTargetEffect(SavedDamageValue.instance) - .setText("it deals that much damage to any target"), false, false); + Ability ability = new DealtDamageToSourceTriggeredAbility( + new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false); ability.addTarget(new TargetAnyTarget()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/i/IllusoryAmbusher.java b/Mage.Sets/src/mage/cards/i/IllusoryAmbusher.java index b6142aaab4..6dfabd1fbd 100644 --- a/Mage.Sets/src/mage/cards/i/IllusoryAmbusher.java +++ b/Mage.Sets/src/mage/cards/i/IllusoryAmbusher.java @@ -1,19 +1,15 @@ - package mage.cards.i; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.keyword.FlashAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; -import mage.game.Game; -import mage.players.Player; /** * @@ -32,7 +28,8 @@ public final class IllusoryAmbusher extends CardImpl { this.addAbility(FlashAbility.getInstance()); // Whenever Illusory Ambusher is dealt damage, draw that many cards. - this.addAbility(new DealtDamageToSourceTriggeredAbility(new IllusoryAmbusherDealtDamageEffect(), false, false)); + this.addAbility(new DealtDamageToSourceTriggeredAbility( + new DrawCardSourceControllerEffect(SavedDamageValue.MANY), false)); } private IllusoryAmbusher(final IllusoryAmbusher card) { @@ -44,33 +41,3 @@ public final class IllusoryAmbusher extends CardImpl { return new IllusoryAmbusher(this); } } - -class IllusoryAmbusherDealtDamageEffect extends OneShotEffect { - - public IllusoryAmbusherDealtDamageEffect() { - super(Outcome.Damage); - this.staticText = "draw that many cards"; - } - - public IllusoryAmbusherDealtDamageEffect(final IllusoryAmbusherDealtDamageEffect effect) { - super(effect); - } - - @Override - public IllusoryAmbusherDealtDamageEffect copy() { - return new IllusoryAmbusherDealtDamageEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - int amount = (Integer) getValue("damage"); - if (amount > 0) { - player.drawCards(amount, source, game); - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/l/LathrilBladeOfTheElves.java b/Mage.Sets/src/mage/cards/l/LathrilBladeOfTheElves.java index c51eca941a..2872d2bdbf 100644 --- a/Mage.Sets/src/mage/cards/l/LathrilBladeOfTheElves.java +++ b/Mage.Sets/src/mage/cards/l/LathrilBladeOfTheElves.java @@ -48,9 +48,8 @@ public final class LathrilBladeOfTheElves extends CardImpl { this.addAbility(new MenaceAbility(false)); // Whenever Lathril, Blade of the Elves deals combat damage to a player, create that many 1/1 green Elf Warrior creature tokens. - this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new CreateTokenEffect( - new ElfWarriorToken(), SavedDamageValue.instance - ).setText("create that many 1/1 green Elf Warrior creature tokens"), false, true)); + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( + new CreateTokenEffect(new ElfWarriorToken(), SavedDamageValue.MANY), false, true)); // {T}, Tap ten untapped Elves you control: Each opponent loses 10 life and you gain 10 life. Ability ability = new SimpleActivatedAbility(new LoseLifeOpponentsEffect(10), new TapSourceCost()); diff --git a/Mage.Sets/src/mage/cards/m/MoggManiac.java b/Mage.Sets/src/mage/cards/m/MoggManiac.java index a94a09fa62..6c9261b277 100644 --- a/Mage.Sets/src/mage/cards/m/MoggManiac.java +++ b/Mage.Sets/src/mage/cards/m/MoggManiac.java @@ -1,17 +1,15 @@ - package mage.cards.m; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; -import mage.game.Game; import mage.target.common.TargetOpponentOrPlaneswalker; /** @@ -26,8 +24,9 @@ public final class MoggManiac extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - // Whenever Mogg Maniac is dealt damage, it deals that much damage to target opponent. - Ability ability = new DealtDamageToSourceTriggeredAbility(new MoggManiacDealDamageEffect(), false, false); + // Whenever Mogg Maniac is dealt damage, it deals that much damage to target opponent or planeswalker. + Ability ability = new DealtDamageToSourceTriggeredAbility( + new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false); ability.addTarget(new TargetOpponentOrPlaneswalker()); this.addAbility(ability); } @@ -41,30 +40,3 @@ public final class MoggManiac extends CardImpl { return new MoggManiac(this); } } - -class MoggManiacDealDamageEffect extends OneShotEffect { - - public MoggManiacDealDamageEffect() { - super(Outcome.Damage); - this.staticText = "it deals that much damage to target opponent or planeswalker"; - } - - public MoggManiacDealDamageEffect(final MoggManiacDealDamageEffect effect) { - super(effect); - } - - @Override - public MoggManiacDealDamageEffect copy() { - return new MoggManiacDealDamageEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = (Integer) getValue("damage"); - if (amount > 0) { - game.damagePlayerOrPlaneswalker(targetPointer.getFirst(game, source), amount, source.getSourceId(), source, game, false, true); - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/s/SaberAnts.java b/Mage.Sets/src/mage/cards/s/SaberAnts.java index aa3cfcca21..df191a05cb 100644 --- a/Mage.Sets/src/mage/cards/s/SaberAnts.java +++ b/Mage.Sets/src/mage/cards/s/SaberAnts.java @@ -1,20 +1,15 @@ - package mage.cards.s; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; import mage.abilities.effects.common.CreateTokenEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; -import mage.game.Game; import mage.game.permanent.token.InsectToken; -import mage.players.Player; /** * @@ -30,7 +25,8 @@ public final class SaberAnts extends CardImpl { this.toughness = new MageInt(3); // Whenever Saber Ants is dealt damage, you may create that many 1/1 green Insect creature tokens. - this.addAbility(new DealtDamageToSourceTriggeredAbility(new SaberAntsEffect(), true, false)); + this.addAbility(new DealtDamageToSourceTriggeredAbility( + new CreateTokenEffect(new InsectToken(), SavedDamageValue.MANY), true)); } private SaberAnts(final SaberAnts card) { @@ -42,30 +38,3 @@ public final class SaberAnts extends CardImpl { return new SaberAnts(this); } } - -class SaberAntsEffect extends OneShotEffect { - - public SaberAntsEffect() { - super(Outcome.Benefit); - this.staticText = "you may create that many 1/1 green Insect creature tokens"; - } - - public SaberAntsEffect(final SaberAntsEffect effect) { - super(effect); - } - - @Override - public SaberAntsEffect copy() { - return new SaberAntsEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int damage = (Integer) this.getValue("damage"); - return new CreateTokenEffect(new InsectToken(), damage).apply(game, source); - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/t/TruefireCaptain.java b/Mage.Sets/src/mage/cards/t/TruefireCaptain.java index bc426562b0..882011676d 100644 --- a/Mage.Sets/src/mage/cards/t/TruefireCaptain.java +++ b/Mage.Sets/src/mage/cards/t/TruefireCaptain.java @@ -4,15 +4,13 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; import mage.abilities.effects.common.DamageTargetEffect; -import mage.constants.SubType; import mage.abilities.keyword.MentorAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.game.Game; +import mage.constants.SubType; import mage.target.TargetPlayer; /** @@ -34,9 +32,7 @@ public final class TruefireCaptain extends CardImpl { // Whenever Truefire Captain is dealt damage, it deals that much damage to target player. Ability ability = new DealtDamageToSourceTriggeredAbility( - new TruefireCaptainEffect(), - false, false - ); + new DamageTargetEffect(SavedDamageValue.MUCH, "it"), false); ability.addTarget(new TargetPlayer()); this.addAbility(ability); } @@ -50,26 +46,3 @@ public final class TruefireCaptain extends CardImpl { return new TruefireCaptain(this); } } - -class TruefireCaptainEffect extends OneShotEffect { - - public TruefireCaptainEffect() { - super(Outcome.Damage); - this.staticText = "it deals that much damage to target player"; - } - - public TruefireCaptainEffect(final TruefireCaptainEffect effect) { - super(effect); - } - - @Override - public TruefireCaptainEffect copy() { - return new TruefireCaptainEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = (Integer) getValue("damage"); - return new DamageTargetEffect(amount).apply(game, source); - } -} diff --git a/Mage.Sets/src/mage/cards/v/VarchildBetrayerOfKjeldor.java b/Mage.Sets/src/mage/cards/v/VarchildBetrayerOfKjeldor.java index c0ade46159..4a9919d829 100644 --- a/Mage.Sets/src/mage/cards/v/VarchildBetrayerOfKjeldor.java +++ b/Mage.Sets/src/mage/cards/v/VarchildBetrayerOfKjeldor.java @@ -6,8 +6,7 @@ import mage.abilities.Ability; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.SavedDamageValue; import mage.abilities.effects.common.CreateTokenTargetEffect; import mage.abilities.effects.common.combat.CantAttackYouOrPlaneswalkerAllEffect; import mage.abilities.effects.common.combat.CantBlockAllEffect; @@ -16,13 +15,10 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.SuperType; import mage.constants.TargetController; -import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; import mage.game.permanent.token.SurvivorToken; /** @@ -31,11 +27,8 @@ import mage.game.permanent.token.SurvivorToken; */ public final class VarchildBetrayerOfKjeldor extends CardImpl { - private static final FilterCreaturePermanent filter1 - = new FilterCreaturePermanent( - SubType.SURVIVOR, - "Survivors your opponents control" - ); + private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent(SubType.SURVIVOR, "Survivors your opponents control"); + private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent(SubType.SURVIVOR, "all Survivors"); static { filter1.add(TargetController.OPPONENT.getControllerPredicate()); @@ -52,16 +45,10 @@ public final class VarchildBetrayerOfKjeldor extends CardImpl { // Whenever Varchild, Betrayer of Kjeldor deals combat damage to a player, that player creates that many 1/1 red Survivor creature tokens. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( - new VarchildBetrayerOfKjeldorEffect(), false, true - )); + new CreateTokenTargetEffect(new SurvivorToken(), SavedDamageValue.MANY), false, true)); // Survivors your opponents control can't block, and they can't attack you or a planeswalker you control. - Ability ability = new SimpleStaticAbility( - Zone.BATTLEFIELD, - new CantBlockAllEffect( - filter1, Duration.WhileOnBattlefield - ) - ); + Ability ability = new SimpleStaticAbility(new CantBlockAllEffect(filter1, Duration.WhileOnBattlefield)); ability.addEffect(new CantAttackYouOrPlaneswalkerAllEffect( Duration.WhileOnBattlefield, filter1 ).setText("and can't attack you or planeswalkers you control")); @@ -69,8 +56,7 @@ public final class VarchildBetrayerOfKjeldor extends CardImpl { // When Varchild leaves the battlefield, gain control of all Survivors. this.addAbility(new LeavesBattlefieldTriggeredAbility( - new GainControlAllEffect(Duration.Custom, new FilterCreaturePermanent(SubType.SURVIVOR, "all Survivors")), false - )); + new GainControlAllEffect(Duration.Custom, filter2), false)); } private VarchildBetrayerOfKjeldor(final VarchildBetrayerOfKjeldor card) { @@ -82,32 +68,3 @@ public final class VarchildBetrayerOfKjeldor extends CardImpl { return new VarchildBetrayerOfKjeldor(this); } } - -class VarchildBetrayerOfKjeldorEffect extends OneShotEffect { - - public VarchildBetrayerOfKjeldorEffect() { - super(Outcome.Benefit); - this.staticText = "that player creates " - + "that many 1/1 red Survivor creature tokens"; - } - - public VarchildBetrayerOfKjeldorEffect(final VarchildBetrayerOfKjeldorEffect effect) { - super(effect); - } - - @Override - public VarchildBetrayerOfKjeldorEffect copy() { - return new VarchildBetrayerOfKjeldorEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int damage = (int) this.getValue("damage"); - if (damage > 0) { - Effect effect = new CreateTokenTargetEffect(new SurvivorToken(), damage); - effect.setTargetPointer(getTargetPointer()); - return effect.apply(game, source); - } - return false; - } -} diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SavedDamageValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SavedDamageValue.java index 8c8428fb2c..cf8f379dfb 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SavedDamageValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SavedDamageValue.java @@ -9,7 +9,14 @@ import mage.game.Game; * @author TheElk801 */ public enum SavedDamageValue implements DynamicValue { - instance; + MANY("many"), + MUCH("much"); + + private final String message; + + SavedDamageValue(String message) { + this.message = message; + } @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -21,8 +28,13 @@ public enum SavedDamageValue implements DynamicValue { return this; } + @Override + public String toString() { + return "that " + message; + } + @Override public String getMessage() { - return "that much"; + return ""; } }