[CLB] Implemented Guildsworn Prowler

This commit is contained in:
Evan Kranzler 2022-05-31 19:33:05 -04:00
parent 8303ac65af
commit 2f640f2b05
3 changed files with 77 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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));

View file

@ -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));
}
}