From 2080ad3ab85644e386f68a165cccc0e3d223fade Mon Sep 17 00:00:00 2001 From: LoneFox Date: Wed, 4 Nov 2015 10:40:07 +0200 Subject: [PATCH] Add CastOnlyIfYouHaveCastAnotherSpellEffect and use it for existing cards. Implement card: Skyshroud Condor --- .../fatereforged/HewedStoneRetainers.java | 47 +---------- .../sets/planechase2012/IllusoryAngel.java | 51 ++---------- .../mage/sets/tempest/SkyshroudCondor.java | 67 ++++++++++++++++ ...stOnlyIfYouHaveCastAnotherSpellEffect.java | 79 +++++++++++++++++++ 4 files changed, 153 insertions(+), 91 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/tempest/SkyshroudCondor.java create mode 100644 Mage/src/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java diff --git a/Mage.Sets/src/mage/sets/fatereforged/HewedStoneRetainers.java b/Mage.Sets/src/mage/sets/fatereforged/HewedStoneRetainers.java index 4a9df6b278..8d2e26b6d0 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/HewedStoneRetainers.java +++ b/Mage.Sets/src/mage/sets/fatereforged/HewedStoneRetainers.java @@ -29,18 +29,12 @@ package mage.sets.fatereforged; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.common.ruleModifying.CastOnlyIfYouHaveCastAnotherSpellEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.watchers.common.CastSpellLastTurnWatcher; /** * @@ -56,7 +50,7 @@ public class HewedStoneRetainers extends CardImpl { this.toughness = new MageInt(4); // Cast Hewed Stone Retainers only if you've cast another spell this turn. - this.addAbility(new SimpleStaticAbility(Zone.ALL, new HewedStoneRetainersEffect())); + this.addAbility(new SimpleStaticAbility(Zone.ALL, new CastOnlyIfYouHaveCastAnotherSpellEffect())); } public HewedStoneRetainers(final HewedStoneRetainers card) { @@ -69,40 +63,3 @@ public class HewedStoneRetainers extends CardImpl { } } -class HewedStoneRetainersEffect extends ContinuousRuleModifyingEffectImpl { - HewedStoneRetainersEffect() { - super(Duration.EndOfGame, Outcome.Detriment); - staticText = "Cast {this} only if you've cast another spell this turn"; - } - - HewedStoneRetainersEffect(final HewedStoneRetainersEffect effect) { - super(effect); - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.CAST_SPELL; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getSourceId().equals(source.getSourceId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); - if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { - return true; - } - } - return false; - - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public HewedStoneRetainersEffect copy() { - return new HewedStoneRetainersEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/planechase2012/IllusoryAngel.java b/Mage.Sets/src/mage/sets/planechase2012/IllusoryAngel.java index 81f8242dc1..b7038bd470 100644 --- a/Mage.Sets/src/mage/sets/planechase2012/IllusoryAngel.java +++ b/Mage.Sets/src/mage/sets/planechase2012/IllusoryAngel.java @@ -28,21 +28,14 @@ package mage.sets.planechase2012; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.ruleModifying.CastOnlyIfYouHaveCastAnotherSpellEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.watchers.common.CastSpellLastTurnWatcher; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; /** * @@ -55,7 +48,6 @@ public class IllusoryAngel extends CardImpl { this.expansionSetCode = "PC2"; this.subtype.add("Angel"); this.subtype.add("Illusion"); - this.power = new MageInt(4); this.toughness = new MageInt(4); @@ -63,7 +55,7 @@ public class IllusoryAngel extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Cast Illusory Angel only if you've cast another spell this turn. - this.addAbility(new SimpleStaticAbility(Zone.ALL, new IllusoryAngelEffect())); + this.addAbility(new SimpleStaticAbility(Zone.ALL, new CastOnlyIfYouHaveCastAnotherSpellEffect())); } public IllusoryAngel(final IllusoryAngel card) { @@ -75,36 +67,3 @@ public class IllusoryAngel extends CardImpl { return new IllusoryAngel(this); } } - -class IllusoryAngelEffect extends ContinuousRuleModifyingEffectImpl { - IllusoryAngelEffect() { - super(Duration.EndOfGame, Outcome.Detriment); - staticText = "Cast {this} only if you've cast another spell this turn"; - } - - IllusoryAngelEffect(final IllusoryAngelEffect effect) { - super(effect); - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.CAST_SPELL; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getSourceId().equals(source.getSourceId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); - if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { - return true; - } - } - return false; - - } - - @Override - public IllusoryAngelEffect copy() { - return new IllusoryAngelEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/tempest/SkyshroudCondor.java b/Mage.Sets/src/mage/sets/tempest/SkyshroudCondor.java new file mode 100644 index 0000000000..79ba487f4d --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/SkyshroudCondor.java @@ -0,0 +1,67 @@ +/* + * 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.tempest; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.ruleModifying.CastOnlyIfYouHaveCastAnotherSpellEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; + +/** + * + * @author LoneFox + */ +public class SkyshroudCondor extends CardImpl { + + public SkyshroudCondor(UUID ownerId) { + super(ownerId, 88, "Skyshroud Condor", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}"); + this.expansionSetCode = "TMP"; + this.subtype.add("Bird"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + // Cast Skyshroud Condor only if you've cast another spell this turn. + this.addAbility(new SimpleStaticAbility(Zone.ALL, new CastOnlyIfYouHaveCastAnotherSpellEffect())); + } + + public SkyshroudCondor(final SkyshroudCondor card) { + super(card); + } + + @Override + public SkyshroudCondor copy() { + return new SkyshroudCondor(this); + } +} diff --git a/Mage/src/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java b/Mage/src/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java new file mode 100644 index 0000000000..072e2360ef --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java @@ -0,0 +1,79 @@ +/* + * 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.effects.common.ruleModifying; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.common.CastSpellLastTurnWatcher; + +/** + * + * @author LoneFox + */ + +public class CastOnlyIfYouHaveCastAnotherSpellEffect extends ContinuousRuleModifyingEffectImpl { + public CastOnlyIfYouHaveCastAnotherSpellEffect() { + super(Duration.EndOfGame, Outcome.Detriment); + staticText = "Cast {this} only if you've cast another spell this turn"; + } + + public CastOnlyIfYouHaveCastAnotherSpellEffect(final CastOnlyIfYouHaveCastAnotherSpellEffect effect) { + super(effect); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CAST_SPELL; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getSourceId().equals(source.getSourceId())) { + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); + if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { + return true; + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public CastOnlyIfYouHaveCastAnotherSpellEffect copy() { + return new CastOnlyIfYouHaveCastAnotherSpellEffect(this); + } +}