* Spellskite - Fixed a bug of log message. Fixed a bug that multiple targets from different target instances could be changed with one activation.

This commit is contained in:
LevelX2 2015-08-30 21:14:11 +02:00
parent f2bb7470cf
commit a6662b5dcc

View file

@ -120,33 +120,44 @@ class SpellskiteEffect extends OneShotEffect {
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game); target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
} }
} else { } else {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
for (Target target : targets) { boolean validTargets = false;
for (UUID targetId : target.getTargets()) { do {
MageObject object = game.getObject(targetId); for (Target target : targets) {
String name; for (UUID targetId : target.getTargets()) {
if (object == null) { MageObject object = game.getObject(targetId);
Player targetPlayer = game.getPlayer(targetId); String name;
name = targetPlayer.getLogName(); if (object == null) {
} else { Player targetPlayer = game.getPlayer(targetId);
name = object.getLogName(); name = targetPlayer.getLogName();
} } else {
if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) { name = object.getLogName();
// you can't change this target to Spellskite because Spellskite is already another targetId of that target. }
twoTimesTarget = true; if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) {
continue; // you can't change this target to Spellskite because Spellskite is already another targetId of that target.
} twoTimesTarget = true;
if (name != null && player.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) { continue;
}
if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) { if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) {
oldTarget = game.getObject(targets.getFirstTarget()); validTargets = true;
target.remove(targetId); if (name != null
// The source is still the spell on the stack && controller.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) {
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game); oldTarget = game.getObject(targetId);
break; target.remove(targetId);
// The source is still the spell on the stack
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
break;
}
} }
} }
if (oldTarget != null) {
break;
}
} }
} if (oldTarget == null) {
game.informPlayer(controller, "You have to select at least one target to change to spellskite!");
}
} while (validTargets && oldTarget == null);
} }
if (oldTarget != null) { if (oldTarget != null) {
game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTarget.getLogName() + " to " + sourceObject.getLogName()); game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTarget.getLogName() + " to " + sourceObject.getLogName());