mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-04 03:10:01 +08:00
update alapi
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import os
|
||||
|
||||
import nonebot
|
||||
from .update_game_info import update_info
|
||||
from .announcement import PrettyAnnouncement
|
||||
from .util import download_img, init_star_rst, generate_img, max_card, BaseData, \
|
||||
set_list, get_star, format_card_information, UpEvent
|
||||
from .util import init_star_rst, generate_img, max_card, BaseData, \
|
||||
set_list, get_star, format_card_information, init_up_char
|
||||
import random
|
||||
from .config import PRETTY_THREE_P, PRETTY_TWO_P, DRAW_PATH, PRETTY_ONE_P, PRETTY_FLAG
|
||||
from dataclasses import dataclass
|
||||
from .init_card_pool import init_game_pool
|
||||
from util.init_result import image
|
||||
from configs.path_config import IMAGE_PATH
|
||||
from services.log import logger
|
||||
from nonebot.adapters.cqhttp import MessageSegment, Message
|
||||
|
||||
try:
|
||||
import ujson as json
|
||||
@@ -19,6 +17,8 @@ except ModuleNotFoundError:
|
||||
|
||||
driver: nonebot.Driver = nonebot.get_driver()
|
||||
|
||||
announcement = PrettyAnnouncement()
|
||||
|
||||
ALL_CHAR = []
|
||||
ALL_CARD = []
|
||||
|
||||
@@ -76,7 +76,7 @@ async def pretty_draw(count: int, pool_name):
|
||||
rst = init_star_rst(star_list, cnlist, three_list, three_olist, up_list)
|
||||
if count > 90:
|
||||
obj_list = set_list(obj_list)
|
||||
return pool_info + image(b64=await generate_img(obj_list, 'pretty', star_list)) \
|
||||
return pool_info + MessageSegment.image("base64://" + await generate_img(obj_list, 'pretty', star_list)) \
|
||||
+ '\n' + rst[:-1] + '\n' + max_card(obj_dict)
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ async def update_pretty_info():
|
||||
data, code = await update_info(url, 'pretty_card')
|
||||
if code == 200:
|
||||
ALL_CARD = init_game_pool('pretty_card', data, PrettyChar)
|
||||
await _init_up_char()
|
||||
await _pretty_init_up_char()
|
||||
|
||||
|
||||
async def init_pretty_data():
|
||||
@@ -102,13 +102,16 @@ async def init_pretty_data():
|
||||
pretty_card_dict = json.load(f)
|
||||
ALL_CHAR = init_game_pool('pretty', pretty_char_dict, PrettyChar)
|
||||
ALL_CARD = init_game_pool('pretty_card', pretty_card_dict, PrettyChar)
|
||||
await _init_up_char()
|
||||
await _pretty_init_up_char()
|
||||
|
||||
|
||||
# 抽取卡池
|
||||
def _get_pretty_card(pool_name: str):
|
||||
def _get_pretty_card(pool_name: str, mode: int = 1):
|
||||
global ALL_CHAR, ALL_CARD, _CURRENT_CHAR_POOL_TITLE, _CURRENT_CARD_POOL_TITLE
|
||||
star = get_star([3, 2, 1], [PRETTY_THREE_P, PRETTY_TWO_P, PRETTY_ONE_P])
|
||||
if mode == 1:
|
||||
star = get_star([3, 2, 1], [PRETTY_THREE_P, PRETTY_TWO_P, PRETTY_ONE_P])
|
||||
else:
|
||||
star = get_star([3, 2], [PRETTY_THREE_P, PRETTY_TWO_P])
|
||||
if pool_name == 'card':
|
||||
title = _CURRENT_CARD_POOL_TITLE
|
||||
up_data = UP_CARD
|
||||
@@ -126,6 +129,7 @@ def _get_pretty_card(pool_name: str):
|
||||
acquire_operator = random.choice(all_up_star)
|
||||
if pool_name == 'char':
|
||||
acquire_operator = acquire_operator.split(']')[1]
|
||||
print(acquire_operator)
|
||||
acquire_operator = [x for x in data if x.name == acquire_operator][0]
|
||||
else:
|
||||
acquire_operator = random.choice([x for x in data if x.star == star and not x.limited])
|
||||
@@ -135,39 +139,13 @@ def _get_pretty_card(pool_name: str):
|
||||
|
||||
|
||||
# 获取up和概率
|
||||
async def _init_up_char():
|
||||
async def _pretty_init_up_char():
|
||||
global _CURRENT_CHAR_POOL_TITLE, _CURRENT_CARD_POOL_TITLE, UP_CHAR, UP_CARD, POOL_IMG
|
||||
UP_CHAR = []
|
||||
UP_CARD = []
|
||||
up_char_dict = await PrettyAnnouncement.update_up_char()
|
||||
_CURRENT_CHAR_POOL_TITLE = up_char_dict['char']['title']
|
||||
_CURRENT_CARD_POOL_TITLE = up_char_dict['card']['title']
|
||||
if _CURRENT_CHAR_POOL_TITLE and _CURRENT_CARD_POOL_TITLE:
|
||||
await download_img(up_char_dict['char']['pool_img'], 'pretty', 'up_char_pool_img')
|
||||
await download_img(up_char_dict['card']['pool_img'], 'pretty', 'up_card_pool_img')
|
||||
POOL_IMG = image('up_char_pool_img.png', '/draw_card/pretty/') + \
|
||||
image('up_card_pool_img.png', '/draw_card/pretty/')
|
||||
else:
|
||||
if os.path.exists(IMAGE_PATH + '/draw_card/genshin/up_char_pool_img.png'):
|
||||
os.remove(IMAGE_PATH + '/draw_card/pretty/up_char_pool_img.png')
|
||||
if os.path.exists(IMAGE_PATH + '/draw_card/genshin/up_arms_pool_img.png'):
|
||||
os.remove(IMAGE_PATH + '/draw_card/pretty/up_card_pool_img.png')
|
||||
logger.info(f'成功获取赛马娘当前up信息...当前up池: {_CURRENT_CHAR_POOL_TITLE} & {_CURRENT_CARD_POOL_TITLE}')
|
||||
for key in up_char_dict.keys():
|
||||
for star in up_char_dict[key]['up_char'].keys():
|
||||
up_lst = []
|
||||
for char in up_char_dict[key]['up_char'][star].keys():
|
||||
up_lst.append(char)
|
||||
if key == 'char':
|
||||
if up_lst:
|
||||
UP_CHAR.append(UpEvent(star=int(star), operators=up_lst, zoom=0))
|
||||
else:
|
||||
if up_lst:
|
||||
UP_CARD.append(UpEvent(star=int(star), operators=up_lst, zoom=0))
|
||||
_CURRENT_CHAR_POOL_TITLE, _CURRENT_CARD_POOL_TITLE, POOL_IMG, UP_CHAR, UP_CARD = await init_up_char(announcement)
|
||||
|
||||
|
||||
async def reload_pretty_pool():
|
||||
await _init_up_char()
|
||||
return f'当前UP池子:{_CURRENT_CHAR_POOL_TITLE} & {_CURRENT_CARD_POOL_TITLE} {POOL_IMG}'
|
||||
await _pretty_init_up_char()
|
||||
return Message(f'当前UP池子:{_CURRENT_CHAR_POOL_TITLE} & {_CURRENT_CARD_POOL_TITLE} {POOL_IMG}')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user