From 2f640f2b0517ba74d08458bc8f4845feca6a4e3f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 31 May 2022 19:33:05 -0400 Subject: [PATCH] [CLB] Implemented Guildsworn Prowler --- .../src/mage/cards/g/GuildswornProwler.java | 66 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + .../common/BlockingOrBlockedWatcher.java | 10 +++ 3 files changed, 77 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GuildswornProwler.java diff --git a/Mage.Sets/src/mage/cards/g/GuildswornProwler.java b/Mage.Sets/src/mage/cards/g/GuildswornProwler.java new file mode 100644 index 0000000000..c479d2a70b --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GuildswornProwler.java @@ -0,0 +1,66 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.game.Game; +import mage.watchers.common.BlockingOrBlockedWatcher; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GuildswornProwler extends CardImpl { + + public GuildswornProwler(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.subtype.add(SubType.TIEFLING); + this.subtype.add(SubType.ROGUE); + this.subtype.add(SubType.ASSASSIN); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // Deathtouch + this.addAbility(DeathtouchAbility.getInstance()); + + // When Guildsworn Prowler dies, if it wasn't blocking, draw a card. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new DiesSourceTriggeredAbility(new DrawCardSourceControllerEffect(1)), + GuildswornProwlerCondition.instance, "When {this} dies, if it wasn't blocking, draw a card." + )); + } + + private GuildswornProwler(final GuildswornProwler card) { + super(card); + } + + @Override + public GuildswornProwler copy() { + return new GuildswornProwler(this); + } +} + +enum GuildswornProwlerCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return Optional + .of(source.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(permanent -> !BlockingOrBlockedWatcher.check(permanent, game)) + .orElse(false); + } +} \ 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 c99b41a091..16ce815ef0 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -153,6 +153,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Guardian Naga", 23, Rarity.COMMON, mage.cards.g.GuardianNaga.class)); cards.add(new SetCardInfo("Guiding Bolt", 24, Rarity.COMMON, mage.cards.g.GuidingBolt.class)); cards.add(new SetCardInfo("Guild Artisan", 179, Rarity.UNCOMMON, mage.cards.g.GuildArtisan.class)); + cards.add(new SetCardInfo("Guildsworn Prowler", 130, Rarity.COMMON, mage.cards.g.GuildswornProwler.class)); cards.add(new SetCardInfo("Guiltfeeder", 756, Rarity.RARE, mage.cards.g.Guiltfeeder.class)); cards.add(new SetCardInfo("Gut, True Soul Zealot", 180, Rarity.UNCOMMON, mage.cards.g.GutTrueSoulZealot.class)); cards.add(new SetCardInfo("Halsin, Emerald Archdruid", 234, Rarity.UNCOMMON, mage.cards.h.HalsinEmeraldArchdruid.class)); diff --git a/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java b/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java index 66e0abd555..d565605e1f 100644 --- a/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java @@ -53,4 +53,14 @@ public class BlockingOrBlockedWatcher extends Watcher { .stream() .anyMatch(mor -> mor.refersTo(blocker, game)); } + + public static boolean check(Permanent blocker, Game game) { + return game.getState() + .getWatcher(BlockingOrBlockedWatcher.class) + .blockerMap + .values() + .stream() + .flatMap(Collection::stream) + .anyMatch(mor -> mor.refersTo(blocker, game)); + } }