From b09ee6ced1cfc16cfca7dfcdfed1aeb01ee187d2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 3 Jun 2022 20:48:16 -0400 Subject: [PATCH] [CLB] Implemented Undercellar Sweep --- .../src/mage/cards/u/UndercellarSweep.java | 65 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 66 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/UndercellarSweep.java diff --git a/Mage.Sets/src/mage/cards/u/UndercellarSweep.java b/Mage.Sets/src/mage/cards/u/UndercellarSweep.java new file mode 100644 index 00000000000..d6b13fe54bf --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UndercellarSweep.java @@ -0,0 +1,65 @@ +package mage.cards.u; + +import mage.abilities.Ability; +import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.TakeTheInitiativeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.game.Game; +import mage.game.permanent.token.SoldierToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class UndercellarSweep extends CardImpl { + + public UndercellarSweep(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}"); + + // When Undercellar Sweep enters the battlefield, you take the initiative. + this.addAbility(new EntersBattlefieldTriggeredAbility(new TakeTheInitiativeEffect())); + + // Whenever you attack, if you or a player you're attacking has the initiative, you create two 1/1 white Soldier creature token that are tapped and attacking. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new AttacksWithCreaturesTriggeredAbility( + new CreateTokenEffect(new SoldierToken(), 2, true, true), 1 + ), UndercellarSweepCondition.instance, "Whenever you attack, if you or a player you're attacking " + + "has the initiative, you create two 1/1 white Soldier creature token that are tapped and attacking." + )); + } + + private UndercellarSweep(final UndercellarSweep card) { + super(card); + } + + @Override + public UndercellarSweep copy() { + return new UndercellarSweep(this); + } +} + +enum UndercellarSweepCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + if (game.getInitiativeId() == null) { + return false; + } + return source.isControlledBy(game.getInitiativeId()) + || game + .getCombat() + .getAttackers() + .stream() + .filter(uuid -> source.isControlledBy(game.getControllerId(uuid))) + .map(game.getCombat()::getDefenderId) + .anyMatch(game.getInitiativeId()::equals); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 8883e69b763..743d28bd989 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -557,6 +557,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Uchuulon", 673, Rarity.RARE, mage.cards.u.Uchuulon.class)); cards.add(new SetCardInfo("Unbreakable Formation", 710, Rarity.RARE, mage.cards.u.UnbreakableFormation.class)); cards.add(new SetCardInfo("Undercellar Myconid", 259, Rarity.COMMON, mage.cards.u.UndercellarMyconid.class)); + cards.add(new SetCardInfo("Undercellar Sweep", 47, Rarity.UNCOMMON, mage.cards.u.UndercellarSweep.class)); cards.add(new SetCardInfo("Underdark Explorer", 154, Rarity.COMMON, mage.cards.u.UnderdarkExplorer.class)); cards.add(new SetCardInfo("Undermountain Adventurer", 260, Rarity.RARE, mage.cards.u.UndermountainAdventurer.class)); cards.add(new SetCardInfo("Universal Solvent", 342, Rarity.COMMON, mage.cards.u.UniversalSolvent.class));