Refactor rules scripting to use shared ScriptRef#7
Merged
Conversation
There was a problem hiding this comment.
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.jsmodule with a registry-based script execution system supporting multiple verb types - Refactors affixes and spells to use string keys instead of inline functions
- Migrates
ScriptRefcomponent 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
- Superfluous argument passed to anonymous function.
if (a) cb(a, slotId);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_690d17d57a988333ae38aa4ce27f8d8b