Skip to content

Unify event dispatch in Permanent#receive_event - #528

Merged
radar merged 1 commit into
masterfrom
pr8-unify-event-dispatch
Apr 22, 2026
Merged

Unify event dispatch in Permanent#receive_event#528
radar merged 1 commit into
masterfrom
pr8-unify-event-dispatch

Conversation

@radar

@radar radar commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces three separate event dispatch paths in Permanent#receive_event with two private methods: dispatch_lifecycle_triggers and dispatch_event_handlers
  • Renames def performdef call in 18 card lifecycle trigger classes so all triggers go through perform!should_perform?call
  • Fixes accumulation bug in add_event_handler

Details

receive_event previously had a hardcoded case statement routing ETB/LTB/death events to three separate helper methods (entered_the_battlefield!, left_the_battlefield!, died!), then a separate hash lookup for everything else. The two paths used different method names (perform vs call) and the lifecycle path bypassed should_perform? entirely.

dispatch_lifecycle_triggers preserves all existing guards: event.permanent == self check and attachment cleanup on LTB. dispatch_event_handlers wraps the hash lookup in Array() so single-class and array values both work, enabling add_event_handler to accumulate multiple handlers per event type.

entered_the_battlefield! stays public since two specs use it directly as a test shortcut.

Test plan

  • All 534 tests pass

🤖 Generated with Claude Code

Three separate dispatch paths (case statement for lifecycle events,
event_handlers hash for others, and inconsistent perform vs call naming)
are replaced with two private methods: dispatch_lifecycle_triggers and
dispatch_event_handlers. Lifecycle trigger classes renamed from def perform
to def call so all triggers go through perform! -> should_perform? -> call.
Fixed add_event_handler accumulation bug in Cards::Shared::Events.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@radar
radar merged commit b095111 into master Apr 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant