mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Allow spells to have lifelink.
This commit is contained in:
parent
799d7b1a23
commit
83ba73ab24
2 changed files with 25 additions and 8 deletions
|
@ -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())) {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue