From 697214118eb9bee1279dcf2712af05b1714e7383 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 3 Jun 2022 20:57:58 -0400 Subject: [PATCH] [CLB] Implemented Stunning Strike --- .../src/mage/cards/s/StunningStrike.java | 106 ++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/StunningStrike.java diff --git a/Mage.Sets/src/mage/cards/s/StunningStrike.java b/Mage.Sets/src/mage/cards/s/StunningStrike.java new file mode 100644 index 0000000000..845b561faf --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/StunningStrike.java @@ -0,0 +1,106 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.AttachedToMatchesFilterCondition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DontUntapInControllersUntapStepEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +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 StunningStrike extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent(); + + static { + filter.add(Predicates.not(SuperType.LEGENDARY.getPredicate())); + } + + private static final Condition condition = new AttachedToMatchesFilterCondition(filter); + + public StunningStrike(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); + + 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)); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); + + // When Stunning Strike enters the battlefield, tap enchanted creature and remove it from combat. + this.addAbility(new EntersBattlefieldTriggeredAbility(new StunningStrikeEffect())); + + // As long as enchanted creature isn't legendary, it doesn't untap during its controller's untap step. + this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect( + new DontUntapInControllersUntapStepEnchantedEffect(), condition, "as long as " + + "enchanted creature isn't legendary, it doesn't untap during its controller's untap step" + ))); + } + + private StunningStrike(final StunningStrike card) { + super(card); + } + + @Override + public StunningStrike copy() { + return new StunningStrike(this); + } +} + +class StunningStrikeEffect extends OneShotEffect { + + StunningStrikeEffect() { + super(Outcome.Benefit); + staticText = "tap enchanted creature and remove it from combat"; + } + + private StunningStrikeEffect(final StunningStrikeEffect effect) { + super(effect); + } + + @Override + public StunningStrikeEffect copy() { + return new StunningStrikeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Optional.of(source.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(Permanent::getAttachedTo) + .map(game::getPermanent) + .ifPresent(permanent -> { + permanent.tap(source, game); + permanent.removeFromCombat(game); + }); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 743d28bd98..7eca2428fb 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -511,6 +511,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Stonespeaker Crystal", 338, Rarity.UNCOMMON, mage.cards.s.StonespeakerCrystal.class)); cards.add(new SetCardInfo("Street Urchin", 197, Rarity.UNCOMMON, mage.cards.s.StreetUrchin.class)); cards.add(new SetCardInfo("Stuffy Doll", 875, Rarity.RARE, mage.cards.s.StuffyDoll.class)); + cards.add(new SetCardInfo("Stunning Strike", 97, Rarity.COMMON, mage.cards.s.StunningStrike.class)); cards.add(new SetCardInfo("Summon Undead", 151, Rarity.COMMON, mage.cards.s.SummonUndead.class)); cards.add(new SetCardInfo("Sunken Hollow", 918, Rarity.RARE, mage.cards.s.SunkenHollow.class)); cards.add(new SetCardInfo("Swamp", 459, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));