From 5ed28d6f5302882cd794f6d78ffa0490e210ec65 Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Wed, 15 Jan 2025 12:10:23 +0000 Subject: [PATCH 1/6] [DSK] Implement Unable to Scream --- .../src/mage/cards/u/UnableToScream.java | 129 ++++++++++++++++++ .../src/mage/sets/DuskmournHouseOfHorror.java | 1 + 2 files changed, 130 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/UnableToScream.java diff --git a/Mage.Sets/src/mage/cards/u/UnableToScream.java b/Mage.Sets/src/mage/cards/u/UnableToScream.java new file mode 100644 index 000000000000..729301740e43 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnableToScream.java @@ -0,0 +1,129 @@ +package mage.cards.u; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author markort147 + */ +public final class UnableToScream extends CardImpl { + + public UnableToScream(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); + this.addAbility(new EnchantAbility(auraTarget)); + + // Enchanted creature loses all abilities and is a Toy artifact creature with base power and toughness 0/2 + // in addition to its other types. + this.addAbility(new SimpleStaticAbility(new UnableToScreamBecomesEffect())); + + // As long as enchanted creature is face down, it can't be turned face up. + this.addAbility(new SimpleStaticAbility(new UnableToScreamPreventingEffect())); + } + + private UnableToScream(final UnableToScream card) { + super(card); + } + + @Override + public UnableToScream copy() { + return new UnableToScream(this); + } +} + +class UnableToScreamBecomesEffect extends ContinuousEffectImpl { + + UnableToScreamBecomesEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + setText("Enchanted creature loses all abilities and is " + + "a Toy artifact creature with base power and " + + "toughness 0/2 in addition to its other types."); + } + + private UnableToScreamBecomesEffect(final UnableToScreamBecomesEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent aura = game.getPermanent(source.getSourceId()); + if (aura == null) + return false; + + Permanent creature = game.getPermanent(aura.getAttachedTo()); + if (creature == null) + return false; + + creature.getPower().setModifiedBaseValue(0); + creature.getToughness().setModifiedBaseValue(2); + creature.removeAllAbilities(source.getSourceId(), game); + creature.getCardType().add(CardType.ARTIFACT); + creature.getSubtype().add(SubType.TOY); + + return true; + } + + @Override + public ContinuousEffect copy() { + return new UnableToScreamBecomesEffect(this); + } +} + +class UnableToScreamPreventingEffect extends ContinuousRuleModifyingEffectImpl { + + UnableToScreamPreventingEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + setText("As long as enchanted creature is face down, it can't be turned face up."); + } + + private UnableToScreamPreventingEffect(final UnableToScreamPreventingEffect effect) { + super(effect); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType().equals(GameEvent.EventType.TURN_FACE_UP); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + Permanent aura = game.getPermanent(source.getSourceId()); + if (aura == null) + return false; + + Permanent creature = game.getPermanent(aura.getAttachedTo()); + if (creature == null) + return false; + + return creature.isFaceDown(game) && event.getTargetId().equals(creature.getId()); + } + + @Override + public ContinuousEffect copy() { + return new UnableToScreamPreventingEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java index 069107adced4..7145a37429f7 100644 --- a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java +++ b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java @@ -240,6 +240,7 @@ private DuskmournHouseOfHorror() { cards.add(new SetCardInfo("Twist Reality", 77, Rarity.COMMON, mage.cards.t.TwistReality.class)); cards.add(new SetCardInfo("Twitching Doll", 201, Rarity.RARE, mage.cards.t.TwitchingDoll.class)); cards.add(new SetCardInfo("Tyvar, the Pummeler", 202, Rarity.MYTHIC, mage.cards.t.TyvarThePummeler.class)); + cards.add(new SetCardInfo("Unable to Scream", 78, Rarity.COMMON, mage.cards.u.UnableToScream.class)); cards.add(new SetCardInfo("Under the Skin", 203, Rarity.UNCOMMON, mage.cards.u.UnderTheSkin.class)); cards.add(new SetCardInfo("Unidentified Hovership", 37, Rarity.RARE, mage.cards.u.UnidentifiedHovership.class)); cards.add(new SetCardInfo("Unnerving Grasp", 80, Rarity.UNCOMMON, mage.cards.u.UnnervingGrasp.class)); From f2916db1b079e2354c4d5284e461c378b86f4647 Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Thu, 16 Jan 2025 13:32:34 +0000 Subject: [PATCH 2/6] Introduced LoseAllAbilitiesAttachedEffect --- .../LoseAllAbilitiesAttachedEffect.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java new file mode 100644 index 000000000000..e0493903163a --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java @@ -0,0 +1,50 @@ + + +package mage.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * @author markort147 + */ +public class LoseAllAbilitiesAttachedEffect extends ContinuousEffectImpl { + + protected AttachmentType attachmentType; + + public LoseAllAbilitiesAttachedEffect(AttachmentType attachmentType) { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.LoseAbility); + this.attachmentType = attachmentType; + setText(); + } + + protected LoseAllAbilitiesAttachedEffect(final LoseAllAbilitiesAttachedEffect effect) { + super(effect); + this.attachmentType = effect.attachmentType; + } + + @Override + public LoseAllAbilitiesAttachedEffect copy() { + return new LoseAllAbilitiesAttachedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent equipment = game.getPermanent(source.getSourceId()); + if (equipment != null && equipment.getAttachedTo() != null) { + Permanent creature = game.getPermanent(equipment.getAttachedTo()); + if (creature != null) { + creature.removeAllAbilities(source.getSourceId(), game); + } + } + return true; + } + + private void setText() { + staticText = attachmentType.verb() + " creature loses all abilities"; + } + +} From 2f85026ca919f8f27233abcf1814ac6d1c5df2a5 Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Thu, 16 Jan 2025 13:33:32 +0000 Subject: [PATCH 3/6] Fixed Unable to Scream abilities --- .../src/mage/cards/u/UnableToScream.java | 58 ++++--------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UnableToScream.java b/Mage.Sets/src/mage/cards/u/UnableToScream.java index 729301740e43..1874fa5a1763 100644 --- a/Mage.Sets/src/mage/cards/u/UnableToScream.java +++ b/Mage.Sets/src/mage/cards/u/UnableToScream.java @@ -3,16 +3,16 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.AddCardSubtypeAttachedEffect; +import mage.abilities.effects.common.continuous.AddCardTypeAttachedEffect; +import mage.abilities.effects.common.continuous.LoseAllAbilitiesAttachedEffect; +import mage.abilities.effects.common.continuous.SetBasePowerToughnessEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.SubType; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -34,12 +34,16 @@ public UnableToScream(UUID ownerId, CardSetInfo setInfo) { // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); this.addAbility(new EnchantAbility(auraTarget)); // Enchanted creature loses all abilities and is a Toy artifact creature with base power and toughness 0/2 // in addition to its other types. - this.addAbility(new SimpleStaticAbility(new UnableToScreamBecomesEffect())); + Ability ability = new SimpleStaticAbility(new LoseAllAbilitiesAttachedEffect(AttachmentType.AURA)); + ability.addEffect(new AddCardSubtypeAttachedEffect(SubType.TOY, AttachmentType.AURA).setText(" and is a Toy")); + ability.addEffect(new AddCardTypeAttachedEffect(CardType.ARTIFACT, AttachmentType.AURA).setText(" artifact creature")); + ability.addEffect(new SetBasePowerToughnessEnchantedEffect(0, 2).setText(" with base power and toughness 0/2 in addition to its other types.")); + this.addAbility(ability); // As long as enchanted creature is face down, it can't be turned face up. this.addAbility(new SimpleStaticAbility(new UnableToScreamPreventingEffect())); @@ -55,48 +59,10 @@ public UnableToScream copy() { } } -class UnableToScreamBecomesEffect extends ContinuousEffectImpl { - - UnableToScreamBecomesEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - setText("Enchanted creature loses all abilities and is " + - "a Toy artifact creature with base power and " + - "toughness 0/2 in addition to its other types."); - } - - private UnableToScreamBecomesEffect(final UnableToScreamBecomesEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent aura = game.getPermanent(source.getSourceId()); - if (aura == null) - return false; - - Permanent creature = game.getPermanent(aura.getAttachedTo()); - if (creature == null) - return false; - - creature.getPower().setModifiedBaseValue(0); - creature.getToughness().setModifiedBaseValue(2); - creature.removeAllAbilities(source.getSourceId(), game); - creature.getCardType().add(CardType.ARTIFACT); - creature.getSubtype().add(SubType.TOY); - - return true; - } - - @Override - public ContinuousEffect copy() { - return new UnableToScreamBecomesEffect(this); - } -} - class UnableToScreamPreventingEffect extends ContinuousRuleModifyingEffectImpl { UnableToScreamPreventingEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Detriment); setText("As long as enchanted creature is face down, it can't be turned face up."); } From be21701cf45115573436241f9d39922aacadec29 Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Thu, 16 Jan 2025 15:01:52 +0000 Subject: [PATCH 4/6] Added unit tests for Unable to Scream --- .../cards/single/dsk/UnableToScreamTest.java | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java new file mode 100644 index 000000000000..d7ac6ae1a524 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java @@ -0,0 +1,125 @@ +package org.mage.test.cards.single.dsk; + +import mage.abilities.mana.GreenManaAbility; +import mage.constants.*; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +import java.util.Arrays; +import java.util.List; + +/** + * @author markort147 + */ +public class UnableToScreamTest extends CardTestPlayerBase { + + public static final String UNABLE_TO_SCREAM = "Unable to Scream"; + + @Test + public void cannotTurnFaceUpTest() { + String akroma = "Akroma, Angel of Fury"; + String breakOpen = "Break Open"; + + addCard(Zone.HAND, playerB, akroma); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 6); + + addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); + addCard(Zone.HAND, playerA, breakOpen, 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, akroma + " using Morph"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, breakOpen, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); + + setStopAt(4, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1); + assertPowerToughness(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0, 2); + } + + @Test + public void turnFaceUpAfterRemovingAuraTest() { + String akroma = "Akroma, Angel of Fury"; + String breakOpen = "Break Open"; + String removal = "Appetite for the Unnatural"; + + addCard(Zone.HAND, playerB, akroma); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 6); + addCard(Zone.HAND, playerB, removal); + addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); + + addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); + addCard(Zone.HAND, playerA, breakOpen, 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, akroma + " using Morph"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); + castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, removal, UNABLE_TO_SCREAM); + castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, breakOpen, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); + + setStopAt(5, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0); + assertPermanentCount(playerB, akroma, 1); + } + + + @Test + public void becomesToyTest() { + String elves = "Llanowar Elves"; + + addCard(Zone.BATTLEFIELD, playerB, elves); + addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, elves); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerB, elves, 1); + assertPermanentCount(playerA, UNABLE_TO_SCREAM, 1); + assertPowerToughness(playerB, elves, 0, 2); + assertAbility(playerB, elves, new GreenManaAbility(), false); + List types = Arrays.asList(CardType.CREATURE, CardType.ARTIFACT); + List subTypes = Arrays.asList(SubType.TOY, SubType.ELF, SubType.DRUID); + types.forEach(t -> + subTypes.forEach(st -> + assertType(elves, t, st) + ) + ); + } + + @Test + public void removeAuraTest() { + String elves = "Llanowar Elves"; + String removal = "Appetite for the Unnatural"; + + addCard(Zone.BATTLEFIELD, playerB, elves); + addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); + addCard(Zone.HAND, playerB, removal); + addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, elves); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, removal, UNABLE_TO_SCREAM); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerB, elves, 1); + assertPermanentCount(playerA, UNABLE_TO_SCREAM, 0); + + assertPowerToughness(playerB, elves, 1, 1); + assertType(elves, CardType.CREATURE, true); + assertType(elves, CardType.ARTIFACT, false); + assertSubtype(elves, SubType.ELF); + assertSubtype(elves, SubType.DRUID); + assertNotSubtype(elves, SubType.TOY); + assertAbility(playerB, elves, new GreenManaAbility(), true); + } +} From ce74783462e108dbdc5d9c8cd844b4c58306a83f Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Sat, 18 Jan 2025 14:01:28 +0000 Subject: [PATCH 5/6] Improved implementation and tests of Unable to Scream --- .../src/mage/cards/u/UnableToScream.java | 9 +- .../cards/single/dsk/UnableToScreamTest.java | 189 ++++++++++-------- .../LoseAllAbilitiesAttachedEffect.java | 3 +- 3 files changed, 116 insertions(+), 85 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UnableToScream.java b/Mage.Sets/src/mage/cards/u/UnableToScream.java index 1874fa5a1763..bced020427d8 100644 --- a/Mage.Sets/src/mage/cards/u/UnableToScream.java +++ b/Mage.Sets/src/mage/cards/u/UnableToScream.java @@ -37,8 +37,7 @@ public UnableToScream(UUID ownerId, CardSetInfo setInfo) { this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); this.addAbility(new EnchantAbility(auraTarget)); - // Enchanted creature loses all abilities and is a Toy artifact creature with base power and toughness 0/2 - // in addition to its other types. + // Enchanted creature loses all abilities and is a Toy artifact creature with base power and toughness 0/2 in addition to its other types. Ability ability = new SimpleStaticAbility(new LoseAllAbilitiesAttachedEffect(AttachmentType.AURA)); ability.addEffect(new AddCardSubtypeAttachedEffect(SubType.TOY, AttachmentType.AURA).setText(" and is a Toy")); ability.addEffect(new AddCardTypeAttachedEffect(CardType.ARTIFACT, AttachmentType.AURA).setText(" artifact creature")); @@ -78,12 +77,14 @@ public boolean checksEventType(GameEvent event, Game game) { @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent aura = game.getPermanent(source.getSourceId()); - if (aura == null) + if (aura == null) { return false; + } Permanent creature = game.getPermanent(aura.getAttachedTo()); - if (creature == null) + if (creature == null) { return false; + } return creature.isFaceDown(game) && event.getTargetId().equals(creature.getId()); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java index d7ac6ae1a524..7d7e95ec257c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/dsk/UnableToScreamTest.java @@ -1,125 +1,154 @@ package org.mage.test.cards.single.dsk; +import mage.abilities.Ability; import mage.abilities.mana.GreenManaAbility; +import mage.cards.Card; import mage.constants.*; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; import java.util.Arrays; -import java.util.List; +import java.util.Collections; +import java.util.HashSet; +import java.util.stream.Collectors; /** * @author markort147 */ public class UnableToScreamTest extends CardTestPlayerBase { + /* + * Unable to Scream {U} + * Enchantment - Aura + * Enchant creature + * Enchanted creature loses all abilities and is a Toy artifact creature with base power and toughness 0/2 in addition to its other types. + * As long as enchanted creature is face down, it can't be turned face up. + */ public static final String UNABLE_TO_SCREAM = "Unable to Scream"; - @Test - public void cannotTurnFaceUpTest() { - String akroma = "Akroma, Angel of Fury"; - String breakOpen = "Break Open"; + /* + * Appetite for the Unnatural {2}{G} + * Instant + * Destroy target artifact or enchantment. You gain 2 life. + */ + public static final String APPETITE_FOR_THE_UNNATURAL = "Appetite for the Unnatural"; + - addCard(Zone.HAND, playerB, akroma); + // Cast a spell that would turn the creature face up, but Unable to Scream negates the effect. + // After removing Unable to Scream, cast the spell again and the effect applies correctly. + @Test + public void preventFromTurningFaceUpTest() { + /* + * Akroma, Angel of Fury {5}{R}{R}{R} + * Creature - Legendary Angel + * 6/6 + * Akroma, Angel of Fury can't be countered. + * Flying + * Trample + * Protection from white and from blue. + * {R}: Akroma, Angel of Fury gets +1/+0 until end of turn. + * Morph {3}{R}{R}{R} + */ + final String akromaAngelOfFury = "Akroma, Angel of Fury"; + + /* + * Break Open {1}{R} + * Instant + * Turn target face-down creature an opponent controls face up. + */ + final String breakOpen = "Break Open"; + + setStrictChooseMode(true); + + addCard(Zone.HAND, playerB, akromaAngelOfFury); + addCard(Zone.HAND, playerB, APPETITE_FOR_THE_UNNATURAL); addCard(Zone.BATTLEFIELD, playerB, "Mountain", 6); + addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); - addCard(Zone.HAND, playerA, breakOpen, 1); + addCard(Zone.HAND, playerA, breakOpen, 2); addCard(Zone.BATTLEFIELD, playerA, "Island", 2); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, akroma + " using Morph"); + // prepare the face down creature + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, akromaAngelOfFury + " using Morph"); + // attach Unable to Scream to it castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true); + // cast a spell that would turn the creature face up castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, breakOpen, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); - setStopAt(4, PhaseStep.BEGIN_COMBAT); - execute(); - - assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1); - assertPowerToughness(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0, 2); - } - - @Test - public void turnFaceUpAfterRemovingAuraTest() { - String akroma = "Akroma, Angel of Fury"; - String breakOpen = "Break Open"; - String removal = "Appetite for the Unnatural"; + // the creature is still face down + checkPermanentCount("Face down creature is on the battlefield", 3, PhaseStep.BEGIN_COMBAT, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1); + checkPermanentCount("Akroma is not on the battlefield", 3, PhaseStep.BEGIN_COMBAT, playerB, akromaAngelOfFury, 0); - addCard(Zone.HAND, playerB, akroma); - addCard(Zone.BATTLEFIELD, playerB, "Mountain", 6); - addCard(Zone.HAND, playerB, removal); - addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); - - addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); - addCard(Zone.HAND, playerA, breakOpen, 1); - addCard(Zone.BATTLEFIELD, playerA, "Island", 2); - addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); - - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, akroma + " using Morph"); - castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); - castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, removal, UNABLE_TO_SCREAM); + // destroy Unable to Scream + castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, APPETITE_FOR_THE_UNNATURAL, UNABLE_TO_SCREAM); + // cast a spell that would turn the creature face up castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, breakOpen, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); + // now the creature is turned face up + checkPermanentCount("Face down creature is not on the battlefield", 5, PhaseStep.BEGIN_COMBAT, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0); + checkPermanentCount("Akroma is on the battlefield", 5, PhaseStep.BEGIN_COMBAT, playerB, akromaAngelOfFury, 1); + setStopAt(5, PhaseStep.BEGIN_COMBAT); execute(); - - assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0); - assertPermanentCount(playerB, akroma, 1); } - + // Unable to Scream changes type, subtype and base stats of a creature. + // After removing Unable to Scream, the creature restores its type, subtype, and base stats. @Test - public void becomesToyTest() { - String elves = "Llanowar Elves"; + public void becomesEffectTest() { + /* + * Llanowar Elves {G} + * Creature - Elf Druid + * 1/1 + * {T}: Add {G}. + */ + final String llanowarElves = "Llanowar Elves"; + + setStrictChooseMode(true); + + addCard(Zone.HAND, playerB, APPETITE_FOR_THE_UNNATURAL); + addCard(Zone.BATTLEFIELD, playerB, llanowarElves); + addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); - addCard(Zone.BATTLEFIELD, playerB, elves); addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); addCard(Zone.BATTLEFIELD, playerA, "Island", 2); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, elves); - - setStopAt(1, PhaseStep.BEGIN_COMBAT); - execute(); - - assertPermanentCount(playerB, elves, 1); - assertPermanentCount(playerA, UNABLE_TO_SCREAM, 1); - assertPowerToughness(playerB, elves, 0, 2); - assertAbility(playerB, elves, new GreenManaAbility(), false); - List types = Arrays.asList(CardType.CREATURE, CardType.ARTIFACT); - List subTypes = Arrays.asList(SubType.TOY, SubType.ELF, SubType.DRUID); - types.forEach(t -> - subTypes.forEach(st -> - assertType(elves, t, st) - ) + // attach Unable to Scream to the creature + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, llanowarElves); + + // the creature is an artifact creature, toy elf druid with base stats 0/2 + runCode("The creature is an artifact creature, toy elf druid with base stats 0/2", 1, PhaseStep.BEGIN_COMBAT, playerB, + (info, player, game) -> { + Card elves = game.getBattlefield().getAllActivePermanents().stream().filter(p -> p.getName().equals(llanowarElves)).findAny().orElse(null); + Assert.assertNotNull("The creature must be on the battlefield", elves); + Assert.assertEquals("The creature must have base power 0", 0, elves.getPower().getValue()); + Assert.assertEquals("The creature must have base toughness 2", 2, elves.getToughness().getValue()); + Assert.assertTrue("The creature must have lost its abilities", elves.getAbilities(game).isEmpty()); + Assert.assertEquals("The creature must be an artifact creature", new HashSet<>(Arrays.asList(CardType.ARTIFACT, CardType.CREATURE)), new HashSet<>(elves.getCardType(game))); + Assert.assertEquals("The creature must be a Toy Elf Druid", new HashSet<>(Arrays.asList(SubType.TOY, SubType.ELF, SubType.DRUID)), new HashSet<>(elves.getSubtype(game))); + } ); - } - - @Test - public void removeAuraTest() { - String elves = "Llanowar Elves"; - String removal = "Appetite for the Unnatural"; - - addCard(Zone.BATTLEFIELD, playerB, elves); - addCard(Zone.BATTLEFIELD, playerB, "Forest", 3); - addCard(Zone.HAND, playerB, removal); - addCard(Zone.HAND, playerA, UNABLE_TO_SCREAM); - addCard(Zone.BATTLEFIELD, playerA, "Island", 2); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, UNABLE_TO_SCREAM, elves); - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, removal, UNABLE_TO_SCREAM); + // destroy Unable to Scream + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, APPETITE_FOR_THE_UNNATURAL, UNABLE_TO_SCREAM); + + // the creature is a creature, elf druid with base stats 1/1 + runCode("The creature is creature, toy elf druid with base stats 1/1", 2, PhaseStep.BEGIN_COMBAT, playerB, + (info, player, game) -> { + Card elves = game.getBattlefield().getAllActivePermanents().stream().filter(p -> p.getName().equals(llanowarElves)).findAny().orElse(null); + Assert.assertNotNull("The creature must be on the battlefield", elves); + Assert.assertEquals("The creature must have base power 1", 1, elves.getPower().getValue()); + Assert.assertEquals("The creature must have base toughness 1", 1, elves.getToughness().getValue()); + Assert.assertTrue("The creature must have restored its abilities", elves.getAbilities(game).stream().map(Ability::getClass).collect(Collectors.toList()).contains(GreenManaAbility.class)); + Assert.assertEquals("The creature must be just a creature", Collections.singleton(CardType.CREATURE), new HashSet<>(elves.getCardType(game))); + Assert.assertEquals("The creature must be an Elf Druid", new HashSet<>(Arrays.asList(SubType.ELF, SubType.DRUID)), new HashSet<>(elves.getSubtype(game))); + } + ); setStopAt(2, PhaseStep.BEGIN_COMBAT); execute(); - - assertPermanentCount(playerB, elves, 1); - assertPermanentCount(playerA, UNABLE_TO_SCREAM, 0); - - assertPowerToughness(playerB, elves, 1, 1); - assertType(elves, CardType.CREATURE, true); - assertType(elves, CardType.ARTIFACT, false); - assertSubtype(elves, SubType.ELF); - assertSubtype(elves, SubType.DRUID); - assertNotSubtype(elves, SubType.TOY); - assertAbility(playerB, elves, new GreenManaAbility(), true); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java index e0493903163a..ea9ef01f1063 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAttachedEffect.java @@ -38,9 +38,10 @@ public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(equipment.getAttachedTo()); if (creature != null) { creature.removeAllAbilities(source.getSourceId(), game); + return true; } } - return true; + return false; } private void setText() { From 360485594cc54ca985c415b2b303dc1433d7a4a8 Mon Sep 17 00:00:00 2001 From: Marco Romano Date: Sun, 19 Jan 2025 08:31:26 +0000 Subject: [PATCH 6/6] UnableToScream.java: made copy method covariant --- Mage.Sets/src/mage/cards/u/UnableToScream.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UnableToScream.java b/Mage.Sets/src/mage/cards/u/UnableToScream.java index bced020427d8..215f870b1bd8 100644 --- a/Mage.Sets/src/mage/cards/u/UnableToScream.java +++ b/Mage.Sets/src/mage/cards/u/UnableToScream.java @@ -2,7 +2,6 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continuous.AddCardSubtypeAttachedEffect; @@ -90,7 +89,7 @@ public boolean applies(GameEvent event, Ability source, Game game) { } @Override - public ContinuousEffect copy() { + public UnableToScreamPreventingEffect copy() { return new UnableToScreamPreventingEffect(this); } }