* Curse of Spite - Fixed that the effects of the curse were not correctly applied after the target player dies. (fixes #3401).

This commit is contained in:
LevelX2 2017-05-20 09:30:23 +02:00
parent 2c919f3391
commit 3cd63003c0
2 changed files with 46 additions and 7 deletions

View file

@ -25,9 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
@ -50,8 +50,6 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author spjspj
*/
@ -158,7 +156,7 @@ class CurseOfVengeancePlayerLosesTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "When enchanted player loses the game, you gain X life and draw X cards, where X is the number of spite counters on Curse of Vengeance";
return "When enchanted player loses the game, you gain X life and draw X cards, where X is the number of spite counters on {this}";
}
}
@ -181,13 +179,13 @@ class CurseOfVengeanceDrawLifeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
if (sourceObject != null) {
Permanent sourceObject = (Permanent) game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null && controller != null) {
if (sourceObject.getCounters(game).containsKey(CounterType.SPITE)) {
controller.drawCards(sourceObject.getCounters(game).getCount(CounterType.SPITE), game);
controller.gainLife(sourceObject.getCounters(game).getCount(CounterType.SPITE), game);
}
return true;
}
return false;
}

View file

@ -266,4 +266,45 @@ public class PlayerLeftGameRangeAllTest extends CardTestMultiPlayerBase {
assertCounterCount(playerA, "Luminarch Ascension", CounterType.QUEST, 1); // 1 from turn 2
}
/**
* "When playing in a multiplayer match against humans, the aura curse
* "Curse of Vengeance" is supposed to award cards and life to its caster
* when the victim of the spell loses the game. It seems to erroneously
* award those cards to the victim of the curse, who, by that point, is
* already dead, making the spell almost totally useless."
*/
@Test
public void TestCurseOfVengeance() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
// Whenever enchanted player casts a spell, put a spite counter on Curse of Vengeance.
// When enchanted player loses the game, you gain X life and draw X cards, where X is the number of spite counters on Curse of Vengeance.
addCard(Zone.HAND, playerA, "Curse of Vengeance"); // Enchantment {B}
addCard(Zone.HAND, playerC, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerC, "Mountain", 1);
addCard(Zone.HAND, playerD, "Silvercoat Lion", 2);
addCard(Zone.BATTLEFIELD, playerD, "Plains", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curse of Vengeance", playerD);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerD, "Silvercoat Lion");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerD, "Silvercoat Lion");
castSpell(2, PhaseStep.BEGIN_COMBAT, playerC, "Lightning Bolt", playerD);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerC, "Lightning Bolt", 1);
assertGraveyardCount(playerA, "Curse of Vengeance", 1);
assertLife(playerD, -1);
Assert.assertFalse("Player D is no longer in the game", playerD.isInGame());
assertHandCount(playerA, 3);
assertLife(playerA, 4);
}
}