diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db8ce3d..9088f4fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ Release notes for Arda. The design ledger (decisions, stage records and per-change detail) lives in `docs/capstone/changelog.md` and `docs/capstone/changelog.d/`. +## Unreleased + +**API (`/v1`, additive)** + +- `GET /v1/npc/occupations` lists every key `POST /v1/npc/generate` takes: 96 jobs and 21 offices, each with its kind (`job` or `office`), a label, a job's female label and category, and the tiers it is accepted in with its `SocialRank` in each. New schema `OccupationList` (family `npc_format`, unchanged at 1). Stable, in the contract kit as `npc-occupations`. + +**Content changes (flagged per the versioning policy)** + +- `GET /v1/schema` lists `OccupationList`. No other body changes. + ## 1.1.1 — 2026-11-14 Dependency security updates. No API, format or content change from 1.1.0, which was tagged but not published; 1.1.1 is the first published release with the dungeon and cave sites described under 1.1.0. diff --git a/bindings/schema/OccupationList.json b/bindings/schema/OccupationList.json new file mode 100644 index 00000000..c456d8e6 --- /dev/null +++ b/bindings/schema/OccupationList.json @@ -0,0 +1,232 @@ +{ + "$defs": { + "JobCategory": { + "description": "Broad kind of work.", + "oneOf": [ + { + "const": "agriculture", + "description": "Fields and herds.", + "type": "string" + }, + { + "const": "craft", + "description": "Workshops and trades.", + "type": "string" + }, + { + "const": "trade", + "description": "Buying and selling.", + "type": "string" + }, + { + "const": "service", + "description": "Inns, kitchens and households.", + "type": "string" + }, + { + "const": "religion", + "description": "Clergy.", + "type": "string" + }, + { + "const": "military", + "description": "Soldiers and watch.", + "type": "string" + }, + { + "const": "government", + "description": "Officials.", + "type": "string" + }, + { + "const": "maritime", + "description": "Boats and docks.", + "type": "string" + }, + { + "const": "extraction", + "description": "Mines and forests.", + "type": "string" + }, + { + "const": "scholar", + "description": "Books and teaching.", + "type": "string" + }, + { + "const": "labour", + "description": "Unskilled work.", + "type": "string" + }, + { + "const": "nobility", + "description": "Nobles.", + "type": "string" + }, + { + "const": "dependent", + "description": "Children and the retired.", + "type": "string" + } + ] + }, + "Occupation": { + "description": "One key of the catalogue. `(kind, key)` is unique; `reeve`, `elder`,\n`harbourmaster` and others are both a job and an office.", + "properties": { + "category": { + "anyOf": [ + { + "$ref": "#/$defs/JobCategory" + }, + { + "type": "null" + } + ], + "description": "A job's category; `null` for an office." + }, + "key": { + "description": "The key `POST /v1/npc/generate` takes.", + "type": "string" + }, + "kind": { + "$ref": "#/$defs/OccupationKind", + "description": "Job or office." + }, + "label": { + "description": "Display label: a job's title, an office's title without its place.", + "type": "string" + }, + "label_female": { + "description": "A job's female title where it differs; otherwise `null`.", + "type": [ + "string", + "null" + ] + }, + "tiers": { + "description": "Tiers the key is accepted in, smallest first, with its rank in\neach. A job outside them is refused (`bad_request`).", + "items": { + "$ref": "#/$defs/OccupationTier" + }, + "type": "array" + } + }, + "required": [ + "key", + "kind", + "label", + "tiers" + ], + "type": "object" + }, + "OccupationKind": { + "description": "Whether a key is a `job` or an `office` of `GenerateNpcRequest`.", + "oneOf": [ + { + "const": "job", + "description": "An occupation: `GenerateNpcRequest.job`, `Npc.job.key`.", + "type": "string" + }, + { + "const": "office", + "description": "A society office: `GenerateNpcRequest.office`.", + "type": "string" + } + ] + }, + "OccupationTier": { + "description": "A tier a key is accepted in, and the rank it carries there.", + "properties": { + "rank": { + "$ref": "#/$defs/SocialRank", + "description": "A job's social rank in the tier; for an office, the lowest rank of\nits holder there (a holder ranks at the higher of job and office)." + }, + "tier": { + "$ref": "#/$defs/Tier", + "description": "Settlement size class (`GenerateNpcRequest.tier`)." + } + }, + "required": [ + "tier", + "rank" + ], + "type": "object" + }, + "SocialRank": { + "description": "Standing in local society.", + "oneOf": [ + { + "const": "dependent", + "description": "Children and dependants.", + "type": "string" + }, + { + "const": "labourer", + "description": "Labourers, hands and servants.", + "type": "string" + }, + { + "const": "tradesfolk", + "description": "Journeymen, clerks and small traders.", + "type": "string" + }, + { + "const": "master", + "description": "Masters, owners and minor officials.", + "type": "string" + }, + { + "const": "gentry", + "description": "Clergy leads, officers and magistrates.", + "type": "string" + }, + { + "const": "noble", + "description": "Lords and ladies.", + "type": "string" + } + ] + }, + "Tier": { + "description": "Settlement size class.", + "oneOf": [ + { + "const": "hamlet", + "description": "Hamlet.", + "type": "string" + }, + { + "const": "village", + "description": "Village.", + "type": "string" + }, + { + "const": "town", + "description": "Town.", + "type": "string" + }, + { + "const": "city", + "description": "City.", + "type": "string" + } + ] + } + }, + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "Body of `GET /v1/npc/occupations`: every key `POST /v1/npc/generate`\ntakes as `job` or `office`. Every job, then every office, each in key\norder; the same on every world (bundled data).", + "properties": { + "occupations": { + "description": "The catalogue.", + "items": { + "$ref": "#/$defs/Occupation" + }, + "type": "array" + } + }, + "required": [ + "occupations" + ], + "title": "OccupationList", + "type": "object" +} diff --git a/bindings/schema/index.json b/bindings/schema/index.json index 7c57ee30..39774af9 100644 --- a/bindings/schema/index.json +++ b/bindings/schema/index.json @@ -180,6 +180,15 @@ "stability": "stable", "url": "/v1/schema/NpcPage.json" }, + { + "family": "npc_format", + "name": "OccupationList", + "routes": [ + "GET /v1/npc/occupations" + ], + "stability": "stable", + "url": "/v1/schema/OccupationList.json" + }, { "family": "contract_version", "name": "PointSample", diff --git a/bindings/ts/arda/Occupation.ts b/bindings/ts/arda/Occupation.ts new file mode 100644 index 00000000..7e25cfa5 --- /dev/null +++ b/bindings/ts/arda/Occupation.ts @@ -0,0 +1,35 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { JobCategory } from "./JobCategory"; +import type { OccupationKind } from "./OccupationKind"; +import type { OccupationTier } from "./OccupationTier"; + +/** + * One key of the catalogue. `(kind, key)` is unique; `reeve`, `elder`, + * `harbourmaster` and others are both a job and an office. + */ +export type Occupation = { +/** + * The key `POST /v1/npc/generate` takes. + */ +key: string, +/** + * Job or office. + */ +kind: OccupationKind, +/** + * Display label: a job's title, an office's title without its place. + */ +label: string, +/** + * A job's female title where it differs; otherwise `null`. + */ +label_female: string | null, +/** + * A job's category; `null` for an office. + */ +category: JobCategory | null, +/** + * Tiers the key is accepted in, smallest first, with its rank in + * each. A job outside them is refused (`bad_request`). + */ +tiers: Array, }; diff --git a/bindings/ts/arda/OccupationKind.ts b/bindings/ts/arda/OccupationKind.ts new file mode 100644 index 00000000..207b7f15 --- /dev/null +++ b/bindings/ts/arda/OccupationKind.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Whether a key is a `job` or an `office` of `GenerateNpcRequest`. + */ +export type OccupationKind = "job" | "office"; diff --git a/bindings/ts/arda/OccupationList.ts b/bindings/ts/arda/OccupationList.ts new file mode 100644 index 00000000..ae6ca229 --- /dev/null +++ b/bindings/ts/arda/OccupationList.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Occupation } from "./Occupation"; + +/** + * Body of `GET /v1/npc/occupations`: every key `POST /v1/npc/generate` + * takes as `job` or `office`. Every job, then every office, each in key + * order; the same on every world (bundled data). + */ +export type OccupationList = { +/** + * The catalogue. + */ +occupations: Array, }; diff --git a/bindings/ts/arda/OccupationTier.ts b/bindings/ts/arda/OccupationTier.ts new file mode 100644 index 00000000..bad64e51 --- /dev/null +++ b/bindings/ts/arda/OccupationTier.ts @@ -0,0 +1,17 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { SocialRank } from "./SocialRank"; +import type { Tier } from "./Tier"; + +/** + * A tier a key is accepted in, and the rank it carries there. + */ +export type OccupationTier = { +/** + * Settlement size class (`GenerateNpcRequest.tier`). + */ +tier: Tier, +/** + * A job's social rank in the tier; for an office, the lowest rank of + * its holder there (a holder ranks at the higher of job and office). + */ +rank: SocialRank, }; diff --git a/bindings/ts/arda/index.ts b/bindings/ts/arda/index.ts index 3506a7db..de81c26f 100644 --- a/bindings/ts/arda/index.ts +++ b/bindings/ts/arda/index.ts @@ -88,6 +88,10 @@ export type { NpcEntry } from "./NpcEntry"; export type { NpcId } from "./NpcId"; export type { NpcPage } from "./NpcPage"; export type { ObscurementDto } from "./ObscurementDto"; +export type { Occupation } from "./Occupation"; +export type { OccupationKind } from "./OccupationKind"; +export type { OccupationList } from "./OccupationList"; +export type { OccupationTier } from "./OccupationTier"; export type { Personality } from "./Personality"; export type { PlacementDto } from "./PlacementDto"; export type { PointSample } from "./PointSample"; diff --git a/contract-kit/README.md b/contract-kit/README.md index 51e1a650..30eac0ef 100644 --- a/contract-kit/README.md +++ b/contract-kit/README.md @@ -126,7 +126,7 @@ a changed image and its 304, an unreachable server). ## Cases -54 cases over 41 of the 42 stable routes of `docs/capstone/versioning.md`, at MICRO-42 places +61 cases over 48 of the 49 stable routes of `docs/capstone/versioning.md`, at MICRO-42 places picked from the fixture: village 10 (Ifyil, realm 3), its cell (479, 1245), building 10.2, commoner `10.2.1`, the open-sea cell (5, 5); the scene cases read town 2's cell (732, 1081), where notables stand by day and by @@ -143,7 +143,7 @@ night, so the kit exercises token shapes. | Battle map | `tactical-cell`, `tactical-scene-day`, `tactical-scene-night`, `tactical-cell-png` (+ `-304`), `tactical-cell-tile`, `tactical-window` (2 × 1), `tactical-window-png`, `tactical-window-tile` | | Warm, bake, library | `tactical-prefetch`, `tactical-bake`, `tactical-bake-delete`, `tactical-library` | | Dungeon | `dungeon`, `dungeon-png`, `dungeon-scene` | -| People | `npc-notable`, `npc-commoner-ref`, `npc-commoner-id`, `npcs`, `npcs-realm-job`, `building-residents`, `building-workers`, `npc-population`, `npc-generate` | +| People | `npc-notable`, `npc-commoner-ref`, `npc-commoner-id`, `npcs`, `npcs-realm-job`, `building-residents`, `building-workers`, `npc-population`, `npc-generate`, `npc-occupations` | | Shapes | `schema-index`, `schema-file` | | Errors | `error-no-block`, `error-out-of-range`, `error-npc-not-found`, `error-bad-request`, `error-bake-not-found` | diff --git a/contract-kit/golden/npc-occupations.json b/contract-kit/golden/npc-occupations.json new file mode 100644 index 00000000..7a1abd63 --- /dev/null +++ b/contract-kit/golden/npc-occupations.json @@ -0,0 +1 @@ +{"occupations":[{"key":"acolyte","kind":"job","label":"Acolyte","label_female":null,"category":"religion","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"apothecary","kind":"job","label":"Apothecary","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"apothecary_assistant","kind":"job","label":"Apothecary's Assistant","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"apprentice","kind":"job","label":"Apprentice","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"apprentice_smith","kind":"job","label":"Smith's Apprentice","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"baker","kind":"job","label":"Master Baker","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"baker_hand","kind":"job","label":"Baker's Hand","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"barkeep","kind":"job","label":"Barkeep","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"boat_hand","kind":"job","label":"Boat Hand","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"boatwright","kind":"job","label":"Boatwright","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"bouncer","kind":"job","label":"Doorwarden","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"brewer","kind":"job","label":"Brewer","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"brewer_hand","kind":"job","label":"Brewer's Hand","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"butcher","kind":"job","label":"Butcher","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"camp_boss","kind":"job","label":"Lumber Camp Boss","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"carter","kind":"job","label":"Carter","label_female":null,"category":"labour","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"castellan","kind":"job","label":"Castellan","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"chandler","kind":"job","label":"Chandler","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"charcoal_burner","kind":"job","label":"Charcoal Burner","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"child","kind":"job","label":"Child","label_female":null,"category":"dependent","tiers":[{"tier":"hamlet","rank":"dependent"},{"tier":"village","rank":"dependent"},{"tier":"town","rank":"dependent"},{"tier":"city","rank":"dependent"}]},{"key":"clerk","kind":"job","label":"Warehouse Clerk","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"cook","kind":"job","label":"Cook","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"cooper","kind":"job","label":"Cooper","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"cottage_weaver","kind":"job","label":"Cottage Weaver","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"craft_master","kind":"job","label":"Master Crafter","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"dockhand","kind":"job","label":"Dockhand","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"elder","kind":"job","label":"Village Elder","label_female":null,"category":"government","tiers":[{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"}]},{"key":"factor","kind":"job","label":"Merchant Factor","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"farmer","kind":"job","label":"Farmer","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"farmhand","kind":"job","label":"Farmhand","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"ferry_hand","kind":"job","label":"Ferry Hand","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"fisher","kind":"job","label":"Fisher","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"fishmonger","kind":"job","label":"Fishmonger","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"garrison_captain","kind":"job","label":"Garrison Captain","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"harbourmaster","kind":"job","label":"Harbourmaster","label_female":null,"category":"government","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"headman","kind":"job","label":"Headman","label_female":"Headwoman","category":"government","tiers":[{"tier":"hamlet","rank":"tradesfolk"}]},{"key":"hedge_druid","kind":"job","label":"Grove Warden","label_female":null,"category":"religion","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"herald","kind":"job","label":"Royal Herald","label_female":null,"category":"government","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"herder","kind":"job","label":"Herder","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"high_priest","kind":"job","label":"High Priest","label_female":"High Priestess","category":"religion","tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"hunter","kind":"job","label":"Hunter","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"innkeeper","kind":"job","label":"Innkeeper","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"journeyman","kind":"job","label":"Journeyman","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"journeyman_smith","kind":"job","label":"Journeyman Smith","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"knight","kind":"job","label":"Knight","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"labourer","kind":"job","label":"Labourer","label_female":null,"category":"labour","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"launderer","kind":"job","label":"Launderer","label_female":null,"category":"labour","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"librarian","kind":"job","label":"Keeper of Books","label_female":null,"category":"scholar","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"lord","kind":"job","label":"Lord of the Manor","label_female":"Lady of the Manor","category":"nobility","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"noble"},{"tier":"city","rank":"noble"}]},{"key":"lord_mayor","kind":"job","label":"Lord Mayor","label_female":"Lady Mayor","category":"government","tiers":[{"tier":"city","rank":"gentry"}]},{"key":"magister","kind":"job","label":"Magister","label_female":null,"category":"scholar","tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"magistrate","kind":"job","label":"Magistrate","label_female":null,"category":"government","tiers":[{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"man_at_arms","kind":"job","label":"Man-at-Arms","label_female":"Woman-at-Arms","category":"military","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"market_warden","kind":"job","label":"Market Warden","label_female":null,"category":"government","tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"mayor","kind":"job","label":"Mayor","label_female":null,"category":"government","tiers":[{"tier":"town","rank":"gentry"}]},{"key":"midwife","kind":"job","label":"Midwife","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"mill_hand","kind":"job","label":"Mill Hand","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"miller","kind":"job","label":"Miller","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"mine_foreman","kind":"job","label":"Mine Foreman","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"miner","kind":"job","label":"Miner","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"noble_kin","kind":"job","label":"Noble Scion","label_female":null,"category":"nobility","tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"ostler","kind":"job","label":"Ostler","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"peddler","kind":"job","label":"Peddler","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"porter","kind":"job","label":"Porter","label_female":null,"category":"labour","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"priest","kind":"job","label":"Priest","label_female":"Priestess","category":"religion","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"reeve","kind":"job","label":"Reeve","label_female":null,"category":"government","tiers":[{"tier":"village","rank":"tradesfolk"}]},{"key":"retired","kind":"job","label":"Retired","label_female":null,"category":"dependent","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"sailor","kind":"job","label":"Sailor","label_female":null,"category":"maritime","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"schoolmaster","kind":"job","label":"Schoolmaster","label_female":"Schoolmistress","category":"scholar","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"scout","kind":"job","label":"Forest Scout","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"scribe","kind":"job","label":"Scribe","label_female":null,"category":"scholar","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"sergeant","kind":"job","label":"Sergeant","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"servant","kind":"job","label":"Servant","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"server","kind":"job","label":"Server","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"shepherd","kind":"job","label":"Shepherd","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"shrine_keeper","kind":"job","label":"Shrine Keeper","label_female":null,"category":"religion","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"smith","kind":"job","label":"Master Smith","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"soldier","kind":"job","label":"Soldier","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"stable_hand","kind":"job","label":"Stable Hand","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"stable_master","kind":"job","label":"Stable Master","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"stall_help","kind":"job","label":"Stall Hand","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"stallholder","kind":"job","label":"Stallholder","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"steward","kind":"job","label":"Steward","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"tailor","kind":"job","label":"Tailor","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"tanner","kind":"job","label":"Master Tanner","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"tanner_hand","kind":"job","label":"Tannery Hand","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"tavern_keeper","kind":"job","label":"Tavern Keeper","label_female":null,"category":"service","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"tax_collector","kind":"job","label":"Tax Collector","label_female":null,"category":"government","tiers":[{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"thatcher","kind":"job","label":"Thatcher","label_female":null,"category":"craft","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"tutor","kind":"job","label":"Tutor","label_female":null,"category":"scholar","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"warehouse_hand","kind":"job","label":"Warehouse Hand","label_female":null,"category":"labour","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"watch_sergeant","kind":"job","label":"Watch Sergeant","label_female":null,"category":"military","tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"watchman","kind":"job","label":"Watchman","label_female":"Watchwoman","category":"military","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"weigher","kind":"job","label":"Market Weigher","label_female":null,"category":"trade","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"woodcutter","kind":"job","label":"Woodcutter","label_female":null,"category":"extraction","tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"yeoman","kind":"job","label":"Yeoman Farmer","label_female":null,"category":"agriculture","tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"abbot","kind":"office","label":"Prior","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"boatmaster","kind":"office","label":"Master of the Lightermen","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"captain","kind":"office","label":"Captain of the Watch","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"gentry"}]},{"key":"commons_voice","kind":"office","label":"Voice of the Commons","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"court_mage","kind":"office","label":"Court Mage","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"craftmaster","kind":"office","label":"Master of the Craft Guild","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"crime_boss","kind":"office","label":"Underworld Boss","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"elder","kind":"office","label":"Elder","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"fisher_head","kind":"office","label":"Headman of the Fishers","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"forester","kind":"office","label":"Chief Woodward","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"guildmaster","kind":"office","label":"Master of the Merchants","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"gentry"}]},{"key":"harbourmaster","kind":"office","label":"Harbourmaster","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"master"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"high_priest","kind":"office","label":"High Priest","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"master"},{"tier":"village","rank":"master"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"lord","kind":"office","label":"Lord","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"noble"},{"tier":"city","rank":"noble"}]},{"key":"mine_overseer","kind":"office","label":"Mine Overseer","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"master"},{"tier":"city","rank":"master"}]},{"key":"miner_captain","kind":"office","label":"Captain of the Delvers","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"labourer"},{"tier":"village","rank":"labourer"},{"tier":"town","rank":"labourer"},{"tier":"city","rank":"labourer"}]},{"key":"reeve","kind":"office","label":"Reeve","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"ruler","kind":"office","label":"Ruler","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"noble"},{"tier":"village","rank":"noble"},{"tier":"town","rank":"noble"},{"tier":"city","rank":"noble"}]},{"key":"shrine_keeper","kind":"office","label":"Shrine Keeper","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"tradesfolk"},{"tier":"village","rank":"tradesfolk"},{"tier":"town","rank":"tradesfolk"},{"tier":"city","rank":"tradesfolk"}]},{"key":"spymaster","kind":"office","label":"Spymaster","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]},{"key":"steward","kind":"office","label":"Steward","label_female":null,"category":null,"tiers":[{"tier":"hamlet","rank":"gentry"},{"tier":"village","rank":"gentry"},{"tier":"town","rank":"gentry"},{"tier":"city","rank":"gentry"}]}]} \ No newline at end of file diff --git a/contract-kit/golden/schema-index.json b/contract-kit/golden/schema-index.json index 7c57ee30..39774af9 100644 --- a/contract-kit/golden/schema-index.json +++ b/contract-kit/golden/schema-index.json @@ -180,6 +180,15 @@ "stability": "stable", "url": "/v1/schema/NpcPage.json" }, + { + "family": "npc_format", + "name": "OccupationList", + "routes": [ + "GET /v1/npc/occupations" + ], + "stability": "stable", + "url": "/v1/schema/OccupationList.json" + }, { "family": "contract_version", "name": "PointSample", diff --git a/contract-kit/manifest.json b/contract-kit/manifest.json index be505fad..96dec887 100644 --- a/contract-kit/manifest.json +++ b/contract-kit/manifest.json @@ -736,6 +736,17 @@ "schema": "Npc", "golden": "golden/npc-generate.json" }, + { + "id": "npc-occupations", + "route": "GET /v1/npc/occupations", + "method": "GET", + "uri": "/v1/npc/occupations", + "status": 200, + "content_type": "application/json", + "headers": {}, + "schema": "OccupationList", + "golden": "golden/npc-occupations.json" + }, { "id": "schema-index", "route": "GET /v1/schema", diff --git a/crates/arda-npc/data/content/occupations.json b/crates/arda-npc/data/content/occupations.json index ec4df7fe..d9949759 100644 --- a/crates/arda-npc/data/content/occupations.json +++ b/crates/arda-npc/data/content/occupations.json @@ -172,27 +172,27 @@ {"job": "fishmonger", "scale": "urban", "base": 0, "functions": {"fishing": 2, "port": 2, "market": 1}, "needs": "water"} ], "offices": { - "ruler": {"rank": 5, "civic": true}, - "lord": {"rank": 5, "rank_by_tier": {"hamlet": 4, "village": 4}, "civic": true}, - "steward": {"rank": 4, "civic": true}, - "reeve": {"rank": 2, "civic": true, "covers": ["reeve"]}, - "elder": {"rank": 2, "civic": true, "covers": ["headman", "elder"]}, - "commons_voice": {"rank": 1, "civic": true}, - "harbourmaster": {"rank": 3, "rank_by_tier": {"hamlet": 2}, "civic": true, "covers": ["harbourmaster"]}, - "captain": {"rank": 3, "rank_by_tier": {"city": 4}, "civic": false}, - "high_priest": {"rank": 4, "rank_by_tier": {"hamlet": 3, "village": 3}, "civic": false}, - "abbot": {"rank": 4, "civic": false}, - "shrine_keeper": {"rank": 2, "civic": false}, - "mine_overseer": {"rank": 3, "rank_by_tier": {"hamlet": 2, "village": 2}, "civic": false}, - "court_mage": {"rank": 4, "civic": false}, - "spymaster": {"rank": 4, "civic": false}, - "guildmaster": {"rank": 3, "rank_by_tier": {"city": 4}, "civic": false}, - "craftmaster": {"rank": 3, "civic": false}, - "crime_boss": {"rank": 2, "civic": false}, - "fisher_head": {"rank": 1, "civic": false}, - "miner_captain": {"rank": 1, "civic": false}, - "forester": {"rank": 1, "civic": false}, - "boatmaster": {"rank": 2, "civic": false} + "ruler": {"label": "Ruler", "rank": 5, "civic": true}, + "lord": {"label": "Lord", "rank": 5, "rank_by_tier": {"hamlet": 4, "village": 4}, "civic": true}, + "steward": {"label": "Steward", "rank": 4, "civic": true}, + "reeve": {"label": "Reeve", "rank": 2, "civic": true, "covers": ["reeve"]}, + "elder": {"label": "Elder", "rank": 2, "civic": true, "covers": ["headman", "elder"]}, + "commons_voice": {"label": "Voice of the Commons", "rank": 1, "civic": true}, + "harbourmaster": {"label": "Harbourmaster", "rank": 3, "rank_by_tier": {"hamlet": 2}, "civic": true, "covers": ["harbourmaster"]}, + "captain": {"label": "Captain of the Watch", "rank": 3, "rank_by_tier": {"city": 4}, "civic": false}, + "high_priest": {"label": "High Priest", "rank": 4, "rank_by_tier": {"hamlet": 3, "village": 3}, "civic": false}, + "abbot": {"label": "Prior", "rank": 4, "civic": false}, + "shrine_keeper": {"label": "Shrine Keeper", "rank": 2, "civic": false}, + "mine_overseer": {"label": "Mine Overseer", "rank": 3, "rank_by_tier": {"hamlet": 2, "village": 2}, "civic": false}, + "court_mage": {"label": "Court Mage", "rank": 4, "civic": false}, + "spymaster": {"label": "Spymaster", "rank": 4, "civic": false}, + "guildmaster": {"label": "Master of the Merchants", "rank": 3, "rank_by_tier": {"city": 4}, "civic": false}, + "craftmaster": {"label": "Master of the Craft Guild", "rank": 3, "civic": false}, + "crime_boss": {"label": "Underworld Boss", "rank": 2, "civic": false}, + "fisher_head": {"label": "Headman of the Fishers", "rank": 1, "civic": false}, + "miner_captain": {"label": "Captain of the Delvers", "rank": 1, "civic": false}, + "forester": {"label": "Chief Woodward", "rank": 1, "civic": false}, + "boatmaster": {"label": "Master of the Lightermen", "rank": 2, "civic": false} }, "rank_lifestyles": { "labourer": ["squalid", "modest"], diff --git a/crates/arda-npc/src/data/content.rs b/crates/arda-npc/src/data/content.rs index ecfb48d5..55b61786 100644 --- a/crates/arda-npc/src/data/content.rs +++ b/crates/arda-npc/src/data/content.rs @@ -114,6 +114,9 @@ pub struct LandJob { /// A society office (a notable slot's `kind`, logic/14 §soc-offices). #[derive(Debug, Clone, Deserialize)] pub struct OfficeData { + /// Display label: the office's title without its place + /// (`roles.json` "Reeve of {settlement}" is "Reeve"). + pub label: String, /// Lowest social rank of the holder, 0–5. pub rank: u8, /// Rank where the tier differs from `rank`. diff --git a/crates/arda-npc/src/lib.rs b/crates/arda-npc/src/lib.rs index 61c0f78f..46d600c9 100644 --- a/crates/arda-npc/src/lib.rs +++ b/crates/arda-npc/src/lib.rs @@ -40,7 +40,7 @@ pub use npc::{ HouseholdId, Ideal, Job, JobCategory, Lifestyle, Name, Npc, NpcId, Personality, RelationKind, Relationship, Sex, SocialRank, }; -pub use one::{generate_one, OneRequest}; +pub use one::{generate_one, occupations, Occupation, OccupationKind, OccupationTier, OneRequest}; pub use population::{Household, HouseholdRelation, Population, RosterEntry}; pub use sheet::Sheet; pub use skeleton::Resident; diff --git a/crates/arda-npc/src/one/catalog.rs b/crates/arda-npc/src/one/catalog.rs new file mode 100644 index 00000000..21da766d --- /dev/null +++ b/crates/arda-npc/src/one/catalog.rs @@ -0,0 +1,97 @@ +//! The occupation catalogue: every job and office key [`super::generate_one`] +//! takes, with the tiers and social ranks it accepts (logic/13 +//! §npc-occupations; `GET /v1/npc/occupations`). + +use serde::{Deserialize, Serialize}; + +use crate::data::Data; +use crate::error::NpcError; +use crate::input::Tier; +use crate::npc::{JobCategory, SocialRank}; + +use super::layout::reachable; +use super::TIERS; + +/// Whether a key is a `job` or an `office` of [`super::OneRequest`]. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum OccupationKind { + /// An occupation (`OneRequest::job`, `Npc.job.key`). + Job, + /// A society office (`OneRequest::office`, a notable slot's kind). + Office, +} + +/// A tier a key is accepted in, and the rank it carries there. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub struct OccupationTier { + /// Settlement size class. + pub tier: Tier, + /// A job's social rank in the tier; for an office, the lowest rank of + /// its holder there (a holder ranks at the higher of job and office). + pub rank: SocialRank, +} + +/// One key of the catalogue. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Occupation { + /// The key `generate_one` takes. A key may be both a job and an office + /// (`reeve`); `(kind, key)` is unique. + pub key: String, + /// Job or office. + pub kind: OccupationKind, + /// Display label: a job's title, an office's title without its place. + pub label: String, + /// A job's female title where it differs. + pub label_female: Option, + /// A job's category; `None` for an office. + pub category: Option, + /// Tiers the key is accepted in, smallest first. + pub tiers: Vec, +} + +/// Every job, then every office, each in key order. +/// +/// # Errors +/// [`NpcError::Data`] for invalid bundled data. +pub fn occupations() -> Result, NpcError> { + let data = Data::get()?; + let occ = &data.occupations; + let mut out = Vec::with_capacity(occ.jobs.len() + occ.offices.len()); + for (key, job) in &occ.jobs { + let category = JobCategory::from_key(&job.category) + .ok_or_else(|| NpcError::Data(format!("job {key}: category {}", job.category)))?; + out.push(Occupation { + key: key.clone(), + kind: OccupationKind::Job, + label: job.title.clone(), + label_female: job.title_female.clone(), + category: Some(category), + tiers: TIERS + .into_iter() + .filter(|&t| reachable(data, key, t)) + .map(|tier| OccupationTier { + tier, + rank: SocialRank::from_level(job.rank_in(tier.key())), + }) + .collect(), + }); + } + for (key, office) in &occ.offices { + out.push(Occupation { + key: key.clone(), + kind: OccupationKind::Office, + label: office.label.clone(), + label_female: None, + category: None, + tiers: TIERS + .into_iter() + .map(|tier: Tier| OccupationTier { + tier, + rank: SocialRank::from_level(office.rank_in(tier.key())), + }) + .collect(), + }); + } + Ok(out) +} diff --git a/crates/arda-npc/src/one/mod.rs b/crates/arda-npc/src/one/mod.rs index 9d3177a2..cd44e284 100644 --- a/crates/arda-npc/src/one/mod.rs +++ b/crates/arda-npc/src/one/mod.rs @@ -22,8 +22,11 @@ use crate::input::{ use crate::npc::{Npc, NpcId, Sex, SocialRank}; use crate::plan::Plan; +mod catalog; mod layout; +pub use catalog::{occupations, Occupation, OccupationKind, OccupationTier}; + use layout::{buildings, notable_source, office_building, office_slot, reachable, route, Route}; /// Settlement id of the synthetic settlement: "not in the world". diff --git a/crates/arda-npc/tests/occupation_catalog.rs b/crates/arda-npc/tests/occupation_catalog.rs new file mode 100644 index 00000000..8e4831e2 --- /dev/null +++ b/crates/arda-npc/tests/occupation_catalog.rs @@ -0,0 +1,145 @@ +//! The occupation catalogue (logic/13 §npc-occupations): every job and +//! office key `generate_one` takes, with the tiers and ranks it accepts. + +#![allow(clippy::unwrap_used, clippy::expect_used)] + +mod common; + +use arda_npc::{ + generate_one, occupations, NpcError, Occupation, OccupationKind, OneRequest, SocialRank, Tier, +}; +use std::collections::BTreeSet; + +const WORLD: u64 = 42; +const TIERS: [Tier; 4] = [Tier::Hamlet, Tier::Village, Tier::Town, Tier::City]; + +fn keys(field: &str) -> Vec { + common::content("occupations.json")[field] + .as_object() + .unwrap() + .keys() + .cloned() + .collect() +} + +fn of(kind: OccupationKind) -> Vec { + occupations() + .unwrap() + .into_iter() + .filter(|o| o.kind == kind) + .collect() +} + +#[test] +fn every_job_then_every_office_once_in_key_order() { + let all = occupations().unwrap(); + let jobs: Vec = of(OccupationKind::Job).into_iter().map(|o| o.key).collect(); + let offices: Vec = of(OccupationKind::Office) + .into_iter() + .map(|o| o.key) + .collect(); + assert_eq!(jobs, keys("jobs")); + assert_eq!(offices, keys("offices")); + assert_eq!(jobs.len(), 96); + assert_eq!(offices.len(), 21); + assert_eq!(all.len(), jobs.len() + offices.len()); + assert!(all + .iter() + .take(jobs.len()) + .all(|o| o.kind == OccupationKind::Job)); +} + +#[test] +fn labels_come_from_the_table() { + let table = common::content("occupations.json"); + for job in of(OccupationKind::Job) { + let row = &table["jobs"][&job.key]; + assert_eq!(job.label, row["title"].as_str().unwrap(), "{}", job.key); + assert_eq!( + job.label_female.as_deref(), + row["title_female"].as_str(), + "{}", + job.key + ); + assert!(job.category.is_some(), "{}", job.key); + } + for office in of(OccupationKind::Office) { + assert!(!office.label.is_empty(), "{}", office.key); + assert_eq!(office.label_female, None); + assert_eq!(office.category, None); + } +} + +/// A job's listed tiers and ranks are exactly what `generate_one` accepts. +#[test] +fn every_listed_job_tier_and_rank_generates_and_no_other_tier_does() { + for job in of(OccupationKind::Job) { + assert!(!job.tiers.is_empty(), "{} has no tier", job.key); + let listed: BTreeSet = job.tiers.iter().map(|t| t.tier).collect(); + for t in &job.tiers { + let req = OneRequest { + job: Some(job.key.clone()), + tier: Some(t.tier), + rank: Some(t.rank), + ..OneRequest::default() + }; + let npc = generate_one(WORLD, &req).unwrap_or_else(|e| panic!("{req:?}: {e}")); + assert_eq!(npc.job.key, job.key); + assert_eq!(npc.social_rank, t.rank, "{} in {:?}", job.key, t.tier); + } + for tier in TIERS.into_iter().filter(|t| !listed.contains(t)) { + let req = OneRequest { + job: Some(job.key.clone()), + tier: Some(tier), + ..OneRequest::default() + }; + assert!( + matches!(generate_one(WORLD, &req), Err(NpcError::Unreachable(_))), + "{} is not listed in {tier:?} but generates there", + job.key + ); + } + } +} + +/// An office is held in every tier, by someone of at least its rank. +#[test] +fn every_office_generates_in_every_tier_at_or_above_its_rank() { + for office in of(OccupationKind::Office) { + let tiers: Vec = office.tiers.iter().map(|t| t.tier).collect(); + assert_eq!(tiers, TIERS, "{}", office.key); + for t in &office.tiers { + let req = OneRequest { + office: Some(office.key.clone()), + tier: Some(t.tier), + ..OneRequest::default() + }; + let npc = generate_one(WORLD, &req).unwrap_or_else(|e| panic!("{req:?}: {e}")); + assert!(npc.notable, "{} holder is not a notable", office.key); + assert!( + npc.social_rank >= t.rank, + "{} in {:?}: {:?} below {:?}", + office.key, + t.tier, + npc.social_rank, + t.rank + ); + } + } +} + +#[test] +fn ranks_follow_the_table() { + let smith = of(OccupationKind::Job) + .into_iter() + .find(|o| o.key == "smith") + .unwrap(); + assert!(smith.tiers.iter().all(|t| t.rank >= SocialRank::Tradesfolk)); + let lord = of(OccupationKind::Office) + .into_iter() + .find(|o| o.key == "lord") + .unwrap(); + let rank = |tier| lord.tiers.iter().find(|t| t.tier == tier).unwrap().rank; + assert_eq!(rank(Tier::Hamlet), SocialRank::Gentry); + assert_eq!(rank(Tier::City), SocialRank::Noble); +} diff --git a/crates/arda-server/API.md b/crates/arda-server/API.md index b82c9a5f..51ee43b8 100644 --- a/crates/arda-server/API.md +++ b/crates/arda-server/API.md @@ -1255,8 +1255,8 @@ own id (DiceMaster: `game:`). Body (TS `GenerateNpcRequest`, JSON Schema | Field | Type | Default | Meaning | |---|---|---|---| | `seed` | decimal u64 string | `"0"` | Caller's salt, e.g. derived from its own uuid. Different salts give different people. | -| `job` | occupation key | none | `occupations.json` `jobs`: `smith`, `farmer`, `priest`, `mayor`, `child`, … (96 keys). | -| `office` | office kind | none | `occupations.json` `offices`: `reeve`, `high_priest`, `captain`, … The NPC holds it, is a notable and is addressed by its title. | +| `job` | occupation key | none | A `kind: job` key of `GET /v1/npc/occupations`: `smith`, `farmer`, `priest`, `mayor`, `child`, … (96 keys). | +| `office` | office kind | none | A `kind: office` key of `GET /v1/npc/occupations`: `reeve`, `high_priest`, `captain`, … The NPC holds it, is a notable and is addressed by its title. | | `rank` | `SocialRank` | none | `dependent`, `labourer`, `tradesfolk`, `master`, `gentry`, `noble` (logic/13 §npc-ranks). | | `ancestry` | SRD race key | culture's mix | `human`, `dwarf`, `elf`, `halfling`, `dragonborn`, `gnome`, `half-elf`, `half-orc`, `tiefling`. | | `sex` | `female` \| `male` | either | | @@ -1298,6 +1298,39 @@ ability scores, background, equipment) and Arda does not consume it; this endpoi Arda inhabitant by job and rank. The body is small and optional-everything so an adapter on DiceMaster's side can map its own fields onto it. +### `GET /v1/npc/occupations` + +Every key `POST /v1/npc/generate` takes as `job` or `office`, with what a caller needs to +choose one (logic/13 §npc-occupations). The list comes from the bundled tables, so the body is +the same on every world, with or without `society/`; it changes only with a release's content. +Response (TS `OccupationList`, JSON Schema `OccupationList.json`, family `npc_format`): + +```json +{"occupations": [ + {"key": "smith", "kind": "job", "label": "Master Smith", "label_female": null, "category": "craft", + "tiers": [{"tier": "hamlet", "rank": "tradesfolk"}, {"tier": "village", "rank": "tradesfolk"}, + {"tier": "town", "rank": "master"}, {"tier": "city", "rank": "master"}]}, + … + {"key": "reeve", "kind": "office", "label": "Reeve", "label_female": null, "category": null, + "tiers": [{"tier": "hamlet", "rank": "tradesfolk"}, …]} +]} +``` + +- Order: every job (96), then every office (21), each in key order. `(kind, key)` is unique: a + few keys are both a job and an office (`reeve`, `elder`, `harbourmaster`, `steward`, + `lord`, …); send a `job` entry's key as `job` and an `office` entry's key as `office`. +- `label`: a job's title (`Npc.job.title`), or an office's title without its place ("Reeve" + for "Reeve of Ifyil"). `label_female` is a job's female title where it differs. +- `category`: a job's `JobCategory`; `null` for an office. +- `tiers`, smallest first: a **job**'s tiers are exactly those `generate` accepts it in, and + `rank` is its `SocialRank` there, so `{"job", "tier", "rank"}` taken from one entry always + generates; any other tier is refused with `400` ("no hamlet has a mayor"). An **office** is + held in every tier; `rank` is the lowest rank of its holder there (a holder ranks at the + higher of their job's rank and the office's). +- `child` is a job (rank `dependent`); `generate` never draws it unless it is asked for. + +Errors: none of its own. + ```sh curl -s -X POST -H 'content-type: application/json' \ -d '{"job":"smith","ancestry":"dwarf","seed":"7"}' \ diff --git a/crates/arda-server/src/bindings.rs b/crates/arda-server/src/bindings.rs index f8948049..6bc5409e 100644 --- a/crates/arda-server/src/bindings.rs +++ b/crates/arda-server/src/bindings.rs @@ -149,6 +149,10 @@ exported!( npc::Population, npc::PopulationRequest, npc::GenerateNpcRequest, + npc::OccupationKind, + npc::OccupationTier, + npc::Occupation, + npc::OccupationList, npc::NpcDemo, npc::Tier, npc::SettlementFunction, diff --git a/crates/arda-server/src/npc.rs b/crates/arda-server/src/npc.rs index 205bde85..e33319e3 100644 --- a/crates/arda-server/src/npc.rs +++ b/crates/arda-server/src/npc.rs @@ -231,6 +231,21 @@ pub(crate) async fn generate_route( .await } +/// `GET /v1/npc/occupations` (logic/13 §npc-occupations): every job and +/// office key `POST /v1/npc/generate` takes, from the bundled tables, so +/// the body is the same on every world. +pub(crate) async fn occupations_route() -> ServerResult> { + Ok(Json(Occupations { + occupations: arda_npc::occupations()?, + })) +} + +/// Body of `GET /v1/npc/occupations` (TS and schema: `OccupationList`). +#[derive(Debug, Serialize)] +pub(crate) struct Occupations { + occupations: Vec, +} + /// Parses an NPC id path segment: the decimal u64 string. /// /// # Errors diff --git a/crates/arda-server/src/npc_dto/mod.rs b/crates/arda-server/src/npc_dto/mod.rs index 8ab87ae6..69f2e4b6 100644 --- a/crates/arda-server/src/npc_dto/mod.rs +++ b/crates/arda-server/src/npc_dto/mod.rs @@ -8,11 +8,13 @@ //! an `arda-ids` u64 and travels as a decimal string. mod input; +mod occupations; mod sheet; pub use input::{ Biome, BuildingFunction, BuildingSpec, SettlementFunction, SettlementProfile, Tier, Tongue, }; +pub use occupations::{Occupation, OccupationKind, OccupationList, OccupationTier}; pub use sheet::{ Ability, Attack, AttackKind, Background, Coins, Item, SaveBonus, Sheet, SheetKind, SkillBonus, SpellRef, Spellcasting, diff --git a/crates/arda-server/src/npc_dto/occupations.rs b/crates/arda-server/src/npc_dto/occupations.rs new file mode 100644 index 00000000..e140ab97 --- /dev/null +++ b/crates/arda-server/src/npc_dto/occupations.rs @@ -0,0 +1,58 @@ +//! Mirrors of the occupation catalogue (`arda_npc::occupations`, +//! logic/13 §npc-occupations), served by `GET /v1/npc/occupations`. + +use super::{JobCategory, SocialRank, Tier}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +/// Body of `GET /v1/npc/occupations`: every key `POST /v1/npc/generate` +/// takes as `job` or `office`. Every job, then every office, each in key +/// order; the same on every world (bundled data). +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)] +#[serde(deny_unknown_fields)] +pub struct OccupationList { + /// The catalogue. + pub occupations: Vec, +} + +/// Whether a key is a `job` or an `office` of `GenerateNpcRequest`. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum OccupationKind { + /// An occupation: `GenerateNpcRequest.job`, `Npc.job.key`. + Job, + /// A society office: `GenerateNpcRequest.office`. + Office, +} + +/// A tier a key is accepted in, and the rank it carries there. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)] +#[serde(deny_unknown_fields)] +pub struct OccupationTier { + /// Settlement size class (`GenerateNpcRequest.tier`). + pub tier: Tier, + /// A job's social rank in the tier; for an office, the lowest rank of + /// its holder there (a holder ranks at the higher of job and office). + pub rank: SocialRank, +} + +/// One key of the catalogue. `(kind, key)` is unique; `reeve`, `elder`, +/// `harbourmaster` and others are both a job and an office. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)] +#[serde(deny_unknown_fields)] +pub struct Occupation { + /// The key `POST /v1/npc/generate` takes. + pub key: String, + /// Job or office. + pub kind: OccupationKind, + /// Display label: a job's title, an office's title without its place. + pub label: String, + /// A job's female title where it differs; otherwise `null`. + pub label_female: Option, + /// A job's category; `null` for an office. + pub category: Option, + /// Tiers the key is accepted in, smallest first, with its rank in + /// each. A job outside them is refused (`bad_request`). + pub tiers: Vec, +} diff --git a/crates/arda-server/src/npc_dto/tests.rs b/crates/arda-server/src/npc_dto/tests.rs index 74a4ad48..52dea1d8 100644 --- a/crates/arda-server/src/npc_dto/tests.rs +++ b/crates/arda-server/src/npc_dto/tests.rs @@ -93,3 +93,10 @@ fn generate_requests_match_their_mirror() { let empty: GenerateNpcRequest = same(&crate::npc::GenerateNpcRequest::default()); assert_eq!(serde_json::to_string(&empty).unwrap(), "{}"); } + +#[test] +fn the_occupation_catalogue_matches_its_mirror() { + let list = serde_json::json!({ "occupations": arda_npc::occupations().unwrap() }); + let mirror: OccupationList = same(&list); + assert_eq!(mirror.occupations.len(), 117); +} diff --git a/crates/arda-server/src/routes.rs b/crates/arda-server/src/routes.rs index 1cbeacfd..8796f97d 100644 --- a/crates/arda-server/src/routes.rs +++ b/crates/arda-server/src/routes.rs @@ -46,6 +46,7 @@ pub fn router(state: Arc) -> Router { post(crate::npc::generate_route) .layer(DefaultBodyLimit::max(crate::npc::MAX_GENERATE_BODY_BYTES)), ) + .route("/npc/occupations", get(crate::npc::occupations_route)) .route("/npc/demo", get(npc_demo)) .route("/npc/demo/{npc_id}", get(npc_demo_one)) .route("/npc/{npc_id}", get(crate::npcs::one)) diff --git a/crates/arda-server/src/schema/mod.rs b/crates/arda-server/src/schema/mod.rs index bd54072f..a0cab2ec 100644 --- a/crates/arda-server/src/schema/mod.rs +++ b/crates/arda-server/src/schema/mod.rs @@ -110,7 +110,9 @@ use crate::columnar::AreaCells; use crate::contract::{CellSample, PointSample}; use crate::dto::{AreaLakes, AreaRivers, Health, WorldInfo}; use crate::error::{ApiError, NotYetError}; -use crate::npc_dto::{GenerateNpcRequest, Npc, NpcDemo, Population, PopulationRequest, Sheet}; +use crate::npc_dto::{ + GenerateNpcRequest, Npc, NpcDemo, OccupationList, Population, PopulationRequest, Sheet, +}; use crate::npcs::dto::NpcPage; use crate::sites::dto::{SiteDto, SiteLevel, SiteList}; use crate::tactical::bake::{BakeAccepted, BakeRequest, BakeStatus}; @@ -158,6 +160,7 @@ catalog! { "Population" => Population, "npc_format", Stable, ["POST /v1/npc/population"]; "PopulationRequest" => PopulationRequest, "npc_format", Stable, ["POST /v1/npc/population (request)"]; "GenerateNpcRequest" => GenerateNpcRequest, "npc_format", Stable, ["POST /v1/npc/generate (request)"]; + "OccupationList" => OccupationList, "npc_format", Stable, ["GET /v1/npc/occupations"]; "NpcDemo" => NpcDemo, "npc_format", Debug, ["GET /v1/npc/demo"]; "SettlementList" => SettlementList, "settlement_format", Stable, ["GET /v1/settlements"]; "SettlementDetail" => SettlementDetail, "settlement_format", Stable, ["GET /v1/settlements/{id}"]; diff --git a/crates/arda-server/tests/world_api/inventory.rs b/crates/arda-server/tests/world_api/inventory.rs index e27dd3e5..cd441990 100644 --- a/crates/arda-server/tests/world_api/inventory.rs +++ b/crates/arda-server/tests/world_api/inventory.rs @@ -139,6 +139,12 @@ fn probes(ids: &Ids) -> Vec<(&'static str, &'static str, String, Option<&'static "/v1/npc/generate".into(), Some(r#"{"seed":"7"}"#), ), + ( + "GET /v1/npc/occupations", + "GET", + "/v1/npc/occupations".into(), + None, + ), ( "GET /v1/gazetteer", "GET", diff --git a/crates/arda-server/tests/world_api/main.rs b/crates/arda-server/tests/world_api/main.rs index 230d163f..dbcec541 100644 --- a/crates/arda-server/tests/world_api/main.rs +++ b/crates/arda-server/tests/world_api/main.rs @@ -18,6 +18,7 @@ mod looks; mod mapping; mod npc; mod npc_generate; +mod occupations; mod one_composition; mod overview_overlay; mod people; diff --git a/crates/arda-server/tests/world_api/occupations.rs b/crates/arda-server/tests/world_api/occupations.rs new file mode 100644 index 00000000..129871dd --- /dev/null +++ b/crates/arda-server/tests/world_api/occupations.rs @@ -0,0 +1,35 @@ +//! `GET /v1/npc/occupations` (logic/13 §npc-occupations): the job and +//! office keys `POST /v1/npc/generate` takes, the same on every world. + +use crate::support::{get, get_with, society_state}; +use axum::http::StatusCode; +use serde_json::{json, Value}; + +#[tokio::test] +async fn lists_the_library_catalogue_on_every_world() { + let plain = get("/v1/npc/occupations").await; + assert_eq!(plain.status, StatusCode::OK); + assert_eq!( + plain.headers.get("content-type").unwrap(), + "application/json" + ); + let want = json!({ "occupations": arda_npc::occupations().unwrap() }); + assert_eq!(plain.json(), want); + let society = get_with(society_state(), "/v1/npc/occupations", None).await; + assert_eq!(society.body, plain.body, "bundled data: the same bytes"); +} + +#[tokio::test] +async fn every_entry_names_its_kind_label_and_tier_ranks() { + let body = get("/v1/npc/occupations").await.json(); + let list = body["occupations"].as_array().unwrap(); + let kinds = |k: &str| list.iter().filter(|o| o["kind"] == k).count(); + assert_eq!((kinds("job"), kinds("office")), (96, 21)); + let reeve: Vec<&Value> = list.iter().filter(|o| o["key"] == "reeve").collect(); + assert_eq!(reeve.len(), 2, "reeve is a job and an office"); + let smith = list.iter().find(|o| o["key"] == "smith").unwrap(); + assert_eq!(smith["label"], "Master Smith"); + assert_eq!(smith["category"], "craft"); + assert_eq!(smith["tiers"][0]["tier"], "hamlet"); + assert!(smith["tiers"][0]["rank"].is_string()); +} diff --git a/docs/capstone/01-architecture.md b/docs/capstone/01-architecture.md index 72d2c8eb..a42f99c4 100644 --- a/docs/capstone/01-architecture.md +++ b/docs/capstone/01-architecture.md @@ -168,6 +168,7 @@ Payload field tables live in `09-interfaces.md`; each row cites its section ther | GET | `/v1/tiles/relief/{z}/{x}/{y}` | `crates/arda-server/src/routes.rs:429` | path + `labels` query → WebP tile; `09-interfaces.md § GET /v1/tiles/relief/{z}/{x}/{y}.webp` | | POST | `/v1/npc/population` | `crates/arda-server/src/routes.rs:454` | JSON `PopulationRequest` (body limit `npc::MAX_BODY_BYTES`, `crates/arda-server/src/routes.rs:42`) → population JSON; `09-interfaces.md § POST /v1/npc/population` | | POST | `/v1/npc/generate` | `crates/arda-server/src/npc.rs:217` | JSON body (limit `npc::MAX_GENERATE_BODY_BYTES`, `crates/arda-server/src/npc.rs:33`, `crates/arda-server/src/routes.rs:46`) → one generated NPC; `09-interfaces.md § POST /v1/npc/generate` | +| GET | `/v1/npc/occupations` | `crates/arda-server/src/npc.rs:237` | none → every job and office key of `POST /v1/npc/generate` from the bundled tables; `09-interfaces.md § GET /v1/npc/occupations` | | GET | `/v1/npc/demo` | `crates/arda-server/src/routes.rs:475` | none → demo population; `09-interfaces.md § GET /v1/npc/demo` | | GET | `/v1/npc/demo/{npc_id}` | `crates/arda-server/src/routes.rs:482` | path → one NPC; `09-interfaces.md § GET /v1/npc/demo/{npc_id}` | | GET | `/v1/npc/{npc_id}` | `crates/arda-server/src/npcs/mod.rs:218` | path → stored NPC; `09-interfaces.md § GET /v1/npc/{npc_id}` | diff --git a/docs/capstone/02-models.md b/docs/capstone/02-models.md index 799c92d0..6e088401 100644 --- a/docs/capstone/02-models.md +++ b/docs/capstone/02-models.md @@ -584,6 +584,10 @@ Storage values: `HTTP JSON; ts-rs bindings/ts/arda/.ts` means the type is | Population | `crates/arda-server/src/npc_dto/mod.rs:305` | HTTP JSON; ts-rs `bindings/ts/arda/Population.ts` | The population of one settlement; notables stored in full. | | PopulationRequest | `crates/arda-server/src/npc_dto/mod.rs:327` | HTTP JSON; ts-rs `bindings/ts/arda/PopulationRequest.ts` | Body of `POST /v1/npc/population`. | | GenerateNpcRequest | `crates/arda-server/src/npc_dto/mod.rs:340` | HTTP JSON; ts-rs `bindings/ts/arda/GenerateNpcRequest.ts` | Body of `POST /v1/npc/generate`: Arda's own inputs, every field optional. | +| OccupationList | `crates/arda-server/src/npc_dto/occupations.rs` | HTTP JSON; ts-rs `bindings/ts/arda/OccupationList.ts` | Body of `GET /v1/npc/occupations`: every job and office key `POST /v1/npc/generate` takes. | +| Occupation | `crates/arda-server/src/npc_dto/occupations.rs` | HTTP JSON; ts-rs `bindings/ts/arda/Occupation.ts` | One key: `kind`, `label`, `label_female`, `category`, `tiers`. Domain `arda_npc::Occupation` (`crates/arda-npc/src/one/catalog.rs`). | +| OccupationKind | `crates/arda-server/src/npc_dto/occupations.rs` | HTTP JSON; ts-rs `bindings/ts/arda/OccupationKind.ts` | `job` or `office`. | +| OccupationTier | `crates/arda-server/src/npc_dto/occupations.rs` | HTTP JSON; ts-rs `bindings/ts/arda/OccupationTier.ts` | A tier a key is accepted in and its `SocialRank` there. | | NpcDemo | `crates/arda-server/src/npc_dto/mod.rs:386` | HTTP JSON; ts-rs `bindings/ts/arda/NpcDemo.ts` | Body of `GET /v1/npc/demo`: the market-town example and its population. | | Ability | `crates/arda-server/src/npc_dto/sheet.rs:9` | HTTP JSON; ts-rs `bindings/ts/arda/Ability.ts` | One of the six abilities, in SRD order. | | SheetKind | `crates/arda-server/src/npc_dto/sheet.rs:33` | HTTP JSON; ts-rs `bindings/ts/arda/SheetKind.ts` | What the sheet is built from. | diff --git a/docs/capstone/09-interfaces.md b/docs/capstone/09-interfaces.md index 1b99a467..ce2cc298 100644 --- a/docs/capstone/09-interfaces.md +++ b/docs/capstone/09-interfaces.md @@ -29,6 +29,7 @@ edges: - { kind: http, name: "GET /v1/tiles/relief/{z}/{x}/{y}.webp", site: crates/arda-server/src/routes.rs } - { kind: http, name: "POST /v1/npc/population", site: crates/arda-server/src/routes.rs, schema: Population } - { kind: http, name: "POST /v1/npc/generate", site: crates/arda-server/src/npc.rs, schema: Npc } + - { kind: http, name: "GET /v1/npc/occupations", site: crates/arda-server/src/npc.rs, schema: OccupationList } - { kind: http, name: "GET /v1/npc/demo", site: crates/arda-server/src/routes.rs } - { kind: http, name: "GET /v1/npc/demo/{npc_id}", site: crates/arda-server/src/routes.rs, schema: Npc } - { kind: http, name: "GET /v1/npc/{npc_id}", site: crates/arda-server/src/npcs/mod.rs, schema: Npc } @@ -98,6 +99,7 @@ The only cross-repo surface is `arda-server`'s HTTP API under `/v1` (consumed by | http | GET /v1/tiles/relief/{z}/{x}/{y}.webp | - | `crates/arda-server/src/routes.rs` | | http | POST /v1/npc/population | - | `crates/arda-server/src/routes.rs` | | http | POST /v1/npc/generate | - | `crates/arda-server/src/npc.rs` | +| http | GET /v1/npc/occupations | - | `crates/arda-server/src/npc.rs` | | http | GET /v1/npc/demo | - | `crates/arda-server/src/routes.rs` | | http | GET /v1/npc/demo/{npc_id} | - | `crates/arda-server/src/routes.rs` | | http | GET /v1/npc/{npc_id} | - | `crates/arda-server/src/npcs/mod.rs` | @@ -292,6 +294,22 @@ Request body: `GenerateNpcRequest` (`crates/arda-server/src/npc_dto/mod.rs:340`; 400 `bad_request` (malformed seed or id, unknown field or key, a rank or tier the job lacks), 404 `not_found`, 413, 415, 422 `unsatisfiable`. +### GET /v1/npc/occupations + +Model: OccupationList + +Handler `occupations_route` (`crates/arda-server/src/npc.rs:237`) serves `arda_npc::occupations()` (`crates/arda-npc/src/one/catalog.rs`): the keys `POST /v1/npc/generate` takes as `job` and `office`. No world work and no query parameters; the body is the same on every world. Type `OccupationList` (`crates/arda-server/src/npc_dto/occupations.rs`). + +| Field | Type | Required | Notes | +|---|---|---|---| +| occupations | Occupation[] | yes | every job, then every office, each in key order | +| occupations[].key | String | yes | the `job` or `office` value of `GenerateNpcRequest` | +| occupations[].kind | OccupationKind | yes | `job` or `office`; `(kind, key)` is unique | +| occupations[].label | String | yes | job title, or office title without its place | +| occupations[].label_female | String \| null | yes | a job's female title | +| occupations[].category | JobCategory \| null | yes | jobs only | +| occupations[].tiers | OccupationTier[] | yes | `{tier: Tier, rank: SocialRank}`, smallest tier first: a job's accepted tiers and rank in each; an office's four tiers and lowest holder rank | + ### GET /v1/npc/demo Type `NpcDemo` (`crates/arda-server/src/npc_dto/mod.rs:386`; wire struct `crates/arda-server/src/npc.rs:86`). diff --git a/docs/capstone/changelog.md b/docs/capstone/changelog.md index ddd7f44c..c7f14060 100644 --- a/docs/capstone/changelog.md +++ b/docs/capstone/changelog.md @@ -2,6 +2,21 @@ generated_date: 2026-08-24 --- +## 2026-11-14 - implement: 2026-11-14-occupation-keys +key: implement/2026-11-14-occupation-keys@Q3 + +- What: `GET /v1/npc/occupations` serves every job and office key `POST /v1/npc/generate` takes, so DiceMaster does not pin a hand copy of the 96 occupation keys. +- Approach: a pure `arda_npc::occupations()` (`one/catalog.rs`) built from the bundled tables and the generator's own tier rule (`layout::reachable`), so the list cannot drift from what `generate` accepts; the server serves it as `OccupationList` in family `npc_format`. +- Rejected: a published JSON schema enum of the keys only (no labels, tiers or ranks, and a schema change for every content change). +- Rejected: separate `jobs` and `offices` arrays; one list with `kind` answers "job or office" per key, and `(kind, key)` is unique where seven keys are both. +- Rejected: a `notable` flag per tier (whether a holder can be a notable): not asked for, and "can be" is a weaker promise than the filter it would advertise. +- Office labels: a new `label` per office in `occupations.json`, its `roles.json` title without the place; `arda-npc` does not depend on `arda-society`. +- Task 1: `occupations()`, `Occupation`, `OccupationKind`, `OccupationTier`; office labels; `tests/occupation_catalog.rs` proves every listed job, tier and rank generates, no unlisted tier does, and every office generates in all four tiers at or above its rank. +- Task 2: route, mirror DTOs (`npc_dto/occupations.rs`), schema entry, four TS bindings, inventory probe, `world_api/occupations.rs`. +- Task 3: contract-kit case `npc-occupations` (61 cases over 48 of 49 stable routes); `schema-index` golden gained the entry; no other golden changed. +- Process: the user was away; spec and plan were written from the DiceMaster session's brief without the approval gates, and the pull request is the gate. +- `logic/13`: §npc-occupations. `logic/16`: route row. `09-interfaces.md`: edge, row and payload section. `02-models.md`: four entities. `01-architecture.md`: route row. `versioning.md`: one stable row (56 rows, 49 stable), `npc_format` covers `OccupationList`. `API.md` and the kit README. + ## 2026-11-14 - implement: 2026-11-14-dungeon-sites key: implement/2026-11-14-dungeon-sites@Q12 diff --git a/docs/capstone/logic/13-npc-population.md b/docs/capstone/logic/13-npc-population.md index 50f6774b..e394f0e4 100644 --- a/docs/capstone/logic/13-npc-population.md +++ b/docs/capstone/logic/13-npc-population.md @@ -102,6 +102,14 @@ Wealth (0–255) is `settlement/4 + home/4 + 30 × rank + d40`, then held inside - **Scrub.** `relationships` is emptied and `employer` and `workplace_building` are cleared, since they point into the synthetic settlement; `id` becomes `subseed(seed, "npc-generate/id", [id])`. `home_building` and `household` stay synthetic. - **Refusals.** Unknown job, office, ancestry or culture: `NpcError::UnknownKey` listing the valid keys. A `rank` the job (raised by the office) does not have in the tier, a job the fixed tier lacks, or a rank no job of the tier has (a noble in a hamlet or village): `NpcError::Unreachable` listing what is valid. Valid inputs with no match in 16 attempts (`farmhand` + `notable`): `NpcError::Unsatisfiable`. +### §npc-occupations + +`occupations() -> Vec` (`crates/arda-npc/src/one/catalog.rs`) lists every key §npc-generate-one takes, so a caller never pins a copy of `occupations.json`; `GET /v1/npc/occupations` serves it (16 §api-routes). Every job, then every office, each in key order; `(kind, key)` is unique, since `elder`, `harbourmaster`, `high_priest`, `lord`, `reeve`, `shrine_keeper` and `steward` are both. + +- **Job.** `label` is the job's `title`, `label_female` its `title_female`, `category` its category. `tiers` are exactly the tiers in which the job exists by §npc-generate-one's Tier rule, each with the job's rank there by §npc-ranks; a job, a tier and a rank taken from one entry always generate. +- **Office.** `label` is the office's own `label` in `occupations.json` (its `roles.json` title without the place: "Reeve of {settlement}" is "Reeve"); no female label or category. `tiers` are all four, each with the office's rank there, the lowest rank of a holder (a holder ranks at the higher of job and office). +- **Data only.** The list is a function of the bundled tables: the same on every world and seed. + ### §npc-queries `Population` answers `residents(building)`, `workers(building)`, `by_job(key)`, `job_of(id)`, `notables()`, `job_counts()`, `category_counts()` (goal 57). Realm-level and world-level queries (by realm, by job across settlements) are the service's, built by iterating settlements (16 §api-routes). diff --git a/docs/capstone/logic/16-service-api.md b/docs/capstone/logic/16-service-api.md index 7f6236e7..76a94ed3 100644 --- a/docs/capstone/logic/16-service-api.md +++ b/docs/capstone/logic/16-service-api.md @@ -68,6 +68,7 @@ Implemented (registered in `crates/arda-server/src/routes.rs` and `src/tactical/ | `GET /v1/buildings/{building}/residents`, `/workers` | `NpcPage` | 13 | | `POST /v1/npc/population` | `Population` for a posted `PopulationRequest` | 13 | | `POST /v1/npc/generate` | `Npc`: one new NPC from optional `GenerateNpcRequest` inputs (Arda's own: `seed`, `job`, `office`, `rank`, `ancestry`, `sex`, `tier`, `culture`, `settlement_id`, `notable`), stored nowhere, synthetic ids; body ≤ 16 KiB, JSON only (415); 422 `unsatisfiable` | 13 §npc-generate-one | +| `GET /v1/npc/occupations` | `OccupationList`: every job and office key `POST /v1/npc/generate` takes, with label, category and the tiers and ranks it is accepted in; the same on every world | 13 §npc-occupations | | `GET /v1/npc/demo`, `/v1/npc/demo/{npc_id}` | `NpcDemo`, `Npc` of the `arda-npc` sample town (debug) | 13 | | `GET /v1/gazetteer[?kind=&bbox=&min_rank=]` | `Gazetteer` (§api-gazetteer): natural features then settlement points in one list; `kind` is a comma list of kind keys, `bbox=x0,y0,x1,y1` metres keeps what meets the box, `min_rank=N` keeps rank N or more important; 400 on a bad value, 404 without `society/` or `gazetteer.json` | 08, 15 | | `GET /v1/realms` | `RealmList`: `{format_version, realms: [RealmSummary]}`, the `realms.json` records without `borders` plus `style`, `rank`, `government_label`, `ruler` when `society.json` exists, and `colour` (`#rrggbb`, the realm's political-map colour, §political-map) | 08, 14 | diff --git a/docs/capstone/versioning.md b/docs/capstone/versioning.md index c9b99af0..4951828e 100644 --- a/docs/capstone/versioning.md +++ b/docs/capstone/versioning.md @@ -15,7 +15,7 @@ The rules are held by tests: ## Route review (1.0 freeze) -Every route `crates/arda-server/src/routes.rs` and `crates/arda-server/src/tactical/routes.rs` (with `tactical/bake_routes.rs`) register, one row per method and documented path. Paths that share a registered route are listed apart: `/cell/{gx}/{gy}` also serves `{gy}.png`, `/layout/{file}` serves `{name}` and `{name}.png`, `/sites/{id}/levels/{file}` serves `{n}` and `{n}.png`, and every `tiles/{z}/{x}/{y}` route takes the format as the suffix of `{y}`. Checked by hand against both routers on 2026-10-13, with the five site routes (`crates/arda-server/src/sites/routes.rs`) added on 2026-11-14: 55 rows, of which **48 stable**, **1 unstable** and **6 debug**. `HEAD` is answered wherever `GET` is, and `OPTIONS` is the CORS preflight; neither has a row. +Every route `crates/arda-server/src/routes.rs` and `crates/arda-server/src/tactical/routes.rs` (with `tactical/bake_routes.rs`) register, one row per method and documented path. Paths that share a registered route are listed apart: `/cell/{gx}/{gy}` also serves `{gy}.png`, `/layout/{file}` serves `{name}` and `{name}.png`, `/sites/{id}/levels/{file}` serves `{n}` and `{n}.png`, and every `tiles/{z}/{x}/{y}` route takes the format as the suffix of `{y}`. Checked by hand against both routers on 2026-10-13, with the five site routes (`crates/arda-server/src/sites/routes.rs`) and `GET /v1/npc/occupations` added on 2026-11-14: 56 rows, of which **49 stable**, **1 unstable** and **6 debug**. `HEAD` is answered wherever `GET` is, and `OPTIONS` is the CORS preflight; neither has a row. Stability: @@ -48,6 +48,7 @@ Every route can also answer `500 internal`; the table lists the other codes. "Di | `GET /v1/buildings/{building}/workers` | stable | `NpcPage` | `npc_page_format`, `npc_format` | `bad_request`, `not_found`, `sheet_mapping` | yes | | `POST /v1/npc/population` | stable | `Population` (body `PopulationRequest`) | `npc_format` | `bad_request`, `payload_too_large`, `unsupported_media_type`, `sheet_mapping` | yes | | `POST /v1/npc/generate` | stable | `Npc` (body `GenerateNpcRequest`) | `npc_format` | `bad_request`, `not_found`, `payload_too_large`, `unsupported_media_type`, `unsatisfiable`, `sheet_mapping` | no (planned) | +| `GET /v1/npc/occupations` | stable | `OccupationList` | `npc_format` | — | no (planned) | | `GET /v1/npc/demo` | debug | `NpcDemo` | `npc_format` | `sheet_mapping` | no | | `GET /v1/npc/demo/{npc_id}` | debug | `Npc` | `npc_format` | `bad_request`, `not_found`, `sheet_mapping` | no | | `GET /v1/gazetteer` | stable | `Gazetteer` | `gazetteer_format` | `bad_request`, `not_found` | no (planned) | @@ -104,7 +105,7 @@ Unstable and debug surface inside stable routes: | `scene_format` | `scene.format_version` | 1 | `SceneDto` (`arda-scene` `SCENE_FORMAT_VERSION`) | | `rules_sidecar_format` | `rules.format_version` | 2 | `RulesSidecarDto` (`arda-scene` `SIDECAR_FORMAT_VERSION`) | | `bake_format` | `format_version` | 1 | `BakeRequest`, `BakeAccepted`, `BakeStatus` | -| `npc_format` | — | 1 | `Npc`, `Sheet`, `Population`, `PopulationRequest`, `GenerateNpcRequest`, `NpcDemo` | +| `npc_format` | — | 1 | `Npc`, `Sheet`, `Population`, `PopulationRequest`, `GenerateNpcRequest`, `OccupationList`, `NpcDemo` | | `npc_page_format` | `format_version` | 1 | `NpcPage` | | `settlement_format` | `format_version` (list) | 1 | `SettlementList`, `SettlementDetail`, `Settlement`, `SettlementSociety`, `TownPlan`, `SettlementNpcs` | | `realm_format` | `format_version` (list) | 1 | `RealmList`, `RealmDetail`, `Realm`, `RealmSociety`, `Relation`, `Event` |