From 83ba73ab2416813a07d7ab8cc373916768ef2cbc Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 3 Jan 2015 23:46:45 +0100 Subject: [PATCH] Allow spells to have lifelink. --- Mage/src/mage/game/permanent/PermanentImpl.java | 16 ++++++++++++++-- Mage/src/mage/players/PlayerImpl.java | 17 +++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 1473de600fa..7b3692e29de 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -67,6 +67,7 @@ import mage.game.events.DamagedPlaneswalkerEvent; import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.stack.Spell; import mage.players.Player; /** @@ -634,9 +635,20 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { damageDone = damageCreature(damageAmount, sourceId, game, preventable, combat, markDamage, appliedEffects); } if (damageDone > 0) { - Permanent source = game.getPermanentOrLKIBattlefield(sourceId); + UUID sourceControllerId = null; + MageObject source = game.getPermanentOrLKIBattlefield(sourceId); + if (source == null) { + source = game.getObject(sourceId); + if (source instanceof Spell) { + sourceControllerId = ((Spell) source).getControllerId(); + } else { + source = null; + } + } else { + sourceControllerId = ((Permanent) source).getControllerId(); + } if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) { - Player player = game.getPlayer(source.getControllerId()); + Player player = game.getPlayer(sourceControllerId); player.gainLife(damageAmount, game); } if (source != null && source.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 5f6fcbf8392..79e8a9f5732 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -1613,12 +1613,17 @@ public abstract class PlayerImpl implements Player, Serializable { if (!game.replaceEvent(event)) { int actualDamage = event.getAmount(); if (actualDamage > 0) { - Permanent source = game.getPermanent(sourceId); - if(source == null){ - MageObject lastKnownInformation = game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD); - if(lastKnownInformation != null && lastKnownInformation instanceof Permanent){ - source = (Permanent) lastKnownInformation; + UUID sourceControllerId = null; + MageObject source = game.getPermanentOrLKIBattlefield(sourceId); + if (source == null) { + source = game.getObject(sourceId); + if (source instanceof Spell) { + sourceControllerId = ((Spell) source).getControllerId(); + } else { + source = null; } + } else { + sourceControllerId = ((Permanent) source).getControllerId(); } if (source != null && (source.getAbilities().containsKey(InfectAbility.getInstance().getId()))) { addCounters(CounterType.POISON.createInstance(actualDamage), game); @@ -1629,7 +1634,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) { - Player player = game.getPlayer(source.getControllerId()); + Player player = game.getPlayer(sourceControllerId); player.gainLife(actualDamage, game); } game.fireEvent(new DamagedPlayerEvent(playerId, sourceId, playerId, actualDamage, combatDamage));