From e9f58d20a537ec2b98b1beb957b6ed01cb4ca0d9 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 Jan 2016 22:11:09 +0100 Subject: [PATCH] * Fossil Find - Fixed card movement handling. --- .../src/mage/sets/magic2013/AugurOfBolas.java | 4 +- .../src/mage/sets/shadowmoor/FossilFind.java | 19 ++- .../continuous/WardenOfTheFirstTreeTest.java | 123 ++++++++++++++++++ .../ExileAndReturnUnderYourControl.java | 45 +++++++ .../cards/copy/PhyrexianMetamorphTest.java | 2 +- .../test/cards/single/FracturingGustTest.java | 30 ++++- .../EntersTheBattlefieldTriggerTest.java | 31 +++++ .../cards/triggers/dies/BloodArtistTest.java | 96 +++++++++++++- .../triggers/dies/ZulaportCutthroatTest.java | 69 ++++++++++ .../main/java/mage/abilities/AbilityImpl.java | 6 +- .../src/main/java/mage/filter/FilterCard.java | 3 + Mage/src/main/java/mage/game/GameState.java | 6 + 12 files changed, 410 insertions(+), 24 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/continuous/WardenOfTheFirstTreeTest.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java diff --git a/Mage.Sets/src/mage/sets/magic2013/AugurOfBolas.java b/Mage.Sets/src/mage/sets/magic2013/AugurOfBolas.java index 7f1084a1331..90d6c555f7f 100644 --- a/Mage.Sets/src/mage/sets/magic2013/AugurOfBolas.java +++ b/Mage.Sets/src/mage/sets/magic2013/AugurOfBolas.java @@ -113,7 +113,7 @@ class AugurOfBolasEffect extends OneShotEffect { int number = topCards.count(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game); if (number > 0) { if (controller.chooseUse(outcome, "Reveal an instant or sorcery card from the looked at cards and put it into your hand?", source, game)) { - Card card = null; + Card card; if (number == 1) { card = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game).iterator().next(); } else { @@ -122,7 +122,7 @@ class AugurOfBolasEffect extends OneShotEffect { card = topCards.get(target.getFirstTarget(), game); } if (card != null) { - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game); topCards.remove(card); } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/FossilFind.java b/Mage.Sets/src/mage/sets/shadowmoor/FossilFind.java index 25f6fc97393..41eebbc7ec4 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/FossilFind.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/FossilFind.java @@ -28,14 +28,14 @@ package mage.sets.shadowmoor; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -49,7 +49,6 @@ public class FossilFind extends CardImpl { super(ownerId, 206, "Fossil Find", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{R/G}"); this.expansionSetCode = "SHM"; - // Return a card at random from your graveyard to your hand, then reorder your graveyard as you choose. this.getSpellAbility().addEffect(new FossilFindEffect()); } @@ -82,14 +81,14 @@ class FossilFindEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null && !player.getGraveyard().isEmpty()) { - Card card = player.getGraveyard().getRandom(game); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null && !controller.getGraveyard().isEmpty()) { + Card card = controller.getGraveyard().getRandom(game); if (card != null) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, true); - game.informPlayers(card.getName() + "returned to the hand of" + player.getLogName()); + controller.moveCards(card, Zone.HAND, source, game); return true; } + controller.moveCards(controller.getGraveyard(), Zone.GRAVEYARD, source, game); } return false; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WardenOfTheFirstTreeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WardenOfTheFirstTreeTest.java new file mode 100644 index 00000000000..5e2058b2c65 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WardenOfTheFirstTreeTest.java @@ -0,0 +1,123 @@ +/* + * 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 org.mage.test.cards.continuous; + +import mage.abilities.keyword.LifelinkAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.constants.CardType; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.filter.Filter; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class WardenOfTheFirstTreeTest extends CardTestPlayerBase { + + @Test + public void testFirstAbility() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + // {1}{W/B}: Warden of the First Tree becomes a Human Warrior with base power and toughness 3/3. + // {2}{W/B}{W/B}: If Warden of the First Tree is a Warrior, it becomes a Human Spirit Warrior with trample and lifelink. + // {3}{W/B}{W/B}{W/B}: If Warden of the First Tree is a Spirit, put five +1/+1 counters on it. + addCard(Zone.HAND, playerA, "Warden of the First Tree", 2); // {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Warden of the First Tree"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W/B}:"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPowerToughness(playerA, "Warden of the First Tree", 3, 3, Filter.ComparisonScope.Any); + assertType("Warden of the First Tree", CardType.CREATURE, "Human"); + assertType("Warden of the First Tree", CardType.CREATURE, "Warrior"); + assertAbility(playerA, "Warden of the First Tree", TrampleAbility.getInstance(), false); + assertAbility(playerA, "Warden of the First Tree", LifelinkAbility.getInstance(), false); + } + + @Test + public void testSecondAbility() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + // {1}{W/B}: Warden of the First Tree becomes a Human Warrior with base power and toughness 3/3. + // {2}{W/B}{W/B}: If Warden of the First Tree is a Warrior, it becomes a Human Spirit Warrior with trample and lifelink. + // {3}{W/B}{W/B}{W/B}: If Warden of the First Tree is a Spirit, put five +1/+1 counters on it. + addCard(Zone.HAND, playerA, "Warden of the First Tree", 2); // {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Warden of the First Tree"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W/B}:"); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{2}{W/B}{W/B}:"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPowerToughness(playerA, "Warden of the First Tree", 3, 3, Filter.ComparisonScope.Any); + assertType("Warden of the First Tree", CardType.CREATURE, "Human"); + assertType("Warden of the First Tree", CardType.CREATURE, "Spirit"); + assertType("Warden of the First Tree", CardType.CREATURE, "Warrior"); + assertAbility(playerA, "Warden of the First Tree", TrampleAbility.getInstance(), true); + assertAbility(playerA, "Warden of the First Tree", LifelinkAbility.getInstance(), true); + } + + @Test + public void testThirdAbility() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + // {1}{W/B}: Warden of the First Tree becomes a Human Warrior with base power and toughness 3/3. + // {2}{W/B}{W/B}: If Warden of the First Tree is a Warrior, it becomes a Human Spirit Warrior with trample and lifelink. + // {3}{W/B}{W/B}{W/B}: If Warden of the First Tree is a Spirit, put five +1/+1 counters on it. + addCard(Zone.HAND, playerA, "Warden of the First Tree", 2); // {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Warden of the First Tree"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W/B}:"); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{2}{W/B}{W/B}:"); + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{3}{W/B}{W/B}{W/B}:"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPowerToughness(playerA, "Warden of the First Tree", 8, 8, Filter.ComparisonScope.Any); + assertType("Warden of the First Tree", CardType.CREATURE, "Human"); + assertType("Warden of the First Tree", CardType.CREATURE, "Spirit"); + assertType("Warden of the First Tree", CardType.CREATURE, "Warrior"); + assertAbility(playerA, "Warden of the First Tree", TrampleAbility.getInstance(), true); + assertAbility(playerA, "Warden of the First Tree", LifelinkAbility.getInstance(), true); + } + + /** + * When a Warden of the First Tree enters the battlefield, if it is not the + * first warden played during the game, it enters with a random + * power/toughness instead of 1/1. I have had it enter with both 2/2 and + * 4/4, neither of which are actual values the card can hold. + */ +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/control/ExileAndReturnUnderYourControl.java b/Mage.Tests/src/test/java/org/mage/test/cards/control/ExileAndReturnUnderYourControl.java index 13f434621e6..ae2ab5f4d82 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/control/ExileAndReturnUnderYourControl.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/control/ExileAndReturnUnderYourControl.java @@ -148,4 +148,49 @@ public class ExileAndReturnUnderYourControl extends CardTestPlayerBase { } + /** + * I cast a Villainous Wealth in Vintage Cube, and when it came time to cast + * my opponent's cards (Mox Sapphire, Mox Emerald, Brainstorm, Snapcaster + * Mage, Fact or Fiction and a Quicken), it rolled back to before I had cast + * my spell after Quicken resolved. I have the error, but the forums won't + * let me post them. I did find it was replicatable whenever you try to cast + * Quicken off a Villainous Wealth. + */ + @Test + public void testVillainousWealthAndQuicken() { + // Villainous Wealth {X}{B}{G}{U} + // Target opponent exiles the top X cards of his or her library. You may cast any number + // of nonland cards with converted mana cost X or less from among them without paying + // their mana costs. + addCard(Zone.HAND, playerA, "Villainous Wealth"); // {X}{B}{G}{U} + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + + // At the beginning of your draw step, you may draw two additional cards. + // If you do, choose two cards in your hand drawn this turn. + // For each of those cards, pay 4 life or put the card on top of your library. + addCard(Zone.LIBRARY, playerB, "Mox Emerald"); + // The next sorcery card you cast this turn can be cast as though it had flash. + // Draw a card. + addCard(Zone.LIBRARY, playerB, "Quicken"); // Instant - {U} + addCard(Zone.LIBRARY, playerB, "Mox Sapphire"); + skipInitShuffling(); // to keep this card on top of library + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Villainous Wealth", playerB); + setChoice(playerA, "X=3"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Mox Emerald"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Quicken"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Mox Sapphire"); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertGraveyardCount(playerA, "Villainous Wealth", 1); + assertExileCount(playerB, 0); + assertPermanentCount(playerA, "Mox Emerald", 1); + assertPermanentCount(playerA, "Mox Sapphire", 1); + assertGraveyardCount(playerB, "Quicken", 1); + + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhyrexianMetamorphTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhyrexianMetamorphTest.java index 1f3ac8a3242..07f84407316 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhyrexianMetamorphTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhyrexianMetamorphTest.java @@ -152,7 +152,7 @@ public class PhyrexianMetamorphTest extends CardTestPlayerBase { /** * If a Harmonic Sliver enters the battlefield the controller has to destroy - * one artifacts or enchantments + * one artifact or enchantment */ @Test public void testHarmonicSliverNative1() { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/FracturingGustTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/FracturingGustTest.java index 3c91554cf73..b38e6c72ac4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/FracturingGustTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/FracturingGustTest.java @@ -36,12 +36,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class FracturingGustTest extends CardTestPlayerBase { @Test - public void testCard() { + public void testWithStaticAbility() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); + // Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way. addCard(Zone.HAND, playerA, "Fracturing Gust", 1); // Players can't gain life. @@ -49,13 +49,11 @@ public class FracturingGustTest extends CardTestPlayerBase { // At the beginning of your end step, target opponent chosen at random gains control of Witch Hunt. addCard(Zone.BATTLEFIELD, playerB, "Witch Hunt", 1); - // Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way. castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fracturing Gust"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertGraveyardCount(playerA, "Fracturing Gust", 1); assertGraveyardCount(playerB, "Witch Hunt", 1); @@ -65,4 +63,26 @@ public class FracturingGustTest extends CardTestPlayerBase { } -} \ No newline at end of file + @Test + public void testWithTriggerdAbility() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); + // Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way. + addCard(Zone.HAND, playerA, "Fracturing Gust", 1); + + // When Guardian Automaton dies, you gain 3 life. + addCard(Zone.BATTLEFIELD, playerA, "Guardian Automaton", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fracturing Gust"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Fracturing Gust", 1); + assertGraveyardCount(playerA, "Guardian Automaton", 1); + + // + 2 from destroyed Guardian Automaton + assertLife(playerA, 25); + assertLife(playerB, 20); + + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/EntersTheBattlefieldTriggerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/EntersTheBattlefieldTriggerTest.java index fbeebe9d6eb..d6950d92b97 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/EntersTheBattlefieldTriggerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/EntersTheBattlefieldTriggerTest.java @@ -64,4 +64,35 @@ public class EntersTheBattlefieldTriggerTest extends CardTestPlayerBase { assertLife(playerB, 20); } + /** + * Diluvian Primordial is bugged and doesn't trigger upon entering the + * battlefield + */ + @Test + public void testDiluvianPrimordial() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 7); + // Flying + // When Diluvian Primordial enters the battlefield, for each opponent, you may cast up to one target instant or sorcery card from that player's graveyard without paying its mana cost. If a card cast this way would be put into a graveyard this turn, exile it instead. + addCard(Zone.HAND, playerA, "Diluvian Primordial", 1); // {5}{U}{U} + + addCard(Zone.GRAVEYARD, playerB, "Lightning Bolt"); + + // You may have Clever Impersonator enter the battlefield as a copy of any nonland permanent on the battlefield. + addCard(Zone.HAND, playerB, "Clever Impersonator", 1); + addCard(Zone.BATTLEFIELD, playerB, "Island", 4); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Diluvian Primordial"); + addTarget(playerA, "Lightning Bolt"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Diluvian Primordial", 1); + + assertExileCount("Lightning Bolt", 1); + + assertLife(playerA, 20); + assertLife(playerB, 17); + } + } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/BloodArtistTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/BloodArtistTest.java index ae5d9ab002c..c845c89ce14 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/BloodArtistTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/BloodArtistTest.java @@ -9,18 +9,21 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author noxx * - * Whenever Blood Artist or another creature dies, target player loses 1 life and you gain 1 life. + * Whenever Blood Artist or another creature dies, target player loses 1 life + * and you gain 1 life. */ public class BloodArtistTest extends CardTestPlayerBase { /** - * Tests that whenever Blood Artist goes to graveyard, it would trigger its ability. - * Tests that after Blood Artist went to graveyard, his ability doesn't work anymore. + * Tests that whenever Blood Artist goes to graveyard, it would trigger its + * ability. Tests that after Blood Artist went to graveyard, his ability + * doesn't work anymore. */ @Test public void testDisabledEffectOnChangeZone() { addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); addCard(Zone.HAND, playerA, "Lightning Bolt", 2); + // Whenever Blood Artist or another creature dies, target player loses 1 life and you gain 1 life. addCard(Zone.BATTLEFIELD, playerA, "Blood Artist", 2); addCard(Zone.GRAVEYARD, playerA, "Blood Artist", 1); @@ -36,4 +39,91 @@ public class BloodArtistTest extends CardTestPlayerBase { assertLife(playerB, 17); } + /** + * There is realy something wrong with sacrifice effects triggers. Had + * Zulaport Cutthroat on battlefield and tried Altar's Reap and Bone + * Splinters on it. Neither triggered ZC's abbility. Tried the same with + * Blood Artist on battlefield, same result - no trigger. + */ + @Test + public void testWithBoneSplinters() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); + // As an additional cost to cast Bone Splinters, sacrifice a creature. + // Destroy target creature. + addCard(Zone.HAND, playerA, "Bone Splinters", 1); // Sorcery - {B} + // Whenever Blood Artist or another creature dies, target player loses 1 life and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Blood Artist", 1); + + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bone Splinters", "Pillarfield Ox"); + setChoice(playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Bone Splinters", 1); + assertGraveyardCount(playerA, "Silvercoat Lion", 1); + assertGraveyardCount(playerB, "Pillarfield Ox", 1); + assertLife(playerA, 22); + assertLife(playerB, 18); + } + + @Test + public void testWithBoneSplinters2() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); + // As an additional cost to cast Bone Splinters, sacrifice a creature. + // Destroy target creature. + addCard(Zone.HAND, playerA, "Bone Splinters", 1); // Sorcery - {B} + // Whenever Blood Artist or another creature dies, target player loses 1 life and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Blood Artist", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bone Splinters", "Pillarfield Ox"); + setChoice(playerA, "Blood Artist"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Bone Splinters", 1); + assertGraveyardCount(playerA, "Blood Artist", 1); + assertGraveyardCount(playerB, "Pillarfield Ox", 1); + assertLife(playerA, 21); // For sacrifice both Blood Artist trigger, for destoy effect only one ist left + assertLife(playerB, 19); + } + + @Test + public void testWithBoneSplinters3() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); + // As an additional cost to cast Bone Splinters, sacrifice a creature. + // Destroy target creature. + addCard(Zone.HAND, playerA, "Bone Splinters", 1); // Sorcery - {B} + // Destroy target nonartifact, nonblack creature. It can't be regenerated. + addCard(Zone.HAND, playerA, "Terror", 1); // Instant - {1}{B} + // Whenever Blood Artist or another creature dies, target player loses 1 life and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Blood Artist", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1); + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bone Splinters", "Pillarfield Ox"); + setChoice(playerA, "Blood Artist"); + // Blood Artist may no longer trigger from destroyed creature because already in the graveyard + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Terror", "Silvercoat Lion", "Bone Splinters"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Bone Splinters", 1); + assertGraveyardCount(playerA, "Terror", 1); + assertGraveyardCount(playerA, "Blood Artist", 1); + assertGraveyardCount(playerB, "Pillarfield Ox", 1); + assertGraveyardCount(playerB, "Silvercoat Lion", 1); + assertLife(playerA, 21); // For sacrifice both Blood Artist trigger, for destoy effect only one ist left + assertLife(playerB, 19); + } + } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java new file mode 100644 index 00000000000..32514bec91b --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/ZulaportCutthroatTest.java @@ -0,0 +1,69 @@ +/* + * 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 org.mage.test.cards.triggers.dies; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class ZulaportCutthroatTest extends CardTestPlayerBase { + + /** + * Zulaport's ability doesn't trigger when it dies. I'm not sure if that's + * always the case, but I've encountered that bug at least several times + * today. + * + */ + @Test + public void testDiesAndControllerDamage() { + // Whenever Zulaport Cutthroat or another creature you control dies, each opponent loses 1 life and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Zulaport Cutthroat", 1); // 1/1 + + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); + // Target creature you control gets +1/+0 and gains deathtouch until end of turn. + // Whenever a creature dealt damage by that creature this turn dies, its controller loses 2 life. + addCard(Zone.HAND, playerB, "Lightning Bolt"); // {B} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "Zulaport Cutthroat"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerB, "Lightning Bolt", 1); + assertGraveyardCount(playerA, "Zulaport Cutthroat", 1); + + assertLife(playerA, 21); + assertLife(playerB, 19); + + } + +} diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index c4d7e73616a..2e1f1e31c77 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -229,11 +229,11 @@ public abstract class AbilityImpl implements Ability { game.resetShortLivingLKI(); /** * game.applyEffects() has to be done at least for every effect - * that moves cards/permanent between zones, or chnages control + * that moves cards/permanent between zones, or changes control * of objects so Static effects work as intened if dependant * from the moved objects zone it is in Otherwise for example - * were static abilities with replacement effects deactivated to - * late Example: + * were static abilities with replacement effects deactivated + * too late Example: * {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy} */ if (effect.applyEffectsAfter()) { diff --git a/Mage/src/main/java/mage/filter/FilterCard.java b/Mage/src/main/java/mage/filter/FilterCard.java index 2995a693184..a59885e9905 100644 --- a/Mage/src/main/java/mage/filter/FilterCard.java +++ b/Mage/src/main/java/mage/filter/FilterCard.java @@ -74,6 +74,9 @@ public class FilterCard extends FilterObject { */ @Override public boolean match(Card card, Game game) { + if (card == null) { + return false; + } if (card.isSplitCard()) { return super.match(((SplitCard) card).getLeftHalfCard(), game) || super.match(((SplitCard) card).getRightHalfCard(), game); diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 748ead016f2..ff241124290 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -530,6 +530,12 @@ public class GameState implements Serializable, Copyable { this.gameOver = true; } + // 608.2e + public void processAction(Game game) { + game.getState().handleSimultaneousEvent(game); + applyEffects(game); + } + public void applyEffects(Game game) { game.resetShortLivingLKI(); for (Player player : players.values()) {