Add combatant side assignment for encounter difficulty
Combatants can now be assigned to party or enemy side via a toggle in the difficulty breakdown panel. Party-side NPCs subtract their XP from the encounter total, letting allied NPCs reduce difficulty. PCs default to party, non-PCs to enemy — users who don't use sides see no change. Side persists across reload and export/import. Closes #22 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -241,6 +241,28 @@ describe("rehydrateCombatant", () => {
|
||||
expect(result?.cr).toBeUndefined();
|
||||
});
|
||||
|
||||
it("preserves valid side field", () => {
|
||||
for (const side of ["party", "enemy"]) {
|
||||
const result = rehydrateCombatant({ ...minimalCombatant(), side });
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.side).toBe(side);
|
||||
}
|
||||
});
|
||||
|
||||
it("drops invalid side field", () => {
|
||||
for (const side of ["ally", "", 42, null, true]) {
|
||||
const result = rehydrateCombatant({ ...minimalCombatant(), side });
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.side).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it("combatant without side rehydrates as before", () => {
|
||||
const result = rehydrateCombatant(minimalCombatant());
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.side).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