Add manual CR assignment and difficulty breakdown panel
Implement issue #21: custom combatants can now have a challenge rating assigned via a new breakdown panel, opened by tapping the difficulty indicator. Bestiary-linked combatants show read-only CR with source name; custom combatants get a CR picker with all standard 5e values. CR persists across reloads and round-trips through JSON export/import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -219,6 +219,28 @@ describe("rehydrateCombatant", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves valid cr field", () => {
|
||||
for (const cr of ["5", "1/4", "0", "30"]) {
|
||||
const result = rehydrateCombatant({ ...minimalCombatant(), cr });
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.cr).toBe(cr);
|
||||
}
|
||||
});
|
||||
|
||||
it("drops invalid cr field", () => {
|
||||
for (const cr of ["99", "", 42, null, "abc"]) {
|
||||
const result = rehydrateCombatant({ ...minimalCombatant(), cr });
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.cr).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it("combatant without cr rehydrates as before", () => {
|
||||
const result = rehydrateCombatant(minimalCombatant());
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.cr).toBeUndefined();
|
||||
});
|
||||
|
||||
it("drops invalid tempHp — keeps combatant", () => {
|
||||
for (const tempHp of [-1, 1.5, "3"]) {
|
||||
const result = rehydrateCombatant({
|
||||
|
||||
Reference in New Issue
Block a user