mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-08 13:20:01 +08:00
update
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import ujson as json
|
||||
import os
|
||||
from util.init_result import image
|
||||
from nonebot.adapters.cqhttp import MessageSegment
|
||||
import nonebot
|
||||
import random
|
||||
from .update_game_info import update_info
|
||||
from .update_game_simple_info import update_simple_info
|
||||
from .util import generate_img, init_star_rst, BaseData, set_list, get_star, max_card
|
||||
from .config import PCR_TWO_P, PCR_THREE_P, PCR_ONE_P, DRAW_PATH, PCR_FLAG, PCR_G_TWO_P, PCR_G_THREE_P
|
||||
from .config import PCR_TWO_P, PCR_THREE_P, PCR_ONE_P, DRAW_PATH, PCR_FLAG, PCR_G_TWO_P, PCR_G_THREE_P, PCR_TAI
|
||||
from dataclasses import dataclass
|
||||
from .init_card_pool import init_game_pool
|
||||
|
||||
@@ -26,28 +27,28 @@ async def pcr_draw(count: int):
|
||||
rst = init_star_rst(star_list, cnlist, three_list, three_index_list)
|
||||
if count > 90:
|
||||
char_list = set_list(char_list)
|
||||
return image(b64=await generate_img(char_list, 'pcr', star_list)) \
|
||||
return MessageSegment.image("base64://" + await generate_img(char_list, 'pcr', star_list)) \
|
||||
+ '\n' + rst[:-1] + '\n' + max_card(char_dict)
|
||||
|
||||
|
||||
async def update_pcr_info():
|
||||
global ALL_CHAR
|
||||
url = 'https://wiki.biligame.com/pcr/角色筛选表'
|
||||
data, code = await update_info(url, 'pcr')
|
||||
if PCR_TAI:
|
||||
url = 'https://wiki.biligame.com/pcr/角色图鉴'
|
||||
data, code = await update_simple_info(url, 'pcr')
|
||||
else:
|
||||
url = 'https://wiki.biligame.com/pcr/角色筛选表'
|
||||
data, code = await update_info(url, 'pcr')
|
||||
if code == 200:
|
||||
ALL_CHAR = init_game_pool('pcr', data, PcrChar)
|
||||
|
||||
|
||||
@driver.on_startup
|
||||
async def init_data():
|
||||
async def init_pcr_data():
|
||||
global ALL_CHAR
|
||||
if PCR_FLAG:
|
||||
if not os.path.exists(DRAW_PATH + 'pcr.json'):
|
||||
await update_pcr_info()
|
||||
else:
|
||||
with open(DRAW_PATH + 'pcr.json', 'r', encoding='utf8') as f:
|
||||
pcr_dict = json.load(f)
|
||||
ALL_CHAR = init_game_pool('pcr', pcr_dict, PcrChar)
|
||||
with open(DRAW_PATH + 'pcr.json', 'r', encoding='utf8') as f:
|
||||
pcr_dict = json.load(f)
|
||||
ALL_CHAR = init_game_pool('pcr', pcr_dict, PcrChar)
|
||||
|
||||
|
||||
# 抽取卡池
|
||||
@@ -58,7 +59,7 @@ def _get_pcr_card(mode: int = 1):
|
||||
else:
|
||||
star = get_star([3, 2, 1], [PCR_THREE_P, PCR_TWO_P, PCR_ONE_P])
|
||||
chars = [x for x in ALL_CHAR if x.star == star and not x.limited]
|
||||
return random.choice(chars), abs(star - 3)
|
||||
return random.choice(chars), 3 - star
|
||||
|
||||
|
||||
def _format_card_information(_count: int):
|
||||
@@ -77,7 +78,7 @@ def _format_card_information(_count: int):
|
||||
count = 0
|
||||
else:
|
||||
char, code = _get_pcr_card()
|
||||
if code == 1:
|
||||
if code < 2:
|
||||
count = 0
|
||||
star_list[code] += 1
|
||||
if code == 0:
|
||||
|
||||
Reference in New Issue
Block a user