[KHM] fixed Vorinclex, Monstrous Raider - can't double counters on planeswalkers (#7463);

This commit is contained in:
Oleg Agafonov 2021-01-29 17:41:49 +04:00
parent 6f2ce47885
commit 91bac931b7
2 changed files with 32 additions and 2 deletions

View file

@ -12,6 +12,8 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -85,10 +87,17 @@ class VorinclexMonstrousRaiderEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getPlayer(event.getTargetId()) == null Player targetPlayer = game.getPlayer(event.getTargetId());
&& game.getState().getZone(event.getTargetId()) != Zone.BATTLEFIELD) { Permanent targetPermanet = game.getPermanentEntering(event.getTargetId());
if (targetPermanet == null) {
targetPermanet = game.getPermanent(event.getTargetId());
}
// on a permanent or player
if (targetPlayer == null && targetPermanet == null) {
return false; return false;
} }
return source.isControlledBy(event.getPlayerId()) return source.isControlledBy(event.getPlayerId())
|| game.getOpponents(event.getPlayerId()).contains(source.getControllerId()); || game.getOpponents(event.getPlayerId()).contains(source.getControllerId());
} }

View file

@ -11,10 +11,15 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*/ */
public class VorinclexMonstrousRaiderTest extends CardTestPlayerBase { public class VorinclexMonstrousRaiderTest extends CardTestPlayerBase {
// If you would put one or more counters on a permanent or player, put twice that many of each of
// those kinds of counters on that permanent or player instead.
// If an opponent would put one or more counters on a permanent or player, they put half that
// many of each of those kinds of counters on that permanent or player instead, rounded down.
private static final String vorinclex = "Vorinclex, Monstrous Raider"; private static final String vorinclex = "Vorinclex, Monstrous Raider";
private static final String boon = "Dragonscale Boon"; private static final String boon = "Dragonscale Boon";
private static final String bear = "Grizzly Bears"; private static final String bear = "Grizzly Bears";
private static final String rats = "Ichor Rats"; private static final String rats = "Ichor Rats";
private static final String planeswalker = "Chandra, Fire Artisan"; // 4 loyalty
@Test @Test
public void testIDoubleCountersOnMyStuff() { public void testIDoubleCountersOnMyStuff() {
@ -67,6 +72,22 @@ public class VorinclexMonstrousRaiderTest extends CardTestPlayerBase {
assertCounterCount(playerB, CounterType.POISON, 2); assertCounterCount(playerB, CounterType.POISON, 2);
} }
@Test
public void testIDoubleCountersOnPlaneswalker() {
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
addCard(Zone.HAND, playerA, planeswalker); // {2}{R}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, planeswalker);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertCounterCount(playerA, planeswalker, CounterType.LOYALTY, 4 * 2);
}
@Test @Test
public void testTheyHalveCountersOnTheirStuff() { public void testTheyHalveCountersOnTheirStuff() {
addCard(Zone.BATTLEFIELD, playerB, "Forest", 4); addCard(Zone.BATTLEFIELD, playerB, "Forest", 4);