aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2026-04-22Revert the worldgen stub pending the full pipeline and authored region contentBobby1-48/+0
2026-04-22Generate a fresh year-1111 world on Begin and persist it to the user-data ↵Bobby1-0/+48
database
2026-04-22Migrate remaining relative imports to @hollowdark/*; strip //-comments and ↵Bobby4-17/+4
doc references, JSDoc-only
2026-04-22Drop all barrel index.ts files; imports target leaf files directlyBobby5-15/+12
2026-04-22Switch cross-module imports to @hollowdark/* scoped aliasBobby8-8/+8
2026-04-22Set up IndexedDB schema via DexieBobby1-0/+71
2026-04-22Add shared utilities: Result, assert, deepEqual, common types, logBobby3-0/+276
Foundational helpers referenced by most subsequent code. Small, pure, no dependencies on anything in the project. utils/result.ts Result<T, E> = Ok<T> | Err<E> for recoverable failures at system boundaries (save/load, manifest fetch, content validation). Internal pure logic still uses throw for programmer errors. ok / err / isOk / isErr / mapResult / mapErr / unwrap / unwrapOr. utils/assert.ts assert (with type-narrowing asserts), assertNever for exhaustive-switch termination, assertDefined for narrowing T | null | undefined → T. utils/equal.ts Structural deepEqual for tests comparing simulation snapshots. Handles plain objects, arrays, Map, Set, Date, primitives. Does not handle cyclic graphs (simulation state is a tree). utils/types.ts Common type aliases: NonEmptyArray, JsonValue, ElementOf, DeepReadonly, Brand<T, B> for nominal / branded types (PersonId vs RelationshipId). utils/log.ts Structured logging wrapping console. Developer- facing only; the game ships with no runtime telemetry. utils/index.ts Public re-exports. 40 unit tests in tests/unit/utils/ cover Result constructors and combinators, assert variants, and deepEqual's primitive / array / object / Map / Set / Date paths plus a realistic simulation-snapshot comparison.
2026-04-22Implement GameTime and the 12-month calendarBobby3-0/+445
The Hollowdark calendar is 12 × 30-day months + a 5-day year-end festival = 365 days, with 7-day weeks (docs/01-world.md and the style bible). Months live in canonical order: spring 1 Thawing 2 Greening 3 Blossomtide summer 4 Highsun 5 Amberhaze 6 Harvestmark autumn 7 Firstfall 8 Stormturn 9 Ashfall winter 10 Rainfall 11 Hollowdark 12 Rimefrost festival 13 Year's End Festival (5 days) time/calendar.ts month names, season mapping, days-per-month, festival helpers time/gameTime.ts GameTime shape + arithmetic: makeGameTime, addDays / addWeeks / addMonths / addYears, daysBetween / weeksBetween, compare / isBefore / isAfter / isSameDay, dayOfWeek, dayOfYear, toAbsoluteDays, formatGameTime time/granularity.ts LifeStage + TickUnit mapping — one tick is a year in infancy, a season in childhood, a month in adolescence and old age, a week in adult life (docs/05-time-system.md, ARCHITECTURE.md §5) time/speed.ts Speed type: 'paused' | 'play' | 'fast' time/index.ts public re-exports Arithmetic is implemented by flattening GameTime to absolute-day integers (year × 365 + dayOfYear - 1) so addDays, daysBetween, and ordering are exact integer math. addMonths uses 13-month modular arithmetic and clamps the day into the festival's 5-day length on overflow. 59 unit tests in tests/unit/time/ cover constants, validation, arithmetic edge cases (Rimefrost 30 → Festival 1, Festival 5 → Thawing 1 of next year, day-clamping when landing in the festival), negative offsets, tickOfDay preservation, day-of-week stability, and life-stage boundaries.
2026-04-22Implement seeded PRNG with deterministic sub-RNG derivationBobby1-0/+233
rng/ is the load-bearing primitive for simulation determinism (ARCHITECTURE.md §26). All gameplay randomness routes through createRNG; Math.random is forbidden in gameplay code by ESLint. rng/derive.ts xmur3 string hash + deriveSeed(parentSeed, label), stable across processes and runs rng/seeded.ts SeededRNG interface, mulberry32 implementation, next / nextInt / nextBool / pick / weightedPick / sub rng/index.ts public re-exports Sub-RNG derivation is the key technical move: seeding a child with hash(parent_seed + label) lets NPCs' trajectories be regenerated deterministically from their identity tuple alone — which is how Tier 3 NPCs stay off-disk until the player needs them. 29 determinism tests in tests/determinism/rng.test.ts cover: same seed → same sequence, sub-RNG independence from parent consumption, sub-order matters, input validation, and a byte-level inline snapshot that locks the PRNG output for seed "hollowdark". The snapshot is load-bearing — if mulberry32 or xmur3 changes, every existing save diverges, so treat a snapshot break as a migration concern, not an update-the-snapshot fix.