mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
ChangeZoneAllEffect: add ChangesZoneAll Trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -14,11 +15,13 @@ import forge.game.card.CardUtil;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||||
@Override
|
@Override
|
||||||
@@ -128,7 +131,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
// movedCards should have same timestamp
|
// movedCards should have same timestamp
|
||||||
long ts = game.getNextTimestamp();
|
long ts = game.getNextTimestamp();
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
for (final Card c : cards) {
|
for (final Card c : cards) {
|
||||||
|
final Zone originZone = game.getZoneOf(c);
|
||||||
|
|
||||||
if (destination == ZoneType.Battlefield) {
|
if (destination == ZoneType.Battlefield) {
|
||||||
// Auras without Candidates stay in their current location
|
// Auras without Candidates stay in their current location
|
||||||
if (c.isAura()) {
|
if (c.isAura()) {
|
||||||
@@ -147,7 +153,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
|||||||
movedCard = game.getAction().moveToPlay(c, sa.getActivatingPlayer());
|
movedCard = game.getAction().moveToPlay(c, sa.getActivatingPlayer());
|
||||||
} else {
|
} else {
|
||||||
movedCard = game.getAction().moveTo(destination, c, libraryPos);
|
movedCard = game.getAction().moveTo(destination, c, libraryPos);
|
||||||
if (!c.isToken()) {
|
if (destination == ZoneType.Exile && !c.isToken()) {
|
||||||
Card host = sa.getOriginalHost();
|
Card host = sa.getOriginalHost();
|
||||||
if (host == null) {
|
if (host == null) {
|
||||||
host = sa.getHostCard();
|
host = sa.getHostCard();
|
||||||
@@ -184,6 +190,20 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
|||||||
if (destination == ZoneType.Battlefield) {
|
if (destination == ZoneType.Battlefield) {
|
||||||
movedCard.setTimestamp(ts);
|
movedCard.setTimestamp(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!movedCard.getZone().equals(originZone)) {
|
||||||
|
if (!triggerList.containsKey(originZone.getZoneType())) {
|
||||||
|
triggerList.put(originZone.getZoneType(), new CardCollection());
|
||||||
|
}
|
||||||
|
triggerList.get(originZone.getZoneType()).add(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if Shuffle parameter exists, and any amount of cards were owned by
|
// if Shuffle parameter exists, and any amount of cards were owned by
|
||||||
|
|||||||
Reference in New Issue
Block a user