Fix TargetSelection adding spell as card when choosing from multiple zones

This commit is contained in:
Bug Hunter
2021-02-15 16:01:19 +00:00
committed by Hans Mackowiak
parent 98dc6edc99
commit 0d08cfd1f5

View File

@@ -263,8 +263,23 @@ public class TargetSelection {
if (!gameCacheChooseCard.containsKey(chosen)) {
return false;
}
if (((CardView) chosen).getZone().equals(ZoneType.Stack)) {
for (final SpellAbilityStackInstance si : game.getStack()) {
// avoid peeking own SI so target is not changed
if (si.compareToSpellAbility(ability)) {
continue;
}
SpellAbility abilityOnStack = si.getSpellAbility(true);
if (abilityOnStack.getHostCard().getView().equals(chosen)) {
ability.getTargets().add(abilityOnStack);
break;
}
}
}
else {
ability.getTargets().add(gameCacheChooseCard.get((CardView) chosen));
}
}
return true;
}
@@ -277,12 +292,12 @@ public class TargetSelection {
final Game game = ability.getActivatingPlayer().getGame();
for (final SpellAbilityStackInstance si : game.getStack()) {
SpellAbility abilityOnStack = si.getSpellAbility(true);
if (ability.equals(abilityOnStack)) {
// By peeking at stack item, target is set to its SI state. So set it back before adding targets
ability.resetTargets();
// avoid peeking own SI so target is not changed
if (si.compareToSpellAbility(ability)) {
continue;
}
else if (ability.canTargetSpellAbility(abilityOnStack)) {
SpellAbility abilityOnStack = si.getSpellAbility(true);
if (ability.canTargetSpellAbility(abilityOnStack)) {
stackItemViewCache.put(si.getView(), si);
selectOptions.add(si.getView());
}