From 76d0baa792ed3aef22ca79918c1362c35d46b69f Mon Sep 17 00:00:00 2001 From: Will Hall Date: Fri, 27 Jul 2018 18:33:58 -0700 Subject: [PATCH] Implemented Gyrus, Waker of Corpses --- .../src/mage/cards/g/GyrusWakerOfCorpses.java | 129 ++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 1 + .../common/ManaSpentToCastCount.java | 2 +- 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java diff --git a/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java new file mode 100644 index 0000000000..b7224b4424 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java @@ -0,0 +1,129 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards.g; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; +import mage.abilities.dynamicvalue.common.ManaSpentToCastCount; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.CreateTokenCopyTargetEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author Will + */ +public final class GyrusWakerOfCorpses extends CardImpl { + + private static final FilterCreatureCard filter = new FilterCreatureCard("target creature card with lesser power from your graveyard"); + + static { + filter.add(new GyrusWakerOfCorpsesPowerLessThanSourcePredicate()); + } + + public GyrusWakerOfCorpses(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{B}{R}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HYDRA); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Gyrus, Walker of Corpses enters the battlefield with a number of +1/+1 counters on it equal to the amount of mana spent to cast it. + Effect effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(0), new ManaSpentToCastCount(), true); + effect.setText("with a number of +1/+1 counters on it equal to the amount of mana spent to cast it"); + this.addAbility(new EntersBattlefieldAbility(effect)); + + // Whenever Gyrus attacks, you may exile target creature card with lesser power from your graveyard. If you do, create a token that’s a copy of that card and that’s tapped and attacking. Exile the token at the end of combat. + Ability ability = new AttacksTriggeredAbility(new GyrusWakerOfCorpsesEffect(), true); + ability.addTarget(new TargetCardInYourGraveyard(filter)); + this.addAbility(ability); + } + + public GyrusWakerOfCorpses(final GyrusWakerOfCorpses card) { + super(card); + } + + @Override + public GyrusWakerOfCorpses copy() { + return new GyrusWakerOfCorpses(this); + } +} + +class GyrusWakerOfCorpsesEffect extends OneShotEffect { + + public GyrusWakerOfCorpsesEffect() { + super(Outcome.Copy); + this.staticText = "exile target creature card with lesser power from your graveyard. If you do, create a token that’s a copy of that card and that’s tapped and attacking. Exile the token at the end of combat."; + } + + public GyrusWakerOfCorpsesEffect(final GyrusWakerOfCorpsesEffect effect) { + super(effect); + } + + @Override + public GyrusWakerOfCorpsesEffect copy() { + return new GyrusWakerOfCorpsesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + + Card card = game.getCard(source.getFirstTarget()); + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || card == null) { + return false; + } + controller.moveCards(card, Zone.EXILED, source, game); + CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true); + effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.apply(game, source); + for (Permanent addedToken : effect.getAddedPermanent()) { + Effect exileEffect = new ExileTargetEffect(); + exileEffect.setTargetPointer(new FixedTarget(addedToken, game)); + new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), false).apply(game, source); + } + return true; + } +} + +class GyrusWakerOfCorpsesPowerLessThanSourcePredicate implements ObjectSourcePlayerPredicate> { + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + return sourcePermanent != null && input.getObject().getPower().getValue() < sourcePermanent.getPower().getValue(); + } + + @Override + public String toString() { + return "lesser power"; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index c3aa0955e2..65db6e261d 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -133,6 +133,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Grisly Salvage", 182, Rarity.COMMON, mage.cards.g.GrislySalvage.class)); cards.add(new SetCardInfo("Ground Seal", 149, Rarity.RARE, mage.cards.g.GroundSeal.class)); cards.add(new SetCardInfo("Gruul Turf", 252, Rarity.UNCOMMON, mage.cards.g.GruulTurf.class)); + cards.add(new SetCardInfo("Gyrus, Waker of Corpses", 41, Rarity.MYTHIC, mage.cards.g.GyrusWakerOfCorpses.class)); cards.add(new SetCardInfo("Halimar Depths", 253, Rarity.COMMON, mage.cards.h.HalimarDepths.class)); cards.add(new SetCardInfo("Harrow", 150, Rarity.COMMON, mage.cards.h.Harrow.class)); cards.add(new SetCardInfo("Haunted Fengraf", 254, Rarity.COMMON, mage.cards.h.HauntedFengraf.class)); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java index d2e841f720..767c185e7a 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java @@ -29,7 +29,7 @@ public class ManaSpentToCastCount implements DynamicValue { } if (spell != null) { // NOT the cmc of the spell on the stack - return spell.getSpellAbility().getManaCostsToPay().convertedManaCost() + spell.getSpellAbility().getManaCostsToPay().getX(); + return spell.getSpellAbility().getManaCostsToPay().convertedManaCost(); } return 0; }