Refactor to Support SRD 5.1 and SRD 5.2 Rulesets#1
Refactor to Support SRD 5.1 and SRD 5.2 Rulesets#1google-labs-jules[bot] wants to merge 2 commits intomainfrom
Conversation
This refactors the D&D character management to support both SRD 5.1 and SRD 5.2 rulesets. - Adds a `ruleset` field to the `Character` schema and a corresponding database migration. - Splits the D&D data into `srd51.ts` and `srd52.ts` files. - Refactors `src/lib/dnd.ts` to be a core rules file with a `getRuleset` function to dynamically load the correct ruleset. - Updates character computation and services to be ruleset-aware, using the dynamically loaded ruleset data.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. |
| import type { | ||
| AbilityScoreModifiers, | ||
| AbilityType, | ||
| Background, | ||
| BackgroundFeature, | ||
| BackgroundNameType, | ||
| CasterKindType, | ||
| Choice, | ||
| ClassDef, | ||
| ClassNameType, | ||
| HitDieType, | ||
| Race, | ||
| SizeType, | ||
| SkillType, | ||
| SlotProgression, | ||
| SpellSlotsType, | ||
| Subrace, | ||
| SpellcastingInfo, | ||
| SpellChangeEventType | ||
| } from "../dnd"; |
There was a problem hiding this comment.
lots of unused imports here and in other files; can you clean up unused imports?
src/lib/dnd/srd52.ts
Outdated
| const ArtisanTools = [ | ||
| "alchemist’s supplies", | ||
| "brewer’s supplies", | ||
| "calligrapher’s supplies", | ||
| "carpenter’s tools", | ||
| "cartographer’s tools", | ||
| "cobbler’s tools", | ||
| "cook’s utensils", | ||
| "glassblower’s tools", | ||
| "jeweler’s tools", | ||
| "leatherworker’s tools", | ||
| "mason’s tools", | ||
| "painter’s supplies", | ||
| "potter’s tools", | ||
| "smith’s tools", | ||
| "tinker’s tools", | ||
| "weaver’s tools", | ||
| "woodcarver’s tools", | ||
| ] as const; | ||
|
|
||
| const Instruments = [ | ||
| "bagpipes", | ||
| "drum", | ||
| "dulcimer", | ||
| "flute", | ||
| "lute", | ||
| "lyre", | ||
| "horn", | ||
| "pan flute", | ||
| "shawm", | ||
| "viol", | ||
| ] as const; |
src/lib/dnd/srd51.ts
Outdated
| Races, | ||
| RaceNames, | ||
| SubraceNames, |
There was a problem hiding this comment.
lets stick with consistent terminology and just go with 'species' and 'lineage' in both rulesets.
| // ===================== | ||
| // Data (Player’s Handbook classes, lowercase) | ||
| // ===================== | ||
| export const Classes: Record<ClassNameType, ClassDef> = { |
There was a problem hiding this comment.
this is removed, but still imported in, e.g. addLevel service. please double-check all places that depend on removed imports from this file, and convert them to use rulesets
src/lib/dnd/srd51.ts
Outdated
| {level: 1, cantrips: 3, prepared: 4, slots: [2, 0, 0, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 2, cantrips: 3, prepared: 5, slots: [3, 0, 0, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 3, cantrips: 3, prepared: 6, slots: [4, 2, 0, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 4, cantrips: 4, prepared: 7, slots: [4, 3, 0, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 5, cantrips: 4, prepared: 9, slots: [4, 3, 2, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 6, cantrips: 4, prepared: 10, slots: [4, 3, 3, 0, 0, 0, 0, 0, 0]}, | ||
| {level: 7, cantrips: 4, prepared: 11, slots: [4, 3, 3, 1, 0, 0, 0, 0, 0]}, | ||
| {level: 8, cantrips: 4, prepared: 12, slots: [4, 3, 3, 2, 0, 0, 0, 0, 0]}, | ||
| {level: 9, cantrips: 4, prepared: 14, slots: [4, 3, 3, 3, 1, 0, 0, 0, 0]}, | ||
| {level: 10, cantrips: 5, prepared: 15, slots: [4, 3, 3, 3, 2, 0, 0, 0, 0]}, | ||
| {level: 11, cantrips: 5, prepared: 16, slots: [4, 3, 3, 3, 2, 1, 0, 0, 0]}, | ||
| {level: 12, cantrips: 5, prepared: 16, slots: [4, 3, 3, 3, 2, 1, 0, 0, 0]}, | ||
| {level: 13, cantrips: 5, prepared: 17, slots: [4, 3, 3, 3, 2, 1, 1, 0, 0]}, | ||
| {level: 14, cantrips: 5, prepared: 17, slots: [4, 3, 3, 3, 2, 1, 1, 0, 0]}, | ||
| {level: 15, cantrips: 5, prepared: 18, slots: [4, 3, 3, 3, 2, 1, 1, 1, 0]}, | ||
| {level: 16, cantrips: 5, prepared: 18, slots: [4, 3, 3, 3, 2, 1, 1, 1, 0]}, | ||
| {level: 17, cantrips: 5, prepared: 19, slots: [4, 3, 3, 3, 2, 1, 1, 1, 1]}, | ||
| {level: 18, cantrips: 5, prepared: 20, slots: [4, 3, 3, 3, 3, 1, 1, 1, 1]}, | ||
| {level: 19, cantrips: 5, prepared: 21, slots: [4, 3, 3, 3, 3, 2, 1, 1, 1]}, | ||
| {level: 20, cantrips: 5, prepared: 22, slots: [4, 3, 3, 3, 3, 2, 2, 1, 1]}, |
There was a problem hiding this comment.
the srd51 rules don't list a number of prepared spells by level. instead, the rules say "You
prepare
the
list
of
cleric
spells
that
are
available
for
you
to
cast,
choosing
from
the
cleric
spell
list.
When
you
do
so,
choose
a
number
of
cleric
spells
equal
to
your
Wisdom
modifier
+
your
cleric
level
(minimum
of
one
spell).
The
spells
must
be
of
a
level
for
which
you
have
spell
slots." this is true for other prepared spellcasters as well, e.g. druid, or for paladin it says "When
you
do
so,
choose
a
number
of
paladin
spells
equal
to
your
Charisma
modifier
+
half
your
paladin
level,
rounded
down
(minimum
of
one
spell)." can you double-check all of these and correct them?
| "acolyte", "criminal", "sage", "soldier" | ||
| ] as const; | ||
|
|
||
| const Backgrounds: Record<BackgroundNameType, Background> = { |
There was a problem hiding this comment.
we don't have all backgrounds here. we might need to move BackgroundNameType to the rulesets as well, since this is an invalid type.
This refactors the D&D character management to support both SRD 5.1 and SRD 5.2 rulesets. - Adds a `ruleset` field to the `Character` schema and a corresponding database migration. - Splits the D&D data into `srd51.ts` and `srd52.ts` files. - Refactors `src/lib/dnd.ts` to be a core rules file with a `getRuleset` function to dynamically load the correct ruleset. - Updates character computation and services to be ruleset-aware, using the dynamically loaded ruleset data. - Corrects spell preparation calculations for SRD 5.1 and cleans up unused imports and data inconsistencies.
This refactoring enables the application to support both SRD 5.1 and SRD 5.2 rulesets for D&D characters. It introduces a
rulesetattribute to the character data model, separates the rules-specific data into distinct files for each version, and updates the character computation services to dynamically load and apply the correct ruleset based on the character's data. This makes the system more flexible and extensible for future ruleset additions.PR created automatically by Jules for task 17671055234094048508