From bc13b02b8ea54116f2b6c565c7bd1b98e874cbf3 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Sat, 10 Sep 2022 16:38:40 -0400 Subject: [PATCH] [TOR] Implemented Floating Shield --- .../src/mage/cards/f/FloatingShield.java | 90 +++++++++++++++++++ Mage.Sets/src/mage/sets/Torment.java | 1 + 2 files changed, 91 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FloatingShield.java diff --git a/Mage.Sets/src/mage/cards/f/FloatingShield.java b/Mage.Sets/src/mage/cards/f/FloatingShield.java new file mode 100644 index 0000000000..69a4571c5d --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FloatingShield.java @@ -0,0 +1,90 @@ +package mage.cards.f; + +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.ChooseColorEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.keyword.ProtectionChosenColorAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.ProtectionAbility; +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.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * + * @author awjackson + */ +public final class FloatingShield extends CardImpl { + + public FloatingShield(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect)); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); + + // As Floating Shield enters the battlefield, choose a color. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Protect))); + + // Enchanted creature has protection from the chosen color. This effect doesn't remove Floating Shield. + this.addAbility(new SimpleStaticAbility(new ProtectionChosenColorAttachedEffect(true))); + + // Sacrifice Floating Shield: Target creature gains protection from the chosen color until end of turn. + Ability ability = new SimpleActivatedAbility(new FloatingShieldEffect(), new SacrificeSourceCost()); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + private FloatingShield(final FloatingShield card) { + super(card); + } + + @Override + public FloatingShield copy() { + return new FloatingShield(this); + } +} + +class FloatingShieldEffect extends OneShotEffect { + + public FloatingShieldEffect() { + super(Outcome.Protect); + this.staticText = "target creature gains protection from the chosen color until end of turn"; + } + + public FloatingShieldEffect(final FloatingShieldEffect effect) { + super(effect); + } + + @Override + public FloatingShieldEffect copy() { + return new FloatingShieldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); + if (color == null) { + return false; + } + game.addEffect(new GainAbilityTargetEffect(ProtectionAbility.from(color)), source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Torment.java b/Mage.Sets/src/mage/sets/Torment.java index f6bf726014..9c8b9fac77 100644 --- a/Mage.Sets/src/mage/sets/Torment.java +++ b/Mage.Sets/src/mage/sets/Torment.java @@ -77,6 +77,7 @@ public final class Torment extends ExpansionSet { cards.add(new SetCardInfo("Far Wanderings", 125, Rarity.COMMON, mage.cards.f.FarWanderings.class)); cards.add(new SetCardInfo("Fiery Temper", 97, Rarity.COMMON, mage.cards.f.FieryTemper.class)); cards.add(new SetCardInfo("Flash of Defiance", 99, Rarity.COMMON, mage.cards.f.FlashOfDefiance.class)); + cards.add(new SetCardInfo("Floating Shield", 5, Rarity.COMMON, mage.cards.f.FloatingShield.class)); cards.add(new SetCardInfo("Frantic Purification", 6, Rarity.COMMON, mage.cards.f.FranticPurification.class)); cards.add(new SetCardInfo("Ghostly Wings", 38, Rarity.COMMON, mage.cards.g.GhostlyWings.class)); cards.add(new SetCardInfo("Gloomdrifter", 61, Rarity.UNCOMMON, mage.cards.g.Gloomdrifter.class));