/** * Per-stat growth definition for one species. `base` is the level-1 value of the stat; `growth` * is how much a single distributed point adds, expressed as a fraction of `base` — so a point on a * `growth: 0.1` stat is worth +10% of base. The resolved value is `base * (1 + points * growth)`. */ export interface SpawnStatDef { base: number; growth: number; } /** * A species' stat table: every stat the creature owns keyed to its {@link SpawnStatDef}. The key * order is the deterministic order random points are distributed over, so a serialized species * definition reproduces the same rolls under the same rng sequence. */ export type SpawnSpeciesDef = Record; /** * A single creature's serializable stat record — a reference to its species (`speciesId`), the * current `level`, the per-stat count of distributed points, and how many post-capture domestic * levels have been spent. Plain data: round-trips through JSON, save/load, and multiplayer sync. * Resolve display values with {@link resolveSpawnStats}. */ export interface CreatureStatInstance { speciesId: string; level: number; points: Record; domesticLevels: number; } /** * Outcome of {@link applyCaptureEffectiveness}: the granted `bonusLevels`, the `tamedLevel` * (wild level plus bonus levels), and the post-capture {@link CreatureStatInstance}. * @internal */ export interface CaptureResult { bonusLevels: number; tamedLevel: number; instance: CreatureStatInstance; } /** * Options for {@link spendDomesticLevel}. `maxDomesticLevels` caps how many post-capture levels a * creature may spend; once reached, further spends are refused. * @internal */ export interface SpendLevelOptions { maxDomesticLevels?: number; } /** * Result of {@link spendDomesticLevel}: the resulting instance and whether the level was applied * (`spent: false` when the domestic-level cap blocked it, leaving the instance untouched). * @internal */ export interface SpendLevelResult { instance: CreatureStatInstance; spent: boolean; } /** * Roll a fresh wild creature at `level`: distribute `(level - 1)` points randomly across the * species' stats using the injected rng and return a serializable {@link CreatureStatInstance}. * Deterministic — the same rng sequence yields the same point spread. Levels below 1 clamp to 1 * (no points). Use `seededRng` from `../random/rng` for a persisted, reproducible stream. * * @capability spawn-level-roll distribute a wild creature's spawn level into random per-stat points */ export declare function rollSpawnInstance(speciesId: string, species: SpawnSpeciesDef, level: number, rng: () => number): CreatureStatInstance; /** * Resolve an instance's live stat values from its distributed points: * `value = base * (1 + points * growth)` per stat. Stats with zero points return their base. * * @capability spawn-stat-values resolve a creature's per-stat values from its distributed points */ export declare function resolveSpawnStats(species: SpawnSpeciesDef, instance: CreatureStatInstance): Record; /** * Bonus levels granted by a capture at the given effectiveness: * `floor(level * clamp01(effectiveness) / 2)`. A perfect (1.0) capture grants half the wild * level; a botched (0) capture grants none. Effectiveness outside `[0,1]` clamps. * * @capability capture-bonus-levels convert wild level and capture effectiveness into bonus levels */ export declare function captureBonusLevels(level: number, effectiveness: number): number; /** * Apply a capture at the given effectiveness: compute bonus levels via {@link captureBonusLevels}, * distribute those extra points randomly with the injected rng, and return the post-capture * instance (level raised to the tamed total) alongside the granted bonus levels and tamed level. * The input instance is not mutated. * * @capability capture-effectiveness-tame apply capture effectiveness to grant and distribute bonus levels */ export declare function applyCaptureEffectiveness(species: SpawnSpeciesDef, instance: CreatureStatInstance, effectiveness: number, rng: () => number): CaptureResult; /** * Spend one earned post-capture level into `stat`, adding a single growth increment (one point) * and raising both `level` and `domesticLevels`. When `maxDomesticLevels` is set and already * reached, the spend is refused (`spent: false`) and the instance is returned untouched. Pure: * returns a new instance rather than mutating the input. * * @capability domestic-level-spend spend an earned post-capture level into a chosen stat under a cap */ export declare function spendDomesticLevel(instance: CreatureStatInstance, stat: TStat, options?: SpendLevelOptions): SpendLevelResult; /** * Deep-copy an instance into a detached, serializable record — the transport/save counterpart of * {@link restoreSpawnInstance}. Copies the points map so later edits don't leak into the snapshot. * * @capability spawn-instance-snapshot deep-copy a creature stat instance into a serializable record */ export declare function snapshotSpawnInstance(instance: CreatureStatInstance): CreatureStatInstance; /** * Rehydrate a creature stat instance from decoded data (e.g. `JSON.parse` output), returning a * fresh deep copy the caller owns. Inverse of {@link snapshotSpawnInstance}. * * @capability spawn-instance-restore rehydrate a creature stat instance from decoded snapshot data */ export declare function restoreSpawnInstance(data: CreatureStatInstance): CreatureStatInstance;