(rng: () => number)
| 89 | } |
| 90 | |
| 91 | function rollFrom(rng: () => number): Roll { |
| 92 | const rarity = rollRarity(rng) |
| 93 | const bones: CompanionBones = { |
| 94 | rarity, |
| 95 | species: pick(rng, SPECIES), |
| 96 | eye: pick(rng, EYES), |
| 97 | hat: rarity === 'common' ? 'none' : pick(rng, HATS), |
| 98 | shiny: rng() < 0.01, |
| 99 | stats: rollStats(rng, rarity), |
| 100 | } |
| 101 | return { bones, inspirationSeed: Math.floor(rng() * 1e9) } |
| 102 | } |
| 103 | |
| 104 | // Called from three hot paths (500ms sprite tick, per-keystroke PromptInput, |
| 105 | // per-turn observer) with the same userId → cache the deterministic result. |
no test coverage detected