Skip to content

Commit

Permalink
tests: added AI reproduceable bug from #13290
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDi85 committed Feb 3, 2025
1 parent 58fbfdd commit 356d677
Showing 1 changed file with 79 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
Expand All @@ -17,7 +17,7 @@
*
* @author noxx, JayDi85
*/
public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
public class AttackBlockRestrictionsTest extends CardTestPlayerBaseWithAIHelps {

@Test
public void testFlyingVsNonFlying() {
Expand Down Expand Up @@ -946,4 +946,81 @@ public void test_MustBeBlockedWithMenace_low_blockers_manual() {
assertLife(playerB, 20 - 4);
assertGraveyardCount(playerA, "Alley Strangler", 0);
}

@Test
public void test_MustBeBlockedWithMenace_low_small_blockers_AI() {
// At the beginning of combat on your turn, you may pay {2}{R/G}. If you do, double target creature’s
// power until end of turn. That creature must be blocked this combat if able.
addCard(Zone.BATTLEFIELD, playerA, "Neyith of the Dire Hunt"); // 3/3
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
//
// Menace
addCard(Zone.BATTLEFIELD, playerA, "Alley Strangler", 1); // 2/3
//
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 1); // 1/1

// If the target creature has menace, two creatures must block it if able.
// (2020-06-23)
//
// If a creature is required to block a creature with menace, another creature must also block that creature
// if able. If none can, the creature that’s required to block can block another creature or not block at all.
// (2020-04-17)

// auto-fix block config inside
// AI must ignore such use case

addTarget(playerA, "Alley Strangler"); // boost target
setChoice(playerA, true); // boost target
attack(1, playerA, "Alley Strangler");
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
checkAttackers("x1 attacker", 1, playerA, "Alley Strangler");
checkBlockers("no blockers", 1, playerB, "");

setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();

assertLife(playerB, 20 - 4);
assertGraveyardCount(playerA, "Alley Strangler", 0);
}

@Test
@Ignore // TODO: need to fix
public void test_MustBeBlockedWithMenace_low_big_blockers_AI() {
// bug: #13290, AI can try to use bigger creature to block

// At the beginning of combat on your turn, you may pay {2}{R/G}. If you do, double target creature’s
// power until end of turn. That creature must be blocked this combat if able.
addCard(Zone.BATTLEFIELD, playerA, "Neyith of the Dire Hunt"); // 3/3
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
//
// Menace
addCard(Zone.BATTLEFIELD, playerA, "Alley Strangler", 1); // 2/3
//
addCard(Zone.BATTLEFIELD, playerB, "Deadbridge Goliath", 1); // 5/5

// If the target creature has menace, two creatures must block it if able.
// (2020-06-23)
//
// If a creature is required to block a creature with menace, another creature must also block that creature
// if able. If none can, the creature that’s required to block can block another creature or not block at all.
// (2020-04-17)

// auto-fix block config inside
// AI must ignore BIG creature to wrongly block

addTarget(playerA, "Alley Strangler"); // boost target
setChoice(playerA, true); // boost target
attack(1, playerA, "Alley Strangler");
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
checkAttackers("x1 attacker", 1, playerA, "Alley Strangler");
checkBlockers("no blockers", 1, playerB, "");

setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();

assertLife(playerB, 20 - 4);
assertGraveyardCount(playerA, "Alley Strangler", 0);
}
}

0 comments on commit 356d677

Please sign in to comment.