diff --git a/Mage.Sets/src/mage/sets/avacynrestored/ReforgeTheSoul.java b/Mage.Sets/src/mage/sets/avacynrestored/ReforgeTheSoul.java index d59ec802eb4..90ac73de417 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/ReforgeTheSoul.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/ReforgeTheSoul.java @@ -28,20 +28,14 @@ package mage.sets.avacynrestored; import java.util.UUID; -import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardAllEffect; import mage.abilities.effects.common.discard.DiscardHandAllEffect; import mage.abilities.keyword.MiracleAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.game.Game; -import mage.players.Player; /** * @@ -72,38 +66,3 @@ public class ReforgeTheSoul extends CardImpl { return new ReforgeTheSoul(this); } } - -class ReforgeTheSoulEffect extends OneShotEffect { - - public ReforgeTheSoulEffect() { - super(Outcome.DrawCard); - this.staticText = "Each player discards his or her hand, then draws seven cards"; - } - - public ReforgeTheSoulEffect(final ReforgeTheSoulEffect effect) { - super(effect); - } - - @Override - public ReforgeTheSoulEffect copy() { - return new ReforgeTheSoulEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - for (UUID playerId : controller.getInRange()) { - Player player = game.getPlayer(playerId); - if (player != null) { - for (Card card : player.getHand().getCards(game)) { - player.discard(card, source, game); - } - player.drawCards(7, game); - } - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/knightsvsdragons/Ghostfire.java b/Mage.Sets/src/mage/sets/knightsvsdragons/Ghostfire.java index d9afd38ba45..fbe9406fa1f 100644 --- a/Mage.Sets/src/mage/sets/knightsvsdragons/Ghostfire.java +++ b/Mage.Sets/src/mage/sets/knightsvsdragons/Ghostfire.java @@ -28,8 +28,9 @@ package mage.sets.knightsvsdragons; import java.util.UUID; - +import mage.ObjectColor; import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.InfoEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -46,6 +47,9 @@ public class Ghostfire extends CardImpl { this.expansionSetCode = "DDG"; // Ghostfire is colorless. + this.color = new ObjectColor(); + this.getSpellAbility().addEffect(new InfoEffect("{this} is colorless")); + // Ghostfire deals 3 damage to target creature or player. this.getSpellAbility().addEffect(new DamageTargetEffect(3)); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); diff --git a/Mage.Sets/src/mage/sets/tenthedition/DragonsClaw.java b/Mage.Sets/src/mage/sets/tenthedition/DragonsClaw.java index 86a28f2dd3c..918791b2d0f 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/DragonsClaw.java +++ b/Mage.Sets/src/mage/sets/tenthedition/DragonsClaw.java @@ -1,16 +1,16 @@ /* * 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 @@ -20,25 +20,22 @@ * 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.tenthedition; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; -import mage.abilities.TriggeredAbilityImpl; +import mage.ObjectColor; +import mage.abilities.common.SpellCastAllTriggeredAbility; import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.stack.Spell; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.filter.FilterSpell; +import mage.filter.predicate.mageobject.ColorPredicate; /** * @@ -46,10 +43,18 @@ import mage.game.stack.Spell; */ public class DragonsClaw extends CardImpl { + private final static FilterSpell filter = new FilterSpell("a red spell"); + + static { + filter.add(new ColorPredicate(ObjectColor.RED)); + } + public DragonsClaw(UUID ownerId) { super(ownerId, 322, "Dragon's Claw", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "10E"; - this.addAbility(new DragonsClawAbility()); + + // Whenever a player casts a red spell, you may gain 1 life. + this.addAbility(new SpellCastAllTriggeredAbility(new GainLifeEffect(1), filter, true)); } public DragonsClaw(final DragonsClaw card) { @@ -62,36 +67,3 @@ public class DragonsClaw extends CardImpl { } } - -class DragonsClawAbility extends TriggeredAbilityImpl { - - public DragonsClawAbility() { - super(Zone.BATTLEFIELD, new GainLifeEffect(1), true); - } - - public DragonsClawAbility(final DragonsClawAbility ability) { - super(ability); - } - - @Override - public DragonsClawAbility copy() { - return new DragonsClawAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.SPELL_CAST; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - return spell != null && spell.getColor(game).isRed(); - } - - @Override - public String getRule() { - return "Whenever a player casts a red spell, you may gain 1 life."; - } - -} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ColorCausedTriggerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ColorCausedTriggerTest.java new file mode 100644 index 00000000000..29344603010 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ColorCausedTriggerTest.java @@ -0,0 +1,61 @@ +/* + * 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 org.mage.test.cards.triggers; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class ColorCausedTriggerTest extends CardTestPlayerBase { + + @Test + public void testGhostfire() { + // Whenever a player casts a red spell, you may gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Dragon's Claw", 1); + + // Ghostfire deals 3 damage to target creature or player. + addCard(Zone.HAND, playerA, "Ghostfire", 1); // {2}{R} + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ghostfire", playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Ghostfire", 1); + + assertLife(playerA, 20); + assertLife(playerB, 17); + } + +}