mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
update several callers of runTriggerOld to runTrigger
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.common.eventbus.EventBus;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardStateName;
|
||||
import forge.card.CardType.Supertype;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.card.*;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.event.Event;
|
||||
@@ -713,9 +714,9 @@ public class Game {
|
||||
ingamePlayers.remove(p);
|
||||
lostPlayers.add(p);
|
||||
|
||||
final Map<String, Object> runParams = new TreeMap<>();
|
||||
runParams.put("Player", p);
|
||||
getTriggerHandler().runTriggerOld(TriggerType.LosesGame, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, p);
|
||||
getTriggerHandler().runTrigger(TriggerType.LosesGame, runParams, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import forge.GameCommand;
|
||||
import forge.StaticData;
|
||||
import forge.card.CardStateName;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.effects.AttachEffect;
|
||||
@@ -79,7 +80,7 @@ public class GameAction {
|
||||
return changeZone(zoneFrom, zoneTo, c, position, cause, null);
|
||||
}
|
||||
|
||||
private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer position, SpellAbility cause, Map<String, Object> params) {
|
||||
private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer position, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
if (c.isCopiedSpell() || (c.isImmutable() && zoneTo.is(ZoneType.Exile))) {
|
||||
// Remove Effect from command immediately, this is essential when some replacement
|
||||
// effects happen during the resolving of a spellability ("the next time ..." effect)
|
||||
@@ -284,19 +285,19 @@ public class GameAction {
|
||||
copied.getOwner().addInboundToken(copied);
|
||||
}
|
||||
|
||||
Map<String, Object> repParams = Maps.newHashMap();
|
||||
repParams.put("Event", "Moved");
|
||||
repParams.put("Affected", copied);
|
||||
repParams.put("CardLKI", lastKnownInfo);
|
||||
repParams.put("Cause", cause);
|
||||
repParams.put("Origin", zoneFrom != null ? zoneFrom.getZoneType() : null);
|
||||
repParams.put("Destination", zoneTo.getZoneType());
|
||||
Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Event, "Moved");
|
||||
repParams.put(AbilityKey.Affected, copied);
|
||||
repParams.put(AbilityKey.CardLKI, lastKnownInfo);
|
||||
repParams.put(AbilityKey.Cause, cause);
|
||||
repParams.put(AbilityKey.Origin, zoneFrom != null ? zoneFrom.getZoneType() : null);
|
||||
repParams.put(AbilityKey.Destination, zoneTo.getZoneType());
|
||||
|
||||
if (params != null) {
|
||||
repParams.putAll(params);
|
||||
}
|
||||
|
||||
ReplacementResult repres = game.getReplacementHandler().run(repParams);
|
||||
ReplacementResult repres = game.getReplacementHandler().run(EnumMapUtil.toStringMap(repParams));
|
||||
if (repres != ReplacementResult.NotReplaced) {
|
||||
// reset failed manifested Cards back to original
|
||||
if (c.isManifested()) {
|
||||
@@ -399,27 +400,27 @@ public class GameAction {
|
||||
// play the change zone sound
|
||||
game.fireEvent(new GameEventCardChangeZone(c, zoneFrom, zoneTo));
|
||||
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", lastKnownInfo);
|
||||
runParams.put("Cause", cause);
|
||||
runParams.put("Origin", zoneFrom != null ? zoneFrom.getZoneType().name() : null);
|
||||
runParams.put("Destination", zoneTo.getZoneType().name());
|
||||
runParams.put("SpellAbilityStackInstance", game.stack.peek());
|
||||
runParams.put("IndividualCostPaymentInstance", game.costPaymentStack.peek());
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, lastKnownInfo);
|
||||
runParams.put(AbilityKey.Cause, cause);
|
||||
runParams.put(AbilityKey.Origin, zoneFrom != null ? zoneFrom.getZoneType().name() : null);
|
||||
runParams.put(AbilityKey.Destination, zoneTo.getZoneType().name());
|
||||
runParams.put(AbilityKey.SpellAbilityStackInstance, game.stack.peek());
|
||||
runParams.put(AbilityKey.IndividualCostPaymentInstance, game.costPaymentStack.peek());
|
||||
|
||||
if (params != null) {
|
||||
runParams.putAll(params);
|
||||
}
|
||||
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.ChangesZone, runParams, true);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams, true);
|
||||
if (zoneFrom != null && zoneFrom.is(ZoneType.Battlefield) && !zoneFrom.getPlayer().equals(zoneTo.getPlayer())) {
|
||||
final Map<String, Object> runParams2 = Maps.newHashMap();
|
||||
runParams2.put("Card", lastKnownInfo);
|
||||
runParams2.put("OriginalController", zoneFrom.getPlayer());
|
||||
final Map<AbilityKey, Object> runParams2 = AbilityKey.newMap();
|
||||
runParams2.put(AbilityKey.Card, lastKnownInfo);
|
||||
runParams2.put(AbilityKey.OriginalController, zoneFrom.getPlayer());
|
||||
if(params != null) {
|
||||
runParams2.putAll(params);
|
||||
}
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.ChangesController, runParams2, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams2, false);
|
||||
}
|
||||
// AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||
|
||||
@@ -533,13 +534,13 @@ public class GameAction {
|
||||
return moveTo(zoneTo, c, position, cause, null);
|
||||
}
|
||||
|
||||
private Card moveTo(final Zone zoneTo, Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
private Card moveTo(final Zone zoneTo, Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
// FThreads.assertExecutedByEdt(false); // This code must never be executed from EDT,
|
||||
// use FThreads.invokeInNewThread to run code in a pooled thread
|
||||
return moveTo(zoneTo, c, null, cause, params);
|
||||
}
|
||||
|
||||
private Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility cause, Map<String, Object> params) {
|
||||
private Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
// Ideally move to should never be called without a prevZone
|
||||
// Remove card from Current Zone, if it has one
|
||||
final Zone zoneFrom = game.getZoneOf(c);
|
||||
@@ -599,10 +600,10 @@ public class GameAction {
|
||||
c.setTurnInZone(tiz);
|
||||
c.setCameUnderControlSinceLastUpkeep(true);
|
||||
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", c);
|
||||
runParams.put("OriginalController", original);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.ChangesController, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, c);
|
||||
runParams.put(AbilityKey.OriginalController, original);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams, false);
|
||||
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
for (Player p : game.getPlayers()) {
|
||||
@@ -619,7 +620,7 @@ public class GameAction {
|
||||
public final Card moveToGraveyard(final Card c, SpellAbility cause) {
|
||||
return moveToGraveyard(c, cause, null);
|
||||
}
|
||||
public final Card moveToGraveyard(final Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToGraveyard(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
final PlayerZone grave = c.getOwner().getZone(ZoneType.Graveyard);
|
||||
// must put card in OWNER's graveyard not controller's
|
||||
return moveTo(grave, c, cause, params);
|
||||
@@ -629,7 +630,7 @@ public class GameAction {
|
||||
return moveToHand(c, cause, null);
|
||||
}
|
||||
|
||||
public final Card moveToHand(final Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToHand(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
final PlayerZone hand = c.getOwner().getZone(ZoneType.Hand);
|
||||
return moveTo(hand, c, cause, params);
|
||||
}
|
||||
@@ -643,7 +644,7 @@ public class GameAction {
|
||||
return moveToPlay(c, p, cause, null);
|
||||
}
|
||||
|
||||
public final Card moveToPlay(final Card c, final Player p, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToPlay(final Card c, final Player p, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
// move to a specific player's Battlefield
|
||||
final PlayerZone play = p.getZone(ZoneType.Battlefield);
|
||||
return moveTo(play, c, cause, params);
|
||||
@@ -653,7 +654,7 @@ public class GameAction {
|
||||
return moveToBottomOfLibrary(c, cause, null);
|
||||
}
|
||||
|
||||
public final Card moveToBottomOfLibrary(final Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToBottomOfLibrary(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
return moveToLibrary(c, -1, cause, params);
|
||||
}
|
||||
|
||||
@@ -661,7 +662,7 @@ public class GameAction {
|
||||
return moveToLibrary(c, cause, null);
|
||||
}
|
||||
|
||||
public final Card moveToLibrary(final Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToLibrary(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
return moveToLibrary(c, 0, cause, params);
|
||||
}
|
||||
|
||||
@@ -669,7 +670,7 @@ public class GameAction {
|
||||
return moveToLibrary(c, libPosition, cause, null);
|
||||
}
|
||||
|
||||
public final Card moveToLibrary(Card c, int libPosition, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card moveToLibrary(Card c, int libPosition, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
final PlayerZone library = c.getOwner().getZone(ZoneType.Library);
|
||||
if (libPosition == -1 || libPosition > library.size()) {
|
||||
libPosition = library.size();
|
||||
@@ -688,7 +689,7 @@ public class GameAction {
|
||||
public final Card exile(final Card c, SpellAbility cause) {
|
||||
return exile(c, cause, null);
|
||||
}
|
||||
public final Card exile(final Card c, SpellAbility cause, Map<String, Object> params) {
|
||||
public final Card exile(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
if (game.isCardExiled(c)) {
|
||||
return c;
|
||||
}
|
||||
@@ -698,15 +699,15 @@ public class GameAction {
|
||||
final Card copied = moveTo(removed, c, cause, params);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", c);
|
||||
runParams.put("Cause", cause);
|
||||
runParams.put("Origin", origin.getZoneType().name());
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, c);
|
||||
runParams.put(AbilityKey.Cause, cause);
|
||||
runParams.put(AbilityKey.Origin, origin.getZoneType().name());
|
||||
if (params != null) {
|
||||
runParams.putAll(params);
|
||||
}
|
||||
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Exiled, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Exiled, runParams, false);
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
||||
@@ -6,17 +6,24 @@ import java.util.EnumMap;
|
||||
* Keys for Ability parameter maps.
|
||||
*/
|
||||
public enum AbilityKey {
|
||||
Affected("Affected"),
|
||||
Attackers("Attackers"),
|
||||
AttackingPlayer("AttackingPlayer"),
|
||||
AttackedTarget("AttackedTarget"),
|
||||
Card("Card"),
|
||||
CardLKI("CardLKI"),
|
||||
Cause("Cause"),
|
||||
CounteredSA("CounteredSA"),
|
||||
Destination("Destination"),
|
||||
Event("Event"),
|
||||
Fizzle("Fizzle"),
|
||||
Player("Player"),
|
||||
IndividualCostPaymentInstance("IndividualCostPaymentInstance"),
|
||||
Origin("Origin"),
|
||||
SpellAbilityStackInstance("SpellAbilityStackInstance")
|
||||
;
|
||||
OriginalController("OriginalController"),
|
||||
SpellAbilityStackInstance("SpellAbilityStackInstance"),
|
||||
StackSa("StackSa"),
|
||||
StackSi("StackSi");
|
||||
|
||||
|
||||
private String key;
|
||||
|
||||
@@ -10,6 +10,7 @@ import forge.card.CardStateName;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.*;
|
||||
@@ -1199,9 +1200,9 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
final Zone originZone = tgtHost.getZone();
|
||||
game.getStack().remove(si);
|
||||
|
||||
Map<String,Object> params = Maps.newHashMap();
|
||||
params.put("StackSa", tgtSA);
|
||||
params.put("StackSi", si);
|
||||
Map<AbilityKey,Object> params = AbilityKey.newMap();
|
||||
params.put(AbilityKey.StackSa, tgtSA);
|
||||
params.put(AbilityKey.StackSi, si);
|
||||
|
||||
Card movedCard = null;
|
||||
if (srcSA.hasParam("Destination")) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
@@ -168,9 +169,9 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
tgtSA.getHostCard().unanimateBestow(true);
|
||||
}
|
||||
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("StackSa", tgtSA);
|
||||
params.put("StackSi", si);
|
||||
Map<AbilityKey, Object> params = AbilityKey.newMap();
|
||||
params.put(AbilityKey.StackSa, tgtSA);
|
||||
params.put(AbilityKey.StackSi, si);
|
||||
|
||||
String destination = srcSA.hasParam("Destination") ? srcSA.getParam("Destination") : tgtSA.isAftermath() ? "Exile" : "Graveyard";
|
||||
if (srcSA.hasParam("DestinationChoice")) {//Hinder
|
||||
@@ -208,12 +209,12 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
+ srcSA.getHostCard().getName());
|
||||
}
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", tgtSA.getActivatingPlayer());
|
||||
runParams.put("Card", tgtSA.getHostCard());
|
||||
runParams.put("Cause", srcSA.getHostCard());
|
||||
runParams.put("CounteredSA", tgtSA);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Countered, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, tgtSA.getActivatingPlayer());
|
||||
runParams.put(AbilityKey.Card, tgtSA.getHostCard());
|
||||
runParams.put(AbilityKey.Cause, srcSA.getHostCard());
|
||||
runParams.put(AbilityKey.CounteredSA, tgtSA);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Countered, runParams, false);
|
||||
|
||||
|
||||
if (!tgtSA.isAbility()) {
|
||||
|
||||
@@ -242,7 +242,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
activeScheme = getZone(ZoneType.SchemeDeck).get(0);
|
||||
// gameAction moveTo ?
|
||||
game.getAction().moveTo(ZoneType.Command, activeScheme, null, null);
|
||||
game.getAction().moveTo(ZoneType.Command, activeScheme, null);
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
|
||||
// Run triggers
|
||||
@@ -1651,7 +1651,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
for (Card m : milledView) {
|
||||
final ZoneType origin = m.getZone().getZoneType();
|
||||
final Card d = game.getAction().moveTo(destination, m, sa, null);
|
||||
final Card d = game.getAction().moveTo(destination, m, sa);
|
||||
table.put(origin, d.getZone().getZoneType(), d);
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
if (land.isFaceDown()) {
|
||||
land.turnFaceUp();
|
||||
}
|
||||
game.getAction().moveTo(getZone(ZoneType.Battlefield), land, null, new HashMap<>());
|
||||
game.getAction().moveTo(getZone(ZoneType.Battlefield), land, null);
|
||||
|
||||
// play a sound
|
||||
game.fireEvent(new GameEventLandPlayed(this, land));
|
||||
@@ -2512,7 +2512,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
game.getView().updatePlanarPlayer(getView());
|
||||
|
||||
for (Card c : currentPlanes) {
|
||||
game.getAction().moveTo(ZoneType.Command,c, null, null);
|
||||
game.getAction().moveTo(ZoneType.Command,c, null);
|
||||
//getZone(ZoneType.PlanarDeck).remove(c);
|
||||
//getZone(ZoneType.Command).add(c);
|
||||
}
|
||||
@@ -2542,7 +2542,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
//game.getZoneOf(plane).remove(plane);
|
||||
plane.clearControllers();
|
||||
//getZone(ZoneType.PlanarDeck).add(plane);
|
||||
game.getAction().moveTo(ZoneType.PlanarDeck, plane,-1, null, null);
|
||||
game.getAction().moveTo(ZoneType.PlanarDeck, plane,-1, null);
|
||||
}
|
||||
currentPlanes.clear();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.GameCommand;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
@@ -531,10 +532,10 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
else if ((source.isInstant() || source.isSorcery() || fizzle) &&
|
||||
source.isInZone(ZoneType.Stack)) {
|
||||
// If Spell and still on the Stack then let it goto the graveyard or replace its own movement
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("StackSa", sa);
|
||||
params.put("StackSi", si);
|
||||
params.put("Fizzle", fizzle);
|
||||
Map<AbilityKey, Object> params = AbilityKey.newMap();
|
||||
params.put(AbilityKey.StackSa, sa);
|
||||
params.put(AbilityKey.StackSi, si);
|
||||
params.put(AbilityKey.Fizzle, fizzle);
|
||||
game.getAction().moveToGraveyard(source, null, params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user