103 lines
2.4 KiB
TypeScript
103 lines
2.4 KiB
TypeScript
/** 实验事故表(来自《中学化学_试剂器材操作清单》第五节) */
|
|
|
|
export interface Accident {
|
|
id: string
|
|
name: string
|
|
weight: number
|
|
money?: number
|
|
mood?: number
|
|
oxidation?: number
|
|
bark: string
|
|
}
|
|
|
|
export const ACCIDENTS: Accident[] = [
|
|
{
|
|
id: 'tube-burst',
|
|
name: '试管炸裂',
|
|
weight: 3,
|
|
money: -20,
|
|
mood: -8,
|
|
bark: '(手忙脚乱)试管炸了……冷凝水回流,要赔玻璃钱 (>﹏<)'
|
|
},
|
|
{
|
|
id: 'spill',
|
|
name: '液体喷出',
|
|
weight: 3,
|
|
money: -10,
|
|
mood: -6,
|
|
bark: '(擦桌子)液体喷出来了……加热不能超过三分之一呀 (´・ω・`)'
|
|
},
|
|
{
|
|
id: 'label',
|
|
name: '标签腐蚀',
|
|
weight: 2,
|
|
money: -15,
|
|
bark: '(看着烂掉的标签)呜,倒液体要标签朝手心才对……整瓶报废了'
|
|
},
|
|
{
|
|
id: 'stopper',
|
|
name: '瓶塞污染',
|
|
weight: 2,
|
|
money: -12,
|
|
bark: '(叹气)瓶塞倒放在桌上了,这瓶不能用了……'
|
|
},
|
|
{
|
|
id: 'turbid',
|
|
name: '滤液浑浊',
|
|
weight: 2,
|
|
money: -8,
|
|
bark: '(盯着浑浊的滤液)一贴二低三靠……要返工了'
|
|
},
|
|
{
|
|
id: 'miscalc',
|
|
name: '浓度算错',
|
|
weight: 2,
|
|
money: -20,
|
|
bark: '(掰手指)算错了……5% 和 50% 差好多,被退货了'
|
|
},
|
|
{
|
|
id: 'acid',
|
|
name: '酸溅到身上',
|
|
weight: 2,
|
|
mood: -10,
|
|
bark: '(急急忙忙去冲洗)酸入水!沿器壁、慢慢倒……我记得的!'
|
|
},
|
|
{
|
|
id: 'fire',
|
|
name: '酒精灯失火',
|
|
weight: 1,
|
|
money: -30,
|
|
mood: -12,
|
|
bark: '(用灯帽盖住)不能吹!不能吹!……吓死我了'
|
|
},
|
|
{
|
|
id: 'overload',
|
|
name: '称量超量程',
|
|
weight: 1,
|
|
money: -25,
|
|
bark: '(心虚)天平好像被我压坏了……超载了'
|
|
},
|
|
{
|
|
id: 'smuggle',
|
|
name: '药品带出实验室',
|
|
weight: 1,
|
|
money: -40,
|
|
mood: -15,
|
|
bark: '(被老师抓个正着)我、我错了……剩余药品不能带走的'
|
|
}
|
|
]
|
|
|
|
const CHANCE = 0.12
|
|
|
|
/** 完成一次任务后掷一次事故骰子,返回 null 表示平安 */
|
|
export function rollAccident(): Accident | null {
|
|
if (Math.random() > CHANCE) return null
|
|
const total = ACCIDENTS.reduce((a, b) => a + b.weight, 0)
|
|
let r = Math.random() * total
|
|
for (const a of ACCIDENTS) {
|
|
r -= a.weight
|
|
if (r <= 0) return a
|
|
}
|
|
return null
|
|
}
|