Added Mirran Spy.

Added SpellCastTriggeredAbility
Refactored cards to use SpellCastTriggeredAbility
This commit is contained in:
North 2011-06-23 07:40:14 +03:00
parent 8cdc679cbd
commit 581d8eb099
12 changed files with 239 additions and 433 deletions

View file

@ -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<SigilOfTheEmptyThrone> {
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<SigilOfTheEmptyThrone> {
}
class SigilOfTheEmptyThroneAbility extends TriggeredAbilityImpl<SigilOfTheEmptyThroneAbility> {
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");

View file

@ -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<InstantOrSorceryCastTriggeredAbility> {
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<MirranSpy> {
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);
}
}

View file

@ -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<KilnFiend> {
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<KilnFiend> {
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) {

View file

@ -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<Embersmith> {
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<Embersmith> {
}
class EmbersmithTriggeredAbility extends TriggeredAbilityImpl<EmbersmithTriggeredAbility> {
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> {
EmbersmithEffect() {
super(Constants.Outcome.Damage);

View file

@ -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<GolemFoundry> {
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<GolemFoundry> {
}
class GolemFoundryAbility extends TriggeredAbilityImpl<GolemFoundryAbility> {
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");

View file

@ -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<HandOfThePraetors> {
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<HandOfThePraetors> {
}
}
class HandOfThePraetorsAbility extends TriggeredAbilityImpl<HandOfThePraetorsAbility> {
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.";
}
}

View file

@ -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<InexorableTide> {
@ -51,7 +45,8 @@ public class InexorableTide extends CardImpl<InexorableTide> {
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<InexorableTide> {
}
}
class InexorableTideAbility extends TriggeredAbilityImpl<InexorableTideAbility> {
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.";
}
}

View file

@ -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<Lifesmith> {
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<Lifesmith> {
}
}
class LifesmithTriggeredAbility extends TriggeredAbilityImpl<LifesmithTriggeredAbility> {
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> {
LifesmithEffect() {
super(Constants.Outcome.GainLife);

View file

@ -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<Myrsmith> {
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<Myrsmith> {
}
class MyrsmithTriggeredAbility extends TriggeredAbilityImpl<MyrsmithTriggeredAbility> {
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<MyrsmithEffect> {
public MyrsmithEffect() {
super(Constants.Outcome.PutCreatureInPlay);
@ -132,6 +102,6 @@ class MyrsmithEffect extends OneShotEffect<MyrsmithEffect> {
@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";
}
}

View file

@ -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<Painsmith> {
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<Painsmith> {
return new Painsmith(this);
}
}
class PainsmithTriggeredAbility extends TriggeredAbilityImpl<PainsmithTriggeredAbility> {
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.";
}
}

View file

@ -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<Riddlesmith> {
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<Riddlesmith> {
}
}
class RiddlesmithTriggeredAbility extends TriggeredAbilityImpl<RiddlesmithTriggeredAbility> {
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.";
}
}

View file

@ -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<SpellCastTriggeredAbility> {
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);
}
}