From 51c6a89753ea3dc22194009826e5263f4e25444b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 7 Jul 2015 17:09:52 +0200 Subject: [PATCH] * Enshrouding Mist - Fixed that the target creature was not untapped if renowned. --- .../sets/magicorigins/ConsulsLieutenant.java | 4 +- .../sets/magicorigins/EnshroudingMist.java | 11 ++- .../sets/magicorigins/GoblinGloryChaser.java | 4 +- .../sets/magicorigins/HonoredHierarch.java | 6 +- .../sets/magicorigins/ScabClanBerserker.java | 4 +- .../cards/abilities/keywords/RenownTest.java | 35 +++++++++- ...tion.java => RenownedSourceCondition.java} | 12 ++-- .../common/RenownedTargetCondition.java | 67 +++++++++++++++++++ .../mage/abilities/keyword/RenownAbility.java | 16 ++--- Mage/src/mage/game/permanent/Permanent.java | 4 +- .../mage/game/permanent/PermanentImpl.java | 12 ++-- 11 files changed, 135 insertions(+), 40 deletions(-) rename Mage/src/mage/abilities/condition/common/{RenownCondition.java => RenownedSourceCondition.java} (69%) create mode 100644 Mage/src/mage/abilities/condition/common/RenownedTargetCondition.java diff --git a/Mage.Sets/src/mage/sets/magicorigins/ConsulsLieutenant.java b/Mage.Sets/src/mage/sets/magicorigins/ConsulsLieutenant.java index 26befe1d8f4..0359438bf99 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/ConsulsLieutenant.java +++ b/Mage.Sets/src/mage/sets/magicorigins/ConsulsLieutenant.java @@ -30,7 +30,7 @@ package mage.sets.magicorigins; import java.util.UUID; import mage.MageInt; import mage.abilities.common.AttacksTriggeredAbility; -import mage.abilities.condition.common.RenownCondition; +import mage.abilities.condition.common.RenownedSourceCondition; import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.common.continuous.BoostControlledEffect; import mage.abilities.keyword.FirstStrikeAbility; @@ -62,7 +62,7 @@ public class ConsulsLieutenant extends CardImpl { // Whenever Consul's Lieutenant attacks, if it's renowned, other attacking creatures you control get +1/+1 until end of turn. this.addAbility(new ConditionalTriggeredAbility(new AttacksTriggeredAbility( new BoostControlledEffect(1, 1, Duration.EndOfTurn, new FilterAttackingCreature("other attacking creatures you control"), true), false), - RenownCondition.getInstance(), + RenownedSourceCondition.getInstance(), "Whenever Consul's Lieutenant attacks, if it's renowned, other attacking creatures you control get +1/+1 until end of turn.")); } diff --git a/Mage.Sets/src/mage/sets/magicorigins/EnshroudingMist.java b/Mage.Sets/src/mage/sets/magicorigins/EnshroudingMist.java index 9c81ff6e17d..f85197d29d8 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/EnshroudingMist.java +++ b/Mage.Sets/src/mage/sets/magicorigins/EnshroudingMist.java @@ -28,12 +28,12 @@ package mage.sets.magicorigins; import java.util.UUID; -import mage.abilities.condition.common.RenownCondition; +import mage.abilities.condition.common.RenownedTargetCondition; import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.PreventDamageToTargetEffect; -import mage.abilities.effects.common.UntapSourceEffect; +import mage.abilities.effects.common.UntapTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -56,12 +56,11 @@ public class EnshroudingMist extends CardImpl { Effect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE); effect.setText("Prevent all damage that would dealt to it this turn"); this.getSpellAbility().addEffect(effect); - OneShotEffect effect2 = new UntapSourceEffect(); + OneShotEffect effect2 = new UntapTargetEffect(); effect2.setText("untap it"); - this.getSpellAbility().addEffect(new ConditionalOneShotEffect(effect2, RenownCondition.getInstance())); + this.getSpellAbility().addEffect(new ConditionalOneShotEffect(effect2, RenownedTargetCondition.getInstance())); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - - + } public EnshroudingMist(final EnshroudingMist card) { diff --git a/Mage.Sets/src/mage/sets/magicorigins/GoblinGloryChaser.java b/Mage.Sets/src/mage/sets/magicorigins/GoblinGloryChaser.java index 09faa522915..c5a5ae8e4ce 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/GoblinGloryChaser.java +++ b/Mage.Sets/src/mage/sets/magicorigins/GoblinGloryChaser.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.condition.common.RenownCondition; +import mage.abilities.condition.common.RenownedSourceCondition; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; @@ -63,7 +63,7 @@ public class GoblinGloryChaser extends CardImpl { // As long as Goblin Glory Chaser is renowned, it has menace. Effect effect = new ConditionalContinuousEffect( new GainAbilitySourceEffect(new MenaceAbility(), Duration.WhileOnBattlefield), - RenownCondition.getInstance(), + RenownedSourceCondition.getInstance(), "As long as {this} is renowned, it has menace"); Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/magicorigins/HonoredHierarch.java b/Mage.Sets/src/mage/sets/magicorigins/HonoredHierarch.java index d09a2fb9e63..0661baef1d0 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/HonoredHierarch.java +++ b/Mage.Sets/src/mage/sets/magicorigins/HonoredHierarch.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.condition.common.RenownCondition; +import mage.abilities.condition.common.RenownedSourceCondition; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; @@ -64,12 +64,12 @@ public class HonoredHierarch extends CardImpl { // As long as Honored Hierarch is renowned, it has vigilance and "{T}: Add one mana of any color to your mana pool." Effect effect = new ConditionalContinuousEffect( new GainAbilitySourceEffect(VigilanceAbility.getInstance(), Duration.WhileOnBattlefield), - RenownCondition.getInstance(), + RenownedSourceCondition.getInstance(), "As long as {this} is renown, it has vigilance"); Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); effect = new ConditionalContinuousEffect( new GainAbilitySourceEffect(new AnyColorManaAbility(), Duration.WhileOnBattlefield), - RenownCondition.getInstance(), + RenownedSourceCondition.getInstance(), "and \"{T}: Add one mana of any color to your mana pool.\""); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/magicorigins/ScabClanBerserker.java b/Mage.Sets/src/mage/sets/magicorigins/ScabClanBerserker.java index d325fe9e592..35c7bd9d9e3 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/ScabClanBerserker.java +++ b/Mage.Sets/src/mage/sets/magicorigins/ScabClanBerserker.java @@ -30,7 +30,7 @@ package mage.sets.magicorigins; import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.condition.common.RenownCondition; +import mage.abilities.condition.common.RenownedSourceCondition; import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; @@ -68,7 +68,7 @@ public class ScabClanBerserker extends CardImpl { // Whenever an opponent casts a noncreature spell, if Scab-Clan Berserker is renowned, Scab-Clan Berserker deals 2 damage to that player. this.addAbility(new ConditionalTriggeredAbility( new ScabClanBerserkerTriggeredAbility(), - RenownCondition.getInstance(), + RenownedSourceCondition.getInstance(), "Whenever an opponent casts a noncreature spell, if Scab-Clan Berserker is renowned, Scab-Clan Berserker deals 2 damage to that player")); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java index 16637cc14cd..60e740bb1b3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java @@ -174,7 +174,7 @@ public class RenownTest extends CardTestPlayerBase { assertPowerToughness(playerA, "Rhox Maulers", 6, 6); // renown again in turn 7 after the attack Permanent rhoxMaulers = getPermanent("Rhox Maulers", playerA); - Assert.assertEquals("may not be renown", true, rhoxMaulers.isRenown()); + Assert.assertEquals("may not be renown", true, rhoxMaulers.isRenowned()); } @@ -202,7 +202,7 @@ public class RenownTest extends CardTestPlayerBase { execute(); Permanent goblin = getPermanent("Goblin Glory Chaser", playerA); - Assert.assertEquals("has has renown", true, goblin.isRenown()); + Assert.assertEquals("has has renown", true, goblin.isRenowned()); assertAbility(playerA, "Goblin Glory Chaser", new MenaceAbility(), true); assertPowerToughness(playerA, "Goblin Glory Chaser", 2, 2); @@ -231,11 +231,40 @@ public class RenownTest extends CardTestPlayerBase { execute(); Permanent berserker = getPermanent("Scab-Clan Berserker", playerA); - Assert.assertEquals("has has renown", true, berserker.isRenown()); + Assert.assertEquals("has has renown", true, berserker.isRenowned()); assertPowerToughness(playerA, "Scab-Clan Berserker", 3, 3); assertLife(playerA, 17); // Lightning Bolt assertLife(playerB, 16); // 2 from attack 2 from triggered ability } + + /** + * Enshrouding Mist (new card from ORI) isn't untapping renowned creatures. + */ + @Test + public void testEnshroudingMist() { + // Renown 1 + // Whenever an opponent casts a noncreature spell, if Scab-Clan Berserker is renowned, Scab-Clan Berserker deals 2 damage to that player. + addCard(Zone.BATTLEFIELD, playerB, "Scab-Clan Berserker"); // 2/2 {1}{R}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Plains", 1); + // Target creature gets +1/+1 until end of turn. Prevent all damage that would dealt to it this turn. If it's renowned, untap it. + addCard(Zone.HAND, playerB, "Enshrouding Mist"); + + attack(2, playerB, "Scab-Clan Berserker"); // 1 damage + castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Enshrouding Mist", "Scab-Clan Berserker"); + + setStopAt(2, PhaseStep.END_TURN); + execute(); + + Permanent berserker = getPermanent("Scab-Clan Berserker", playerB); + Assert.assertEquals("has has renown", true, berserker.isRenowned()); + assertPowerToughness(playerB, "Scab-Clan Berserker", 4, 4); // +1 from renowned + 1 from Enshrouding Mist + assertTapped("Scab-Clan Berserker", false); + + assertLife(playerA, 18); // Lightning Bolt + assertLife(playerB, 20); + + } } diff --git a/Mage/src/mage/abilities/condition/common/RenownCondition.java b/Mage/src/mage/abilities/condition/common/RenownedSourceCondition.java similarity index 69% rename from Mage/src/mage/abilities/condition/common/RenownCondition.java rename to Mage/src/mage/abilities/condition/common/RenownedSourceCondition.java index 1e00bba4426..edd058a64b2 100644 --- a/Mage/src/mage/abilities/condition/common/RenownCondition.java +++ b/Mage/src/mage/abilities/condition/common/RenownedSourceCondition.java @@ -16,15 +16,15 @@ import mage.game.permanent.Permanent; * @author LevelX2 */ -public class RenownCondition implements Condition { +public class RenownedSourceCondition implements Condition { - private static RenownCondition fInstance = null; + private static RenownedSourceCondition fInstance = null; - private RenownCondition() {} + private RenownedSourceCondition() {} - public static RenownCondition getInstance() { + public static RenownedSourceCondition getInstance() { if (fInstance == null) { - fInstance = new RenownCondition(); + fInstance = new RenownedSourceCondition(); } return fInstance; } @@ -33,7 +33,7 @@ public class RenownCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - return permanent.isRenown(); + return permanent.isRenowned(); } return false; } diff --git a/Mage/src/mage/abilities/condition/common/RenownedTargetCondition.java b/Mage/src/mage/abilities/condition/common/RenownedTargetCondition.java new file mode 100644 index 00000000000..0d822b288d5 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/RenownedTargetCondition.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.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class RenownedTargetCondition implements Condition { + + private static RenownedTargetCondition fInstance = null; + + private RenownedTargetCondition() { + } + + public static RenownedTargetCondition getInstance() { + if (fInstance == null) { + fInstance = new RenownedTargetCondition(); + } + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget()); + if (permanent != null) { + return permanent.isRenowned(); + } + return false; + } + + @Override + public String toString() { + return "it's renowned"; + } + +} diff --git a/Mage/src/mage/abilities/keyword/RenownAbility.java b/Mage/src/mage/abilities/keyword/RenownAbility.java index 81fac74c52f..878a7659768 100644 --- a/Mage/src/mage/abilities/keyword/RenownAbility.java +++ b/Mage/src/mage/abilities/keyword/RenownAbility.java @@ -27,7 +27,7 @@ public class RenownAbility extends TriggeredAbilityImpl { private int renownValue; public RenownAbility(int renownValue) { - super(Zone.BATTLEFIELD, new BecomeRenownSourceEffect(renownValue), false); + super(Zone.BATTLEFIELD, new BecomesRenownedSourceEffect(renownValue), false); this.renownValue = renownValue; } @@ -49,7 +49,7 @@ public class RenownAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); - return sourcePermanent != null && !sourcePermanent.isRenown(); + return sourcePermanent != null && !sourcePermanent.isRenowned(); } @Override @@ -63,20 +63,20 @@ public class RenownAbility extends TriggeredAbilityImpl { } } -class BecomeRenownSourceEffect extends OneShotEffect { +class BecomesRenownedSourceEffect extends OneShotEffect { - public BecomeRenownSourceEffect(int renownValue) { + public BecomesRenownedSourceEffect(int renownValue) { super(Outcome.BoostCreature); this.staticText = setText(renownValue); } - public BecomeRenownSourceEffect(final BecomeRenownSourceEffect effect) { + public BecomesRenownedSourceEffect(final BecomesRenownedSourceEffect effect) { super(effect); } @Override - public BecomeRenownSourceEffect copy() { - return new BecomeRenownSourceEffect(this); + public BecomesRenownedSourceEffect copy() { + return new BecomesRenownedSourceEffect(this); } @Override @@ -90,7 +90,7 @@ class BecomeRenownSourceEffect extends OneShotEffect { renownValue = source.getManaCostsToPay().getX(); } new AddCountersSourceEffect(CounterType.P1P1.createInstance(renownValue), true).apply(game, source); - permanent.setRenown(true); + permanent.setRenowned(true); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_RENOWNED, source.getSourceId(), source.getSourceId(), source.getControllerId(), renownValue)); return true; } diff --git a/Mage/src/mage/game/permanent/Permanent.java b/Mage/src/mage/game/permanent/Permanent.java index 22e6319590d..33221ea2fb7 100644 --- a/Mage/src/mage/game/permanent/Permanent.java +++ b/Mage/src/mage/game/permanent/Permanent.java @@ -75,8 +75,8 @@ public interface Permanent extends Card, Controllable { boolean isMonstrous(); void setMonstrous(boolean value); - boolean isRenown(); - void setRenown(boolean value); + boolean isRenowned(); + void setRenowned(boolean value); void setCardNumber(int cid); void setExpansionSetCode(String expansionSetCode); diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index b71c09a9a31..5ba200bae69 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -90,7 +90,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { protected boolean flipped; protected boolean transformed; protected boolean monstrous; - protected boolean renown; + protected boolean renowned; protected boolean manifested = false; protected boolean morphed = false; protected UUID originalControllerId; @@ -176,7 +176,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { this.maxBlockedBy = permanent.maxBlockedBy; this.transformed = permanent.transformed; this.monstrous = permanent.monstrous; - this.renown = permanent.renown; + this.renowned = permanent.renowned; this.pairedCard = permanent.pairedCard; this.timesLoyaltyUsed = permanent.timesLoyaltyUsed; @@ -1268,13 +1268,13 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public boolean isRenown() { - return this.renown; + public boolean isRenowned() { + return this.renowned; } @Override - public void setRenown(boolean value) { - this.renown = value; + public void setRenowned(boolean value) { + this.renowned = value; } @Override