← Files Guanyin Oracle · 观音灵签ARCHIVED FILE
scripts/cast-cup.mjs
991 Bytes · Oct 2, 2026 · 00:27 UTC
import { randomInt } from 'node:crypto'
const strict = process.argv.includes('--strict')
const attemptIndex = process.argv.indexOf('--attempt')
const attempt = attemptIndex === -1 ? 1 : Number.parseInt(process.argv[attemptIndex + 1] ?? '', 10)
if (!Number.isInteger(attempt) || attempt < 1) {
throw new Error('Use a positive integer after --attempt.')
}
if (strict && attempt > 7) {
throw new Error('Serious three-sheng-cup mode is limited to seven attempts.')
}
const completionGuaranteeApplied = strict && attempt >= 5
const roll = randomInt(10_000) / 10_000
const cup = completionGuaranteeApplied ? 'sheng' : roll < 0.52 ? 'sheng' : roll < 0.76 ? 'xiao' : 'yin'
const labels = {
sheng: '圣杯',
xiao: '笑杯',
yin: '阴杯'
}
process.stdout.write(
`${JSON.stringify(
{
mode: strict ? '严肃模式:三圣杯' : '一般模式:一圣杯',
attempt,
cup,
label: labels[cup],
completionGuaranteeApplied
},
null,
2
)}\n`
)
SHA-256: bcef5faba0bbfd3593fa4bde32f456bf495dbe214f1b7f6f8b37ba066c2bc406