mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
ChangeZoneEffect: add ChangesZoneAll Trigger
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -33,6 +34,7 @@ import forge.util.MessageUtil;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ChangeZoneEffect extends SpellAbilityEffect {
|
public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||||
@Override
|
@Override
|
||||||
@@ -409,6 +411,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
final boolean optional = sa.hasParam("Optional");
|
final boolean optional = sa.hasParam("Optional");
|
||||||
final long ts = game.getNextTimestamp();
|
final long ts = game.getNextTimestamp();
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
|
|
||||||
for (final Card tgtC : tgtCards) {
|
for (final Card tgtC : tgtCards) {
|
||||||
if (tgt != null && tgtC.isInPlay() && !tgtC.canBeTargetedBy(sa)) {
|
if (tgt != null && tgtC.isInPlay() && !tgtC.canBeTargetedBy(sa)) {
|
||||||
@@ -583,16 +586,30 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (remember != null && !movedCard.getZone().equals(originZone)) {
|
if (!movedCard.getZone().equals(originZone)) {
|
||||||
|
if (!triggerList.containsKey(originZone.getZoneType())) {
|
||||||
|
triggerList.put(originZone.getZoneType(), new CardCollection());
|
||||||
|
}
|
||||||
|
triggerList.get(originZone.getZoneType()).add(movedCard);
|
||||||
|
|
||||||
|
if (remember != null) {
|
||||||
hostCard.addRemembered(movedCard);
|
hostCard.addRemembered(movedCard);
|
||||||
}
|
}
|
||||||
if (forget != null && !movedCard.getZone().equals(originZone)) {
|
if (forget != null) {
|
||||||
hostCard.removeRemembered(movedCard);
|
hostCard.removeRemembered(movedCard);
|
||||||
}
|
}
|
||||||
if (imprint != null && !movedCard.getZone().equals(originZone)) {
|
if (imprint != null) {
|
||||||
hostCard.addImprintedCard(movedCard);
|
hostCard.addImprintedCard(movedCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!triggerList.isEmpty()) {
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Cards", triggerList);
|
||||||
|
runParams.put("Destination", destination);
|
||||||
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||||
|
}
|
||||||
|
|
||||||
// for things like Gaea's Blessing
|
// for things like Gaea's Blessing
|
||||||
if (destination.equals(ZoneType.Library) && sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"))) {
|
if (destination.equals(ZoneType.Library) && sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"))) {
|
||||||
@@ -897,8 +914,10 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
CardCollection movedCards = new CardCollection();
|
CardCollection movedCards = new CardCollection();
|
||||||
long ts = game.getNextTimestamp();
|
long ts = game.getNextTimestamp();
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
for (Card c : chosenCards) {
|
for (Card c : chosenCards) {
|
||||||
Card movedCard = null;
|
Card movedCard = null;
|
||||||
|
final Zone originZone = game.getZoneOf(c);
|
||||||
if (destination.equals(ZoneType.Library)) {
|
if (destination.equals(ZoneType.Library)) {
|
||||||
movedCard = game.getAction().moveToLibrary(c, libraryPos);
|
movedCard = game.getAction().moveToLibrary(c, libraryPos);
|
||||||
}
|
}
|
||||||
@@ -1051,6 +1070,11 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
movedCards.add(movedCard);
|
movedCards.add(movedCard);
|
||||||
|
|
||||||
|
if (!triggerList.containsKey(originZone.getZoneType())) {
|
||||||
|
triggerList.put(originZone.getZoneType(), new CardCollection());
|
||||||
|
}
|
||||||
|
triggerList.get(originZone.getZoneType()).add(movedCard);
|
||||||
|
|
||||||
if (champion) {
|
if (champion) {
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
runParams.put("Card", source);
|
runParams.put("Card", source);
|
||||||
@@ -1079,6 +1103,14 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
|| (sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle")))) {
|
|| (sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle")))) {
|
||||||
player.shuffle(sa);
|
player.shuffle(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!triggerList.isEmpty()) {
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Cards", triggerList);
|
||||||
|
runParams.put("Destination", destination);
|
||||||
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user