Skip to content
Jerome Leclanche edited this page Jul 13, 2015 · 6 revisions

It is possible to watch over Action objects. Whenever an Action is triggered, Action.broadcast() will run, triggering matching events in Entity._events for every "live" entity in the Game.

A matching event is an Action object which has the same Action class as the triggered event, and of which the arguments encompass the queued action's arguments. For example, the event Play(OPPONENT) will match the action Play(<card>) whenever the card argument matches the OPPONENT selector. In other words, whenever the opponent plays a card.

Another example: Playing a Dread Infernal queues the action Damage(ALL_CHARACTERS, 1). This matches [Floating Watcher]'s event Damage(FRIENDLY_HERO), because the FRIENDLY_HERO selector will cause a Damage event on the player's Hero, which then matches the ALL_CHARACTERS selector.

Event Listeners

An Event Listener can be created from an Action instance. There are three different methods:

  • action.on(*actions)
  • action.after(*actions)
  • action.once(*actions)

The *actions arguments are one or more action which will happen when the event listener is triggered.

The on() event listeners are the most common. They will trigger right before the action actually resolves. after() event listeners will trigger after the resolution has completed. Only the Play() and Summon() action support the after() event listener.

once() event listeners are on() listeners, but will only trigger once. For example, Headcrack's combo effect is defined as TURN_END.once(Give(CONTROLLER, "EX1_137")).

Event Listeners on cards are defined in the events class attribute. It is a list of all the Event Listeners on the card.

Event helpers

Some event helpers are defined to improve readability and avoid creating unnecessary duplicate objects. The following event helpers are available in fireplace.events:

  • OWN_CARD_PLAY (Play(CONTROLLER))
  • OWN_MINION_PLAY (Play(CONTROLLER, MINION))
  • OWN_SECRET_PLAY (Play(CONTROLLER, SECRET))
  • OWN_SPELL_PLAY (Play(CONTROLLER, SPELL))
  • TURN_BEGIN (BeginTurn())
  • OWN_TURN_BEGIN (BeginTurn(CONTROLLER))
  • TURN_END (EndTurn())
  • OWN_TURN_END (EndTurn(CONTROLLER))
  • SELF_DAMAGE (Damage(SELF))