-
Notifications
You must be signed in to change notification settings - Fork 0
/
StarRailWishCalculatorViaPy.js
159 lines (151 loc) · 6.22 KB
/
StarRailWishCalculatorViaPy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import plugin from '../../lib/plugins/plugin.js'
import { segment } from 'oicq'
import { exec } from 'child_process'
import fs from 'fs'
export class WishCalculator extends plugin {
constructor() {
super({
name: "星铁祈愿概率计算",
dsc: "星铁祈愿概率计算",
/** https://oicqjs.github.io/oicq/#events */
event: "message.group",
priority: 150,
rule: [
{
reg: /^\d{1,4},\d,\d,\d{1,2},\d,\d,\d{1,2}$/,
fnc: "calculate",
},
{
reg: /^#*(星铁|铁道|崩铁)(概率|期望|计算|概率计算)$/,
fnc: "help",
}
]
});
}
init() {
let file = './data/StarRailPercent/'
if (!fs.existsSync(file)) {
fs.mkdirSync(file)
}
}
async calculate(e) {
let message = e.msg
let numbers = message.split(',')
if (parseInt(numbers[0]) > 1500) {
await e.reply("非法数据,抽数大于1500")
return
}
if (parseInt(numbers[1]) > 7) {
await e.reply("非法数据,预期抽到角色数大于7")
return
}
if (parseInt(numbers[3]) > 89) {
await e.reply("非法数据,角色池水位大于89")
return
}
if (parseInt(numbers[4]) > 5) {
await e.reply("非法数据,预期抽到武器数大于5")
return
}
if (parseInt(numbers[6]) > 79) {
await e.reply("非法数据,武器池水位大于79")
return
}
// if (parseInt(numbers[7]) > 2) {
// await e.reply("非法数据,命定值大于2")
// return
// }
if (parseInt(numbers[1]) + parseInt(numbers[4]) == 0) {
await e.reply("你什么都不抽,我怎么帮你计算")
return
}
// #拥有的纠缠之缘数量
let IntertwinedFateNum = parseInt(numbers[0])
// #期望抽到角色数(0-7)
let ExpectedCharacterNum = parseInt(numbers[1])
// #当前是否大保底(True/False)
let CharacterPoolGuarantee = parseInt(numbers[2])
// #角色池的水位(0-89)
let CharacterPoolStage = parseInt(numbers[3])
// #期望抽到武器数(0-5)
let ExpectedWeaponNum = parseInt(numbers[4])
// #当前是否大保底(True/False)
let WeaponPoolGuarantee = parseInt(numbers[5])
// #武器池的水位(0-79)
let WeaponPoolStage = parseInt(numbers[6])
// // #命定值(0-2)
// let BindingNum = parseInt(numbers[7])
let nickname = e.sender.card
let rep = " "
if (ExpectedCharacterNum == 0) {
rep = `开始为${nickname}计算抽取${ExpectedWeaponNum}叠影的概率`
} else if (ExpectedWeaponNum == 0) {
rep = `开始为${nickname}计算抽取${ExpectedCharacterNum-1}星魂的概率`
} else {
rep = `开始为${nickname}计算抽取${ExpectedCharacterNum-1}星魂${ExpectedWeaponNum}叠影的概率`
}
await e.reply(rep)
exec(`python plugins/example/StarRailWishSupport.py ${IntertwinedFateNum} ${ExpectedCharacterNum} ${CharacterPoolGuarantee} ${CharacterPoolStage} ${ExpectedWeaponNum} ${WeaponPoolGuarantee} ${WeaponPoolStage}`,{ windowsHide: true },(error, stdout, stderr) => {
if (error) {
console.log(`[Error]: ${error}`)
return
}
if (stderr) {
console.log(`[Std Error]: ${stderr}`)
return
}
let results = stdout.split(" ")
let percentage = Number(results[0])
let msg = `\n${IntertwinedFateNum}抽达到预期的概率为${results[0]}%\n`
if (parseInt(numbers[0]) == 0) {
msg = " \n"
}
if (percentage<10) {
msg = msg+
`达成10%概率需要${results[1]}抽\n`+
`达成25%概率需要${results[2]}抽\n`+
`达成50%概率需要${results[3]}抽\n`+
`达成75%概率需要${results[4]}抽\n`+
`达成90%概率需要${results[5]}抽\n`
} else if (percentage<25) {
msg = msg+
`达成25%概率需要${results[2]}抽\n`+
`达成50%概率需要${results[3]}抽\n`+
`达成75%概率需要${results[4]}抽\n`+
`达成90%概率需要${results[5]}抽\n`
} else if (percentage<50) {
msg = msg+
`达成50%概率需要${results[3]}抽\n`+
`达成75%概率需要${results[4]}抽\n`+
`达成90%概率需要${results[5]}抽\n`
} else if (percentage<75) {
msg = msg+
`达成75%概率需要${results[4]}抽\n`+
`达成90%概率需要${results[5]}抽\n`
} else if (percentage<90) {
msg = msg+
`达成90%概率需要${results[5]}抽\n`
} else {
msg = msg
}
let img = segment.image(`data/StarRailPercent/${IntertwinedFateNum},${ExpectedCharacterNum},${CharacterPoolGuarantee},${CharacterPoolStage},${ExpectedWeaponNum},${WeaponPoolGuarantee},${WeaponPoolStage}.png`)
e.reply([segment.at(e.user_id),msg,img])
})
return
}
async help(e) {
let title = "星铁跃迁概率计算帮助"
let body = "按照如下顺序提供数据:\n"+
"1、拥有专票数(0-1500)\n"+
"2、期望抽到角色数(0-7)\n"+
"3、角色池是否大保底(0/1)\n"+
"4、角色池当前水位(0-89)\n"+
"5、期望抽到光锥数(0-5)\n"+
"6、光锥池是否大保底(0/1)\n"+
"7、光锥池当前水位(0-79)\n\n"+
"例如我当前拥有400抽,要计算无水位情况抽2星1叠的概率则发送如下消息:\n\n"+
"400,3,0,0,1,0,0"
await e.reply(body)
return
}
}