From 1195016399688f4edfddda92c8431f436b6e2a35 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 8 Nov 2021 20:50:13 -0500 Subject: [PATCH] [VOW] Implemented Kaya, Geist Hunter --- .../src/mage/cards/k/KayaGeistHunter.java | 116 ++++++++++++++++++ .../src/mage/sets/InnistradCrimsonVow.java | 1 + .../CreateTwiceThatManyTokensEffect.java | 18 ++- 3 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/k/KayaGeistHunter.java diff --git a/Mage.Sets/src/mage/cards/k/KayaGeistHunter.java b/Mage.Sets/src/mage/cards/k/KayaGeistHunter.java new file mode 100644 index 00000000000..e2770582a67 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KayaGeistHunter.java @@ -0,0 +1,116 @@ +package mage.cards.k; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.effects.common.replacement.CreateTwiceThatManyTokensEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.token.SpiritWhiteToken; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class KayaGeistHunter extends CardImpl { + + private static final FilterPermanent filter + = new FilterControlledCreaturePermanent("creature token you control"); + + static { + filter.add(TokenPredicate.TRUE); + } + + public KayaGeistHunter(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{1}{W}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.KAYA); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3)); + + // +1: Creatures you control gain deathtouch until end of turn. Put a +1/+1 counter on up to one target creature token you control. + Ability ability = new LoyaltyAbility(new GainAbilityControlledEffect( + DeathtouchAbility.getInstance(), Duration.EndOfTurn, + StaticFilters.FILTER_PERMANENT_CREATURES + ), 1); + ability.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance())); + ability.addTarget(new TargetPermanent(0, 1, filter)); + this.addAbility(ability); + + // −2: Until end of turn, if one or more tokens would be created under your control, twice that many of those tokens are created instead. + this.addAbility(new LoyaltyAbility(new CreateTwiceThatManyTokensEffect(Duration.EndOfTurn), -2)); + + // −6: Exile all cards from all graveyards, then create a 1/1 white Spirit creature token with flying for each card exiled this way. + this.addAbility(new LoyaltyAbility(new KayaGeistHunterEffect(), -6)); + } + + private KayaGeistHunter(final KayaGeistHunter card) { + super(card); + } + + @Override + public KayaGeistHunter copy() { + return new KayaGeistHunter(this); + } +} + +class KayaGeistHunterEffect extends OneShotEffect { + + KayaGeistHunterEffect() { + super(Outcome.Benefit); + staticText = "exile all cards from all graveyards, then create " + + "a 1/1 white Spirit creature token with flying for each card exiled this way"; + } + + private KayaGeistHunterEffect(final KayaGeistHunterEffect effect) { + super(effect); + } + + @Override + public KayaGeistHunterEffect copy() { + return new KayaGeistHunterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(); + game.getState() + .getPlayersInRange(source.getControllerId(), game) + .stream() + .map(game::getPlayer) + .filter(Objects::nonNull) + .map(Player::getGraveyard) + .map(g -> g.getCards(game)) + .flatMap(Collection::stream) + .forEach(cards::add); + player.moveCards(cards, Zone.EXILED, source, game); + cards.retainZone(Zone.EXILED, game); + if (cards.isEmpty()) { + return true; + } + new SpiritWhiteToken().putOntoBattlefield(cards.size(), game, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index a204f3d782c..f397b20a6d8 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -182,6 +182,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Island", 399, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Katilda's Rising Dawn", 21, Rarity.RARE, mage.cards.k.KatildasRisingDawn.class)); cards.add(new SetCardInfo("Katilda, Dawnhart Martyr", 21, Rarity.RARE, mage.cards.k.KatildaDawnhartMartyr.class)); + cards.add(new SetCardInfo("Kaya, Geist Hunter", 240, Rarity.MYTHIC, mage.cards.k.KayaGeistHunter.class)); cards.add(new SetCardInfo("Kessig Flamebreather", 164, Rarity.COMMON, mage.cards.k.KessigFlamebreather.class)); cards.add(new SetCardInfo("Kessig Wolfrider", 165, Rarity.RARE, mage.cards.k.KessigWolfrider.class)); cards.add(new SetCardInfo("Kindly Ancestor", 22, Rarity.COMMON, mage.cards.k.KindlyAncestor.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/replacement/CreateTwiceThatManyTokensEffect.java b/Mage/src/main/java/mage/abilities/effects/common/replacement/CreateTwiceThatManyTokensEffect.java index ef77c25eec4..428c3cd34fa 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/replacement/CreateTwiceThatManyTokensEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/replacement/CreateTwiceThatManyTokensEffect.java @@ -1,6 +1,7 @@ package mage.abilities.effects.common.replacement; import mage.abilities.Ability; +import mage.abilities.Mode; import mage.abilities.effects.ReplacementEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; @@ -14,9 +15,11 @@ import mage.game.events.GameEvent; public class CreateTwiceThatManyTokensEffect extends ReplacementEffectImpl { public CreateTwiceThatManyTokensEffect() { - super(Duration.WhileOnBattlefield, Outcome.Copy); - staticText = "if one or more tokens would be created under your control, " + - "twice that many of those tokens are created instead"; + this(Duration.WhileOnBattlefield); + } + + public CreateTwiceThatManyTokensEffect(Duration duration) { + super(duration, Outcome.Copy); } private CreateTwiceThatManyTokensEffect(final CreateTwiceThatManyTokensEffect effect) { @@ -46,4 +49,13 @@ public class CreateTwiceThatManyTokensEffect extends ReplacementEffectImpl { return false; } + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + return (duration.toString().isEmpty() ? "" : duration + ", ") + + "if one or more tokens would be created under your control, " + + "twice that many of those tokens are created instead"; + } }