-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path__init__.py
92 lines (81 loc) · 2.77 KB
/
__init__.py
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
# coding=utf-8
from hoshino import Service
from hoshino.typing import HoshinoBot,CQEvent
from os.path import join
from .Life import Life
from .PicClass import *
import traceback
import random
sv = Service("人生重来模拟器")
def genp(prop):
ps = []
# for _ in range(4):
# ps.append(min(prop, 8))
# prop -= ps[-1]
tmp = prop
while True:
for i in range(0,4):
if i == 3:
ps.append(tmp)
else:
if tmp>=10:
ps.append(random.randint(0, 10))
else:
ps.append(random.randint(0, tmp))
tmp -= ps[-1]
if ps[3]<10:
break
else:
tmp = prop
ps.clear()
return {
'CHR': ps[0],
'INT': ps[1],
'STR': ps[2],
'MNY': ps[3]
}
@sv.on_fullmatch(("/remake","人生重来"))
async def remake(bot,ev:CQEvent):
pic_list = []
mes_list = []
Life.load(join(FILE_PATH,'data'))
while True:
life = Life()
life.setErrorHandler(lambda e: traceback.print_exc())
life.setTalentHandler(lambda ts: random.choice(ts).id)
life.setPropertyhandler(genp)
flag = life.choose()
if flag:
break
name = ev["sender"]['card'] or ev["sender"]["nickname"]
choice = 0
person = name + "本次重生的基本信息如下:\n\n【你的天赋】\n"
for t in life.talent.talents:
choice = choice + 1
person = person + str(choice) + "、天赋:【" + t.name + "】" + " 效果:" + t.desc + "\n"
person = person + "\n【基础属性】\n"
person = person + " 美貌值:" + str(life.property.CHR)+" "
person = person + "智力值:" + str(life.property.INT)+" "
person = person + "体质值:" + str(life.property.STR)+" "
person = person + "财富值:" + str(life.property.MNY)+" "
pic_list.append("这是"+name+"本次轮回的基础属性和天赋:")
pic_list.append(ImgText(person).draw_text())
await bot.send(ev, "你的命运正在重启....",at_sender=True)
res = life.run() #命运之轮开始转动
mes = '\n'.join('\n'.join(x) for x in res)
pic_list.append("这是"+name+"本次轮回的生平:")
pic_list.append(ImgText(mes).draw_text())
sum = life.property.gensummary() #你的命运之轮到头了
pic_list.append("这是" + name + "本次轮回的评价:")
pic_list.append(ImgText(sum).draw_text())
for img in pic_list:
data = {
"type": "node",
"data": {
"name": "色图机器人",
"uin": "2854196310",
"content": img
}
}
mes_list.append(data)
await bot.send_group_forward_msg(group_id=ev['group_id'], messages=mes_list)