diff --git a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java index a1c35bd1722..3bdedbe92ab 100644 --- a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java +++ b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java @@ -4,7 +4,6 @@ import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; @@ -38,11 +37,11 @@ public final class HotheadedGiant extends CardImpl { this.addAbility(HasteAbility.getInstance()); // Hotheaded Giant enters the battlefield with two -1/-1 counters on it unless you've cast another red spell this turn. - this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect( + this.addAbility(new EntersBattlefieldAbility( new AddCountersSourceEffect(CounterType.M1M1.createInstance(2)), - HotheadedGiantWatcher::checkSpell, "" - ), "with two -1/-1 counters on it unless you've cast another red spell this turn"), new HotheadedGiantWatcher()); - + HotheadedGiantWatcher::checkSpell, null, + "\"with two -1/-1 counters on it unless you've cast another red spell this turn\"" + ), new HotheadedGiantWatcher()); } private HotheadedGiant(final HotheadedGiant card) { @@ -88,7 +87,6 @@ class HotheadedGiantWatcher extends Watcher { .spellMap .getOrDefault(source.getControllerId(), emptyList) .stream() - .noneMatch(mor -> !mor.getSourceId().equals(source.getSourceId()) - || mor.getZoneChangeCounter() != source.getSourceObjectZoneChangeCounter()); + .noneMatch(mor -> !mor.refersTo(source, game)); } } diff --git a/Mage.Sets/src/mage/cards/s/SoulReap.java b/Mage.Sets/src/mage/cards/s/SoulReap.java index edadd9e2033..e555ecec3d6 100644 --- a/Mage.Sets/src/mage/cards/s/SoulReap.java +++ b/Mage.Sets/src/mage/cards/s/SoulReap.java @@ -121,7 +121,6 @@ class SoulReapWatcher extends Watcher { .spellMap .getOrDefault(source.getControllerId(), emptyList) .stream() - .anyMatch(mor -> !mor.getSourceId().equals(source.getSourceId()) - || mor.getZoneChangeCounter() != source.getSourceObjectZoneChangeCounter()); + .anyMatch(mor -> !mor.refersTo(source, game)); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/HotheadedGiantTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/HotheadedGiantTest.java new file mode 100644 index 00000000000..4e482fd70e1 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/HotheadedGiantTest.java @@ -0,0 +1,47 @@ +package org.mage.test.cards.single.eve; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class HotheadedGiantTest extends CardTestPlayerBase { + private static final String giant = "Hotheaded Giant"; + private static final String goblin = "Mons's Goblin Raiders"; + + @Test + public void testSpell() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); + addCard(Zone.HAND, playerA, goblin); + addCard(Zone.HAND, playerA, giant); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, goblin); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giant); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, giant, CounterType.M1M1, 0); + } + + @Test + public void testNoSpell() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.HAND, playerA, giant); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giant); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, giant, CounterType.M1M1, 2); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/SoulReapTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/SoulReapTest.java index 91a18f147c6..13013b89dc9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/SoulReapTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eve/SoulReapTest.java @@ -14,7 +14,7 @@ public class SoulReapTest extends CardTestPlayerBase { private static final String rats = "Muck Rats"; @Test - public void t() { + public void testSpell() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); addCard(Zone.BATTLEFIELD, playerA, lion); addCard(Zone.HAND, playerA, reap); @@ -36,7 +36,7 @@ public class SoulReapTest extends CardTestPlayerBase { } @Test - public void t2() { + public void testNoSpell() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); addCard(Zone.BATTLEFIELD, playerA, lion); addCard(Zone.HAND, playerA, reap); diff --git a/Mage/src/main/java/mage/MageObjectReference.java b/Mage/src/main/java/mage/MageObjectReference.java index f8ca0fb9271..413bd895dff 100644 --- a/Mage/src/main/java/mage/MageObjectReference.java +++ b/Mage/src/main/java/mage/MageObjectReference.java @@ -147,6 +147,14 @@ public class MageObjectReference implements Comparable, Ser return false; } + public boolean refersTo(Ability source, Game game) { + if (source == null || !source.getSourceId().equals(sourceId)) { + return false; + } + return zoneChangeCounter * source.getSourceObjectZoneChangeCounter() == 0 + || zoneChangeCounter == source.getSourceObjectZoneChangeCounter(); + } + public Permanent getPermanent(Game game) { Permanent permanent = game.getPermanent(sourceId); if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) {