From dd6aaccca5887db54420228ecfaad44cb9a14774 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 2 Aug 2019 08:17:38 -0400 Subject: [PATCH] Implemntd Kadena, Slinking Sorcerer --- .../mage/cards/k/KadenaSlinkingSorcerer.java | 132 ++++++++++++++++++ .../src/mage/sets/Commander2019Edition.java | 1 + 2 files changed, 133 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/k/KadenaSlinkingSorcerer.java diff --git a/Mage.Sets/src/mage/cards/k/KadenaSlinkingSorcerer.java b/Mage.Sets/src/mage/cards/k/KadenaSlinkingSorcerer.java new file mode 100644 index 0000000000..60d0086bc7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KadenaSlinkingSorcerer.java @@ -0,0 +1,132 @@ +package mage.cards.k; + +import mage.MageInt; +import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.WatcherScope; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; +import mage.filter.predicate.other.FaceDownPredicate; +import mage.game.Controllable; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class KadenaSlinkingSorcerer extends CardImpl { + + private static final FilterCard filter = new FilterCard(); + private static final FilterPermanent filter2 = new FilterControlledCreaturePermanent("a face-down creature"); + + static { + filter.add(KadenaSlinkingSorcererPredicate.instance); + filter2.add(FaceDownPredicate.instance); + } + + public KadenaSlinkingSorcerer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{G}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.NAGA); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // The first face-down creature spell you cast each turn costs {3} less to cast. + this.addAbility(new SimpleStaticAbility( + new SpellsCostReductionControllerEffect(filter, 3) + .setText("The first face-down creature spell you cast each turn costs {3} less to cast.") + ), new KadenaSlinkingSorcererWatcher()); + + // Whenever a face-down creature enters the battlefield under your control, draw a card. + this.addAbility(new EntersBattlefieldControlledTriggeredAbility( + new DrawCardSourceControllerEffect(1), filter2 + )); + } + + private KadenaSlinkingSorcerer(final KadenaSlinkingSorcerer card) { + super(card); + } + + @Override + public KadenaSlinkingSorcerer copy() { + return new KadenaSlinkingSorcerer(this); + } +} + +enum KadenaSlinkingSorcererPredicate implements ObjectPlayerPredicate> { + instance; + + @Override + public boolean apply(ObjectPlayer input, Game game) { + if (input.getObject() instanceof Spell + && ((Spell) input.getObject()).isCreature() + && ((Spell) input.getObject()).isFaceDown(game)) { + KadenaSlinkingSorcererWatcher watcher = game.getState().getWatcher(KadenaSlinkingSorcererWatcher.class); + return watcher != null && watcher.castFaceDownThisTurn(input.getPlayerId()); + } + return false; + } +} + +class KadenaSlinkingSorcererWatcher extends Watcher { + + + private final Set castFaceDown; + + KadenaSlinkingSorcererWatcher() { + super(WatcherScope.GAME); + castFaceDown = new HashSet<>(); + } + + private KadenaSlinkingSorcererWatcher(final KadenaSlinkingSorcererWatcher watcher) { + super(watcher); + this.castFaceDown = new HashSet<>(); + castFaceDown.addAll(watcher.castFaceDown); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.SPELL_CAST) { + return; + } + Spell spell = (Spell) game.getObject(event.getTargetId()); + if (spell == null || !spell.isCreature() || !spell.isFaceDown(game)) { + return; + } + castFaceDown.add(event.getPlayerId()); + } + + boolean castFaceDownThisTurn(UUID playerId) { + return castFaceDown.contains(playerId); + } + + @Override + public KadenaSlinkingSorcererWatcher copy() { + return new KadenaSlinkingSorcererWatcher(this); + } + + @Override + public void reset() { + super.reset(); + castFaceDown.clear(); + } + +} diff --git a/Mage.Sets/src/mage/sets/Commander2019Edition.java b/Mage.Sets/src/mage/sets/Commander2019Edition.java index 57db79c495..7dad2d04b9 100644 --- a/Mage.Sets/src/mage/sets/Commander2019Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2019Edition.java @@ -23,6 +23,7 @@ public final class Commander2019Edition extends ExpansionSet { cards.add(new SetCardInfo("Anje's Ravager", 22, Rarity.RARE, mage.cards.a.AnjesRavager.class)); cards.add(new SetCardInfo("Ghired, Conclave Exile", 42, Rarity.MYTHIC, mage.cards.g.GhiredConclaveExile.class)); cards.add(new SetCardInfo("Kadena's Silencer", 8, Rarity.RARE, mage.cards.k.KadenasSilencer.class)); + cards.add(new SetCardInfo("Kadena, Slinking Sorcerer", 45, Rarity.MYTHIC, mage.cards.k.KadenaSlinkingSorcerer.class)); cards.add(new SetCardInfo("Seedborn Muse", 179, Rarity.RARE, mage.cards.s.SeedbornMuse.class)); } }