Refactoring methods which add counters to track which player adds the counters (ready for review) (#7448)

* added parameter for player adding counters to players

* added parameter for player adding counters to cards/permanents

* updated methods to use new parameter

* fixed a few initial errors

* refactored instances of cards that add counters by a player other than the controller

* fixed some instances of incorrect arguments

* refactored abilities that trigger off of a particular player adding counters

* a few more cards that were missed

* [KHM] Implemented Vorinclex, Monstrous Raider

* added test for Vorinclex, Monstrous Raider

* fixed a test failure
This commit is contained in:
Evan Kranzler 2021-01-26 19:06:13 -05:00 committed by GitHub
parent 4db79ae3c1
commit a535cb5adc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
320 changed files with 701 additions and 481 deletions

View file

@ -0,0 +1,120 @@
package org.mage.test.cards.single.khm;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
*/
public class VorinclexMonstrousRaiderTest extends CardTestPlayerBase {
private static final String vorinclex = "Vorinclex, Monstrous Raider";
private static final String boon = "Dragonscale Boon";
private static final String bear = "Grizzly Bears";
private static final String rats = "Ichor Rats";
@Test
public void testIDoubleCountersOnMyStuff() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.HAND, playerA, boon);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, boon, bear);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(bear, CounterType.P1P1, 4);
}
@Test
public void testIDoubleCountersOnTheirStuff() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.BATTLEFIELD, playerB, bear);
addCard(Zone.HAND, playerA, boon);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, boon, bear);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(bear, CounterType.P1P1, 4);
}
@Test
public void testIDoubleCountersOnMyself() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.HAND, playerA, rats);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, rats);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(playerA, CounterType.POISON, 2);
assertCounterCount(playerB, CounterType.POISON, 2);
}
@Test
public void testTheyHalveCountersOnTheirStuff() {
addCard(Zone.BATTLEFIELD, playerB, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.BATTLEFIELD, playerB, bear);
addCard(Zone.HAND, playerB, boon);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, boon, bear);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(bear, CounterType.P1P1, 1);
}
@Test
public void testTheyHalveCountersOnMyStuff() {
addCard(Zone.BATTLEFIELD, playerB, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.HAND, playerB, boon);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, boon, bear);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(bear, CounterType.P1P1, 1);
}
@Test
public void testTheyHalveCountersOnMyself() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.BATTLEFIELD, playerB, vorinclex);
addCard(Zone.HAND, playerA, rats);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, rats);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(playerA, CounterType.POISON, 0);
assertCounterCount(playerB, CounterType.POISON, 0);
}
}

View file

@ -673,7 +673,7 @@ public class TestPlayer implements Player {
CounterType counterType = CounterType.findByName(groups[1]);
Assert.assertNotNull("Invalid counter type " + groups[1], counterType);
Counter counter = counterType.createInstance(Integer.parseInt(groups[2]));
permanent.addCounters(counter, source, game);
permanent.addCounters(counter, source.getControllerId(), source, game);
actions.remove(action);
return true;
}
@ -3135,8 +3135,8 @@ public class TestPlayer implements Player {
}
@Override
public boolean addCounters(Counter counter, Ability source, Game game) {
return computerPlayer.addCounters(counter, source, game);
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game) {
return computerPlayer.addCounters(counter, source.getControllerId(), source, game);
}
@Override

View file

@ -1070,7 +1070,7 @@ public class PlayerStub implements Player {
}
@Override
public boolean addCounters(Counter counter, Ability source, Game game) {
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game) {
return true;
}