reworked/simplified/consolidated effects which exchange life totals, added test (fixes #7668)

This commit is contained in:
Evan Kranzler 2021-03-14 15:56:48 -04:00
parent 1abeec9595
commit d4792e3665
16 changed files with 284 additions and 274 deletions

View file

@ -0,0 +1,117 @@
package org.mage.test.cards.single.cmr;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
*/
public class ProfaneTransfusionTest extends CardTestPlayerBase {
private static final String transfusion = "Profane Transfusion";
private static final String emperion = "Platinum Emperion";
private static final String reflection = "Boon Reflection";
private static final String skullcrack = "Skullcrack";
@Test
public void testRegular() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 9);
addCard(Zone.HAND, playerA, transfusion);
setLife(playerA, 24);
setLife(playerB, 16);
addTarget(playerA, playerA);
addTarget(playerA, playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, transfusion);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertLife(playerA, 16);
assertLife(playerB, 24);
assertPermanentCount(playerA, "Horror", 1);
assertPowerToughness(playerA, "Horror", 24 - 16, 24 - 16);
assertGraveyardCount(playerA, transfusion, 1);
}
@Test
public void testCantChange() {
// Platinum Emperion stops life totals from changing but token is still created
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 9);
addCard(Zone.BATTLEFIELD, playerA, emperion);
addCard(Zone.HAND, playerA, transfusion);
setLife(playerA, 24);
setLife(playerB, 16);
addTarget(playerA, playerA);
addTarget(playerA, playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, transfusion);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertLife(playerA, 24);
assertLife(playerB, 16);
assertPermanentCount(playerA, "Horror", 1);
assertPowerToughness(playerA, "Horror", 24 - 16, 24 - 16);
assertGraveyardCount(playerA, transfusion, 1);
}
@Test
public void testDoubleLife() {
// Boon Reflection doubles life gain, which affects final difference
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 9);
addCard(Zone.BATTLEFIELD, playerB, reflection);
addCard(Zone.HAND, playerA, transfusion);
setLife(playerA, 24);
setLife(playerB, 16);
addTarget(playerA, playerA);
addTarget(playerA, playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, transfusion);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertLife(playerA, 16);
assertLife(playerB, 32);
assertPermanentCount(playerA, "Horror", 1);
assertPowerToughness(playerA, "Horror", 32 - 16, 32 - 16);
assertGraveyardCount(playerA, transfusion, 1);
}
@Test
public void testCantGainLife() {
// Skullcrack prevents life gain, but final difference should still be 3
addCard(Zone.BATTLEFIELD, playerA, "Badlands", 11);
addCard(Zone.HAND, playerA, skullcrack);
addCard(Zone.HAND, playerA, transfusion);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skullcrack, playerB);
addTarget(playerA, playerA);
addTarget(playerA, playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, transfusion);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertLife(playerA, 20);
assertLife(playerB, 17);
assertPermanentCount(playerA, "Horror", 1);
assertPowerToughness(playerA, "Horror", 20 - 17, 20 - 17);
assertGraveyardCount(playerA, transfusion, 1);
}
}

View file

@ -3164,6 +3164,11 @@ public class TestPlayer implements Player {
return computerPlayer.gainLife(amount, game, source);
}
@Override
public void exchangeLife(Player player, Ability source, Game game) {
computerPlayer.exchangeLife(player, source, game);
}
@Override
public int damage(int damage, UUID attackerId, Ability source, Game game) {
return computerPlayer.damage(damage, attackerId, source, game);

View file

@ -137,6 +137,10 @@ public class PlayerStub implements Player {
return 0;
}
@Override
public void exchangeLife(Player player, Ability source, Game game) {
}
@Override
public int damage(int damage, UUID attackerId, Ability source, Game game) {
return 0;