prevent direct access of Player->counters ; some cleanup on counter removal effects ; implement [MH3] Izzet Generatorium (#12314)

This commit is contained in:
Susucre 2024-05-29 22:34:54 +02:00 committed by GitHub
parent 8d02ff14ff
commit 20b7a115da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
110 changed files with 895 additions and 646 deletions

View file

@ -21,7 +21,6 @@ public class PersistTest extends CardTestPlayerBase {
/**
* Tests Safehold Elite don't returns from Persist if already a -1/-1
* counter was put on it from another source
*
*/
@Test
public void testUndyingdoesntTriggerWithMinusCounter() {
@ -48,7 +47,7 @@ public class PersistTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Safehold Elite", 1);
// one poison counter from Virulent Wound
Assert.assertEquals(1, playerA.getCounters().getCount(CounterType.POISON));
Assert.assertEquals(1, playerA.getCountersCount(CounterType.POISON));
}
/**

View file

@ -0,0 +1,95 @@
package org.mage.test.cards.single.mh3;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.players.Player;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class IzzetGeneratoriumTest extends CardTestPlayerBase {
/**
* {@link mage.cards.i.IzzetGeneratorium Izzet Generatorium} {U}{R}
* Artifact
* If you would get one or more {E} (energy counters), you get that many plus one {E} instead.
* {T}: Draw a card. Activate only if youve paid or lost four or more {E} this turn.
*/
private static final String generator = "Izzet Generatorium";
private static void checkEnergyCount(String message, Player player, int expected) {
Assert.assertEquals(message, expected, player.getCountersCount(CounterType.ENERGY));
}
@Test
public void test_Pay_Energy() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, generator);
// When Bristling Hydra enters the battlefield, you get {E}{E}{E} (three energy counters).
// Pay {E}{E}{E}: Put a +1/+1 counter on Bristling Hydra. It gains hexproof until end of turn.
addCard(Zone.HAND, playerA, "Bristling Hydra", 2);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 8);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bristling Hydra", true);
runCode("energy counter is 4", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 4));
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bristling Hydra", true);
runCode("energy counter is 8", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 8));
checkPlayableAbility("1: condition not met before activing once", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw", false);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pay {E}{E}{E}");
runCode("energy counter is 5", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 5));
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("2: condition not met before activing twice", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw", false);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pay {E}{E}{E}");
runCode("energy counter is 2", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 2));
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("3: condition met after activing twice", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw", true);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
}
@Test
public void test_Lose_Energy() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, generator);
// When Bristling Hydra enters the battlefield, you get {E}{E}{E} (three energy counters).
// Pay {E}{E}{E}: Put a +1/+1 counter on Bristling Hydra. It gains hexproof until end of turn.
addCard(Zone.HAND, playerA, "Bristling Hydra");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
// Choose one or more
// Destroy all creatures.
// Destroy all planeswalkers.
// Destroy all battles.
// Exile all graveyards.
// Each opponent loses all counters.
addCard(Zone.HAND, playerB, "Final Act");
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 6);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bristling Hydra", true);
runCode("energy counter is 4", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 4));
checkPlayableAbility("1: condition not met before losing counters", 2, PhaseStep.UPKEEP, playerA, "{T}: Draw", false);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Final Act");
setModeChoice(playerB, "5"); // each opponent loses all counters.
waitStackResolved(2, PhaseStep.PRECOMBAT_MAIN);
runCode("energy counter is 0", 2, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 0));
checkPlayableAbility("2: condition met after losing counters", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw", true);
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
}
}

View file

@ -24,7 +24,7 @@ public class OtharriSunsGloryTest extends CardTestPlayerBase {
private static final String otharri = "Otharri, Suns' Glory";
private static void checkExperienceCounter(String message, Player player, int expected) {
Assert.assertEquals(message, expected, player.getCounters().getCount(CounterType.EXPERIENCE));
Assert.assertEquals(message, expected, player.getCountersCount(CounterType.EXPERIENCE));
}
@Test

View file

@ -29,7 +29,7 @@ public class RadCounterTriggerTest extends CardTestPlayerBase {
private static final String fallout = "Nuclear Fallout";
private static void checkRadCounterCount(String message, Player player, int expected) {
Assert.assertEquals(message, expected, player.getCounters().getCount(CounterType.RAD));
Assert.assertEquals(message, expected, player.getCountersCount(CounterType.RAD));
}
private static void checkGraveyardSize(String message, Player player, int expected) {

View file

@ -2961,8 +2961,8 @@ public class TestPlayer implements Player {
}
@Override
public Counters getCounters() {
return computerPlayer.getCounters();
public Counters getCountersAsCopy() {
return computerPlayer.getCountersAsCopy();
}
@Override
@ -3441,8 +3441,33 @@ public class TestPlayer implements Player {
}
@Override
public void removeCounters(String name, int amount, Ability source, Game game) {
computerPlayer.removeCounters(name, amount, source, game);
public void loseCounters(String counterName, int amount, Ability source, Game game) {
computerPlayer.loseCounters(counterName, amount, source, game);
}
@Override
public int loseAllCounters(Ability source, Game game) {
return computerPlayer.loseAllCounters(source, game);
}
@Override
public int loseAllCounters(String counterName, Ability source, Game game) {
return computerPlayer.loseAllCounters(counterName, source, game);
}
@Override
public int getCountersCount(CounterType counterType) {
return computerPlayer.getCountersCount(counterType);
}
@Override
public int getCountersCount(String counterName) {
return computerPlayer.getCountersCount(counterName);
}
@Override
public int getCountersTotalCount() {
return computerPlayer.getCountersTotalCount();
}
@Override

View file

@ -1143,7 +1143,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertCounterCount(Player player, CounterType type, int count) throws AssertionError {
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + player.getName() + ':' + type + ')', count, player.getCounters().getCount(type));
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + player.getName() + ':' + type + ')', count, player.getCountersCount(type));
}
/**