Skip to content

Refactor rules scripting to use shared ScriptRef#7

Merged
PJensen merged 1 commit intomasterfrom
codex/port-scripted-actions-to-scriptref
Nov 6, 2025
Merged

Refactor rules scripting to use shared ScriptRef#7
PJensen merged 1 commit intomasterfrom
codex/port-scripted-actions-to-scriptref

Conversation

@PJensen
Copy link
Owner

@PJensen PJensen commented Nov 6, 2025

Summary

  • add a central scripting registry and verbs for the rules engine
  • migrate spell and affix definitions to register handlers through the router
  • update combat, equipment, and trigger systems to invoke scripts by key and remove the local ScriptRef component

Testing

  • npm run test:sanity (fails: missing src/lib/ecs-js submodule in environment)

https://chatgpt.com/codex/tasks/task_e_690d17d57a988333ae38aa4ce27f8d8b

Copilot AI review requested due to automatic review settings November 6, 2025 21:58
@PJensen PJensen merged commit 1ba639f into master Nov 6, 2025
4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the scripting system from inline functions to a centralized, verb-based script registry. The change moves from directly storing and executing script functions in data definitions to using string keys that reference handlers registered in a central registry.

  • Introduces a new scripting.js module with a registry-based script execution system supporting multiple verb types
  • Refactors affixes and spells to use string keys instead of inline functions
  • Migrates ScriptRef component from local definition to ecs-js library import

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/rules/scripting.js New central script registry with verb-based handler resolution and registration API
src/rules/data/affixes.js Refactored affix definitions to register scripts separately and reference them by string keys
src/rules/scripts/spells.js Migrated spell scripts to use the central registry system with consistent verb-based handlers
src/rules/systems/equipmentSystem.js Updated to call affix passives through the new runScript function
src/rules/systems/combatSystem.js Updated affix trigger invocations to use runScript with appropriate verbs
src/rules/systems/affixTriggerSystem.js Updated onDamaged affix handling to use the new script execution system
src/rules/data/validate.js Updated validation to expect script and passive fields as strings instead of functions
src/rules/data/equipmentLoader.js Changed ScriptRef import source and updated property name from 'ref' to 'key'
src/rules/components/index.js Removed ScriptRef export as it's now imported from ecs-js library
src/rules/components/ScriptRef.js Deleted local component definition in favor of ecs-js library version
Comments suppressed due to low confidence (1)

src/rules/systems/affixTriggerSystem.js:19

      if (a) cb(a, slotId);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants