From fed8463d76e0ac0424fdc41ee319c5b7bf711257 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 16 Sep 2015 17:36:32 +0200 Subject: [PATCH] Some fixes to shown player messages. Added an effect to add counters to permanents entering the battlefield (e.g. Protean Hydra). --- .../mage/sets/dragonsmaze/RenderSilent.java | 7 +- .../src/mage/sets/eventide/Moonhold.java | 5 +- .../src/mage/sets/magic2010/ProteanHydra.java | 42 +-------- .../src/mage/sets/magic2010/Silence.java | 13 ++- .../magicorigins/AlhammarretHighArbiter.java | 2 +- .../mirrodinbesieged/HeroOfOxidRidge.java | 11 +-- .../src/mage/sets/odyssey/CeaseFire.java | 7 +- .../src/mage/sets/odyssey/PardicMiner.java | 4 +- .../sets/planarchaos/VoidstoneGargoyle.java | 13 +-- .../mage/sets/planechase/IvyElemental.java | 47 +--------- .../src/mage/sets/tempest/HandToHand.java | 2 +- .../sets/timespiral/TeferiMageOfZhalfir.java | 14 ++- .../src/mage/sets/visions/Solfatara.java | 6 +- .../src/mage/sets/weatherlight/Abeyance.java | 4 +- .../sets/zendikar/IonaShieldOfEmeria.java | 8 +- .../EntersBattlefieldWithXCountersEffect.java | 85 +++++++++++++++++++ 16 files changed, 133 insertions(+), 137 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/RenderSilent.java b/Mage.Sets/src/mage/sets/dragonsmaze/RenderSilent.java index 052fb39480..7d819e8b6f 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/RenderSilent.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/RenderSilent.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.dragonsmaze; import java.util.UUID; @@ -52,11 +51,10 @@ import mage.target.targetpointer.FixedTarget; * * @author LevelX2 */ - - public class RenderSilent extends CardImpl { private static final FilterControlledPermanent filter = new FilterControlledPermanent("multicolored permanent"); + static { filter.add(new MulticoloredPredicate()); } @@ -65,7 +63,6 @@ public class RenderSilent extends CardImpl { super(ownerId, 96, "Render Silent", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{W}{U}{U}"); this.expansionSetCode = "DGM"; - // Counter target spell. Its controller can't cast spells this turn. this.getSpellAbility().addEffect(new RenderSilentCounterEffect()); this.getSpellAbility().addTarget(new TargetSpell()); @@ -139,7 +136,7 @@ class RenderSilentEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't cast spells this turn (" + mageObject.getLogName() + ")."; + return "You can't cast spells this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/eventide/Moonhold.java b/Mage.Sets/src/mage/sets/eventide/Moonhold.java index 25d6d5105f..acb45b4cbe 100644 --- a/Mage.Sets/src/mage/sets/eventide/Moonhold.java +++ b/Mage.Sets/src/mage/sets/eventide/Moonhold.java @@ -58,7 +58,6 @@ public class Moonhold extends CardImpl { super(ownerId, 143, "Moonhold", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{R/W}"); this.expansionSetCode = "EVE"; - // Target player can't play land cards this turn if {R} was spent to cast Moonhold and can't play creature cards this turn if {W} was spent to cast it. ContinuousRuleModifyingEffect effect = new MoonholdEffect(); ContinuousRuleModifyingEffect effect2 = new MoonholdEffect2(); @@ -109,7 +108,7 @@ class MoonholdEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "you can't play land cards this turn (" + mageObject.getLogName() + ")."; + return "you can't play land cards this turn (" + mageObject.getIdName() + ")."; } return null; } @@ -152,7 +151,7 @@ class MoonholdEffect2 extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't play creature cards this turn (" + mageObject.getLogName() + ")."; + return "You can't play creature cards this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java b/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java index e84b732672..c036b45ee5 100644 --- a/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java +++ b/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java @@ -31,20 +31,17 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; -import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.EntersBattlefieldEffect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.PreventionEffectData; import mage.abilities.effects.PreventionEffectImpl; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; 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.counters.CounterType; @@ -68,7 +65,7 @@ public class ProteanHydra extends CardImpl { this.toughness = new MageInt(0); // Protean Hydra enters the battlefield with X +1/+1 counters on it. - this.addAbility(new EntersBattlefieldAbility(new ProteanHydraEffect1(), "with X +1/+1 counters on it")); + this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance()))); // If damage would be dealt to Protean Hydra, prevent that damage and remove that many +1/+1 counters from it. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ProteanHydraEffect2())); @@ -87,41 +84,6 @@ public class ProteanHydra extends CardImpl { return new ProteanHydra(this); } - class ProteanHydraEffect1 extends OneShotEffect { - - public ProteanHydraEffect1() { - super(Outcome.BoostCreature); - staticText = "{this} enters the battlefield with X +1/+1 counters on it"; - } - - public ProteanHydraEffect1(final ProteanHydraEffect1 effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); - if (spellAbility != null - && spellAbility.getSourceId().equals(source.getSourceId()) - && permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) { - int amount = spellAbility.getManaCostsToPay().getX(); - if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); - } - } - } - return true; - } - - @Override - public ProteanHydraEffect1 copy() { - return new ProteanHydraEffect1(this); - } - - } - class ProteanHydraEffect2 extends PreventionEffectImpl { public ProteanHydraEffect2() { diff --git a/Mage.Sets/src/mage/sets/magic2010/Silence.java b/Mage.Sets/src/mage/sets/magic2010/Silence.java index 4637cd9f97..4d801a75d4 100644 --- a/Mage.Sets/src/mage/sets/magic2010/Silence.java +++ b/Mage.Sets/src/mage/sets/magic2010/Silence.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,12 +20,11 @@ * 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.magic2010; import java.util.UUID; @@ -90,7 +89,7 @@ class SilenceEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't cast spells this turn (" + mageObject.getLogName() + ")."; + return "You can't cast spells this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/magicorigins/AlhammarretHighArbiter.java b/Mage.Sets/src/mage/sets/magicorigins/AlhammarretHighArbiter.java index a3ffd5c8fb..3ae24d013b 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/AlhammarretHighArbiter.java +++ b/Mage.Sets/src/mage/sets/magicorigins/AlhammarretHighArbiter.java @@ -166,7 +166,7 @@ class AlhammarretHighArbiterCantCastEffect extends ContinuousRuleModifyingEffect public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You may not cast a card named " + cardName + " (" + mageObject.getLogName() + ")."; + return "You may not cast a card named " + cardName + " (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/HeroOfOxidRidge.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/HeroOfOxidRidge.java index a05107e267..30ed390b48 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/HeroOfOxidRidge.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/HeroOfOxidRidge.java @@ -25,13 +25,9 @@ * 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.Duration; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; @@ -39,6 +35,9 @@ import mage.abilities.effects.RestrictionEffect; import mage.abilities.keyword.BattleCryAbility; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; import mage.game.Game; import mage.game.permanent.Permanent; @@ -91,9 +90,7 @@ class HeroOfOxidRidgeEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getPower().getValue() <= 1) - return true; - return false; + return permanent.getPower().getValue() <= 1; } @Override diff --git a/Mage.Sets/src/mage/sets/odyssey/CeaseFire.java b/Mage.Sets/src/mage/sets/odyssey/CeaseFire.java index 46fb361dec..e10245abbe 100644 --- a/Mage.Sets/src/mage/sets/odyssey/CeaseFire.java +++ b/Mage.Sets/src/mage/sets/odyssey/CeaseFire.java @@ -31,7 +31,6 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -55,11 +54,10 @@ public class CeaseFire extends CardImpl { super(ownerId, 14, "Cease-Fire", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{W}"); this.expansionSetCode = "ODY"; - // Target player can't cast creature spells this turn. this.getSpellAbility().addEffect(new CeaseFireEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - + // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); } @@ -77,6 +75,7 @@ public class CeaseFire extends CardImpl { class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl { private static final FilterSpell filter = new FilterSpell(); + static { filter.add(new CardTypePredicate(CardType.CREATURE)); } @@ -104,7 +103,7 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't cast creature spells this turn (" + mageObject.getLogName() + ")."; + return "You can't cast creature spells this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java b/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java index 3dcbfb8222..4287532766 100644 --- a/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java +++ b/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java @@ -75,7 +75,7 @@ public class PardicMiner extends CardImpl { } class PardicMinerEffect extends ContinuousRuleModifyingEffectImpl { - + public PardicMinerEffect() { super(Duration.EndOfTurn, Outcome.Detriment); staticText = "Target player can't play lands this turn."; @@ -99,7 +99,7 @@ class PardicMinerEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't play lands this turn (" + mageObject.getLogName() + ")."; + return "You can't play lands this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java b/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java index 76bc947d8e..9292efe16a 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java +++ b/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java @@ -28,8 +28,6 @@ package mage.sets.planarchaos; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -42,6 +40,11 @@ import mage.cards.CardImpl; import mage.cards.repository.CardRepository; import mage.choices.Choice; import mage.choices.ChoiceImpl; +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.game.events.GameEvent.EventType; @@ -110,9 +113,9 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect { String cardName = cardChoice.getChoice(); game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]"); game.getState().setValue(source.getSourceId().toString(), cardName); - permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"), game); + permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName + "]"), game); return true; - } + } return false; } @@ -148,7 +151,7 @@ class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifyingEffectI public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't cast a card with that name (" + mageObject.getLogName() + ")."; + return "You can't cast a card with that name (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/planechase/IvyElemental.java b/Mage.Sets/src/mage/sets/planechase/IvyElemental.java index 757482edb4..acda1a8a75 100644 --- a/Mage.Sets/src/mage/sets/planechase/IvyElemental.java +++ b/Mage.Sets/src/mage/sets/planechase/IvyElemental.java @@ -29,18 +29,12 @@ package mage.sets.planechase; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.SpellAbility; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.effects.EntersBattlefieldEffect; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -57,7 +51,7 @@ public class IvyElemental extends CardImpl { this.toughness = new MageInt(0); // Ivy Elemental enters the battlefield with X +1/+1 counters on it. - this.addAbility(new EntersBattlefieldAbility(new IvyElementalEntersBattlefieldEffect(), "with X +1/+1 counters on it")); + this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance()))); } public IvyElemental(final IvyElemental card) { @@ -69,40 +63,3 @@ public class IvyElemental extends CardImpl { return new IvyElemental(this); } } - -class IvyElementalEntersBattlefieldEffect extends OneShotEffect { - - public IvyElementalEntersBattlefieldEffect() { - super(Outcome.BoostCreature); - staticText = "{this} enters the battlefield with X +1/+1 counters on it"; - } - - public IvyElementalEntersBattlefieldEffect(final IvyElementalEntersBattlefieldEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); - if (spellAbility != null - && spellAbility.getSourceId().equals(source.getSourceId()) - && permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) { - if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast - int amount = spellAbility.getManaCostsToPay().getX(); - if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); - } - } - } - } - return true; - } - - @Override - public IvyElementalEntersBattlefieldEffect copy() { - return new IvyElementalEntersBattlefieldEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/tempest/HandToHand.java b/Mage.Sets/src/mage/sets/tempest/HandToHand.java index 0e6ce50ad7..d3e4984f67 100644 --- a/Mage.Sets/src/mage/sets/tempest/HandToHand.java +++ b/Mage.Sets/src/mage/sets/tempest/HandToHand.java @@ -92,7 +92,7 @@ class HandToHandEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "During combat, players can't cast instant spells or activate abilities that aren't mana abilities (" + mageObject.getLogName() + ")."; + return "During combat, players can't cast instant spells or activate abilities that aren't mana abilities (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java b/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java index 26395fa7c3..8e58dc1c9b 100644 --- a/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java +++ b/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java @@ -73,7 +73,6 @@ public class TeferiMageOfZhalfir extends CardImpl { // Each opponent can cast spells only any time he or she could cast a sorcery. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new TeferiMageOfZhalfirReplacementEffect())); - } public TeferiMageOfZhalfir(final TeferiMageOfZhalfir card) { @@ -107,31 +106,31 @@ class TeferiMageOfZhalfirAddFlashEffect extends ContinuousEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { // in graveyard - for (UUID cardId: controller.getGraveyard()) { + for (UUID cardId : controller.getGraveyard()) { Card card = game.getCard(cardId); if (card.getCardType().contains(CardType.CREATURE)) { game.getState().addOtherAbility(card, FlashAbility.getInstance()); } } // on Hand - for (UUID cardId: controller.getHand()) { + for (UUID cardId : controller.getHand()) { Card card = game.getCard(cardId); if (card.getCardType().contains(CardType.CREATURE)) { game.getState().addOtherAbility(card, FlashAbility.getInstance()); } } // in Exile - for (Card card: game.getState().getExile().getAllCards(game)) { + for (Card card : game.getState().getExile().getAllCards(game)) { if (card.getOwnerId().equals(controller.getId()) && card.getCardType().contains(CardType.CREATURE)) { game.getState().addOtherAbility(card, FlashAbility.getInstance()); } } // in Library (e.g. for Mystical Teachings) - for (Card card: controller.getLibrary().getCards(game)) { + for (Card card : controller.getLibrary().getCards(game)) { if (card.getOwnerId().equals(controller.getId()) && card.getCardType().contains(CardType.CREATURE)) { game.getState().addOtherAbility(card, FlashAbility.getInstance()); } - } + } // commander in command zone if (controller.getCommanderId() != null && game.getState().getZone(controller.getCommanderId()).equals(Zone.COMMAND)) { Card card = game.getCard(controller.getCommanderId()); @@ -160,7 +159,7 @@ class TeferiMageOfZhalfirReplacementEffect extends ContinuousRuleModifyingEffect public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can cast spells only any time you could cast a sorcery (" + mageObject.getLogName() + ")."; + return "You can cast spells only any time you could cast a sorcery (" + mageObject.getIdName() + ")."; } return null; } @@ -170,7 +169,6 @@ class TeferiMageOfZhalfirReplacementEffect extends ContinuousRuleModifyingEffect return event.getType() == GameEvent.EventType.CAST_SPELL; } - @Override public boolean applies(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/sets/visions/Solfatara.java b/Mage.Sets/src/mage/sets/visions/Solfatara.java index 293563acd9..53ec304a50 100644 --- a/Mage.Sets/src/mage/sets/visions/Solfatara.java +++ b/Mage.Sets/src/mage/sets/visions/Solfatara.java @@ -56,7 +56,7 @@ public class Solfatara extends CardImpl { // Target player can't play land cards this turn. this.getSpellAbility().addEffect(new SolfataraEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - + // Draw a card at the beginning of the next turn's upkeep. this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect( new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1), Duration.OneUse), false)); @@ -73,7 +73,7 @@ public class Solfatara extends CardImpl { } class SolfataraEffect extends ContinuousRuleModifyingEffectImpl { - + public SolfataraEffect() { super(Duration.EndOfTurn, Outcome.Detriment); staticText = "Target player can't play land cards this turn."; @@ -97,7 +97,7 @@ class SolfataraEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't play lands this turn (" + mageObject.getLogName() + ")."; + return "You can't play lands this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/weatherlight/Abeyance.java b/Mage.Sets/src/mage/sets/weatherlight/Abeyance.java index fe3b4d4f6e..4a48d8daa7 100644 --- a/Mage.Sets/src/mage/sets/weatherlight/Abeyance.java +++ b/Mage.Sets/src/mage/sets/weatherlight/Abeyance.java @@ -55,7 +55,7 @@ public class Abeyance extends CardImpl { // Until end of turn, target player can't cast instant or sorcery spells, and that player can't activate abilities that aren't mana abilities. this.getSpellAbility().addEffect(new AbeyanceEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - + // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); } @@ -95,7 +95,7 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't cast instant or sorcery spells or activate abilities that aren't mana abilities this turn (" + mageObject.getLogName() + ")."; + return "You can't cast instant or sorcery spells or activate abilities that aren't mana abilities this turn (" + mageObject.getIdName() + ")."; } return null; } diff --git a/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java b/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java index 91fc8f2419..ae55b9d3e5 100644 --- a/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java +++ b/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java @@ -99,7 +99,7 @@ class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifyingEffectI ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null && chosenColor != null) { - return "You can't cast " + chosenColor.toString() +" spells (" + mageObject.getLogName() + ")."; + return "You can't cast " + chosenColor.toString() + " spells (" + mageObject.getIdName() + ")."; } return null; } @@ -107,11 +107,11 @@ class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifyingEffectI @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 (game.getOpponents(source.getControllerId()).contains(event.getPlayerId()) ) { + if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); // spell is not on the stack yet, so we have to check the card Card card = game.getCard(event.getSourceId()); diff --git a/Mage/src/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java b/Mage/src/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java new file mode 100644 index 0000000000..999e70423d --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java @@ -0,0 +1,85 @@ +/* + * 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; + +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.counters.Counter; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * Use this effect only (I guess) with EntersBattlefieldAbility like abilities + * + * @author LevelX2 + */ +public class EntersBattlefieldWithXCountersEffect extends OneShotEffect { + + protected final Counter counter; + + public EntersBattlefieldWithXCountersEffect(Counter counter) { + super(Outcome.BoostCreature); + this.counter = counter; + staticText = "with X " + counter.getName() + " counters on it"; + } + + public EntersBattlefieldWithXCountersEffect(final EntersBattlefieldWithXCountersEffect effect) { + super(effect); + this.counter = effect.counter; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); + if (spellAbility != null + && spellAbility.getSourceId().equals(source.getSourceId()) + && permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) { + if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast + int amount = spellAbility.getManaCostsToPay().getX(); + if (amount > 0) { + Counter counterToAdd = counter.copy(); + counterToAdd.add(amount - counter.getCount()); + permanent.addCounters(counterToAdd, game); + } + } + } + } + return true; + } + + @Override + public EntersBattlefieldWithXCountersEffect copy() { + return new EntersBattlefieldWithXCountersEffect(this); + } + +}