mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
[NPH] Fix Hex Parasite wrong behaviour when X=0. Closes #9446.
This commit is contained in:
parent
9b0e63ef30
commit
bfa5b6ab5f
2 changed files with 74 additions and 27 deletions
|
@ -66,9 +66,15 @@ class HexParasiteEffect extends OneShotEffect {
|
|||
TargetPermanent target = (TargetPermanent) source.getTargets().get(0);
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null
|
||||
&& controller != null) {
|
||||
if (permanent == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int toRemove = source.getManaCostsToPay().getX();
|
||||
if (toRemove == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int removed = 0;
|
||||
String[] counterNames = permanent.getCounters(game).keySet().toArray(new String[0]);
|
||||
for (String counterName : counterNames) {
|
||||
|
@ -93,7 +99,4 @@ class HexParasiteEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.mage.test.cards.single.nph;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* {@link mage.cards.h.HexParasite Hex Parasite}
|
||||
*
|
||||
* {X}{B/P}: Remove up to X counters from target permanent.
|
||||
* For each counter removed this way, Hex Parasite gets +1/+0 until end of turn.
|
||||
*
|
||||
* @author Alex-Vasile
|
||||
*/
|
||||
public class HexParasiteTest extends CardTestPlayerBase {
|
||||
|
||||
private static final String hexParasite = "Hex Parasite";
|
||||
|
||||
/**
|
||||
* Reported bug: https://github.com/magefree/mage/issues/9446
|
||||
* Removing 0 counters results in "Server's error: (minimum = value = maximum) is false"
|
||||
*/
|
||||
@Test
|
||||
public void remove0Counters() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, hexParasite);
|
||||
addCard(Zone.HAND, playerA, "Urza's Saga");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
|
||||
playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Urza's Saga");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{X}");
|
||||
setChoice(playerA, "X=0");
|
||||
setChoice(playerA, "Yes"); // Pay 2 life
|
||||
addTarget(playerA, "Urza's Saga");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertCounterCount(playerA, "Urza's Saga", CounterType.LORE, 1);
|
||||
assertLife(playerA, 20 - 2);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue