Remove triggers in setup game state

This commit is contained in:
Adam Pantel
2021-04-11 09:28:16 -04:00
parent 3de8bd49ad
commit d473737ca8
3 changed files with 14 additions and 32 deletions

View File

@@ -758,30 +758,10 @@ public abstract class GameState {
} }
game.fireEvent(new GameEventAttackersDeclared(attackingPlayer, attackersMap)); game.fireEvent(new GameEventAttackersDeclared(attackingPlayer, attackersMap));
if (!combat.getAttackers().isEmpty()) {
List<GameEntity> attackedTarget = new ArrayList<>();
for (GameEntity ge : combat.getDefenders()) {
if (!combat.getAttackersOf(ge).isEmpty()) {
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Attackers, combat.getAttackersOf(ge));
runParams.put(AbilityKey.AttackingPlayer, combat.getAttackingPlayer());
runParams.put(AbilityKey.AttackedTarget, ge);
attackedTarget.add(ge);
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclaredOneTarget, runParams, false);
}
}
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Attackers, combat.getAttackers());
runParams.put(AbilityKey.AttackingPlayer, combat.getAttackingPlayer());
runParams.put(AbilityKey.AttackedTarget, attackedTarget);
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclared, runParams, false);
}
for (final Card c : combat.getAttackers()) { for (final Card c : combat.getAttackers()) {
CombatUtil.checkDeclaredAttacker(game, c, combat); CombatUtil.checkDeclaredAttacker(game, c, combat, false);
} }
game.getTriggerHandler().resetActiveTriggers();
game.updateCombatForView(); game.updateCombatForView();
game.fireEvent(new GameEventCombatChanged()); game.fireEvent(new GameEventCombatChanged());

View File

@@ -352,8 +352,9 @@ public class CombatUtil {
* @param c * @param c
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
*/ */
public static void checkDeclaredAttacker(final Game game, final Card c, final Combat combat) { public static void checkDeclaredAttacker(final Game game, final Card c, final Combat combat, boolean triggers) {
// Run triggers // Run triggers
if (triggers) {
final Map<AbilityKey, Object> runParams = AbilityKey.newMap(); final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Attacker, c); runParams.put(AbilityKey.Attacker, c);
final List<Card> otherAttackers = combat.getAttackers(); final List<Card> otherAttackers = combat.getAttackers();
@@ -363,6 +364,7 @@ public class CombatUtil {
runParams.put(AbilityKey.DefendingPlayer, combat.getDefenderPlayerByAttacker(c)); runParams.put(AbilityKey.DefendingPlayer, combat.getDefenderPlayerByAttacker(c));
runParams.put(AbilityKey.Defenders, combat.getDefenders()); runParams.put(AbilityKey.Defenders, combat.getDefenders());
game.getTriggerHandler().runTrigger(TriggerType.Attacks, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.Attacks, runParams, false);
}
c.getDamageHistory().setCreatureAttackedThisCombat(true); c.getDamageHistory().setCreatureAttackedThisCombat(true);
c.getDamageHistory().clearNotAttackedSinceLastUpkeepOf(); c.getDamageHistory().clearNotAttackedSinceLastUpkeepOf();

View File

@@ -632,7 +632,7 @@ public class PhaseHandler implements java.io.Serializable {
} }
for (final Card c : combat.getAttackers()) { for (final Card c : combat.getAttackers()) {
CombatUtil.checkDeclaredAttacker(game, c, combat); CombatUtil.checkDeclaredAttacker(game, c, combat, true);
} }
game.getTriggerHandler().resetActiveTriggers(); game.getTriggerHandler().resetActiveTriggers();