diff --git a/Mage.Sets/src/mage/sets/darkascension/ClingingMists.java b/Mage.Sets/src/mage/sets/darkascension/ClingingMists.java new file mode 100644 index 00000000000..bf83b85f146 --- /dev/null +++ b/Mage.Sets/src/mage/sets/darkascension/ClingingMists.java @@ -0,0 +1,150 @@ +/* + * 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.darkascension; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.condition.common.FatefulHourCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.PreventAllDamageEffect; +import mage.cards.CardImpl; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterAttackingCreature; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author BetaSteward + */ +public class ClingingMists extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent(); + + public ClingingMists(UUID ownerId) { + super(ownerId, 109, "Clinging Mists", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{G}"); + this.expansionSetCode = "DKA"; + + this.color.setGreen(true); + + // Prevent all combat damage that would be dealt this turn. + this.getSpellAbility().addEffect(new PreventAllDamageEffect(filter, Constants.Duration.EndOfTurn, true)); + + // Fateful hour — If you have 5 or less life, tap all attacking creatures. Those creatures don't untap during their controller's next untap step. + this.getSpellAbility().addEffect(new ConditionalOneShotEffect(new ClingingMistsEffect(), + FatefulHourCondition.getInstance(), "If you have 5 or less life, tap all attacking creatures. Those creatures don't untap during their controller's next untap step.")); + + } + + public ClingingMists(final ClingingMists card) { + super(card); + } + + @Override + public ClingingMists copy() { + return new ClingingMists(this); + } +} + +class ClingingMistsEffect extends OneShotEffect { + + private static final FilterAttackingCreature filter = new FilterAttackingCreature("attacking creatures"); + + public ClingingMistsEffect() { + super(Constants.Outcome.Tap); + staticText = "tap all attacking creatures. Those creatures don't untap during their controller's next untap step"; + } + + public ClingingMistsEffect(final ClingingMistsEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Permanent creature: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + creature.tap(game); + game.addEffect(new ClingingMistsEffect2(creature.getId()), source); + } + return true; + } + + @Override + public ClingingMistsEffect copy() { + return new ClingingMistsEffect(this); + } + +} + +class ClingingMistsEffect2 extends ReplacementEffectImpl { + + protected UUID creatureId; + + public ClingingMistsEffect2(UUID creatureId) { + super(Constants.Duration.OneUse, Constants.Outcome.Detriment); + this.creatureId = creatureId; + } + + public ClingingMistsEffect2(final ClingingMistsEffect2 effect) { + super(effect); + creatureId = effect.creatureId; + } + + @Override + public ClingingMistsEffect2 copy() { + return new ClingingMistsEffect2(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + used = true; + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && + event.getType() == GameEvent.EventType.UNTAP && + event.getTargetId().equals(creatureId)) { + return true; + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/darkascension/DeadlyAllure.java b/Mage.Sets/src/mage/sets/darkascension/DeadlyAllure.java new file mode 100644 index 00000000000..0e2bfdd85d6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/darkascension/DeadlyAllure.java @@ -0,0 +1,74 @@ +/* + * 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.darkascension; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.MustBlockSourceEffect; +import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author BetaSteward + */ +public class DeadlyAllure extends CardImpl { + + public DeadlyAllure(UUID ownerId) { + super(ownerId, 58, "Deadly Allure", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{B}"); + this.expansionSetCode = "DKA"; + + this.color.setBlack(true); + + // Target creature gains deathtouch until end of turn and must be blocked this turn if able. + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new MustBlockSourceEffect()), Constants.Duration.EndOfTurn)); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(DeathtouchAbility.getInstance(), Constants.Duration.EndOfTurn)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + + // Flashback {G} + this.addAbility(new FlashbackAbility(new ManaCostsImpl("{G}"), Constants.TimingRule.SORCERY)); + + } + + public DeadlyAllure(final DeadlyAllure card) { + super(card); + } + + @Override + public DeadlyAllure copy() { + return new DeadlyAllure(this); + } +} + diff --git a/Mage.Sets/src/mage/sets/darkascension/SpitefulShadows.java b/Mage.Sets/src/mage/sets/darkascension/SpitefulShadows.java index 8bd703acc46..33cf2df5064 100644 --- a/Mage.Sets/src/mage/sets/darkascension/SpitefulShadows.java +++ b/Mage.Sets/src/mage/sets/darkascension/SpitefulShadows.java @@ -135,7 +135,9 @@ class SpitefulShadowsEffect extends OneShotEffect { Integer damageAmount = (Integer) this.getValue("damageAmount"); UUID targetId = (UUID) this.getValue("targetId"); if (damageAmount != null && targetId != null) { - Permanent permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + Permanent permanent = game.getPermanent(targetId); + if (permanent == null) + permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/TestClingingMists.java b/Mage.Tests/src/test/java/org/mage/test/cards/TestClingingMists.java new file mode 100644 index 00000000000..8a6615f2b24 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/TestClingingMists.java @@ -0,0 +1,72 @@ +package org.mage.test.cards; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * also tests regenerate and + * tests that permanents with protection can be sacrificed + * + * @author BetaSteward + */ +public class TestClingingMists extends CardTestPlayerBase { + + @Test + public void testCard() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "White Knight"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 3); + addCard(Constants.Zone.HAND, playerA, "Clinging Mists"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Clinging Mists"); + attack(1, playerA, "White Knight"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + } + + @Test + public void testCardExile1() { + setLife(playerA, 5); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Abbey Griffin"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 3); + addCard(Constants.Zone.HAND, playerA, "Clinging Mists"); + + attack(1, playerA, "Abbey Griffin"); + castSpell(1, Constants.PhaseStep.DECLARE_BLOCKERS, playerA, "Clinging Mists"); + + setStopAt(3, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 5); + assertLife(playerB, 20); + assertTapped("Abbey Griffin", true); + } + + @Test + public void testCardExile2() { + setLife(playerA, 5); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 3); + addCard(Constants.Zone.HAND, playerA, "Clinging Mists"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Abbey Griffin"); + addCard(Constants.Zone.HAND, playerB, "Lightning Bolt"); + + attack(2, playerB, "Abbey Griffin"); + castSpell(2, Constants.PhaseStep.DECLARE_BLOCKERS, playerA, "Clinging Mists"); + castSpell(2, Constants.PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA); + + setStopAt(6, Constants.PhaseStep.DRAW); + execute(); + + assertLife(playerA, 2); + assertLife(playerB, 20); + assertTapped("Abbey Griffin", false); + assertGraveyardCount(playerB, "Lightning Bolt", 1); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/damage/TestSpitefulShadows.java b/Mage.Tests/src/test/java/org/mage/test/cards/damage/TestSpitefulShadows.java new file mode 100644 index 00000000000..852578bc434 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/damage/TestSpitefulShadows.java @@ -0,0 +1,56 @@ +package org.mage.test.cards.damage; + +import mage.Constants; +import mage.counters.CounterType; +import org.junit.Ignore; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * also tests regenerate and + * tests that permanents with protection can be sacrificed + * + * @author BetaSteward + */ +public class TestSpitefulShadows extends CardTestPlayerBase { + + @Test + public void testCard() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Glistener Elf"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Constants.Zone.HAND, playerA, "Spiteful Shadows"); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Spiteful Shadows", "Glistener Elf"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Glistener Elf"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertCounterCount(playerA, CounterType.POISON, 3); + } + + @Test + public void testCard1() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Craw Wurm"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Constants.Zone.HAND, playerA, "Spiteful Shadows"); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Spiteful Shadows", "Craw Wurm"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Craw Wurm"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 17); + assertLife(playerB, 20); + assertCounterCount(playerA, CounterType.POISON, 0); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 65dfc07b5b3..064a66ff281 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -391,6 +391,17 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement Assert.assertEquals("(Battlefield) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters().getCount(type)); } + + /** + * Assert counter count on a player + * + * @param player The player whos counters should be counted. + * @param type Type of the counter that should be counted. + * @param count Expected count. + */ + public void assertCounterCount(Player player, CounterType type, int count) throws AssertionError { + Assert.assertEquals("(Battlefield) Counter counts are not equal (" + player.getName() + ":" + type + ")", count, player.getCounters().getCount(type)); + } /** * Assert whether a permanent is a specified type or not