From a223486497c6e96ca5b8244000574afacb20f367 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sun, 9 Apr 2023 15:16:28 -0400 Subject: [PATCH] [MOM] Implement Stasis Field --- Mage.Sets/src/mage/cards/s/StasisField.java | 85 +++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + 2 files changed, 86 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/StasisField.java diff --git a/Mage.Sets/src/mage/cards/s/StasisField.java b/Mage.Sets/src/mage/cards/s/StasisField.java new file mode 100644 index 0000000000..2b15b6c951 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/StasisField.java @@ -0,0 +1,85 @@ +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.SetBasePowerToughnessEnchantedEffect; +import mage.abilities.keyword.DefenderAbility; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class StasisField extends CardImpl { + + public StasisField(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.addAbility(new EnchantAbility(auraTarget)); + + // Enchanted creature has base power and toughness 0/2, has defender, and loses all other abilities. + Ability ability = new SimpleStaticAbility(new SetBasePowerToughnessEnchantedEffect(0, 2)); + ability.addEffect(new StasisFieldEffect()); + this.addAbility(ability); + } + + private StasisField(final StasisField card) { + super(card); + } + + @Override + public StasisField copy() { + return new StasisField(this); + } +} + +class StasisFieldEffect extends ContinuousEffectImpl { + + StasisFieldEffect() { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.Benefit); + staticText = ", has defender, and loses all other abilities"; + } + + private StasisFieldEffect(final StasisFieldEffect effect) { + super(effect); + } + + @Override + public StasisFieldEffect copy() { + return new StasisFieldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = Optional + .ofNullable(source.getSourcePermanentIfItStillExists(game)) + .filter(Objects::nonNull) + .map(Permanent::getAttachedTo) + .map(game::getPermanent) + .orElse(null); + if (permanent == null) { + return false; + } + permanent.removeAllAbilities(source.getSourceId(), game); + permanent.addAbility(DefenderAbility.getInstance(), source.getSourceId(), game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index ced44afb7f..c520e08e72 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -206,6 +206,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Skittering Surveyor", 264, Rarity.COMMON, mage.cards.s.SkitteringSurveyor.class)); cards.add(new SetCardInfo("Skyclave Aerialist", 78, Rarity.UNCOMMON, mage.cards.s.SkyclaveAerialist.class)); cards.add(new SetCardInfo("Skyclave Invader", 78, Rarity.UNCOMMON, mage.cards.s.SkyclaveInvader.class)); + cards.add(new SetCardInfo("Stasis Field", 79, Rarity.COMMON, mage.cards.s.StasisField.class)); cards.add(new SetCardInfo("Stoke the Flames", 166, Rarity.UNCOMMON, mage.cards.s.StokeTheFlames.class)); cards.add(new SetCardInfo("Storm the Seedcore", 206, Rarity.UNCOMMON, mage.cards.s.StormTheSeedcore.class)); cards.add(new SetCardInfo("Stormclaw Rager", 254, Rarity.UNCOMMON, mage.cards.s.StormclawRager.class));