Skip to content

Commit

Permalink
v1.2.1 详细查询深域部分,公主骑士等级采用解包数据进行计算
Browse files Browse the repository at this point in the history
  • Loading branch information
azmiao committed Jul 10, 2024
1 parent 2de9113 commit f11a9bf
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#### 感谢其他用爱发电的各位大佬的鼎力相助

#### 感谢解包数据源 [priconne-diff](https://github.com/Expugn/priconne-diff)

## 本仓库的特性

> ✨增加全局禁用推送功能,不需要自动推送的直接关闭即可✨
Expand All @@ -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后的配置文件

<details>
<summary>更以前的更新日志</summary>

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)
Expand Down
4 changes: 3 additions & 1 deletion create_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 获取文件所在目录的绝对路径
Expand Down Expand Up @@ -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
22 changes: 21 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import json
import time
from asyncio import Lock
Expand All @@ -6,14 +7,15 @@
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

from .create_img import generate_info_pic, generate_support_pic, _get_cx_name, generate_talent_pic
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 = '''
Expand Down Expand Up @@ -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())


# ========== ↑ ↑ ↑ 维护组功能 ↑ ↑ ↑ ==========


Expand Down
5 changes: 0 additions & 5 deletions pcrclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Binary file modified readme_img/主图.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified readme_img/支援图.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified readme_img/深域图.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ nonebot~=1.8.4
Pillow~=9.0.1
pycryptodome~=3.14.1
zhconv~=1.4.3
pandas~=2.0.3
41 changes: 41 additions & 0 deletions res_parse.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f11a9bf

Please sign in to comment.