[schema] PlanetGarden: The gardener's look, from fixed lists, kept on the device
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://rosea.invalid/schema/gardener.json",
|
||||
"title": "Gardener",
|
||||
"description": "The look of the player's gardener, chosen at the first open (.agents/features/planet-garden.md G6). Every value is from a fixed list: no free text, nothing that identifies a person. Kept on the device in `profile`; never sent, never in the rose file. No option recreates the book's boy: there is no scarf, coat, cape, suit or crown to choose.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["presentation", "skin", "hair", "hairColour", "clothes", "hat"],
|
||||
"properties": {
|
||||
"presentation": { "enum": ["girl", "boy"] },
|
||||
"skin": { "enum": ["skin-1", "skin-2", "skin-3", "skin-4", "skin-5", "skin-6"] },
|
||||
"hair": { "enum": ["short", "curly", "ponytail", "braids", "bob", "bun"] },
|
||||
"hairColour": { "enum": ["black", "dark-brown", "brown", "auburn", "red", "fair"] },
|
||||
"clothes": { "enum": ["sage", "rose", "honey", "dusk", "plum"] },
|
||||
"hat": { "enum": ["straw-hat", "cap", "none"] }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* The gardener's fixed lists, read from gardener.schema.json itself, so the choice the player
|
||||
* sees, the shape storage checks and the contract can never disagree (planet-garden.md G6).
|
||||
*/
|
||||
import schema from '../schemas/gardener.schema.json' with { type: 'json' };
|
||||
import type { Gardener } from './generated/index.js';
|
||||
|
||||
type Options = { readonly [K in keyof Gardener]: readonly Gardener[K][] };
|
||||
|
||||
export const GARDENER_OPTIONS: Options = Object.fromEntries(
|
||||
Object.entries(schema.properties).map(([k, v]) => [k, v.enum])
|
||||
) as unknown as Options;
|
||||
|
||||
/** The order the choice asks in. */
|
||||
export const GARDENER_FIELDS = schema.required as readonly (keyof Gardener)[];
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './constants.js';
|
||||
export type * from './generated/index.js';
|
||||
export { GARDENER_FIELDS, GARDENER_OPTIONS } from './gardener.js';
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
*/
|
||||
import { Ajv, type ErrorObject, type ValidateFunction } from 'ajv';
|
||||
import careEvent from '../schemas/care-event.schema.json' with { type: 'json' };
|
||||
import gardener from '../schemas/gardener.schema.json' with { type: 'json' };
|
||||
import hopeSentence from '../schemas/hope-sentence.schema.json' with { type: 'json' };
|
||||
import sentenceOpened from '../schemas/sentence-opened.schema.json' with { type: 'json' };
|
||||
import trace from '../schemas/trace.schema.json' with { type: 'json' };
|
||||
import type { CareEvent, HopeSentence, SentenceOpened, Trace } from './generated/index.js';
|
||||
import type { CareEvent, Gardener, HopeSentence, SentenceOpened, Trace } from './generated/index.js';
|
||||
|
||||
export type SchemaResult<T> =
|
||||
| { readonly ok: true; readonly value: T }
|
||||
@@ -40,4 +41,5 @@ function describe(error: ErrorObject): string {
|
||||
export const validateHopeSentence = wrap<HopeSentence>(ajv.compile(hopeSentence));
|
||||
export const validateCareEvent = wrap<CareEvent>(ajv.compile(careEvent));
|
||||
export const validateSentenceOpened = wrap<SentenceOpened>(ajv.compile(sentenceOpened));
|
||||
export const validateGardener = wrap<Gardener>(ajv.compile(gardener));
|
||||
export const validateTrace = wrap<Trace>(ajv.compile(trace));
|
||||
|
||||
Reference in New Issue
Block a user