Last active
April 1, 2026 18:59
-
-
Save 631068264/c5b085382e30828c00b9a696fec90c16 to your computer and use it in GitHub Desktop.
Specify Caude code buddy userID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| // buddy-reroll-node.js | |
| const crypto = require('crypto') | |
| const SALT = 'friend-2026-401' | |
| const SPECIES = ['duck','goose','blob','cat','dragon','octopus','owl', | |
| 'penguin','turtle','snail','ghost','axolotl','capybara','cactus', | |
| 'robot','rabbit','mushroom','chonk'] | |
| const RARITIES = ['common','uncommon','rare','epic','legendary'] | |
| const RARITY_WEIGHTS = { common:60, uncommon:25, rare:10, epic:4, legendary:1 } | |
| const RARITY_RANK = { common:0, uncommon:1, rare:2, epic:3, legendary:4 } | |
| function mulberry32(seed) { | |
| let a = seed >>> 0 | |
| return function() { | |
| a |= 0; a = (a + 0x6d2b79f5) | 0 | |
| let t = Math.imul(a ^ (a >>> 15), 1 | a) | |
| t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t | |
| return ((t ^ (t >>> 14)) >>> 0) / 4294967296 | |
| } | |
| } | |
| function hashString(s) { | |
| // return Number(BigInt(Bun.hash(s)) & 0xffffffffn) | |
| let h = 2166136261 | |
| for (let i = 0; i < s.length; i++) { | |
| h ^= s.charCodeAt(i) | |
| h = Math.imul(h, 16777619) | |
| } | |
| return h >>> 0 | |
| } | |
| function pick(rng, arr) { return arr[Math.floor(rng() * arr.length)] } | |
| function rollRarity(rng) { | |
| let roll = rng() * 100 | |
| for (const r of RARITIES) { roll -= RARITY_WEIGHTS[r]; if (roll < 0) return r } | |
| return 'common' | |
| } | |
| const TARGET = process.argv[2] || 'duck' | |
| const MAX = parseInt(process.argv[3]) || 500000 | |
| let best = { rarity: 'common', uid: '' } | |
| for (let i = 0; i < MAX; i++) { | |
| const uid = crypto.randomBytes(32).toString('hex') | |
| const rng = mulberry32(hashString(uid + SALT)) | |
| const rarity = rollRarity(rng) | |
| const species = pick(rng, SPECIES) | |
| if (species === TARGET && RARITY_RANK[rarity] > RARITY_RANK[best.rarity]) { | |
| best = { rarity, uid } | |
| console.log(`found: ${rarity} ${species} -> ${uid}`) | |
| if (rarity === 'legendary') break | |
| } | |
| } | |
| console.log(`\nBest: ${best.rarity} ${TARGET} -> ${best.uid}`) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
把刷到的 userID 写进 ~/.claude.json(确保 companion 字段已删除),重启后 /buddy 领取即可。