Skip to content

Conversation

Copy link

Copilot AI commented Sep 12, 2025

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original description:

Goal

Add a safe, non-UA, non-trademarked extensible plugin factory that exposes built-in base classes as editable class-option plugins for the class-builder UI. Provide Ranger and Sorcerer as example entries and add tests and documentation. This PR intentionally does not change existing runtime event registrations to avoid touching complex event wiring; it delivers the core template factory plus docs/tests so the team can wire persistence into the app’s homebrew flow in a follow-up if desired.

What to change

  1. Add new CLJ template factory

File: src/cljc/orcpub/dnd/e5/templates/base_class_editor.cljc
Purpose: Provide a small, well-documented plugin factory function plugin-with-locals that callers can invoke from any template that already has the usual locals in scope (spell-lists, spells-map, plugin-subclasses-map, language-map, weapons-map, invocations, boons). The factory returns a plugin map with :class-options? true and an opt5e/class-selection containing class option configs built by classes5e/ranger-option and classes5e/sorcerer-option. Keep the implementation generic and extensible to other base classes.

Suggested contents (create this exact file):

(ns orcpub.dnd.e5.templates.base-class-editor
  (:require
    [orcpub.dnd.e5.options :as opt5e]
    [orcpub.dnd.e5.classes :as classes5e]
    [orcpub.dnd.e5.spell-lists :as sl]
    [orcpub.dnd.e5.spells :as spells]))

;; Factory that creates a plugin map exposing base classes as editable options.
;; Call this function from a template file where the template locals are already
;; defined (e.g. the file that constructs :selections and provides spell-lists,
;; spells-map, plugin-subclasses-map, language-map, weapons-map, invocations and boons).
(defn plugin-with-locals
  [spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons]
  {:name "Base Class Editor: Ranger & Sorcerer"
   :key :base-class-editor
   :class-options? true
   :selections
   [(opt5e/class-selection
      {:options
       [(classes5e/ranger-option spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons)
        (classes5e/sorcerer-option spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons)]})]})

Notes: This file purposely avoids UA/trademarked content and simply delegates to the canonical class option builders in classes.cljc. The returned plugin map is compatible with the class-builder UI and the event handlers already implemented in the repo (set-class-prop, toggle-class-spell-list, set-class-spell, toggle-subclass-spellcasting, etc.).

  1. Add a small CLJ unit test

File: test/cljc/orcpub/dnd/e5/base_class_editor_test.cljc
Purpose: Verify the plugin factory returns a map with the expected keys and structure.

Suggested contents:

(ns orcpub.dnd.e5.base-class-editor-test
  (:require [clojure.test :refer [deftest is]]
            [orcpub.dnd.e5.templates.base-class-editor :as editor]))

(deftest plugin-shape-test
  (let [plugin (editor/plugin-with-locals {} {} {} {} {} {} {})]
    (is (map? plugin))
    (is (= true (:class-options? plugin)))
    (is (vector? (:selections plugin)))
    (is (seq (:selections plugin)))))

The test uses empty maps for the locals so it focuses on the plugin shape rather than the correctness of the inner class-option builders.

  1. Add documentation

File: docs/BASE_CLASS_EDITOR.md
Purpose: Explain how to use the new factory, how to wire it into an existing template, and how to persist edited classes via the existing homebrew patterns (reg-new-homebrew / reg-edit-homebrew) in a follow-up.

Suggested contents (high-level markdown): explain calling plugin-with-locals from a template, example snippet to require and include plugin in a template's :selections vector, and recommended next steps to wire saving/persistence using reg-new-homebrew and reg-edit-homebrew in src/cljs/orcpub/dnd/e5/events.cljs (include pointers to where similar patterns are used for spells/backgrounds/feats).

Testing and safety

  • All new code is CLJ-only and does not change runtime event registration or DB defaults. This keeps the PR low-risk.
  • The test asserts the factory returns a plugin-shaped map. It should be fast and reliable in the CLJ test runner.

Follow-ups (not in this PR)

  • Wire the plugin into a live template in the running app (for instance by invoking plugin-with-locals inside the template that already provides spell-lists, spells-map, plugin-subclasses-map, language-map and weapons-map). Because many template files are REM'd out due to UA content, include the plugin call in a template you control.
  • Add reg-new-homebrew/reg-edit-homebrew lines in src/cljs/orcpub/dnd/e5/events.cljs to enable the "Save as homebrew plugin" flow for edited classes. Mirror the patterns used for other types (spells, backgrounds, feats) so persistence integrates with existing UIs.

Please create a new branch feature/editable-base-classes and open a PR against develop with the above files and tests. PR title: "Expose base classes as editable plugins (Ranger & Sorcerer)".

This pull request was created as a result of the following prompt from Copilot chat.

Goal

Add a safe, non-UA, non-trademarked extensible plugin factory that exposes built-in base classes as editable class-option plugins for the class-builder UI. Provide Ranger and Sorcerer as example entries and add tests and documentation. This PR intentionally does not change existing runtime event registrations to avoid touching complex event wiring; it delivers the core template factory plus docs/tests so the team can wire persistence into the app’s homebrew flow in a follow-up if desired.

