From 90ec6123b2059d85a1492e8b200b8f66a6aa5d9e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 24 Aug 2013 17:16:42 +0200 Subject: [PATCH] Some changes to RedirectionEffect. --- .../abilities/effects/ContinuousEffects.java | 1 + .../PlaneswalkerRedirectionEffect.java | 10 ++++---- .../abilities/effects/RedirectionEffect.java | 24 ++++--------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Mage/src/mage/abilities/effects/ContinuousEffects.java b/Mage/src/mage/abilities/effects/ContinuousEffects.java index 6df71fc2a1..8d8fa27cde 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffects.java @@ -721,6 +721,7 @@ public class ContinuousEffects implements Serializable { public void addEffect(ContinuousEffect effect, Ability source) { switch (effect.getEffectType()) { case REPLACEMENT: + case REDIRECTION: ReplacementEffect newReplacementEffect = (ReplacementEffect)effect; replacementEffects.addEffect(newReplacementEffect, source); break; diff --git a/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java b/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java index 7608a2e912..ef41ad4a83 100644 --- a/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java +++ b/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java @@ -28,9 +28,10 @@ package mage.abilities.effects; +import java.util.UUID; +import mage.abilities.Ability; import mage.constants.Duration; import mage.constants.Outcome; -import mage.abilities.Ability; import mage.filter.common.FilterPlaneswalkerPermanent; import mage.game.Game; import mage.game.events.DamageEvent; @@ -41,7 +42,6 @@ import mage.game.stack.StackObject; import mage.players.Player; import mage.target.TargetPermanent; -import java.util.UUID; /** * @@ -92,11 +92,13 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect> extends public boolean replaceEvent(GameEvent event, Ability source, Game game) { DamageEvent damageEvent = (DamageEvent)event; Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget()); - Ability damageSource = getSource(damageEvent.getSourceId(), game); - if (permanent != null && damageSource != null) { - permanent.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage()); + if (permanent != null) { + permanent.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage(), event.getAppliedEffects()); return true; } Player player = game.getPlayer(redirectTarget.getFirstTarget()); if (player != null) { - player.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable()); + player.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects()); return true; } return false; } - protected Ability getSource(UUID sourceId, Game game) { - StackObject source = game.getStack().getStackObject(sourceId); - if (source != null) { - if (source instanceof StackAbility) - return (StackAbility)source; - if (source instanceof Spell) - return ((Spell)source).getSpellAbility(); - } - return null; - } - }