diff --git a/Mage.Sets/src/mage/cards/g/GandalfsSanction.java b/Mage.Sets/src/mage/cards/g/GandalfsSanction.java new file mode 100644 index 00000000000..ccc49e6234f --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GandalfsSanction.java @@ -0,0 +1,42 @@ +package mage.cards.g; + +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.effects.common.DamageWithExcessEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.StaticFilters; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GandalfsSanction extends CardImpl { + + private static final DynamicValue xValue = new CardsInControllerGraveyardCount( + StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY, null + ); + private static final Hint hint = new ValueHint("Instants and sorceries in your graveyard", xValue); + + public GandalfsSanction(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}{R}"); + + // Gandalf's Sanction deals X damage to target creature, where X is the number of instant and sorcery spells in your graveyard. Excess damage is dealt to that creature's controller instead. + this.getSpellAbility().addEffect(new DamageWithExcessEffect(xValue)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + private GandalfsSanction(final GandalfsSanction card) { + super(card); + } + + @Override + public GandalfsSanction copy() { + return new GandalfsSanction(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index b6c568a501f..4cbc1b9aed2 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -87,6 +87,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Galadriel of Lothlorien", 206, Rarity.RARE, mage.cards.g.GaladrielOfLothlorien.class)); cards.add(new SetCardInfo("Galadriel, Gift-Giver", 296, Rarity.RARE, mage.cards.g.GaladrielGiftGiver.class)); cards.add(new SetCardInfo("Gandalf the Grey", 207, Rarity.RARE, mage.cards.g.GandalfTheGrey.class)); + cards.add(new SetCardInfo("Gandalf's Sanction", 208, Rarity.UNCOMMON, mage.cards.g.GandalfsSanction.class)); cards.add(new SetCardInfo("Gandalf, Friend of the Shire", 50, Rarity.UNCOMMON, mage.cards.g.GandalfFriendOfTheShire.class)); cards.add(new SetCardInfo("Generous Ent", 169, Rarity.COMMON, mage.cards.g.GenerousEnt.class)); cards.add(new SetCardInfo("Gift of Strands", 170, Rarity.UNCOMMON, mage.cards.g.GiftOfStrands.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageWithExcessEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageWithExcessEffect.java index fcd7cef2fcc..c91adb23b8d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageWithExcessEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageWithExcessEffect.java @@ -2,6 +2,8 @@ package mage.abilities.effects.common; import mage.MageObject; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; import mage.game.Game; @@ -13,13 +15,18 @@ import mage.players.Player; */ public class DamageWithExcessEffect extends OneShotEffect { - private final int amount; + private final DynamicValue amount; public DamageWithExcessEffect(int amount) { + this(StaticValue.get(amount)); + } + + public DamageWithExcessEffect(DynamicValue amount) { super(Outcome.Damage); this.amount = amount; - this.staticText = "{this} deals " + amount + " damage to target creature. " + - "Excess damage is dealt to that creature's controller instead"; + this.staticText = "{this} deals " + amount + " damage to target creature" + + (amount instanceof StaticValue ? "" : ", where X is " + amount.getMessage()) + + ". Excess damage is dealt to that creature's controller instead"; } private DamageWithExcessEffect(final DamageWithExcessEffect effect) { @@ -39,12 +46,13 @@ public class DamageWithExcessEffect extends OneShotEffect { if (permanent == null || sourceObject == null) { return false; } + int damage = amount.calculate(game, source, this); int lethal = permanent.getLethalDamage(source.getSourceId(), game); - lethal = Math.min(lethal, amount); + lethal = Math.min(lethal, damage); permanent.damage(lethal, source.getSourceId(), source, game); Player player = game.getPlayer(permanent.getControllerId()); - if (player != null && lethal < amount) { - player.damage(amount - lethal, source.getSourceId(), source, game); + if (player != null && lethal < damage) { + player.damage(damage - lethal, source.getSourceId(), source, game); } return true; }