From 421cac0ce3cc03cc755dd341ff50d03e09c6a1f2 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 3 Sep 2021 02:11:21 +0400 Subject: [PATCH] * AI: fixed that computer can broke some non mana pays (Echo, Escalate, Recover, Tap source unless pay, Slow Motion, #8182); --- Mage.Sets/src/mage/cards/g/GameTrail.java | 1 - Mage.Sets/src/mage/cards/s/SlowMotion.java | 2 +- .../test/cards/single/soi/GameTrailTest.java | 107 ++++++++++++++++++ .../common/TapSourceUnlessPaysEffect.java | 2 +- .../abilities/effects/keyword/EchoEffect.java | 2 +- .../abilities/keyword/EscalateAbility.java | 2 +- .../abilities/keyword/RecoverAbility.java | 2 +- 7 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/soi/GameTrailTest.java diff --git a/Mage.Sets/src/mage/cards/g/GameTrail.java b/Mage.Sets/src/mage/cards/g/GameTrail.java index 95583afb1b..3eec70584f 100644 --- a/Mage.Sets/src/mage/cards/g/GameTrail.java +++ b/Mage.Sets/src/mage/cards/g/GameTrail.java @@ -1,4 +1,3 @@ - package mage.cards.g; import java.util.UUID; diff --git a/Mage.Sets/src/mage/cards/s/SlowMotion.java b/Mage.Sets/src/mage/cards/s/SlowMotion.java index b3b367d90a..705c11ef3b 100644 --- a/Mage.Sets/src/mage/cards/s/SlowMotion.java +++ b/Mage.Sets/src/mage/cards/s/SlowMotion.java @@ -69,7 +69,7 @@ class SacrificeEquipedUnlessPaysEffect extends OneShotEffect { public SacrificeEquipedUnlessPaysEffect(final SacrificeEquipedUnlessPaysEffect effect) { super(effect); - this.cost = effect.cost; + this.cost = effect.cost.copy(); } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/GameTrailTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/GameTrailTest.java new file mode 100644 index 0000000000..31c7a7001f --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/GameTrailTest.java @@ -0,0 +1,107 @@ +package org.mage.test.cards.single.soi; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author JayDi85 + */ +public class GameTrailTest extends CardTestPlayerBase { + + @Test + public void test_Reveal() { + // As Game Trail enters the battlefield, you may reveal a Mountain or Forest card from your hand. If you don't, Game Trail enters the battlefield tapped. + // {T}: Add {R} or {G}. + addCard(Zone.HAND, playerA, "Game Trail", 1); // land + addCard(Zone.HAND, playerA, "Forest", 1); + addCard(Zone.HAND, playerA, "Mountain", 1); + + // play with reveal + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Game Trail"); + setChoice(playerA, true); // reveal + setChoice(playerA, "Forest"); // reveal forest + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertTapped("Game Trail", false); + } + + @Test + public void test_RevealWithoutCards() { + // As Game Trail enters the battlefield, you may reveal a Mountain or Forest card from your hand. If you don't, Game Trail enters the battlefield tapped. + // {T}: Add {R} or {G}. + addCard(Zone.HAND, playerA, "Game Trail", 1); // land + addCard(Zone.HAND, playerA, "Swamp", 1); + + // play with reveal + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Game Trail"); + // no reveal choices + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertTapped("Game Trail", true); + } + + @Test + public void test_NotReveal() { + // As Game Trail enters the battlefield, you may reveal a Mountain or Forest card from your hand. If you don't, Game Trail enters the battlefield tapped. + // {T}: Add {R} or {G}. + addCard(Zone.HAND, playerA, "Game Trail", 1); // land + addCard(Zone.HAND, playerA, "Forest", 1); + addCard(Zone.HAND, playerA, "Mountain", 1); + + // play with reveal + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Game Trail"); + setChoice(playerA, false); // no reveal + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertTapped("Game Trail", true); + } + + @Test + public void test_RevealAfterCultivate() { + removeAllCardsFromLibrary(playerA); + + // As Game Trail enters the battlefield, you may reveal a Mountain or Forest card from your hand. If you don't, Game Trail enters the battlefield tapped. + // {T}: Add {R} or {G}. + addCard(Zone.HAND, playerA, "Game Trail", 1); // land + addCard(Zone.LIBRARY, playerA, "Forest", 1); + addCard(Zone.LIBRARY, playerA, "Island", 1); + addCard(Zone.LIBRARY, playerA, "Swamp", 1); + // + // Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped + // and the other into your hand. Then shuffle your library. + addCard(Zone.HAND, playerA, "Cultivate", 1); // {2}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); + + // put forest by cultivate + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cultivate"); + addTarget(playerA, "Forest^Swamp"); + setChoice(playerA, "Swamp"); // put tapped + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + + // play game trail + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Game Trail"); + setChoice(playerA, true); // reveal + setChoice(playerA, "Forest"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertTapped("Game Trail", false); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/TapSourceUnlessPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TapSourceUnlessPaysEffect.java index 6549172ace..91a1951c85 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/TapSourceUnlessPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/TapSourceUnlessPaysEffect.java @@ -26,7 +26,7 @@ public class TapSourceUnlessPaysEffect extends OneShotEffect { public TapSourceUnlessPaysEffect(final TapSourceUnlessPaysEffect effect) { super(effect); - this.cost = effect.cost; + this.cost = effect.cost.copy(); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/EchoEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/EchoEffect.java index 88a11a7d03..38fed94a70 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/EchoEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/EchoEffect.java @@ -34,7 +34,7 @@ public class EchoEffect extends OneShotEffect { public EchoEffect(final EchoEffect effect) { super(effect); - this.cost = effect.cost; + this.cost = effect.cost == null ? null : effect.cost.copy(); this.amount = effect.amount; } diff --git a/Mage/src/main/java/mage/abilities/keyword/EscalateAbility.java b/Mage/src/main/java/mage/abilities/keyword/EscalateAbility.java index 4fba5ecc28..4a552751e4 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EscalateAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EscalateAbility.java @@ -45,7 +45,7 @@ class EscalateEffect extends CostModificationEffectImpl { EscalateEffect(final EscalateEffect effect) { super(effect); - this.cost = effect.cost; + this.cost = effect.cost.copy(); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/RecoverAbility.java b/Mage/src/main/java/mage/abilities/keyword/RecoverAbility.java index 511cd5f258..cf6bb384bb 100644 --- a/Mage/src/main/java/mage/abilities/keyword/RecoverAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/RecoverAbility.java @@ -76,7 +76,7 @@ class RecoverEffect extends OneShotEffect { public RecoverEffect(final RecoverEffect effect) { super(effect); - this.cost = effect.cost; + this.cost = effect.cost.copy(); } @Override