From 03a46ffec1ee56a86daaa9e0e1f402c458ad98b7 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 16 Jun 2020 22:03:14 -0400 Subject: [PATCH] fixed Ghostly Pilferer triggered ability --- .../src/mage/cards/g/GhostlyPilferer.java | 8 +-- Mage.Sets/src/mage/cards/h/Hollowsage.java | 62 +++---------------- Mage.Sets/src/mage/cards/k/KeyToTheCity.java | 53 +++------------- .../abilities/keyword/InspiredAbility.java | 61 ++++++++++-------- Utils/mtg-cards-data.txt | 2 +- 5 files changed, 58 insertions(+), 128 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GhostlyPilferer.java b/Mage.Sets/src/mage/cards/g/GhostlyPilferer.java index f583333542..68ffecfd52 100644 --- a/Mage.Sets/src/mage/cards/g/GhostlyPilferer.java +++ b/Mage.Sets/src/mage/cards/g/GhostlyPilferer.java @@ -2,13 +2,13 @@ package mage.cards.g; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.BecomesTappedSourceTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.DiscardCardCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.combat.CantBeBlockedSourceEffect; +import mage.abilities.keyword.InspiredAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -34,10 +34,10 @@ public final class GhostlyPilferer extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(1); - // Whenever Ghostly Pilferer becomes tapped, you may pay {2}. If you do, draw a card. - this.addAbility(new BecomesTappedSourceTriggeredAbility(new DoIfCostPaid( + // Whenever Ghostly Pilferer becomes untapped, you may pay {2}. If you do, draw a card. + this.addAbility(new InspiredAbility(new DoIfCostPaid( new DrawCardSourceControllerEffect(1), new GenericManaCost(2) - ))); + ), false, false)); // Whenever an opponent casts a spell from anywhere other than their hand, draw a card. this.addAbility(new GhostlyPilfererTriggeredAbility()); diff --git a/Mage.Sets/src/mage/cards/h/Hollowsage.java b/Mage.Sets/src/mage/cards/h/Hollowsage.java index d8d2aa755e..5ccc5a6d99 100644 --- a/Mage.Sets/src/mage/cards/h/Hollowsage.java +++ b/Mage.Sets/src/mage/cards/h/Hollowsage.java @@ -1,84 +1,42 @@ - package mage.cards.h; -import java.util.UUID; import mage.MageInt; -import mage.abilities.TriggeredAbility; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; +import mage.abilities.Ability; import mage.abilities.effects.common.discard.DiscardTargetEffect; +import mage.abilities.keyword.InspiredAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.target.TargetPlayer; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class Hollowsage extends CardImpl { - + public Hollowsage(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.subtype.add(SubType.MERFOLK); this.subtype.add(SubType.WIZARD); - + this.power = new MageInt(2); this.toughness = new MageInt(2); // Whenever Hollowsage becomes untapped, you may have target player discard a card. - TriggeredAbility ability = new BecomesUntappedTriggeredAbility(new DiscardTargetEffect(1), true); + Ability ability = new InspiredAbility(new DiscardTargetEffect(1), true, false); ability.addTarget(new TargetPlayer()); this.addAbility(ability); - } - + public Hollowsage(final Hollowsage card) { super(card); } - + @Override public Hollowsage copy() { return new Hollowsage(this); } } - -class BecomesUntappedTriggeredAbility extends TriggeredAbilityImpl { - - public BecomesUntappedTriggeredAbility(Effect effect, boolean isOptional) { - super(Zone.BATTLEFIELD, effect, isOptional); - } - - public BecomesUntappedTriggeredAbility(Effect effect) { - super(Zone.BATTLEFIELD, effect); - } - - public BecomesUntappedTriggeredAbility(final BecomesUntappedTriggeredAbility ability) { - super(ability); - } - - @Override - public BecomesUntappedTriggeredAbility copy() { - return new BecomesUntappedTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.UNTAPPED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return event.getTargetId().equals(sourceId); - } - - @Override - public String getRule() { - return "When {this} becomes untapped, " + super.getRule(); - } -} diff --git a/Mage.Sets/src/mage/cards/k/KeyToTheCity.java b/Mage.Sets/src/mage/cards/k/KeyToTheCity.java index 1fce751780..909321cf6c 100644 --- a/Mage.Sets/src/mage/cards/k/KeyToTheCity.java +++ b/Mage.Sets/src/mage/cards/k/KeyToTheCity.java @@ -1,9 +1,6 @@ - package mage.cards.k; -import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.DiscardCardCost; import mage.abilities.costs.common.TapSourceCost; @@ -11,35 +8,35 @@ import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect; +import mage.abilities.keyword.InspiredAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author emerald000 */ public final class KeyToTheCity extends CardImpl { public KeyToTheCity(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); // {T}, Discard a card: Up to one target creature can't be blocked this turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedTargetEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(new CantBeBlockedTargetEffect(), new TapSourceCost()); ability.addCost(new DiscardCardCost()); ability.addTarget(new TargetCreaturePermanent(0, 1)); this.addAbility(ability); // Whenever Key to the City becomes untapped, you may pay {2}. If you do, draw a card. - this.addAbility(new KeyToTheCityTriggeredAbility()); + this.addAbility(new InspiredAbility(new DoIfCostPaid( + new DrawCardSourceControllerEffect(1), new GenericManaCost(2) + ), false, false)); } - public KeyToTheCity(final KeyToTheCity card) { + private KeyToTheCity(final KeyToTheCity card) { super(card); } @@ -48,35 +45,3 @@ public final class KeyToTheCity extends CardImpl { return new KeyToTheCity(this); } } - -class KeyToTheCityTriggeredAbility extends TriggeredAbilityImpl{ - - KeyToTheCityTriggeredAbility() { - super(Zone.BATTLEFIELD, new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new GenericManaCost(2))); - } - - KeyToTheCityTriggeredAbility(final KeyToTheCityTriggeredAbility ability) { - super(ability); - } - - @Override - public KeyToTheCityTriggeredAbility copy() { - return new KeyToTheCityTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.UNTAPPED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return event.getTargetId().equals(this.getSourceId()); - } - - @Override - public String getRule() { - return "Whenever Key to the City becomes untapped, you may pay {2}. If you do, draw a card."; - } - -} diff --git a/Mage/src/main/java/mage/abilities/keyword/InspiredAbility.java b/Mage/src/main/java/mage/abilities/keyword/InspiredAbility.java index 5ac808f7da..3e20c1da54 100644 --- a/Mage/src/main/java/mage/abilities/keyword/InspiredAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/InspiredAbility.java @@ -1,29 +1,29 @@ /* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. */ package mage.abilities.keyword; @@ -37,21 +37,28 @@ import mage.game.events.GameEvent.EventType; /** * Inspired ability word * - * * @author LevelX2 */ public class InspiredAbility extends TriggeredAbilityImpl { + private final boolean isInspired; + public InspiredAbility(Effect effect) { this(effect, false); } public InspiredAbility(Effect effect, boolean optional) { + this(effect, optional, true); + } + + public InspiredAbility(Effect effect, boolean optional, boolean isInspired) { super(Zone.BATTLEFIELD, effect, optional); + this.isInspired = isInspired; } public InspiredAbility(final InspiredAbility ability) { super(ability); + this.isInspired = ability.isInspired; } @Override @@ -71,6 +78,6 @@ public class InspiredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Inspired — Whenever {this} becomes untapped, " + super.getRule(); + return (isInspired ? "Inspired — " : "") + "Whenever {this} becomes untapped, " + super.getRule(); } } diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 48eb0ed176..87900618f4 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -37489,7 +37489,7 @@ Discontinuity|Core Set 2021|48|M|{3}{U}{U}{U}|Instant|||As long as it's your tur Enthralling Hold|Core Set 2021|49|U|{3}{U}{U}|Enchantment - Aura|||Enchant creature$You can't choose an untapped creature as this spell's target as you cast it.$You control enchanted creature.| Frantic Inventory|Core Set 2021|50|C|{1}{U}|Instant|||Draw a card, then draw cards equal to the number of cards named Frantic Inventory in your graveyard.| Frost Breath|Core Set 2021|51|C|{2}{U}|Instant|||Tap up to two target creatures. Those creatures don't untap during their controller's next untap step.| -Ghostly Pilferer|Core Set 2021|52|R|{1}{U}|Creature - Spirit Rogue|2|1|Whenever Ghostly Pilferer becomes tapped, you may pay {2}. If you do, draw a card.$Whenever an opponent casts a spell from anywhere other than their hand, draw a card.$Discard a card: Ghostly Pilferer can't be blocked this turn.| +Ghostly Pilferer|Core Set 2021|52|R|{1}{U}|Creature - Spirit Rogue|2|1|Whenever Ghostly Pilferer becomes untapped, you may pay {2}. If you do, draw a card.$Whenever an opponent casts a spell from anywhere other than their hand, draw a card.$Discard a card: Ghostly Pilferer can't be blocked this turn.| Jeskai Elder|Core Set 2021|53|U|{1}{U}|Creature - Human Monk|1|2|Prowess$Whenever Jeskai Elder deals combat damage to a player, you may draw a card. If you do, discard a card.| Keen Glidemaster|Core Set 2021|54|C|{1}{U}|Creature - Human Soldier|2|1|{2}{U}: Target creature gains flying until end of turn.| Library Larcenist|Core Set 2021|55|C|{2}{U}|Creature - Merfolk Rogue|1|2|Whenever Library Larcenist attacks, draw a card.|