From 9c1bd767b347271f9350b80c72831d8ecbb7ff52 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 11 Apr 2020 22:10:01 -0400 Subject: [PATCH] Implemented Solid Footing --- Mage.Sets/src/mage/cards/s/SolidFooting.java | 103 ++++++++++++++++++ .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + 2 files changed, 104 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SolidFooting.java diff --git a/Mage.Sets/src/mage/cards/s/SolidFooting.java b/Mage.Sets/src/mage/cards/s/SolidFooting.java new file mode 100644 index 0000000000..348bd4ae26 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SolidFooting.java @@ -0,0 +1,103 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlashAbility; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.PermanentIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SolidFooting extends CardImpl { + + public SolidFooting(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + + this.subtype.add(SubType.AURA); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted creature gets +1/+1. + this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect(1, 1))); + + // As long as enchanted creature has vigilance, it assigns combat damage equal to its toughness rather than its power. + this.addAbility(new SimpleStaticAbility(new GauntletsOfLightEffect())); + } + + private SolidFooting(final SolidFooting card) { + super(card); + } + + @Override + public SolidFooting copy() { + return new SolidFooting(this); + } +} + +class GauntletsOfLightEffect extends ContinuousEffectImpl { + + GauntletsOfLightEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "As long as enchanted creature has vigilance, " + + "it assigns combat damage equal to its toughness rather than its power"; + } + + private GauntletsOfLightEffect(final GauntletsOfLightEffect effect) { + super(effect); + } + + @Override + public GauntletsOfLightEffect copy() { + return new GauntletsOfLightEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null || permanent.getAttachedTo() == null) { + return false; + } + Permanent attachedTo = game.getPermanent(permanent.getAttachedTo()); + if (attachedTo == null || !attachedTo.getAbilities().containsKey(VigilanceAbility.getInstance().getId())) { + return false; + } + FilterCreaturePermanent filter = new FilterCreaturePermanent(); + filter.add(new PermanentIdPredicate(permanent.getAttachedTo())); + game.getCombat().setUseToughnessForDamage(true); + game.getCombat().addUseToughnessForDamageFilter(filter); + return true; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.RulesEffects; + } +} diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index b788ee610e..0312a46bdc 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -257,6 +257,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Slitherwisp", 208, Rarity.RARE, mage.cards.s.Slitherwisp.class)); cards.add(new SetCardInfo("Snapdax, Apex of the Hunt", 209, Rarity.MYTHIC, mage.cards.s.SnapdaxApexOfTheHunt.class)); cards.add(new SetCardInfo("Snare Tactician", 30, Rarity.COMMON, mage.cards.s.SnareTactician.class)); + cards.add(new SetCardInfo("Solid Footing", 31, Rarity.COMMON, mage.cards.s.SolidFooting.class)); cards.add(new SetCardInfo("Song of Creation", 210, Rarity.RARE, mage.cards.s.SongOfCreation.class)); cards.add(new SetCardInfo("Sonorous Howlbonder", 230, Rarity.UNCOMMON, mage.cards.s.SonorousHowlbonder.class)); cards.add(new SetCardInfo("Spelleater Wolverine", 137, Rarity.COMMON, mage.cards.s.SpelleaterWolverine.class));