From d98d59cc55d96157f5b9a312329d494c6043d7ae Mon Sep 17 00:00:00 2001 From: jmlundeen Date: Wed, 29 Oct 2025 21:00:11 -0500 Subject: [PATCH] rework MayhemLandAbility to work properly --- .../src/mage/cards/o/OscorpIndustries.java | 4 +- .../single/spm/OscorpIndustriesTest.java | 54 ++++++++++++++- .../abilities/keyword/MayhemLandAbility.java | 66 +++++++++++-------- 3 files changed, 92 insertions(+), 32 deletions(-) diff --git a/Mage.Sets/src/mage/cards/o/OscorpIndustries.java b/Mage.Sets/src/mage/cards/o/OscorpIndustries.java index f694701108b..d2bf00ac565 100644 --- a/Mage.Sets/src/mage/cards/o/OscorpIndustries.java +++ b/Mage.Sets/src/mage/cards/o/OscorpIndustries.java @@ -20,7 +20,7 @@ import java.util.UUID; public final class OscorpIndustries extends CardImpl { public OscorpIndustries(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + super(ownerId, setInfo, new CardType[]{CardType.LAND}, null); // This land enters tapped. @@ -35,7 +35,7 @@ public final class OscorpIndustries extends CardImpl { this.addAbility(new RedManaAbility()); // Mayhem - this.addAbility(new MayhemLandAbility(this)); + this.addAbility(new MayhemLandAbility()); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/OscorpIndustriesTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/OscorpIndustriesTest.java index 364cc480059..4e3f23468fa 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/OscorpIndustriesTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/OscorpIndustriesTest.java @@ -41,7 +41,7 @@ public class OscorpIndustriesTest extends CardTestPlayerBase { activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw"); setChoice(playerA, oscorpIndustries); - playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries + " with Mayhem"); + playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries); setStopAt(1, PhaseStep.END_TURN); execute(); @@ -49,4 +49,56 @@ public class OscorpIndustriesTest extends CardTestPlayerBase { assertLife(playerA, 20 - 2); assertPermanentCount(playerA, oscorpIndustries, 1); } + + @Test + public void testOscorpIndustriesNoMayhem() { + setStrictChooseMode(true); + + addCard(Zone.HAND, playerA, oscorpIndustries); + addCard(Zone.BATTLEFIELD, playerA, thoughtCourier); + + playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, oscorpIndustries); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertPermanentCount(playerA, oscorpIndustries, 1); + } + + @Test + public void testCantPlayWithoutDiscard() { + setStrictChooseMode(true); + + addCard(Zone.GRAVEYARD, playerA, oscorpIndustries); + + checkPlayableAbility("Can't play without discard", 1, PhaseStep.PRECOMBAT_MAIN, playerA, + "Play " + oscorpIndustries, false); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertPermanentCount(playerA, oscorpIndustries, 0); + } + + @Test + public void testOscorpIndustriesNextTurn() { + setStrictChooseMode(true); + + addCard(Zone.HAND, playerA, oscorpIndustries); + addCard(Zone.BATTLEFIELD, playerA, thoughtCourier); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw"); + setChoice(playerA, oscorpIndustries); + + checkPlayableAbility("Can't play without discard", 3, PhaseStep.PRECOMBAT_MAIN, playerA, + "Play " + oscorpIndustries, false); + + setStopAt(3, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertLife(playerA, 20); + assertPermanentCount(playerA, oscorpIndustries, 0); + } } \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/keyword/MayhemLandAbility.java b/Mage/src/main/java/mage/abilities/keyword/MayhemLandAbility.java index 14c5d962023..064028ae4d0 100644 --- a/Mage/src/main/java/mage/abilities/keyword/MayhemLandAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/MayhemLandAbility.java @@ -1,23 +1,22 @@ package mage.abilities.keyword; -import mage.MageIdentifier; -import mage.abilities.PlayLandAbility; -import mage.cards.Card; -import mage.constants.Zone; +import mage.abilities.Ability; +import mage.abilities.StaticAbility; +import mage.abilities.effects.AsThoughEffect; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.constants.*; import mage.game.Game; -import java.util.Set; import java.util.UUID; -public class MayhemLandAbility extends PlayLandAbility { +public class MayhemLandAbility extends StaticAbility { private final String rule; - public MayhemLandAbility(Card card) { - super(card.getName()); - this.zone = Zone.GRAVEYARD; + public MayhemLandAbility() { + super(AbilityType.STATIC, Zone.GRAVEYARD); this.newId(); - this.name += " with Mayhem"; + this.addEffect(new MayhemPlayEffect()); this.addWatcher(new MayhemWatcher()); this.setRuleAtTheTop(true); this.rule = "Mayhem " + @@ -30,24 +29,6 @@ public class MayhemLandAbility extends PlayLandAbility { this.rule = ability.rule; } - @Override - public ActivationStatus canActivate(UUID playerId, Game game) { - if (!Zone.GRAVEYARD.match(game.getState().getZone(getSourceId())) - || !MayhemWatcher.checkCard(getSourceId(), game)) { - return ActivationStatus.getFalse(); - } - return super.canActivate(playerId, game); - } - - @Override - public boolean activate(Game game, Set allowedIdentifiers, boolean noMana) { - if (!super.activate(game, allowedIdentifiers, noMana)) { - return false; - } - this.setCostsTag(MayhemAbility.MAYHEM_ACTIVATION_VALUE_KEY, null); - return true; - } - @Override public MayhemLandAbility copy() { return new MayhemLandAbility(this); @@ -57,4 +38,31 @@ public class MayhemLandAbility extends PlayLandAbility { public String getRule() { return rule; } - } \ No newline at end of file +} + +class MayhemPlayEffect extends AsThoughEffectImpl { + + public MayhemPlayEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileInGraveyard, Outcome.Neutral); + } + + public MayhemPlayEffect(final MayhemPlayEffect effect) { + super(effect); + } + + @Override + public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + return Zone.GRAVEYARD.match(game.getState().getZone(sourceId)) + && MayhemWatcher.checkCard(sourceId, game); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public AsThoughEffect copy() { + return new MayhemPlayEffect(this); + } +} \ No newline at end of file