mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-31 04:30:29 +08:00
优化&更新 xx能用啥 命令的推荐表
This commit is contained in:
parent
7a5380e27f
commit
3cfec0e799
Binary file not shown.
1556
mihoyo_libs/char_adv_list.json
Normal file
1556
mihoyo_libs/char_adv_list.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,8 @@ from base64 import b64encode
|
||||
from io import BytesIO
|
||||
from typing import List
|
||||
|
||||
import aiofiles
|
||||
|
||||
from openpyxl import load_workbook
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
@ -161,88 +163,58 @@ char_adv_im = """【{}】
|
||||
|
||||
|
||||
async def weapon_adv(name):
|
||||
char_adv_path = os.path.join(FILE_PATH, 'Genshin All Char.xlsx')
|
||||
wb = load_workbook(char_adv_path)
|
||||
ws = wb.active
|
||||
async with aiofiles.open(os.path.join(FILE_PATH, 'mihoyo_libs/char_adv_list.json'), encoding='utf-8') as f:
|
||||
adv_li = json.loads(await f.read())
|
||||
weapons = {}
|
||||
for char, info in adv_li.items():
|
||||
char_weapons = []
|
||||
for i in info['weapon'].values(): # 3 stars, 4 stars, 5 stars
|
||||
char_weapons.extend(i)
|
||||
|
||||
weapons={}
|
||||
for c in range(2, 5):
|
||||
for r in range(2, 300):
|
||||
if ws.cell(r, c).value:
|
||||
# if all(i in ws.cell(r,c).value for i in name):
|
||||
if name in ws.cell(r, c).value:
|
||||
weapon_name = ws.cell(r, c).value
|
||||
weapon=weapons.get(weapon_name,[])
|
||||
weapon.append(ws.cell(2 + ((r - 2) // 5) * 5, 1).value)
|
||||
weapons[weapon_name]=weapon
|
||||
for weapon_name in char_weapons:
|
||||
if name in weapon_name: # fuzzy search
|
||||
char_weapon = weapons.get(weapon_name, [])
|
||||
char_weapon.append(char)
|
||||
weapons[weapon_name] = char_weapon
|
||||
|
||||
if weapons:
|
||||
im = []
|
||||
for k, v in weapons.items():
|
||||
im.append(f'{"、".join(v)}可能会用到【{k}】')
|
||||
im.append(f'{"、".join(v)} 可能会用到【{k}】')
|
||||
im = '\n'.join(im)
|
||||
else:
|
||||
im = '没有角色能使用【{}】'.format(weapon_name)
|
||||
im = '没有角色能使用【{}】'.format(name)
|
||||
# print(im)
|
||||
return im
|
||||
|
||||
|
||||
async def char_adv(name):
|
||||
char_name = None
|
||||
char_adv_path = os.path.join(FILE_PATH, 'Genshin All Char.xlsx')
|
||||
# char_adv_path = FILE_PATH
|
||||
wb = load_workbook(char_adv_path)
|
||||
ws = wb.active
|
||||
char_list = ws['A']
|
||||
index = None
|
||||
for i in char_list:
|
||||
if i.value:
|
||||
if all(g in i.value for g in name):
|
||||
# if name in i.value:
|
||||
index = i.row
|
||||
char_name = i.value
|
||||
if index:
|
||||
weapon_5star = ''
|
||||
for i in range(index, index + 5):
|
||||
if ws.cell(i, 2).value:
|
||||
weapon_5star += ws.cell(i, 2).value + '>'
|
||||
if weapon_5star != '':
|
||||
weapon_5star = weapon_5star[:-1]
|
||||
else:
|
||||
weapon_5star = '无推荐'
|
||||
async with aiofiles.open(os.path.join(FILE_PATH, 'mihoyo_libs/char_adv_list.json'), encoding='utf-8') as f:
|
||||
adv_li = json.loads(await f.read())
|
||||
for char, info in adv_li.items():
|
||||
if name in char:
|
||||
im = [f'「{char}」', '-=-=-=-=-=-=-=-=-=-']
|
||||
if weapon_5 := info['weapon']['5']:
|
||||
im.append(f'推荐5★武器:{"、".join(weapon_5)}')
|
||||
if weapon_4 := info['weapon']['4']:
|
||||
im.append(f'推荐4★武器:{"、".join(weapon_4)}')
|
||||
if weapon_3 := info['weapon']['3']:
|
||||
im.append(f'推荐3★武器:{"、".join(weapon_3)}')
|
||||
if artifacts := info['artifact']:
|
||||
im.append('推荐圣遗物搭配:')
|
||||
for arti in artifacts:
|
||||
if len(arti) > 1:
|
||||
im.append(f'[{arti[0]}]两件套 + [{arti[1]}]两件套')
|
||||
else:
|
||||
im.append(f'[{arti[0]}]四件套')
|
||||
if remark := info['remark']:
|
||||
im.append('-=-=-=-=-=-=-=-=-=-')
|
||||
im.append('备注:')
|
||||
mark = "\n".join(remark)
|
||||
im.append(f'{mark}')
|
||||
return '\n'.join(im)
|
||||
|
||||
weapon_4star = ''
|
||||
for i in range(index, index + 5):
|
||||
if ws.cell(i, 3).value:
|
||||
weapon_4star += ws.cell(i, 3).value + '>'
|
||||
if weapon_4star != '':
|
||||
weapon_4star = weapon_4star[:-1]
|
||||
else:
|
||||
weapon_4star = '无推荐'
|
||||
|
||||
weapon_3star = ''
|
||||
for i in range(index, index + 5):
|
||||
if ws.cell(i, 4).value:
|
||||
weapon_3star += ws.cell(i, 4).value + '>'
|
||||
if weapon_3star != '':
|
||||
weapon_3star = weapon_3star[:-1]
|
||||
else:
|
||||
weapon_3star = '无推荐'
|
||||
|
||||
artifacts = ''
|
||||
for i in range(index, index + 5):
|
||||
if ws.cell(i, 5).value:
|
||||
if ws.cell(i, 6).value:
|
||||
artifacts += ws.cell(i, 5).value + '*2' + ws.cell(i, 6).value + '*2' + '\n'
|
||||
else:
|
||||
artifacts += ws.cell(i, 5).value + '*4' + '\n'
|
||||
|
||||
if artifacts != '':
|
||||
artifacts = artifacts[:-1]
|
||||
else:
|
||||
artifacts = '无推荐'
|
||||
|
||||
im = char_adv_im.format(char_name, weapon_5star, weapon_4star, weapon_3star, artifacts)
|
||||
return im
|
||||
return '没有找到角色信息'
|
||||
|
||||
|
||||
async def deal_ck(mes, qid):
|
||||
|
50
tools/gen_char_li.py
Normal file
50
tools/gen_char_li.py
Normal file
@ -0,0 +1,50 @@
|
||||
import copy
|
||||
import json
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
|
||||
from openpyxl import load_workbook
|
||||
|
||||
R_PATH = Path(__file__).parents[0]
|
||||
|
||||
sample = {
|
||||
'weapon': {
|
||||
'5': [],
|
||||
'4': [],
|
||||
'3': []
|
||||
},
|
||||
'artifact': [], # type: list[list[str,Optional[str]]] # 四件套 / 2+2
|
||||
'remark': []
|
||||
}
|
||||
|
||||
char_json = {}
|
||||
|
||||
wb = load_workbook('../mihoyo_libs/Genshin All Char.xlsx')
|
||||
ws = wb.active
|
||||
for char_i in range(2, 336, 5): # 角色行
|
||||
char_name = ws.cell(char_i, 1).value.replace('\n', '')
|
||||
char_sample = copy.deepcopy(sample)
|
||||
for i in range(5):
|
||||
row = i + char_i
|
||||
|
||||
if star_5 := ws.cell(row, 2).value:
|
||||
char_sample['weapon']['5'].append(star_5)
|
||||
if star_4 := ws.cell(row, 3).value:
|
||||
char_sample['weapon']['4'].append(star_4)
|
||||
|
||||
artifact = []
|
||||
if arti_1 := ws.cell(row, 5).value:
|
||||
artifact.append(arti_1)
|
||||
if arti_2 := ws.cell(row, 6).value:
|
||||
artifact.append(arti_2)
|
||||
if artifact:
|
||||
char_sample['artifact'].append(artifact)
|
||||
|
||||
if remark := ws.cell(row, 7).value:
|
||||
if row > 7:
|
||||
char_sample['remark'].append(remark)
|
||||
|
||||
char_json[char_name] = char_sample
|
||||
|
||||
with open('../mihoyo_libs/char_adv_list.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(char_json, f, indent=2, ensure_ascii=False)
|
Loading…
x
Reference in New Issue
Block a user