From 686600a4fe51d2181761aeba54a6e6ea47b23951 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 1 Jun 2022 08:36:23 -0400 Subject: [PATCH] [CLB] Implemented Folk Hero --- Mage.Sets/src/mage/cards/f/FolkHero.java | 71 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 72 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FolkHero.java diff --git a/Mage.Sets/src/mage/cards/f/FolkHero.java b/Mage.Sets/src/mage/cards/f/FolkHero.java new file mode 100644 index 0000000000..3517be8c37 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FolkHero.java @@ -0,0 +1,71 @@ +package mage.cards.f; + +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.continuous.GainAbilityAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterSpell; +import mage.filter.StaticFilters; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.stack.Spell; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FolkHero extends CardImpl { + + private static final FilterSpell filter = new FilterSpell("a spell that shares a creature type with this creature"); + + static { + filter.add(FolkHeroPredicate.instance); + } + + public FolkHero(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.BACKGROUND); + + // Commander creatures you own have "Whenever you cast a spell that shares a creature type with this creature, draw a card. This ability triggers only once each turn." + this.addAbility(new SimpleStaticAbility(new GainAbilityAllEffect( + new SpellCastControllerTriggeredAbility( + new DrawCardSourceControllerEffect(1), filter, false + ).setTriggersOnce(true), Duration.WhileOnBattlefield, + StaticFilters.FILTER_CREATURES_OWNED_COMMANDER + ))); + } + + private FolkHero(final FolkHero card) { + super(card); + } + + @Override + public FolkHero copy() { + return new FolkHero(this); + } +} + +enum FolkHeroPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return Optional + .of(input.getSource().getSourcePermanentIfItStillExists(game)) + .filter(Objects::nonNull) + .map(permanent -> input.getObject().shareCreatureTypes(game, permanent)) + .orElse(false); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 2de0a0af10..10b8c402dc 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -137,6 +137,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Fireball", 175, Rarity.UNCOMMON, mage.cards.f.Fireball.class)); cards.add(new SetCardInfo("Flaming Fist Officer", 19, Rarity.COMMON, mage.cards.f.FlamingFistOfficer.class)); cards.add(new SetCardInfo("Flaming Fist", 18, Rarity.COMMON, mage.cards.f.FlamingFist.class)); + cards.add(new SetCardInfo("Folk Hero", 650, Rarity.MYTHIC, mage.cards.f.FolkHero.class)); cards.add(new SetCardInfo("Font of Magic", 71, Rarity.MYTHIC, mage.cards.f.FontOfMagic.class)); cards.add(new SetCardInfo("Forest", 467, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Ganax, Astral Hunter", 176, Rarity.UNCOMMON, mage.cards.g.GanaxAstralHunter.class));