mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Experimental: fixed state triggers so they will trigger during the middle of the resolution of a spell or ability. (e.g. Cloudshift an Enchantment creature would fire Tethered Griffin's trigger)
This commit is contained in:
@@ -763,6 +763,9 @@ public class GameAction {
|
||||
game.fireEvent(new GameEventCardStatsChanged(affectedCards));
|
||||
}
|
||||
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -802,9 +805,6 @@ public class GameAction {
|
||||
|
||||
this.checkStaticAbilities();
|
||||
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||
|
||||
for (Player p : game.getPlayers()) {
|
||||
for (Card c : p.getCardsIn(ZoneType.Battlefield)) {
|
||||
if (!c.getController().equals(p)) { // should not be here
|
||||
|
||||
@@ -155,8 +155,9 @@ public class TriggerHandler {
|
||||
}
|
||||
|
||||
//runWaitingTrigger(new TriggerWaiting(mode, runParams));
|
||||
|
||||
if (game.getStack().isFrozen() || holdTrigger) {
|
||||
if (mode == TriggerType.Always) {
|
||||
runStateTrigger(runParams);
|
||||
} else if (game.getStack().isFrozen() || holdTrigger) {
|
||||
waitingTriggers.add(new TriggerWaiting(mode, runParams));
|
||||
} else {
|
||||
runWaitingTrigger(new TriggerWaiting(mode, runParams));
|
||||
@@ -164,6 +165,21 @@ public class TriggerHandler {
|
||||
// Tell auto stop to stop
|
||||
}
|
||||
|
||||
public final boolean runStateTrigger(Map<String, Object> runParams) {
|
||||
boolean checkStatics = false;
|
||||
// only cards in play can run state triggers
|
||||
List<Card> allCards = new ArrayList<Card>(game.getCardsIn(ZoneType.listValueOf("Battlefield,Command")));
|
||||
for (final Card c : allCards) {
|
||||
for (final Trigger t : c.getTriggers()) {
|
||||
if (canRunTrigger(t, TriggerType.Always, runParams)) {
|
||||
this.runSingleTrigger(t, runParams);
|
||||
checkStatics = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return checkStatics;
|
||||
}
|
||||
|
||||
public final boolean runWaitingTriggers() {
|
||||
ArrayList<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers);
|
||||
waitingTriggers.clear();
|
||||
|
||||
Reference in New Issue
Block a user