MCPcopy Create free account
hub / github.com/codeaashu/claude-code / rollStats

Function rollStats

src/buddy/companion.ts:62–82  ·  view source on GitHub ↗
(
  rng: () => number,
  rarity: Rarity,
)

Source from the content-addressed store, hash-verified

60
61// One peak stat, one dump stat, rest scattered. Rarity bumps the floor.
62function rollStats(
63 rng: () => number,
64 rarity: Rarity,
65): Record<StatName, number> {
66 const floor = RARITY_FLOOR[rarity]
67 const peak = pick(rng, STAT_NAMES)
68 let dump = pick(rng, STAT_NAMES)
69 while (dump === peak) dump = pick(rng, STAT_NAMES)
70
71 const stats = {} as Record<StatName, number>
72 for (const name of STAT_NAMES) {
73 if (name === peak) {
74 stats[name] = Math.min(100, floor + 50 + Math.floor(rng() * 30))
75 } else if (name === dump) {
76 stats[name] = Math.max(1, floor - 10 + Math.floor(rng() * 15))
77 } else {
78 stats[name] = floor + Math.floor(rng() * 40)
79 }
80 }
81 return stats
82}
83
84const SALT = 'friend-2026-401'
85

Callers 1

rollFromFunction · 0.85

Calls 2

pickFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected