Merge branch 'surveilFixChangesAll' into 'master'

SurveilEffect: fix triggerChangesZoneAll

See merge request core-developers/forge!4981
This commit is contained in:
Michael Kamensky
2021-07-11 04:00:54 +00:00
2 changed files with 9 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package forge.game.ability.effects;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.CardZoneTable;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.util.Lang;
@@ -32,15 +33,18 @@ public class SurveilEffect extends SpellAbilityEffect {
boolean isOptional = sa.hasParam("Optional");
CardZoneTable table = new CardZoneTable();
for (final Player p : getTargetPlayers(sa)) {
if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) {
if (isOptional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSurveil"))) {
continue;
}
p.surveil(num, sa);
p.surveil(num, sa, table);
}
}
table.triggerChangesZoneAll(sa.getHostCard().getGame(), sa);
}

View File

@@ -1234,7 +1234,7 @@ public class Player extends GameEntity implements Comparable<Player> {
return drawCards(1, null);
}
public void surveil(int num, SpellAbility cause) {
public void surveil(int num, SpellAbility cause, CardZoneTable table) {
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.Source, cause);
repParams.put(AbilityKey.SurveilNum, num);
@@ -1265,7 +1265,9 @@ public class Player extends GameEntity implements Comparable<Player> {
if (toGrave != null) {
for (Card c : toGrave) {
getGame().getAction().moveToGraveyard(c, cause);
ZoneType oZone = c.getZone().getZoneType();
Card moved = getGame().getAction().moveToGraveyard(c, cause);
table.put(oZone, moved.getZone().getZoneType(), moved);
numToGrave++;
}
}