diff --git a/README.md b/README.md index 5adc297..ea08340 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ #### 感谢其他用爱发电的各位大佬的鼎力相助 +#### 感谢解包数据源 [priconne-diff](https://github.com/Expugn/priconne-diff) + ## 本仓库的特性 > ✨增加全局禁用推送功能,不需要自动推送的直接关闭即可✨ @@ -33,17 +35,19 @@ ## 更新日志 +2024-07-10 v1.2.1 详细查询深域部分,公主骑士等级采用解包数据进行计算,数据源自 [priconne-diff](https://github.com/Expugn/priconne-diff) + 2024-06-24 v1.2.0 详细查询新增深域相关的查询图片,可见最下方图片预览,但公主骑士等级由于计算公式暂未解包,因此暂不可用 2024-03-28 v1.1.2 由于谷歌页面经常变化,去除自动更新版本号,改为手动使用命令更新 2023-12-21 v1.1.1 修复自动更新版本号的BUG -2023-08-10 v1.1.0 适配游戏版本v4.0.2后的配置文件 -
更以前的更新日志 +2023-08-10 v1.1.0 适配游戏版本v4.0.2后的配置文件 + 2023-06-29 v1.0.0 优化查询逻辑 2023-06-19 v0.0.3-beta 简化代码,[PR #5](https://github.com/azmiao/pcrjjc_tw_new/pull/5) diff --git a/create_img.py b/create_img.py index 7eacca2..3f5c6f9 100644 --- a/create_img.py +++ b/create_img.py @@ -6,6 +6,7 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor from hoshino import util +from .res_parse import read_knight_exp_rank from ..priconne import chara path = Path(__file__).parent # 获取文件所在目录的绝对路径 @@ -366,6 +367,7 @@ async def generate_talent_pic(data): bbox = (701, 849) im.paste(im=knight_img, box=bbox, mask=knight_img) quest_draw.text(xy=(716, 860), text='公主骑士等级', font=fnt, fill=rgb_w) - quest_draw.text(xy=(1080, 858), text='(暂时无法计算)', font=fnt, fill=rgb) # TODO 暂时无计算公式 + knight_rank = await read_knight_exp_rank('rank_exp.csv', knight_exp) + quest_draw.text(xy=(1080, 858), text=str(knight_rank), font=fnt, fill=rgb) return im diff --git a/main.py b/main.py index 190f6df..76cd837 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import asyncio import json import time from asyncio import Lock @@ -6,7 +7,7 @@ from os.path import dirname, join, exists import requests -from hoshino import priv, get_bot, get_self_ids +from hoshino import priv, get_bot, get_self_ids, R from hoshino.typing import NoticeSession, MessageSegment from hoshino.util import pic2b64 @@ -14,6 +15,7 @@ from .jjchistory import * from .pcrclient import PcrClient, ApiException, default_headers from .playerpref import decrypt_xml +from .res_parse import download_file from .safeservice import SafeService sv_help = ''' @@ -319,6 +321,24 @@ async def update_ver(bot, ev): await bot.send(ev, f'pcrjjc_tw_new的游戏版本为{headers.get("APP-VER", "")}') +# 自动更新解包数据 +@sv.scheduled_job('cron', id='daily_rank_exp_res', day=f'1/1', hour='1/1', minute='1/1') +async def update_rank_exp(): + await download_file( + 'rank_exp.csv', + '/TW/csv/v1_d3f66da6fec99e8ce4b79822bf92720ab7ae27df90fdd7ce50b92b696fcecaa7.csv' + ) + sv.logger.info('"rank_exp.csv" 已经更新到最新版本') + + +# 首次启动 +if not os.path.exists(R.img('pcrjjc_tw_new').path): + os.mkdir(R.img('pcrjjc_tw_new').path) +if not os.path.exists(os.path.join(R.img('pcrjjc_tw_new').path, 'rank_exp.csv')): + loop = asyncio.get_event_loop() + loop.run_until_complete(update_rank_exp()) + + # ========== ↑ ↑ ↑ 维护组功能 ↑ ↑ ↑ ========== diff --git a/pcrclient.py b/pcrclient.py index af797df..64bb175 100644 --- a/pcrclient.py +++ b/pcrclient.py @@ -10,11 +10,6 @@ from hoshino.aiorequests import post from msgpack import packb, unpackb -# 读取代理配置 -with open(os.path.join(os.path.dirname(__file__), 'account.json')) as fp: - p_info = json.load(fp) - - # 默认headers default_headers = { 'Accept-Encoding': 'deflate, gzip', diff --git "a/readme_img/\344\270\273\345\233\276.PNG" "b/readme_img/\344\270\273\345\233\276.PNG" index 06c144e..b288bd5 100644 Binary files "a/readme_img/\344\270\273\345\233\276.PNG" and "b/readme_img/\344\270\273\345\233\276.PNG" differ diff --git "a/readme_img/\346\224\257\346\217\264\345\233\276.PNG" "b/readme_img/\346\224\257\346\217\264\345\233\276.PNG" index 24185a0..87f997b 100644 Binary files "a/readme_img/\346\224\257\346\217\264\345\233\276.PNG" and "b/readme_img/\346\224\257\346\217\264\345\233\276.PNG" differ diff --git "a/readme_img/\346\267\261\345\237\237\345\233\276.PNG" "b/readme_img/\346\267\261\345\237\237\345\233\276.PNG" index 483a4ef..3b92f34 100644 Binary files "a/readme_img/\346\267\261\345\237\237\345\233\276.PNG" and "b/readme_img/\346\267\261\345\237\237\345\233\276.PNG" differ diff --git a/requirements.txt b/requirements.txt index 7f81b58..49cd34c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ nonebot~=1.8.4 Pillow~=9.0.1 pycryptodome~=3.14.1 zhconv~=1.4.3 +pandas~=2.0.3 \ No newline at end of file diff --git a/res_parse.py b/res_parse.py new file mode 100644 index 0000000..f0066a3 --- /dev/null +++ b/res_parse.py @@ -0,0 +1,41 @@ +import json +import os + +import pandas as pd +from hoshino import aiorequests, R + +current_dir = R.img('pcrjjc_tw_new').path + +# 读取代理配置 +with open(os.path.join(os.path.dirname(__file__), 'account.json')) as fp: + p_info = json.load(fp) + + +# 保存解包数据 +async def download_file(file_name: str, file_uri: str): + file_path = os.path.join(current_dir, file_name) + file_url = 'https://raw.githubusercontent.com/Expugn/priconne-diff/master' + file_uri + file_rep = await aiorequests.get(file_url, proxies=p_info['proxy']) + response = await file_rep.content + # 写入文件 + with open(file_path, 'wb') as file: + file.write(response) + + +# 计算实际RANK +async def read_knight_exp_rank(file_name: str, target_value: int) -> int: + file_path = os.path.join(current_dir, file_name) + df = pd.read_csv(file_path) + columns = df.columns.tolist() + + rank = columns[0] + exp = columns[1] + + target_rank = 1 + + for _, row in df.iterrows(): + if target_value >= int(row[exp]): + target_rank = int(row[rank]) + else: + break + return target_rank