* Spellskite - Fixed that target is not changed to Spellskite if Spellskite is no valid taregt for the origin spell (e.g. Ranger's Guile of opponent player).

This commit is contained in:
LevelX2 2014-06-18 16:10:39 +02:00
parent ab3386ac25
commit 889fd417b2

View file

@ -94,19 +94,22 @@ class SpellskiteEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (stackObject != null && sourceObject != null) { if (stackObject != null && sourceObject != null) {
Targets targets; Targets targets;
Ability sourceAbility;
MageObject oldTarget = null; MageObject oldTarget = null;
if (stackObject instanceof Spell) { if (stackObject instanceof Spell) {
Spell spell = (Spell)stackObject; Spell spell = (Spell)stackObject;
sourceAbility = spell.getSpellAbility();
targets = spell.getSpellAbility().getTargets(); targets = spell.getSpellAbility().getTargets();
} else if (stackObject instanceof StackAbility) { } else if (stackObject instanceof StackAbility) {
StackAbility stackAbility = (StackAbility)stackObject; StackAbility stackAbility = (StackAbility)stackObject;
sourceAbility = stackAbility;
targets = stackAbility.getTargets(); targets = stackAbility.getTargets();
} else { } else {
return false; return false;
} }
if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) { if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
Target target = targets.get(0); Target target = targets.get(0);
if (target.canTarget(source.getSourceId(), game)) { if (target.canTarget(source.getSourceId(), stackObject.getControllerId(), sourceAbility, game)) {
oldTarget = game.getObject(targets.getFirstTarget()); oldTarget = game.getObject(targets.getFirstTarget());
target.clearChosen(); target.clearChosen();
target.add(source.getSourceId(), game); target.add(source.getSourceId(), game);
@ -125,7 +128,7 @@ class SpellskiteEffect extends OneShotEffect {
name = object.getName(); name = object.getName();
} }
if (name != null && player.chooseUse(Outcome.Neutral, new StringBuilder("Change target from ").append(name).append(" to ").append(sourceObject.getName()).append("?").toString(), game)) { if (name != null && player.chooseUse(Outcome.Neutral, new StringBuilder("Change target from ").append(name).append(" to ").append(sourceObject.getName()).append("?").toString(), game)) {
if (target.canTarget(source.getSourceId(), game)) { if (target.canTarget(source.getSourceId(), stackObject.getControllerId(), sourceAbility, game)) {
oldTarget = game.getObject(targets.getFirstTarget()); oldTarget = game.getObject(targets.getFirstTarget());
target.remove(targetId); target.remove(targetId);
target.addTarget(source.getSourceId(), source, game); target.addTarget(source.getSourceId(), source, game);
@ -137,6 +140,8 @@ class SpellskiteEffect extends OneShotEffect {
} }
if (oldTarget != null) { if (oldTarget != null) {
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": Changed target of ").append(stackObject.getName()).append(" from ").append(oldTarget.getName()).append(" to ").append(sourceObject.getName()).toString()); game.informPlayers(new StringBuilder(sourceObject.getName()).append(": Changed target of ").append(stackObject.getName()).append(" from ").append(oldTarget.getName()).append(" to ").append(sourceObject.getName()).toString());
} else {
game.informPlayers(sourceObject.getLogName() + ": Target not changed to " + sourceObject.getLogName() + " because its no valid target for " + stackObject.getName());
} }
return true; return true;
} }