- Implement character creation functions to handle adventurer setup. - Add validation for adventurer name and selection of starting items. - Introduce new items in sample content pack: Flint and Steel, Pouch, Wax Sealing Kit, and Backpack. - Create tests for character creation functionality to ensure valid options and error handling. ✨Feature: implement dice rolling mechanics and tests - Add functions for rolling various dice types (d3, d6, 2d6, d66) with validation. - Implement modifier application with clamping for roll results. - Create tests to verify correct behavior of dice rolling functions. ✨Feature: add table lookup functionality and tests - Implement table lookup and resolution logic for defined tables. - Support for modified ranges and fallback to nearest entries. - Create tests to ensure correct table entry resolution based on roll results.
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { sampleContentPack } from "@/data/sampleContentPack";
|
|
|
|
import { createStartingAdventurer, getCharacterCreationOptions } from "./character";
|
|
|
|
describe("character creation", () => {
|
|
it("exposes legal starting options from the content pack", () => {
|
|
const options = getCharacterCreationOptions(sampleContentPack);
|
|
|
|
expect(options.weapons).toHaveLength(1);
|
|
expect(options.armour).toHaveLength(1);
|
|
expect(options.scrolls).toHaveLength(1);
|
|
});
|
|
|
|
it("builds a valid starting adventurer from legal choices", () => {
|
|
const adventurer = createStartingAdventurer(sampleContentPack, {
|
|
name: "Mira",
|
|
weaponId: "weapon.short-sword",
|
|
armourId: "armour.leather-vest",
|
|
scrollId: "scroll.lesser-heal",
|
|
});
|
|
|
|
expect(adventurer.name).toBe("Mira");
|
|
expect(adventurer.level).toBe(1);
|
|
expect(adventurer.stats.shift).toBe(2);
|
|
expect(adventurer.manoeuvreIds).toEqual([
|
|
"manoeuvre.exact-strike",
|
|
"manoeuvre.guard-break",
|
|
]);
|
|
expect(adventurer.inventory.rationCount).toBe(3);
|
|
expect(adventurer.inventory.carried).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({ definitionId: "potion.healing", quantity: 1 }),
|
|
expect.objectContaining({ definitionId: "scroll.lesser-heal", quantity: 1 }),
|
|
]),
|
|
);
|
|
});
|
|
|
|
it("rejects an empty adventurer name", () => {
|
|
expect(() =>
|
|
createStartingAdventurer(sampleContentPack, {
|
|
name: " ",
|
|
weaponId: "weapon.short-sword",
|
|
armourId: "armour.leather-vest",
|
|
scrollId: "scroll.lesser-heal",
|
|
}),
|
|
).toThrow("Adventurer name is required.");
|
|
});
|
|
});
|