[LTR] Implement Gandalf's Sanction

This commit is contained in:
theelk801 2023-06-14 22:01:10 -04:00
parent 4d10ec0cf2
commit f7baa2a338
3 changed files with 57 additions and 6 deletions

View file

@ -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);
}
}

View file

@ -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 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("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 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("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("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)); cards.add(new SetCardInfo("Gift of Strands", 170, Rarity.UNCOMMON, mage.cards.g.GiftOfStrands.class));

View file

@ -2,6 +2,8 @@ package mage.abilities.effects.common;
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.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
@ -13,13 +15,18 @@ import mage.players.Player;
*/ */
public class DamageWithExcessEffect extends OneShotEffect { public class DamageWithExcessEffect extends OneShotEffect {
private final int amount; private final DynamicValue amount;
public DamageWithExcessEffect(int amount) { public DamageWithExcessEffect(int amount) {
this(StaticValue.get(amount));
}
public DamageWithExcessEffect(DynamicValue amount) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.staticText = "{this} deals " + amount + " damage to target creature. " + this.staticText = "{this} deals " + amount + " damage to target creature" +
"Excess damage is dealt to that creature's controller instead"; (amount instanceof StaticValue ? "" : ", where X is " + amount.getMessage()) +
". Excess damage is dealt to that creature's controller instead";
} }
private DamageWithExcessEffect(final DamageWithExcessEffect effect) { private DamageWithExcessEffect(final DamageWithExcessEffect effect) {
@ -39,12 +46,13 @@ public class DamageWithExcessEffect extends OneShotEffect {
if (permanent == null || sourceObject == null) { if (permanent == null || sourceObject == null) {
return false; return false;
} }
int damage = amount.calculate(game, source, this);
int lethal = permanent.getLethalDamage(source.getSourceId(), game); int lethal = permanent.getLethalDamage(source.getSourceId(), game);
lethal = Math.min(lethal, amount); lethal = Math.min(lethal, damage);
permanent.damage(lethal, source.getSourceId(), source, game); permanent.damage(lethal, source.getSourceId(), source, game);
Player player = game.getPlayer(permanent.getControllerId()); Player player = game.getPlayer(permanent.getControllerId());
if (player != null && lethal < amount) { if (player != null && lethal < damage) {
player.damage(amount - lethal, source.getSourceId(), source, game); player.damage(damage - lethal, source.getSourceId(), source, game);
} }
return true; return true;
} }