From f76910b82771de11d635df7b7e41edc2ce57cf2f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 29 Oct 2020 21:10:12 -0400 Subject: [PATCH] [CMR] Implemented Krark, the Thumbless --- .../src/mage/cards/k/KrarkTheThumbless.java | 87 +++++++++++++++++++ Mage.Sets/src/mage/sets/CommanderLegends.java | 1 + .../SpellCastControllerTriggeredAbility.java | 4 +- 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/k/KrarkTheThumbless.java diff --git a/Mage.Sets/src/mage/cards/k/KrarkTheThumbless.java b/Mage.Sets/src/mage/cards/k/KrarkTheThumbless.java new file mode 100644 index 00000000000..05521376400 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KrarkTheThumbless.java @@ -0,0 +1,87 @@ +package mage.cards.k; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.PartnerAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class KrarkTheThumbless extends CardImpl { + + public KrarkTheThumbless(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.GOBLIN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever you cast an instant or sorcery spell, flip a coin. If you lose the flip, return that spell to its owner's hand. If you win the flip, copy that spell, and you may choose new targets for the copy. + this.addAbility(new SpellCastControllerTriggeredAbility( + new KrarkTheThumblessEffect(), + StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, + false, true + )); + + // Partner + this.addAbility(PartnerAbility.getInstance()); + } + + private KrarkTheThumbless(final KrarkTheThumbless card) { + super(card); + } + + @Override + public KrarkTheThumbless copy() { + return new KrarkTheThumbless(this); + } +} + +class KrarkTheThumblessEffect extends OneShotEffect { + + KrarkTheThumblessEffect() { + super(Outcome.Benefit); + staticText = "flip a coin. If you lose the flip, return that spell to its owner's hand. " + + "If you win the flip, copy that spell, and you may choose new targets for the copy"; + } + + private KrarkTheThumblessEffect(final KrarkTheThumblessEffect effect) { + super(effect); + } + + @Override + public KrarkTheThumblessEffect copy() { + return new KrarkTheThumblessEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Spell spell = game.getSpellOrLKIStack(getTargetPointer().getFirst(game, source)); + if (player == null || spell == null) { + return false; + } + if (player.flipCoin(source, game, true)) { + spell.createCopyOnStack(game, source, player.getId(), true); + return true; + } + if (spell.isCopy()) { + game.getStack().remove(spell, game); + return true; + } + return game.getSpell(spell.getId()) == null && player.moveCards(spell, Zone.HAND, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 99dfeff573a..b44cfacaf18 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -67,6 +67,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Kitesail Corsair", 76, Rarity.COMMON, mage.cards.k.KitesailCorsair.class)); cards.add(new SetCardInfo("Kitesail Skirmisher", 77, Rarity.COMMON, mage.cards.k.KitesailSkirmisher.class)); cards.add(new SetCardInfo("Kor Cartographer", 377, Rarity.COMMON, mage.cards.k.KorCartographer.class)); + cards.add(new SetCardInfo("Krark, the Thumbless", 189, Rarity.RARE, mage.cards.k.KrarkTheThumbless.class)); cards.add(new SetCardInfo("Kydele, Chosen of Kruphix", 524, Rarity.MYTHIC, mage.cards.k.KydeleChosenOfKruphix.class)); cards.add(new SetCardInfo("Ludevic, Necro-Alchemist", 525, Rarity.MYTHIC, mage.cards.l.LudevicNecroAlchemist.class)); cards.add(new SetCardInfo("Maelstrom Colossus", 322, Rarity.COMMON, mage.cards.m.MaelstromColossus.class)); diff --git a/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java index 4ea2bde5c07..c4b34b53d56 100644 --- a/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java @@ -1,4 +1,3 @@ - package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; @@ -11,7 +10,6 @@ import mage.game.stack.Spell; import mage.target.targetpointer.FixedTarget; /** - * * @author North */ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl { @@ -67,7 +65,7 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { if (rememberSource) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); + this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId(), game)); } return true; }