From 581d8eb099760f0c4fa694454689a3e30bdacfef Mon Sep 17 00:00:00 2001 From: North Date: Thu, 23 Jun 2011 07:40:14 +0300 Subject: [PATCH] Added Mirran Spy. Added SpellCastTriggeredAbility Refactored cards to use SpellCastTriggeredAbility --- .../sets/conflux/SigilOfTheEmptyThrone.java | 50 ++---- .../mage/sets/mirrodinbesieged/MirranSpy.java | 148 ++++++++---------- .../mage/sets/riseoftheeldrazi/KilnFiend.java | 13 +- .../mage/sets/scarsofmirrodin/Embersmith.java | 49 ++---- .../sets/scarsofmirrodin/GolemFoundry.java | 45 +----- .../scarsofmirrodin/HandOfThePraetors.java | 51 ++---- .../sets/scarsofmirrodin/InexorableTide.java | 44 +----- .../mage/sets/scarsofmirrodin/Lifesmith.java | 44 +----- .../mage/sets/scarsofmirrodin/Myrsmith.java | 48 ++---- .../mage/sets/scarsofmirrodin/Painsmith.java | 51 ++---- .../sets/scarsofmirrodin/Riddlesmith.java | 47 +----- .../common/SpellCastTriggeredAbility.java | 82 ++++++++++ 12 files changed, 239 insertions(+), 433 deletions(-) rename Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java => Mage.Sets/src/mage/sets/mirrodinbesieged/MirranSpy.java (52%) create mode 100644 Mage/src/mage/abilities/common/SpellCastTriggeredAbility.java diff --git a/Mage.Sets/src/mage/sets/conflux/SigilOfTheEmptyThrone.java b/Mage.Sets/src/mage/sets/conflux/SigilOfTheEmptyThrone.java index 5198aeef6b2..b32d36e3a11 100644 --- a/Mage.Sets/src/mage/sets/conflux/SigilOfTheEmptyThrone.java +++ b/Mage.Sets/src/mage/sets/conflux/SigilOfTheEmptyThrone.java @@ -31,30 +31,33 @@ package mage.sets.conflux; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; -import mage.Constants.Zone; import mage.MageInt; import mage.ObjectColor; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; +import mage.filter.FilterCard; import mage.game.permanent.token.Token; -import mage.game.stack.Spell; /** * - * @author Loki + * @author Loki, North */ public class SigilOfTheEmptyThrone extends CardImpl { + private static final FilterCard filter = new FilterCard("an enchantment spell"); + + static { + filter.getCardType().add(CardType.ENCHANTMENT); + } + public SigilOfTheEmptyThrone(UUID ownerId) { super(ownerId, 18, "Sigil of the Empty Throne", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{W}"); this.expansionSetCode = "CON"; this.color.setWhite(true); - this.addAbility(new SigilOfTheEmptyThroneAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new CreateTokenEffect(new AngelToken()), filter, false)); } public SigilOfTheEmptyThrone(final SigilOfTheEmptyThrone card) { @@ -68,37 +71,6 @@ public class SigilOfTheEmptyThrone extends CardImpl { } -class SigilOfTheEmptyThroneAbility extends TriggeredAbilityImpl { - public SigilOfTheEmptyThroneAbility() { - super(Zone.BATTLEFIELD, new CreateTokenEffect(new AngelToken()), false); - } - - public SigilOfTheEmptyThroneAbility(final SigilOfTheEmptyThroneAbility ability) { - super(ability); - } - - @Override - public SigilOfTheEmptyThroneAbility copy() { - return new SigilOfTheEmptyThroneAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.SPELL_CAST) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ENCHANTMENT) && event.getPlayerId().equals(getControllerId())) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an enchantment spell, put a 4/4 white Angel creature token with flying onto the battlefield."; - } -} - class AngelToken extends Token { public AngelToken() { super("Angel", "4/4 white Angel creature token with flying"); diff --git a/Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/MirranSpy.java similarity index 52% rename from Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java rename to Mage.Sets/src/mage/sets/mirrodinbesieged/MirranSpy.java index 33a58782e97..e89405dcbba 100644 --- a/Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/MirranSpy.java @@ -1,79 +1,69 @@ -/* - * 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.common; - -import mage.Constants.CardType; -import mage.Constants.Zone; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.cards.Card; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.target.TargetSpell; - -/** - * - * @author North - */ -public class InstantOrSorceryCastTriggeredAbility extends TriggeredAbilityImpl { - - public InstantOrSorceryCastTriggeredAbility(Effect effect, boolean optional) { - super(Zone.BATTLEFIELD, effect, optional); - } - - public InstantOrSorceryCastTriggeredAbility(final InstantOrSorceryCastTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.CAST_SPELL) { - Card card = game.getCard(event.getSourceId()); - if (card.getOwnerId().equals(this.getControllerId()) - && (card.getCardType().contains(CardType.SORCERY) - || card.getCardType().contains(CardType.INSTANT))) { - TargetSpell target = new TargetSpell(); - target.add(event.getSourceId(), game); - this.addTarget(target); - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an instant or sorcery spell, " + super.getRule(); - } - - @Override - public InstantOrSorceryCastTriggeredAbility copy() { - return new InstantOrSorceryCastTriggeredAbility(this); - } -} +/* + * 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.sets.mirrodinbesieged; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.SpellCastTriggeredAbility; +import mage.abilities.effects.common.UntapTargetEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author North + */ +public class MirranSpy extends CardImpl { + + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + + public MirranSpy(UUID ownerId) { + super(ownerId, 26, "Mirran Spy", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{U}"); + this.expansionSetCode = "MBS"; + this.subtype.add("Drone"); + + this.color.setBlue(true); + this.power = new MageInt(1); + this.toughness = new MageInt(3); + SpellCastTriggeredAbility ability = new SpellCastTriggeredAbility(new UntapTargetEffect(), filter, true); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public MirranSpy(final MirranSpy card) { + super(card); + } + + @Override + public MirranSpy copy() { + return new MirranSpy(this); + } +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java index c2054517497..761a6447846 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java @@ -32,9 +32,11 @@ import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; import mage.MageInt; -import mage.abilities.common.InstantOrSorceryCastTriggeredAbility; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.cards.CardImpl; +import mage.filter.Filter.ComparisonScope; +import mage.filter.FilterCard; /** * @@ -42,6 +44,13 @@ import mage.cards.CardImpl; */ public class KilnFiend extends CardImpl { + private static final FilterCard filter = new FilterCard("an instant or sorcery spell"); + static { + filter.getCardType().add(CardType.INSTANT); + filter.getCardType().add(CardType.SORCERY); + filter.setScopeCardType(ComparisonScope.Any); + } + public KilnFiend(UUID ownerId) { super(ownerId, 153, "Kiln Fiend", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{R}"); this.expansionSetCode = "ROE"; @@ -52,7 +61,7 @@ public class KilnFiend extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(2); - this.addAbility(new InstantOrSorceryCastTriggeredAbility(new BoostSourceEffect(3, 0, Duration.EndOfTurn), false)); + this.addAbility(new SpellCastTriggeredAbility(new BoostSourceEffect(3, 0, Duration.EndOfTurn), filter, false)); } public KilnFiend(final KilnFiend card) { diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Embersmith.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Embersmith.java index 7992cade83c..39652c3f83f 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Embersmith.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Embersmith.java @@ -32,37 +32,40 @@ import java.util.UUID; import mage.Constants; import mage.Constants.CardType; -import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.game.stack.Spell; import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; /** - * @author Loki + * @author Loki, North */ public class Embersmith extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public Embersmith(UUID ownerId) { super(ownerId, 87, "Embersmith", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{R}"); this.expansionSetCode = "SOM"; this.subtype.add("Human"); this.subtype.add("Artificer"); + this.color.setRed(true); this.power = new MageInt(2); this.toughness = new MageInt(1); - this.addAbility(new EmbersmithTriggeredAbility()); + + SpellCastTriggeredAbility ability = new SpellCastTriggeredAbility(new EmbersmithEffect(), filter, false); + ability.addTarget(new TargetCreatureOrPlayer()); + this.addAbility(ability); } public Embersmith(final Embersmith card) { @@ -76,38 +79,6 @@ public class Embersmith extends CardImpl { } -class EmbersmithTriggeredAbility extends TriggeredAbilityImpl { - EmbersmithTriggeredAbility() { - super(Constants.Zone.BATTLEFIELD, new EmbersmithEffect()); - this.addTarget(new TargetCreatureOrPlayer()); - } - - EmbersmithTriggeredAbility(final EmbersmithTriggeredAbility ability) { - super(ability); - } - - @Override - public EmbersmithTriggeredAbility copy() { - return new EmbersmithTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may pay {1}. If you do, Embersmith deals 1 damage to target creature or player."; - } -} - class EmbersmithEffect extends OneShotEffect { EmbersmithEffect() { super(Constants.Outcome.Damage); diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java index 8094747a16a..b5c13829bf1 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java @@ -33,28 +33,29 @@ import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.CreateTokenEffect; import mage.cards.CardImpl; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.events.GameEvent; +import mage.filter.common.FilterArtifactCard; import mage.game.permanent.token.Token; -import mage.game.stack.Spell; /** * - * @author Loki + * @author Loki, North */ public class GolemFoundry extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public GolemFoundry (UUID ownerId) { super(ownerId, 160, "Golem Foundry", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); this.expansionSetCode = "SOM"; - this.addAbility(new GolemFoundryAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, true)); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new GolemToken()), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance(3)))); } @@ -69,38 +70,6 @@ public class GolemFoundry extends CardImpl { } -class GolemFoundryAbility extends TriggeredAbilityImpl { - - public GolemFoundryAbility() { - super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), true); - } - - public GolemFoundryAbility(final GolemFoundryAbility ability) { - super(ability); - } - - @Override - public GolemFoundryAbility copy() { - return new GolemFoundryAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may put a charge counter on Golem Foundry."; - } -} - class GolemToken extends Token { public GolemToken() { super("Golem", "a 3/3 colorless Golem artifact creature token"); diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/HandOfThePraetors.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/HandOfThePraetors.java index 32a9903ad2d..e442e2347cc 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/HandOfThePraetors.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/HandOfThePraetors.java @@ -35,42 +35,45 @@ import mage.Constants.Duration; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.abilities.keyword.InfectAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.stack.Spell; import mage.target.TargetPlayer; import mage.filter.common.FilterCreaturePermanent; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.continious.BoostControlledEffect; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.AddPoisonCounterTargetEffect; +import mage.filter.common.FilterCreatureCard; /** * - * @author Viserion + * @author Viserion, North */ public class HandOfThePraetors extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with infect"); + private static final FilterCreatureCard filterSpell = new FilterCreatureCard("a creature spell with infect"); static { filter.getAbilities().add(InfectAbility.getInstance()); filter.setNotAbilities(false); + filterSpell.getAbilities().add(InfectAbility.getInstance()); } public HandOfThePraetors (UUID ownerId) { super(ownerId, 66, "Hand of the Praetors", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.expansionSetCode = "SOM"; this.subtype.add("Zombie"); + this.color.setBlack(true); this.power = new MageInt(3); this.toughness = new MageInt(2); + this.addAbility(InfectAbility.getInstance()); - this.addAbility(new HandOfThePraetorsAbility()); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); + SpellCastTriggeredAbility ability = new SpellCastTriggeredAbility(new AddPoisonCounterTargetEffect(1), filterSpell, true); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); } public HandOfThePraetors (final HandOfThePraetors card) { @@ -83,37 +86,3 @@ public class HandOfThePraetors extends CardImpl { } } - -class HandOfThePraetorsAbility extends TriggeredAbilityImpl { - - public HandOfThePraetorsAbility() { - super(Zone.BATTLEFIELD, new AddPoisonCounterTargetEffect(1), true); - - this.addTarget(new TargetPlayer()); - } - - public HandOfThePraetorsAbility(final HandOfThePraetorsAbility ability) { - super(ability); - } - - @Override - public HandOfThePraetorsAbility copy() { - return new HandOfThePraetorsAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.SPELL_CAST) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getAbilities().containsKey(InfectAbility.getInstance().getId()) && spell.getControllerId() == this.controllerId) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast a creature spell with infect, target player gets a poison counter."; - } -} diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/InexorableTide.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/InexorableTide.java index c6a49626d83..a9b72fbadae 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/InexorableTide.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/InexorableTide.java @@ -30,20 +30,14 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; import mage.Constants.CardType; -import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.Constants.Zone; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.counter.ProliferateEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; /** * - * @author Loki + * @author Loki, North */ public class InexorableTide extends CardImpl { @@ -51,7 +45,8 @@ public class InexorableTide extends CardImpl { super(ownerId, 35, "Inexorable Tide", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}"); this.expansionSetCode = "SOM"; this.color.setBlue(true); - this.addAbility(new InexorableTideAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new ProliferateEffect(), false)); } public InexorableTide (final InexorableTide card) { @@ -64,34 +59,3 @@ public class InexorableTide extends CardImpl { } } - -class InexorableTideAbility extends TriggeredAbilityImpl { - public InexorableTideAbility() { - super(Zone.BATTLEFIELD, new ProliferateEffect(), false); - } - - public InexorableTideAbility(final InexorableTideAbility ability) { - super(ability); - } - - @Override - public InexorableTideAbility copy() { - return new InexorableTideAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && event.getPlayerId().equals(getControllerId())) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast a spell, proliferate."; - } -} diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Lifesmith.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Lifesmith.java index 77e726f19de..30aa122fdd4 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Lifesmith.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Lifesmith.java @@ -35,15 +35,13 @@ import mage.Constants.CardType; import mage.Constants.Rarity; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; import mage.players.Player; /** @@ -52,15 +50,19 @@ import mage.players.Player; */ public class Lifesmith extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public Lifesmith (UUID ownerId) { super(ownerId, 124, "Lifesmith", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.expansionSetCode = "SOM"; this.subtype.add("Human"); this.subtype.add("Artificer"); + this.color.setGreen(true); this.power = new MageInt(2); this.toughness = new MageInt(1); - this.addAbility(new LifesmithTriggeredAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new LifesmithEffect(), filter, false)); } public Lifesmith (final Lifesmith card) { @@ -73,38 +75,6 @@ public class Lifesmith extends CardImpl { } } -class LifesmithTriggeredAbility extends TriggeredAbilityImpl { - public LifesmithTriggeredAbility() { - super(Constants.Zone.BATTLEFIELD, new LifesmithEffect()); - - } - - public LifesmithTriggeredAbility(final LifesmithTriggeredAbility ability) { - super(ability); - } - - @Override - public LifesmithTriggeredAbility copy() { - return new LifesmithTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may pay {1}. If you do, you gain 3 life."; - } -} - class LifesmithEffect extends OneShotEffect { LifesmithEffect() { super(Constants.Outcome.GainLife); diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Myrsmith.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Myrsmith.java index 73475f18066..ec3f83dc5e3 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Myrsmith.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Myrsmith.java @@ -33,34 +33,36 @@ import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; -import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.token.MyrToken; -import mage.game.stack.Spell; /** * - * @author Loki + * @author Loki, North */ public class Myrsmith extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public Myrsmith (UUID ownerId) { super(ownerId, 16, "Myrsmith", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}"); this.expansionSetCode = "SOM"; this.subtype.add("Human"); this.subtype.add("Artificer"); + this.color.setWhite(true); this.power = new MageInt(2); this.toughness = new MageInt(1); - this.addAbility(new MyrsmithTriggeredAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new MyrsmithEffect(), filter, false)); } public Myrsmith (final Myrsmith card) { @@ -74,38 +76,6 @@ public class Myrsmith extends CardImpl { } -class MyrsmithTriggeredAbility extends TriggeredAbilityImpl { - public MyrsmithTriggeredAbility() { - super(Zone.BATTLEFIELD, new MyrsmithEffect()); - - } - - public MyrsmithTriggeredAbility(final MyrsmithTriggeredAbility ability) { - super(ability); - } - - @Override - public MyrsmithTriggeredAbility copy() { - return new MyrsmithTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may pay {1}. If you do, put a 1/1 colorless Myr artifact creature token onto the battlefield."; - } -} - class MyrsmithEffect extends OneShotEffect { public MyrsmithEffect() { super(Constants.Outcome.PutCreatureInPlay); @@ -132,6 +102,6 @@ class MyrsmithEffect extends OneShotEffect { @Override public String getText(Ability source) { - return "You may pay {1}. If you do, put a 1/1 colorless Myr artifact creature token onto the battlefield"; + return "you may pay {1}. If you do, put a 1/1 colorless Myr artifact creature token onto the battlefield"; } } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Painsmith.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Painsmith.java index 6d0ac2ce6da..1121eb6320a 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Painsmith.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Painsmith.java @@ -33,33 +33,37 @@ import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.abilities.effects.common.continious.GainAbilityTargetEffect; import mage.abilities.keyword.DeathtouchAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; +import mage.filter.common.FilterArtifactCard; import mage.target.common.TargetCreaturePermanent; /** * - * @author Loki + * @author Loki, North */ public class Painsmith extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public Painsmith (UUID ownerId) { super(ownerId, 74, "Painsmith", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{B}"); this.expansionSetCode = "SOM"; this.subtype.add("Human"); this.subtype.add("Artificer"); + this.color.setBlack(true); this.power = new MageInt(2); this.toughness = new MageInt(1); - this.addAbility(new PainsmithTriggeredAbility()); + + SpellCastTriggeredAbility ability = new SpellCastTriggeredAbility(new BoostTargetEffect(2, 0, Duration.EndOfTurn), filter, true); + ability.addEffect(new GainAbilityTargetEffect(DeathtouchAbility.getInstance(), Duration.EndOfTurn)); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); } public Painsmith (final Painsmith card) { @@ -71,36 +75,3 @@ public class Painsmith extends CardImpl { return new Painsmith(this); } } - -class PainsmithTriggeredAbility extends TriggeredAbilityImpl { - public PainsmithTriggeredAbility() { - super(Zone.BATTLEFIELD, new BoostTargetEffect(2, 0, Duration.EndOfTurn)); - this.addEffect(new GainAbilityTargetEffect(DeathtouchAbility.getInstance(), Duration.EndOfTurn)); - this.addTarget(new TargetCreaturePermanent()); - } - - public PainsmithTriggeredAbility(final PainsmithTriggeredAbility ability) { - super(ability); - } - - @Override - public PainsmithTriggeredAbility copy() { - return new PainsmithTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may have target creature get +2/+0 and gain deathtouch until end of turn."; - } -} diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Riddlesmith.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Riddlesmith.java index 84343d24402..3a58481a596 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Riddlesmith.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Riddlesmith.java @@ -30,32 +30,33 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SpellCastTriggeredAbility; import mage.abilities.effects.common.DrawDiscardControllerEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; +import mage.filter.common.FilterArtifactCard; /** * - * @author Loki + * @author Loki, North */ public class Riddlesmith extends CardImpl { + private static final FilterArtifactCard filter = new FilterArtifactCard("an artifact spell"); + public Riddlesmith (UUID ownerId) { super(ownerId, 40, "Riddlesmith", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.expansionSetCode = "SOM"; this.subtype.add("Human"); this.subtype.add("Artificer"); + this.color.setBlue(true); this.power = new MageInt(2); this.toughness = new MageInt(1); - this.addAbility(new RiddlesmithTriggeredAbility()); + + this.addAbility(new SpellCastTriggeredAbility(new DrawDiscardControllerEffect(), filter, true)); } public Riddlesmith (final Riddlesmith card) { @@ -68,35 +69,3 @@ public class Riddlesmith extends CardImpl { } } - -class RiddlesmithTriggeredAbility extends TriggeredAbilityImpl { - public RiddlesmithTriggeredAbility() { - super(Constants.Zone.BATTLEFIELD, new DrawDiscardControllerEffect(), true); - - } - - public RiddlesmithTriggeredAbility(final RiddlesmithTriggeredAbility ability) { - super(ability); - } - - @Override - public RiddlesmithTriggeredAbility copy() { - return new RiddlesmithTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever you cast an artifact spell, you may draw a card. If you do, discard a card."; - } -} \ No newline at end of file diff --git a/Mage/src/mage/abilities/common/SpellCastTriggeredAbility.java b/Mage/src/mage/abilities/common/SpellCastTriggeredAbility.java new file mode 100644 index 00000000000..d8104158179 --- /dev/null +++ b/Mage/src/mage/abilities/common/SpellCastTriggeredAbility.java @@ -0,0 +1,82 @@ +/* + * 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.common; + +import mage.Constants.Zone; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; + +/** + * + * @author North + */ +public class SpellCastTriggeredAbility extends TriggeredAbilityImpl { + + private static final FilterCard spellCard = new FilterCard("a spell"); + protected FilterCard filter; + + public SpellCastTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + this.filter = spellCard; + } + + public SpellCastTriggeredAbility(Effect effect, FilterCard filter, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + this.filter = filter; + } + + public SpellCastTriggeredAbility(final SpellCastTriggeredAbility ability) { + super(ability); + filter = ability.filter; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null && filter.match(spell)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever you cast " + filter.getMessage() + ", " + super.getRule(); + } + + @Override + public SpellCastTriggeredAbility copy() { + return new SpellCastTriggeredAbility(this); + } +} \ No newline at end of file