Fix issue where a spell's target wouldn't be correctly shown in the game log message.

The problem was that by the time the log sees the spell, its target has been swapped with the stack ability.
This commit is contained in:
Myrd
2014-12-01 06:12:05 +00:00
parent 319cd97d83
commit a63f46414a
3 changed files with 12 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import forge.game.zone.ZoneType;
import forge.util.Lang; import forge.util.Lang;
import forge.util.maps.MapOfLists; import forge.util.maps.MapOfLists;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -49,7 +50,12 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
if (event.sa.getTargetRestrictions() != null) { if (event.sa.getTargetRestrictions() != null) {
sb.append(" targeting "); sb.append(" targeting ");
for (TargetChoices ch : event.sa.getAllTargetChoices()) {
ArrayList<TargetChoices> targets = event.sa.getAllTargetChoices();
// Include the TargetChoices from the stack instance, since the real target choices
// are on that object at this point (see SpellAbilityStackInstance constructor).
targets.add(event.si.getTargetChoices());
for (TargetChoices ch : targets) {
if (null != ch) { if (null != ch) {
sb.append(ch.getTargetedString()); sb.append(ch.getTargetedString());
} }

View File

@@ -1,6 +1,7 @@
package forge.game.event; package forge.game.event;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityStackInstance;
/** /**
* TODO: Write javadoc for this type. * TODO: Write javadoc for this type.
@@ -9,10 +10,12 @@ import forge.game.spellability.SpellAbility;
public class GameEventSpellAbilityCast extends GameEvent { public class GameEventSpellAbilityCast extends GameEvent {
public final SpellAbility sa; public final SpellAbility sa;
public final SpellAbilityStackInstance si;
public final boolean replicate; public final boolean replicate;
public GameEventSpellAbilityCast(SpellAbility sp, boolean replicate) { public GameEventSpellAbilityCast(SpellAbility sp, SpellAbilityStackInstance si, boolean replicate) {
sa = sp; sa = sp;
this.si = si;
this.replicate = replicate; this.replicate = replicate;
} }

View File

@@ -425,7 +425,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
sp.getActivatingPlayer().setActivateLoyaltyAbilityThisTurn(true); sp.getActivatingPlayer().setActivateLoyaltyAbilityThisTurn(true);
} }
game.updateStackForView(); game.updateStackForView();
game.fireEvent(new GameEventSpellAbilityCast(sp, false)); game.fireEvent(new GameEventSpellAbilityCast(sp, si, false));
return si; return si;
} }