From f22fb380b787014cfaf1b2dae4304bc24ac489a1 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 27 Sep 2015 01:21:47 +0200 Subject: [PATCH] * Reaper of Sheoldred - Fixed that damage was sometimes dealt to Reaper of Sheoldred controller. --- .../src/mage/sets/magic2015/ChasmSkulker.java | 5 +- .../sets/newphyrexia/ReaperOfSheoldred.java | 17 ++++- .../cards/triggers/DrawTriggeredTest.java | 71 +++++++++++++++++++ 3 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/triggers/DrawTriggeredTest.java diff --git a/Mage.Sets/src/mage/sets/magic2015/ChasmSkulker.java b/Mage.Sets/src/mage/sets/magic2015/ChasmSkulker.java index 874f933c5a9..b8af72b4240 100644 --- a/Mage.Sets/src/mage/sets/magic2015/ChasmSkulker.java +++ b/Mage.Sets/src/mage/sets/magic2015/ChasmSkulker.java @@ -29,7 +29,6 @@ package mage.sets.magic2015; import java.util.UUID; import mage.MageInt; -import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DrawCardControllerTriggeredAbility; @@ -65,7 +64,7 @@ public class ChasmSkulker extends CardImpl { // Whenever you draw a card, put a +1/+1 counter on Chasm Skulker. this.addAbility(new DrawCardControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false)); - + // When Chasm Skulker dies, put X 1/1 blue Squid creature tokens with islandwalk onto the battlefield, where X is the number of +1/+1 counters on Chasm Skulker. this.addAbility(new DiesTriggeredAbility(new ChasmSkulkerEffect(), false)); } @@ -127,4 +126,4 @@ class ChasmSkulkerSquidToken extends Token { this.addAbility(new IslandwalkAbility()); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ReaperOfSheoldred.java b/Mage.Sets/src/mage/sets/newphyrexia/ReaperOfSheoldred.java index c8da60dba23..5e9a8469cf7 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/ReaperOfSheoldred.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/ReaperOfSheoldred.java @@ -41,6 +41,7 @@ import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.players.Player; import mage.target.targetpointer.FixedTarget; /** @@ -57,7 +58,10 @@ public class ReaperOfSheoldred extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(5); + // Infect (This creature deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.) this.addAbility(InfectAbility.getInstance()); + + // Whenever a source deals damage to Reaper of Sheoldred, that source's controller gets a poison counter. this.addAbility(new ReaperOfSheoldredTriggeredAbility()); } @@ -72,6 +76,7 @@ public class ReaperOfSheoldred extends CardImpl { } class ReaperOfSheoldredTriggeredAbility extends TriggeredAbilityImpl { + ReaperOfSheoldredTriggeredAbility() { super(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.POISON.createInstance())); } @@ -93,10 +98,16 @@ class ReaperOfSheoldredTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.getSourceId())) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); + UUID controller = game.getControllerId(event.getSourceId()); + if (controller != null) { + Player player = game.getPlayer(controller); + if (player != null) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(player.getId())); + } + return true; + } } - return true; } return false; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DrawTriggeredTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DrawTriggeredTest.java new file mode 100644 index 00000000000..38bed27ca82 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/DrawTriggeredTest.java @@ -0,0 +1,71 @@ +/* + * 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; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class DrawTriggeredTest extends CardTestPlayerBase { + + /* + * Day's Undoing - Doesn't create card draw triggers "Specifically, it + * doesn't work with Chasm Skulker. + * + * Steps to reproduce: + 1) Have Chasm Skulker on the battlefield. + 2) Cast Day's Undoing. + 3) You will draw 7 cards, but Chasm Skulker's ""when you draw a card"" trigger does not trigger." ==> What is correct + */ + @Test + public void DaysUndoingTriggeredDrewEventAreRemovedTest() { + // Each player shuffles his or her hand and graveyard into his or her library, then draws seven cards. If it's your turn, end the turn. + addCard(Zone.HAND, playerA, "Day's Undoing"); + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + + // Whenever you draw a card, put a +1/+1 counter on Chasm Skulker. + // When Chasm Skulker dies, put X 1/1 blue Squid creature tokens with islandwalk onto the battlefield, where X is the number of +1/+1 counters on Chasm Skulker. + addCard(Zone.BATTLEFIELD, playerB, "Chasm Skulker", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Day's Undoing"); + + setStopAt(2, PhaseStep.UNTAP); + execute(); + + assertExileCount("Day's Undoing", 1); + assertPermanentCount(playerB, "Chasm Skulker", 1); + assertPowerToughness(playerB, "Chasm Skulker", 1, 1); + + } + +}