What to change

  1. Add new CLJ template factory

File: src/cljc/orcpub/dnd/e5/templates/base_class_editor.cljc
Purpose: Provide a small, well-documented plugin factory function plugin-with-locals that callers can invoke from any template that already has the usual locals in scope (spell-lists, spells-map, plugin-subclasses-map, language-map, weapons-map, invocations, boons). The factory returns a plugin map with :class-options? true and an opt5e/class-selection containing class option configs built by classes5e/ranger-option and classes5e/sorcerer-option. Keep the implementation generic and extensible to other base classes.

Suggested contents (create this exact file):

(ns orcpub.dnd.e5.templates.base-class-editor
  (:require
    [orcpub.dnd.e5.options :as opt5e]
    [orcpub.dnd.e5.classes :as classes5e]
    [orcpub.dnd.e5.spell-lists :as sl]
    [orcpub.dnd.e5.spells :as spells]))

;; Factory that creates a plugin map exposing base classes as editable options.
;; Call this function from a template file where the template locals are already
;; defined (e.g. the file that constructs :selections and provides spell-lists,
;; spells-map, plugin-subclasses-map, language-map, weapons-map, invocations and boons).
(defn plugin-with-locals
  [spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons]
  {:name "Base Class Editor: Ranger & Sorcerer"
   :key :base-class-editor
   :class-options? true
   :selections
   [(opt5e/class-selection
      {:options
       [(classes5e/ranger-option spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons)
        (classes5e/sorcerer-option spell-lists spells-map plugin-subclasses-map language-map weapons-map invocations boons)]})]})

Notes: This file purposely avoids UA/trademarked content and simply delegates to the canonical class option builders in classes.cljc. The returned plugin map is compatible with the class-builder UI and the event handlers already implemented in the repo (set-class-prop, toggle-class-spell-list, set-class-spell, toggle-subclass-spellcasting, etc.).

  1. Add a small CLJ unit test

File: test/cljc/orcpub/dnd/e5/base_class_editor_test.cljc
Purpose: Verify the plugin factory returns a map with the expected keys and structure.

Suggested contents:

(ns orcpub.dnd.e5.base-class-editor-test
  (:require [clojure.test :refer [deftest is]]
            [orcpub.dnd.e5.templates.base-class-editor :as editor]))

(deftest plugin-shape-test
  (let [plugin (editor/plugin-with-locals {} {} {} {} {} {} {})]
    (is (map? plugin))
    (is (= true (:class-options? plugin)))
    (is (vector? (:selections plugin)))
    (is (seq (:selections plugin)))))

The test uses empty maps for the locals so it focuses on the plugin shape rather than the correctness of the inner class-option builders.

  1. Add documentation

File: docs/BASE_CLASS_EDITOR.md
Purpose: Explain how to use the new factory, how to wire it into an existing template, and how to persist edited classes via the existing homebrew patterns (reg-new-homebrew / reg-edit-homebrew) in a follow-up.

Suggested contents (high-level markdown): explain calling plugin-with-locals from a template, example snippet to require and include plugin in a template's :selections vector, and recommended next steps to wire saving/persistence using reg-new-homebrew and reg-edit-homebrew in src/cljs/orcpub/dnd/e5/events.cljs (include pointers to where similar patterns are used for spells/backgrounds/feats).

Testing and safety

  • All new code is CLJ-only and does not change runtime event registration or DB defaults. This keeps the PR low-risk.
  • The test asserts the factory returns a plugin-shaped map. It should be fast and reliable in the CLJ test runner.

Follow-ups (not in this PR)

  • Wire the plugin into a live template in the running app (for instance by invoking plugin-with-locals inside the template that already provides spell-lists, spells-map, plugin-subclasses-map, language-map and weapons-map). Because many template files are REM'd out due to UA content, include the plugin call in a template you control.
  • Add reg-new-homebrew/reg-edit-homebrew lines in src/cljs/orcpub/dnd/e5/events.cljs to enable the "Save as homebrew plugin" flow for edited classes. Mirror the patterns used for other types (spells, backgrounds, feats) so persistence integrates with existing UIs.

Please create a new branch feature/editable-base-classes and open a PR against develop with the above files and tests. PR title: "Expose base classes as editable plugins (Ranger & Sorcerer)".


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codeGlaze
Copy link
Owner

@copilot what happened to the actual real code commits

Copilot AI requested a review from codeGlaze September 12, 2025 14:24
Copilot stopped work on behalf of codeGlaze due to an error September 12, 2025 14:25
@codeGlaze
Copy link
Owner

@copilot retry creating and committing the real file changes

@codeGlaze codeGlaze marked this pull request as ready for review September 12, 2025 14:34
Copilot stopped work on behalf of codeGlaze due to an error September 12, 2025 14:40
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.

2 participants