mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'update_run_trigger_callers_part_2' into 'master'
Update run trigger callers part 2 See merge request core-developers/forge!2115
This commit is contained in:
@@ -400,8 +400,7 @@ public class GameAction {
|
||||
// play the change zone sound
|
||||
game.fireEvent(new GameEventCardChangeZone(c, zoneFrom, zoneTo));
|
||||
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, lastKnownInfo);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(lastKnownInfo);
|
||||
runParams.put(AbilityKey.Cause, cause);
|
||||
runParams.put(AbilityKey.Origin, zoneFrom != null ? zoneFrom.getZoneType().name() : null);
|
||||
runParams.put(AbilityKey.Destination, zoneTo.getZoneType().name());
|
||||
@@ -414,8 +413,7 @@ public class GameAction {
|
||||
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams, true);
|
||||
if (zoneFrom != null && zoneFrom.is(ZoneType.Battlefield) && !zoneFrom.getPlayer().equals(zoneTo.getPlayer())) {
|
||||
final Map<AbilityKey, Object> runParams2 = AbilityKey.newMap();
|
||||
runParams2.put(AbilityKey.Card, lastKnownInfo);
|
||||
final Map<AbilityKey, Object> runParams2 = AbilityKey.mapFromCard(lastKnownInfo);
|
||||
runParams2.put(AbilityKey.OriginalController, zoneFrom.getPlayer());
|
||||
if(params != null) {
|
||||
runParams2.putAll(params);
|
||||
@@ -600,8 +598,7 @@ public class GameAction {
|
||||
c.setTurnInZone(tiz);
|
||||
c.setCameUnderControlSinceLastUpkeep(true);
|
||||
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, c);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
|
||||
runParams.put(AbilityKey.OriginalController, original);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams, false);
|
||||
|
||||
@@ -699,8 +696,7 @@ public class GameAction {
|
||||
final Card copied = moveTo(removed, c, cause, params);
|
||||
|
||||
// Run triggers
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Card, c);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
|
||||
runParams.put(AbilityKey.Cause, cause);
|
||||
runParams.put(AbilityKey.Origin, origin.getZoneType().name());
|
||||
if (params != null) {
|
||||
@@ -894,10 +890,10 @@ public class GameAction {
|
||||
// preList means that this is run by a pre Check with LKI objects
|
||||
// in that case Always trigger should not Run
|
||||
if (preList.isEmpty()) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Always, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Immediate, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Immediate, runParams, false);
|
||||
}
|
||||
|
||||
// Update P/T and type in the view only once after all the cards have been processed, to avoid flickering
|
||||
@@ -1416,10 +1412,9 @@ public class GameAction {
|
||||
game.fireEvent(new GameEventCardDestroyed());
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", c);
|
||||
runParams.put("Causer", activator);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Destroyed, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
|
||||
runParams.put(AbilityKey.Causer, activator);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Destroyed, runParams, false);
|
||||
|
||||
final Card sacrificed = sacrificeDestroy(c, sa, table);
|
||||
return sacrificed != null;
|
||||
@@ -1596,8 +1591,7 @@ public class GameAction {
|
||||
checkStateEffects(true); // why?
|
||||
|
||||
// Run Trigger beginning of the game
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.NewGame, runParams, true);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, AbilityKey.newMap(), true);
|
||||
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
||||
|
||||
|
||||
@@ -1760,9 +1754,9 @@ public class GameAction {
|
||||
game.setMonarch(p);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", p);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.BecomeMonarch, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, p);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.BecomeMonarch, runParams, false);
|
||||
}
|
||||
|
||||
// Make scry an action function so that it can be used for mulligans (with a null cause)
|
||||
@@ -1822,9 +1816,9 @@ public class GameAction {
|
||||
|
||||
if (cause != null) {
|
||||
// set up triggers (but not actually do them until later)
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", p);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Scry, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, p);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Scry, runParams, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.game;
|
||||
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardCollectionView;
|
||||
@@ -214,13 +215,13 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
|
||||
int prevent = damage - restDamage;
|
||||
preventMap.put(source, this, damage - restDamage);
|
||||
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("DamageTarget", this);
|
||||
runParams.put("DamageAmount", prevent);
|
||||
runParams.put("DamageSource", source);
|
||||
runParams.put("IsCombatDamage", isCombat);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.DamageTarget, this);
|
||||
runParams.put(AbilityKey.DamageAmount, prevent);
|
||||
runParams.put(AbilityKey.DamageSource, source);
|
||||
runParams.put(AbilityKey.IsCombatDamage, isCombat);
|
||||
|
||||
getGame().getTriggerHandler().runTriggerOld(TriggerType.DamagePrevented, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.DamagePrevented, runParams, false);
|
||||
}
|
||||
|
||||
return restDamage;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Table;
|
||||
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
@@ -47,9 +48,9 @@ public class GameEntityCounterTable extends ForwardingTable<GameEntity, CounterT
|
||||
|
||||
public void triggerCountersPutAll(final Game game) {
|
||||
if (!isEmpty()) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Objects", this);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.CounterAddedAll, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Objects, this);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.CounterAddedAll, runParams, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package forge.game;
|
||||
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.TriggerType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -35,11 +36,11 @@ public enum PlanarDice {
|
||||
{
|
||||
trigRes = Chaos;
|
||||
}
|
||||
|
||||
HashMap<String,Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", roller);
|
||||
runParams.put("Result", trigRes);
|
||||
roller.getGame().getTriggerHandler().runTriggerOld(TriggerType.PlanarDice, runParams,false);
|
||||
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, roller);
|
||||
runParams.put(AbilityKey.Result, trigRes);
|
||||
roller.getGame().getTriggerHandler().runTrigger(TriggerType.PlanarDice, runParams,false);
|
||||
|
||||
|
||||
return res;
|
||||
|
||||
@@ -1,29 +1,51 @@
|
||||
package forge.game.ability;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Keys for Ability parameter maps.
|
||||
*/
|
||||
public enum AbilityKey {
|
||||
AbilityMana("AbilityMana"),
|
||||
Affected("Affected"),
|
||||
Attacker("Attacker"),
|
||||
Attackers("Attackers"),
|
||||
AttackingPlayer("AttackingPlayer"),
|
||||
AttackedTarget("AttackedTarget"),
|
||||
Blocker("Blocker"),
|
||||
Blockers("Blockers"),
|
||||
Card("Card"),
|
||||
CardLKI("CardLKI"),
|
||||
Cause("Cause"),
|
||||
Causer("Causer"),
|
||||
Championed("Championed"),
|
||||
CounteredSA("CounteredSA"),
|
||||
DamageAmount("DamageAmount"),
|
||||
DamageSource("DamageSource"),
|
||||
DamageTarget("DamageTarget"),
|
||||
Defender("Defender"),
|
||||
DefendingPlayer("DefendingPlayer"),
|
||||
Destination("Destination"),
|
||||
Event("Event"),
|
||||
Fighter("Fighter"),
|
||||
Fizzle("Fizzle"),
|
||||
IsCombatDamage("IsCombatDamage"),
|
||||
Player("Player"),
|
||||
IndividualCostPaymentInstance("IndividualCostPaymentInstance"),
|
||||
MonstrosityAmount("MonstrosityAmount"),
|
||||
NumBlockers("NumBlockers"),
|
||||
Objects("Objects"),
|
||||
Origin("Origin"),
|
||||
OriginalController("OriginalController"),
|
||||
Produced("Produced"),
|
||||
Result("Result"),
|
||||
Scheme("Scheme"),
|
||||
SpellAbilityStackInstance("SpellAbilityStackInstance"),
|
||||
StackSa("StackSa"),
|
||||
StackSi("StackSi");
|
||||
StackSi("StackSi"),
|
||||
Target("Target"),
|
||||
Won("Won");
|
||||
|
||||
|
||||
private String key;
|
||||
@@ -40,4 +62,11 @@ public enum AbilityKey {
|
||||
public static <V> EnumMap<AbilityKey, V> newMap() {
|
||||
return new EnumMap<>(AbilityKey.class);
|
||||
}
|
||||
|
||||
public static Map<AbilityKey, Object> mapFromCard(forge.game.card.Card card) {
|
||||
final Map<AbilityKey, Object> runParams = newMap();
|
||||
|
||||
runParams.put(Card, card);
|
||||
return runParams;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
@@ -40,9 +40,9 @@ public class AbandonEffect extends SpellAbilityEffect {
|
||||
controller.getZone(ZoneType.SchemeDeck).add(source);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Scheme", source);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Abandoned, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Scheme, source);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Abandoned, runParams, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.event.GameEventCombatChanged;
|
||||
@@ -11,7 +12,6 @@ import forge.game.trigger.TriggerType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,13 +40,13 @@ public class BecomesBlockedEffect extends SpellAbilityEffect {
|
||||
game.getCombat().setBlocked(c, true);
|
||||
if (!c.getDamageHistory().getCreatureGotBlockedThisCombat()) {
|
||||
isCombatChanged = true;
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Attacker", c);
|
||||
runParams.put("Blockers", Lists.<Card>newArrayList());
|
||||
runParams.put("NumBlockers", 0);
|
||||
runParams.put("Defender", game.getCombat().getDefenderByAttacker(c));
|
||||
runParams.put("DefendingPlayer", game.getCombat().getDefenderPlayerByAttacker(c));
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.AttackerBlocked, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attacker, c);
|
||||
runParams.put(AbilityKey.Blockers, Lists.<Card>newArrayList());
|
||||
runParams.put(AbilityKey.NumBlockers, 0);
|
||||
runParams.put(AbilityKey.Defender, game.getCombat().getDefenderByAttacker(c));
|
||||
runParams.put(AbilityKey.DefendingPlayer, game.getCombat().getDefenderPlayerByAttacker(c));
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlocked, runParams, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -53,26 +53,28 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
blocker.addBlockedThisTurn(attacker);
|
||||
attacker.addBlockedByThisTurn(blocker);
|
||||
|
||||
Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Attacker", attacker);
|
||||
runParams.put("Blocker", blocker);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.AttackerBlockedByCreature, runParams, false);
|
||||
{
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attacker, attacker);
|
||||
runParams.put(AbilityKey.Blocker, blocker);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlockedByCreature, runParams, false);
|
||||
}
|
||||
|
||||
runParams = Maps.newHashMap();
|
||||
runParams.put("Blocker", blocker);
|
||||
runParams.put("Attackers", attacker);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Blocks, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Blocker, blocker);
|
||||
runParams.put(AbilityKey.Attackers, attacker);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Blocks, runParams, false);
|
||||
}
|
||||
|
||||
attacker.getDamageHistory().setCreatureGotBlockedThisCombat(true);
|
||||
if (!wasBlocked) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Attacker", attacker);
|
||||
runParams.put("Blockers", blockers);
|
||||
runParams.put("NumBlockers", blockers.size());
|
||||
runParams.put("Defender", combat.getDefenderByAttacker(attacker));
|
||||
runParams.put("DefendingPlayer", combat.getDefenderPlayerByAttacker(attacker));
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.AttackerBlocked, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attacker, attacker);
|
||||
runParams.put(AbilityKey.Blockers, blockers);
|
||||
runParams.put(AbilityKey.NumBlockers, blockers.size());
|
||||
runParams.put(AbilityKey.Defender, combat.getDefenderByAttacker(attacker));
|
||||
runParams.put(AbilityKey.DefendingPlayer, combat.getDefenderPlayerByAttacker(attacker));
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlocked, runParams, false);
|
||||
|
||||
combat.orderBlockersForDamageAssignment(attacker, new CardCollection(blockers));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.*;
|
||||
@@ -79,10 +79,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
if (!libCards.isEmpty()) {
|
||||
sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner());
|
||||
}
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", sa.getActivatingPlayer());
|
||||
runParams.put("Target", tgtPlayers);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.SearchedLibrary, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, sa.getActivatingPlayer());
|
||||
runParams.put(AbilityKey.Target, tgtPlayers);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
|
||||
}
|
||||
if (origin.contains(ZoneType.Hand) && sa.hasParam("Search")) {
|
||||
CardCollection handCards = CardLists.filterControlledBy(CardLists.getValidCards(cards, "Card.inZoneHand", sa.getActivatingPlayer(), source),
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.GameCommand;
|
||||
import forge.card.CardStateName;
|
||||
import forge.game.Game;
|
||||
@@ -831,10 +830,10 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", decider);
|
||||
runParams.put("Target", Lists.newArrayList(player));
|
||||
decider.getGame().getTriggerHandler().runTriggerOld(TriggerType.SearchedLibrary, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, decider);
|
||||
runParams.put(AbilityKey.Target, Lists.newArrayList(player));
|
||||
decider.getGame().getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
|
||||
}
|
||||
|
||||
if (!defined && changeType != null) {
|
||||
@@ -1132,10 +1131,9 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (champion) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", source);
|
||||
runParams.put("Championed", c);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Championed, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(source);
|
||||
runParams.put(AbilityKey.Championed, c);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Championed, runParams, false);
|
||||
}
|
||||
|
||||
if (remember) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.game.ability.effects;
|
||||
|
||||
import forge.game.GameAction;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -12,7 +13,7 @@ import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.PlayerZone;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClashEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -32,8 +33,8 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
final boolean victory = clashWithOpponent(sa);
|
||||
|
||||
// Run triggers
|
||||
final HashMap<String, Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", sa.getHostCard().getController());
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, sa.getHostCard().getController());
|
||||
|
||||
if (victory) {
|
||||
|
||||
@@ -42,18 +43,18 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
AbilityUtils.resolve(sub);
|
||||
}
|
||||
|
||||
runParams.put("Won", "True");
|
||||
runParams.put(AbilityKey.Won, "True");
|
||||
} else {
|
||||
AbilitySub sub = sa.getAdditionalAbility("OtherwiseSubAbility");
|
||||
if (sub != null) {
|
||||
AbilityUtils.resolve(sub);
|
||||
}
|
||||
|
||||
runParams.put("Won", "False");
|
||||
runParams.put(AbilityKey.Won, "False");
|
||||
}
|
||||
|
||||
|
||||
sa.getHostCard().getGame().getTriggerHandler().runTriggerOld(TriggerType.Clashed, runParams, false);
|
||||
sa.getHostCard().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -209,9 +209,8 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
+ srcSA.getHostCard().getName());
|
||||
}
|
||||
// Run triggers
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(tgtSA.getHostCard());
|
||||
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);
|
||||
|
||||
@@ -8,6 +8,7 @@ import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameEntityCounterTable;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -189,11 +190,10 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (obj instanceof Card) {
|
||||
Card tgtCard = gameCard;
|
||||
counterAmount = sa.usesTargeting() && sa.hasParam("DividedAsYouChoose") ? sa.getTargetRestrictions().getDividedValue(tgtCard) : counterAmount;
|
||||
if (!sa.usesTargeting() || tgtCard.canBeTargetedBy(sa)) {
|
||||
counterAmount = sa.usesTargeting() && sa.hasParam("DividedAsYouChoose") ? sa.getTargetRestrictions().getDividedValue(gameCard) : counterAmount;
|
||||
if (!sa.usesTargeting() || gameCard.canBeTargetedBy(sa)) {
|
||||
if (max != -1) {
|
||||
counterAmount = Math.max(Math.min(max - tgtCard.getCounters(counterType), counterAmount), 0);
|
||||
counterAmount = Math.max(Math.min(max - gameCard.getCounters(counterType), counterAmount), 0);
|
||||
}
|
||||
if (sa.hasParam("UpTo")) {
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
@@ -204,15 +204,15 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
|
||||
// Adapt need extra logic
|
||||
if (sa.hasParam("Adapt")) {
|
||||
if (!(tgtCard.getCounters(CounterType.P1P1) == 0
|
||||
|| tgtCard.hasKeyword("CARDNAME adapts as though it had no +1/+1 counters"))) {
|
||||
if (!(gameCard.getCounters(CounterType.P1P1) == 0
|
||||
|| gameCard.hasKeyword("CARDNAME adapts as though it had no +1/+1 counters"))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.hasParam("Tribute")) {
|
||||
// make a copy to check if it would be on the battlefield
|
||||
Card noTributeLKI = CardUtil.getLKICopy(tgtCard);
|
||||
Card noTributeLKI = CardUtil.getLKICopy(gameCard);
|
||||
// this check needs to check if this card would be on the battlefield
|
||||
noTributeLKI.setLastKnownZone(activator.getZone(ZoneType.Battlefield));
|
||||
|
||||
@@ -235,65 +235,58 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
String message = "Do you want to put " + counterAmount + " +1/+1 counters on " + tgtCard + " ?";
|
||||
String message = "Do you want to put " + counterAmount + " +1/+1 counters on " + gameCard + " ?";
|
||||
Player chooser = pc.chooseSingleEntityForEffect(activator.getOpponents(), sa, "Choose an opponent");
|
||||
|
||||
if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message)) {
|
||||
tgtCard.setTributed(true);
|
||||
gameCard.setTributed(true);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (rememberCards) {
|
||||
card.addRemembered(tgtCard);
|
||||
card.addRemembered(gameCard);
|
||||
}
|
||||
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
|
||||
final Zone zone = gameCard.getGame().getZoneOf(gameCard);
|
||||
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
|
||||
if (etbcounter) {
|
||||
tgtCard.addEtbCounter(counterType, counterAmount, placer);
|
||||
gameCard.addEtbCounter(counterType, counterAmount, placer);
|
||||
} else {
|
||||
tgtCard.addCounter(counterType, counterAmount, placer, true, table);
|
||||
gameCard.addCounter(counterType, counterAmount, placer, true, table);
|
||||
}
|
||||
if (remember) {
|
||||
final int value = tgtCard.getTotalCountersToAdd();
|
||||
tgtCard.addCountersAddedBy(card, counterType, value);
|
||||
final int value = gameCard.getTotalCountersToAdd();
|
||||
gameCard.addCountersAddedBy(card, counterType, value);
|
||||
}
|
||||
|
||||
if (sa.hasParam("Evolve")) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", tgtCard);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Evolved, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Evolved, AbilityKey.mapFromCard(gameCard), false);
|
||||
}
|
||||
if (sa.hasParam("Monstrosity")) {
|
||||
tgtCard.setMonstrous(true);
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", tgtCard);
|
||||
runParams.put("MonstrosityAmount", counterAmount);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.BecomeMonstrous, runParams, false);
|
||||
gameCard.setMonstrous(true);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(gameCard);
|
||||
runParams.put(AbilityKey.MonstrosityAmount, counterAmount);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.BecomeMonstrous, runParams, false);
|
||||
}
|
||||
if (sa.hasParam("Renown")) {
|
||||
tgtCard.setRenowned(true);
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", tgtCard);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.BecomeRenowned, runParams, false);
|
||||
gameCard.setRenowned(true);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.BecomeRenowned, AbilityKey.mapFromCard(gameCard), false);
|
||||
}
|
||||
if (sa.hasParam("Adapt")) {
|
||||
// need to remove special keyword
|
||||
tgtCard.removeHiddenExtrinsicKeyword("CARDNAME adapts as though it had no +1/+1 counters");
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", tgtCard);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Adapt, runParams, false);
|
||||
gameCard.removeHiddenExtrinsicKeyword("CARDNAME adapts as though it had no +1/+1 counters");
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Adapt, AbilityKey.mapFromCard(gameCard), false);
|
||||
}
|
||||
} else {
|
||||
// adding counters to something like re-suspend cards
|
||||
// etbcounter should apply multiplier
|
||||
if (etbcounter) {
|
||||
tgtCard.addEtbCounter(counterType, counterAmount, placer);
|
||||
gameCard.addEtbCounter(counterType, counterAmount, placer);
|
||||
} else {
|
||||
tgtCard.addCounter(counterType, counterAmount, placer, false, table);
|
||||
gameCard.addCounter(counterType, counterAmount, placer, false, table);
|
||||
}
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
game.updateLastStateForCard(gameCard);
|
||||
}
|
||||
} else if (obj instanceof Player) {
|
||||
// Add Counters to players!
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntityCounterTable;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
@@ -16,7 +16,6 @@ import forge.game.zone.ZoneType;
|
||||
import forge.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExploreEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -83,9 +82,7 @@ public class ExploreEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// a creature does explore even if it isn't on the battlefield anymore
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", c);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Explores, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Explores, AbilityKey.mapFromCard(c), false);
|
||||
}
|
||||
table.triggerCountersPutAll(game);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntityCounterTable;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardDamageMap;
|
||||
@@ -59,9 +59,9 @@ public class FightEffect extends DamageBaseEffect {
|
||||
dealDamage(sa, fighters.get(0), fighters.get(1));
|
||||
|
||||
for (Card c : fighters) {
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Fighter", c);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.Fight, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Fighter, c);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Fight, runParams, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -209,10 +209,10 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
caller.getGame().getAction().nofityOfValue(sa, caller, wonFlip ? "win" : "lose", null);
|
||||
|
||||
// Run triggers
|
||||
Map<String,Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", caller);
|
||||
runParams.put("Result", Boolean.valueOf(wonFlip));
|
||||
caller.getGame().getTriggerHandler().runTriggerOld(TriggerType.FlippedCoin, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, caller);
|
||||
runParams.put(AbilityKey.Result, wonFlip);
|
||||
caller.getGame().getTriggerHandler().runTrigger(TriggerType.FlippedCoin, runParams, false);
|
||||
} while (sa.hasParam("FlipUntilYouLose") && wonFlip);
|
||||
|
||||
if (sa.hasParam("FlipUntilYouLose") && sa.hasAdditionalAbility("LoseSubAbility")) {
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.StaticData;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactory;
|
||||
@@ -23,7 +23,6 @@ import forge.item.PaperCard;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayLandVariantEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -80,9 +79,7 @@ public class PlayLandVariantEffect extends SpellAbilityEffect {
|
||||
game.fireEvent(new GameEventLandPlayed(activator, source));
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", source);
|
||||
game.getTriggerHandler().runTriggerOld(TriggerType.LandPlayed, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.LandPlayed, AbilityKey.mapFromCard(source), false);
|
||||
game.getStack().unfreezeStack();
|
||||
activator.addLandPlayedThisTurn();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import forge.card.mana.ManaAtom;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerHandler;
|
||||
import forge.util.TextUtil;
|
||||
@@ -166,13 +167,11 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
manaPool.add(this.lastManaProduced);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
|
||||
runParams.put("Card", source);
|
||||
runParams.put("Player", player);
|
||||
runParams.put("AbilityMana", sa);
|
||||
runParams.put("Produced", afterReplace);
|
||||
player.getGame().getTriggerHandler().runTriggerOld(TriggerType.TapsForMana, runParams, false);
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(source);
|
||||
runParams.put(AbilityKey.Player, player);
|
||||
runParams.put(AbilityKey.AbilityMana, sa);
|
||||
runParams.put(AbilityKey.Produced, afterReplace);
|
||||
player.getGame().getTriggerHandler().runTrigger(TriggerType.TapsForMana, runParams, false);
|
||||
if (source.isLand()) {
|
||||
player.setTappedLandForManaThisTurn(true);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.gamesimulationtests.util;
|
||||
|
||||
import forge.deck.Deck;
|
||||
import forge.game.*;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.event.GameEventGameFinished;
|
||||
import forge.game.player.Player;
|
||||
@@ -137,8 +138,7 @@ public class GameWrapper {
|
||||
//game.getAction().startGame( null ) determines starting player, draws starting hands, handles mulligans, and initiates the first turn
|
||||
//skip drawing initial hand and mulliganing
|
||||
game.setAge( GameStage.Play );
|
||||
final HashMap<String, Object> runParams = new HashMap<>();
|
||||
game.getTriggerHandler().runTriggerOld( TriggerType.NewGame, runParams, false );
|
||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, AbilityKey.newMap(), false);
|
||||
|
||||
//first player in the list starts, no coin toss etc
|
||||
game.getPhaseHandler().startFirstTurn( game.getPlayers().get( 0 ) );
|
||||
|
||||
Reference in New Issue
Block a user