From 8ed312e7e94f3bd6baad81d536b918f419e384ec Mon Sep 17 00:00:00 2001 From: LoneFox Date: Thu, 17 Sep 2015 11:37:17 +0300 Subject: [PATCH] Remove some unnecessary custom effects. --- .../src/mage/sets/magic2010/Earthquake.java | 69 +++++------------ .../src/mage/sets/magic2010/MindSpring.java | 52 +++---------- .../src/mage/sets/magic2010/Weakness.java | 76 ++++--------------- .../mage/sets/scarsofmirrodin/GoldenUrn.java | 46 ++--------- .../mage/sets/stronghold/IntruderAlarm.java | 47 ++---------- 5 files changed, 54 insertions(+), 236 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2010/Earthquake.java b/Mage.Sets/src/mage/sets/magic2010/Earthquake.java index b49cd07434..632d7fc611 100644 --- a/Mage.Sets/src/mage/sets/magic2010/Earthquake.java +++ b/Mage.Sets/src/mage/sets/magic2010/Earthquake.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,7 +20,7 @@ * 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. @@ -29,19 +29,15 @@ package mage.sets.magic2010; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.common.DamageEverythingEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AbilityPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; /** * @@ -49,11 +45,18 @@ import mage.players.Player; */ public class Earthquake extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature without flying"); + + static { + filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); + } + public Earthquake(UUID ownerId) { super(ownerId, 134, "Earthquake", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{R}"); this.expansionSetCode = "M10"; - this.getSpellAbility().addEffect(new EarthquakeEffect()); + // Hurricane deals X damage to each creature with flying and each player. + this.getSpellAbility().addEffect(new DamageEverythingEffect(new ManacostVariableValue(), filter)); } public Earthquake(final Earthquake card) { @@ -65,41 +68,3 @@ public class Earthquake extends CardImpl { return new Earthquake(this); } } - -class EarthquakeEffect extends OneShotEffect { - - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - - static { - filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); - } - - public EarthquakeEffect() { - super(Outcome.Damage); - staticText = "{this} deals X damage to each creature without flying and each player"; - } - - public EarthquakeEffect(final EarthquakeEffect effect) { - super(effect); - } - - @Override - public EarthquakeEffect copy() { - return new EarthquakeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = source.getManaCostsToPay().getX(); - for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { - permanent.damage(amount, source.getSourceId(), game, false, true); - } - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { - Player player = game.getPlayer(playerId); - if (player != null) - player.damage(amount, source.getSourceId(), game, false, true); - } - return true; - } - -} diff --git a/Mage.Sets/src/mage/sets/magic2010/MindSpring.java b/Mage.Sets/src/mage/sets/magic2010/MindSpring.java index 72955a428f..db84d2644b 100644 --- a/Mage.Sets/src/mage/sets/magic2010/MindSpring.java +++ b/Mage.Sets/src/mage/sets/magic2010/MindSpring.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,7 +20,7 @@ * 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. @@ -29,14 +29,11 @@ package mage.sets.magic2010; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.players.Player; +import mage.constants.CardType; +import mage.constants.Rarity; /** * @@ -48,7 +45,7 @@ public class MindSpring extends CardImpl { super(ownerId, 64, "Mind Spring", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{U}{U}"); this.expansionSetCode = "M10"; - this.getSpellAbility().addEffect(new MindSpringEffect()); + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(new ManacostVariableValue())); } public MindSpring(final MindSpring card) { @@ -61,32 +58,3 @@ public class MindSpring extends CardImpl { } } - -class MindSpringEffect extends OneShotEffect { - - public MindSpringEffect() { - super(Outcome.DrawCard); - staticText = "Draw X cards"; - } - - public MindSpringEffect(final MindSpringEffect effect) { - super(effect); - } - - @Override - public MindSpringEffect copy() { - return new MindSpringEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int amount = source.getManaCostsToPay().getX(); - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.drawCards(amount, game); - return true; - } - return false; - } - -} diff --git a/Mage.Sets/src/mage/sets/magic2010/Weakness.java b/Mage.Sets/src/mage/sets/magic2010/Weakness.java index 2047968193..a30710683a 100644 --- a/Mage.Sets/src/mage/sets/magic2010/Weakness.java +++ b/Mage.Sets/src/mage/sets/magic2010/Weakness.java @@ -29,21 +29,17 @@ package mage.sets.magic2010; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.SubLayer; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -56,14 +52,16 @@ public class Weakness extends CardImpl { public Weakness(UUID ownerId) { super(ownerId, 121, "Weakness", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{B}"); this.expansionSetCode = "M10"; - this.subtype.add("Aura"); + + // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); - this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature)); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(ability); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WeaknessEffect())); + this.addAbility(ability); + // Enchanted creature gets -2/-1. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(-2, -1, Duration.WhileOnBattlefield))); } public Weakness(final Weakness card) { @@ -75,51 +73,3 @@ public class Weakness extends CardImpl { return new Weakness(this); } } - -class WeaknessEffect extends ContinuousEffectImpl { - - public WeaknessEffect() { - super(Duration.WhileOnBattlefield, Outcome.UnboostCreature); - staticText = "Enchanted creature gets -2/-1"; - } - - public WeaknessEffect(final WeaknessEffect effect) { - super(effect); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null && enchantment.getAttachedTo() != null) { - Permanent creature = game.getPermanent(enchantment.getAttachedTo()); - if (creature != null) { - switch (layer) { - case PTChangingEffects_7: - if (sublayer == SubLayer.ModifyPT_7c) { - creature.addPower(-2); - creature.addToughness(-1); - } - break; - } - return true; - } - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.PTChangingEffects_7; - } - - @Override - public WeaknessEffect copy() { - return new WeaknessEffect(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/GoldenUrn.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/GoldenUrn.java index 96a83ffbe4..b05de39496 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/GoldenUrn.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/GoldenUrn.java @@ -30,23 +30,20 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.CountersCount; +import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; -import mage.constants.Outcome; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.constants.TargetController; +import mage.constants.Zone; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; /** * @@ -58,7 +55,7 @@ public class GoldenUrn extends CardImpl { super(ownerId, 158, "Golden Urn", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{1}"); this.expansionSetCode = "SOM"; this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, true)); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoldenUrnEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainLifeEffect(new CountersCount(CounterType.CHARGE)), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); } @@ -73,34 +70,3 @@ public class GoldenUrn extends CardImpl { } } - -class GoldenUrnEffect extends OneShotEffect { - public GoldenUrnEffect() { - super(Outcome.GainLife); - staticText = "You gain life equal to the number of charge counters on {this}"; - } - - public GoldenUrnEffect(final GoldenUrnEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent p = game.getBattlefield().getPermanent(source.getSourceId()); - Player player = game.getPlayer(source.getControllerId()); - if (p == null) { - p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - } - if (p != null && player != null) { - player.gainLife(p.getCounters().getCount(CounterType.CHARGE), game); - return true; - } - return false; - } - - @Override - public GoldenUrnEffect copy() { - return new GoldenUrnEffect(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/stronghold/IntruderAlarm.java b/Mage.Sets/src/mage/sets/stronghold/IntruderAlarm.java index 2fe7b27984..83e4c1a291 100644 --- a/Mage.Sets/src/mage/sets/stronghold/IntruderAlarm.java +++ b/Mage.Sets/src/mage/sets/stronghold/IntruderAlarm.java @@ -28,18 +28,17 @@ package mage.sets.stronghold; import java.util.UUID; - -import mage.constants.*; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DontUntapInControllersUntapStepAllEffect; +import mage.abilities.effects.common.UntapAllEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; /** * @@ -53,9 +52,9 @@ public class IntruderAlarm extends CardImpl { // Creatures don't untap during their controllers' untap steps. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DontUntapInControllersUntapStepAllEffect(Duration.WhileOnBattlefield, TargetController.ANY, new FilterCreaturePermanent("Creatures")))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DontUntapInControllersUntapStepAllEffect(Duration.WhileOnBattlefield, TargetController.ANY, new FilterCreaturePermanent("creatures")))); // Whenever a creature enters the battlefield, untap all creatures. - this.addAbility(new EntersBattlefieldAllTriggeredAbility(new UntapAllCreatureEffect(), new FilterCreaturePermanent())); + this.addAbility(new EntersBattlefieldAllTriggeredAbility(new UntapAllEffect(new FilterCreaturePermanent("creatures")), new FilterCreaturePermanent("a creature"))); } public IntruderAlarm(final IntruderAlarm card) { @@ -67,33 +66,3 @@ public class IntruderAlarm extends CardImpl { return new IntruderAlarm(this); } } - -class UntapAllCreatureEffect extends OneShotEffect { - - public UntapAllCreatureEffect() { - super(Outcome.Untap); - staticText = "untap all creatures"; - } - - public UntapAllCreatureEffect(final UntapAllCreatureEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - for (Permanent land: game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { - land.untap(game); - } - return true; - } - return false; - } - - @Override - public UntapAllCreatureEffect copy() { - return new UntapAllCreatureEffect(this); - } - -}