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

Function rollRarity

src/buddy/companion.ts:43–51  ·  view source on GitHub ↗
(rng: () => number)

Source from the content-addressed store, hash-verified

41}
42
43function rollRarity(rng: () => number): Rarity {
44 const total = Object.values(RARITY_WEIGHTS).reduce((a, b) => a + b, 0)
45 let roll = rng() * total
46 for (const rarity of RARITIES) {
47 roll -= RARITY_WEIGHTS[rarity]
48 if (roll < 0) return rarity
49 }
50 return 'common'
51}
52
53const RARITY_FLOOR: Record<Rarity, number> = {
54 common: 5,

Callers 1

rollFromFunction · 0.85

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected