feat: support auto refresh avatars

This commit is contained in:
xtaodada 2023-08-14 15:40:58 +08:00
parent bd07364e51
commit c6a3abc607
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
8 changed files with 790 additions and 103 deletions

427
FightPropRule_genshin.json Normal file
View File

@ -0,0 +1,427 @@
{
"旅行者": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率",
"元素精通"
],
"安柏": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"凯亚": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"丽莎": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"芭芭拉": [
"生命值百分比",
"元素充能效率",
"元素精通"
],
"芭芭拉-核爆": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"雷泽": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成"
],
"香菱": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"北斗": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"行秋": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"凝光": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"菲谢尔": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"班尼特": [
"生命值百分比",
"元素充能效率",
"治疗加成"
],
"诺艾尔": [
"攻击力百分比",
"防御力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"重云": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"砂糖": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"琴": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成",
"元素充能效率",
"治疗加成"
],
"迪卢克": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"七七": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成",
"元素充能效率",
"治疗加成"
],
"莫娜": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"刻晴": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"物理伤害加成"
],
"温迪": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"可莉": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"迪奥娜": [
"生命值百分比",
"元素充能效率",
"治疗加成"
],
"达达利亚": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"辛焱": [
"防御力百分比",
"暴击率",
"暴击伤害",
"攻击力百分比",
"物理伤害加成"
],
"钟离": [
"生命值百分比",
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成",
"元素充能效率"
],
"钟离-安如磐石": [
"生命值百分比",
"暴击率"
],
"阿贝多": [
"防御力百分比",
"暴击率",
"暴击伤害"
],
"甘雨": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"甘雨-永冻": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"魈": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"胡桃": [
"生命值百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"罗莎莉亚": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成",
"元素充能效率"
],
"烟绯": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"优菈": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"物理伤害加成",
"元素充能效率"
],
"枫原万叶": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"神里绫华": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"早柚": [
"攻击力百分比",
"暴击率",
"元素精通",
"元素充能效率",
"治疗加成"
],
"宵宫": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"埃洛伊": [
"攻击力百分比",
"暴击率",
"暴击伤害"
],
"九条裟罗": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"雷电将军": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率",
"元素精通"
],
"珊瑚宫心海": [
"生命值百分比",
"攻击力百分比",
"元素充能效率",
"治疗加成",
"元素精通"
],
"托马": [
"生命值百分比",
"暴击率",
"元素充能效率",
"元素精通"
],
"五郎": [
"防御力百分比",
"暴击率",
"元素充能效率"
],
"荒泷一斗": [
"防御力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"云堇": [
"防御力百分比",
"暴击率",
"元素充能效率"
],
"申鹤": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"八重神子": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"神里绫人": [
"生命值百分比",
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"夜兰": [
"生命值百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"久岐忍": [
"生命值百分比",
"元素精通",
"治疗加成"
],
"鹿野院平藏": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"提纳里": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"柯莱": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"赛诺": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"妮露": [
"生命值百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"纳西妲": [
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率",
"攻击力百分比"
],
"流浪者": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"珐露珊": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素充能效率"
],
"艾尔海森": [
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通",
"元素充能效率"
],
"瑶瑶": [
"生命值百分比",
"元素充能效率"
],
"迪希雅": [
"生命值百分比",
"攻击力百分比",
"暴击率",
"暴击伤害",
"元素精通"
],
"白术": [
"生命值百分比",
"元素充能效率",
"元素精通",
"治疗加成"
],
"卡维": [
"元素精通",
"元素充能效率",
"治疗加成"
],
"绮良良": [
"生命值百分比",
"暴击率",
"暴击伤害",
"元素精通",
"攻击力百分比"
]
}

197
FightPropRule_starrail.json Normal file
View File

@ -0,0 +1,197 @@
{
"丹恒": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"风属性伤害提高百分比",
"速度"
],
"彦卿": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"冰属性伤害提高百分比",
"速度"
],
"希儿": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"量子属性伤害提高百分比",
"速度"
],
"姬子": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"火属性伤害提高百分比",
"效果命中百分比"
],
"阿兰": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"雷属性伤害提高百分比",
"速度"
],
"黑塔": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"冰属性伤害提高百分比"
],
"希露瓦": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"雷属性伤害提高百分比",
"效果命中百分比"
],
"克拉拉": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"物理属性伤害提高百分比"
],
"虎克": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"火属性伤害提高百分比",
"效果命中百分比",
"速度"
],
"青雀": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"量子属性伤害提高百分比",
"速度"
],
"素裳": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"物理属性伤害提高百分比",
"速度",
"击破特攻"
],
"杰帕德": [
"防御力百分比",
"防御力",
"能量恢复效率百分比",
"速度",
"效果命中百分比"
],
"三月七": [
"防御力百分比",
"防御力",
"能量恢复效率百分比",
"速度",
"效果命中百分比"
],
"瓦尔特": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"虚数属性伤害提高百分比",
"速度",
"能量恢复效率百分比",
"效果命中百分比"
],
"桑博": [
"速度",
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"能量恢复效率百分比",
"效果命中百分比",
"风属性伤害提高百分比"
],
"佩拉": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"冰属性伤害提高百分比",
"速度",
"能量恢复效率百分比",
"效果命中百分比"
],
"停云": [
"攻击力百分比",
"攻击力",
"防御力百分比",
"防御力",
"生命值百分比",
"生命值",
"速度",
"能量恢复效率百分比",
"雷属性伤害提高百分比"
],
"艾丝妲": [
"攻击力百分比",
"攻击力",
"防御力百分比",
"防御力",
"火属性伤害提高百分比",
"速度",
"能量恢复效率百分比",
"速度",
"击破特攻",
"效果命中百分比"
],
"白露": [
"生命值百分比",
"生命值",
"治疗量加成百分比",
"能量恢复效率百分比",
"速度"
],
"娜塔莎": [
"生命值百分比",
"生命值",
"治疗量加成百分比",
"能量恢复效率百分比",
"速度"
],
"布洛妮娅": [
"暴击伤害百分比",
"速度",
"能量恢复效率百分比",
"风属性伤害提高百分比"
],
"景元": [
"攻击力百分比",
"暴击率百分比",
"暴击伤害百分比",
"雷属性伤害提高百分比",
"速度"
],
"罗刹": [
"攻击力百分比",
"攻击力",
"效果抵抗百分比",
"治疗量加成百分比"
],
"开拓者·毁灭": [
"攻击力百分比",
"击破特攻",
"暴击率百分比",
"暴击伤害百分比",
"物理属性伤害提高百分比",
"速度"
],
"开拓者·存护": [
"防御力百分比",
"防御力",
"攻击力百分比",
"攻击力",
"暴击率百分比",
"暴击伤害百分比",
"火属性伤害提高百分比",
"击破特攻",
"速度",
"效果命中百分比",
"效果抵抗百分比"
]
}

73
avatars_genshin.json Normal file
View File

@ -0,0 +1,73 @@
[
"琴",
"优菈",
"白术",
"七七",
"九条裟罗",
"妮露",
"雷泽",
"安柏",
"重云",
"胡桃",
"旅行者",
"阿贝多",
"辛焱",
"琳妮特",
"迪奥娜",
"凯亚",
"魈",
"久岐忍",
"米卡",
"赛诺",
"夜兰",
"申鹤",
"迪卢克",
"流浪者",
"托马",
"提纳里",
"温迪",
"诺艾尔",
"烟绯",
"荒泷一斗",
"凝光",
"菲米尼",
"行秋",
"莫娜",
"香菱",
"丽莎",
"瑶瑶",
"八重神子",
"迪希雅",
"鹿野院平藏",
"钟离",
"枫原万叶",
"埃洛伊",
"多莉",
"菲谢尔",
"罗莎莉亚",
"刻晴",
"绮良良",
"柯莱",
"神里绫人",
"班尼特",
"纳西妲",
"可莉",
"坎蒂丝",
"艾尔海森",
"林尼",
"云堇",
"莱依拉",
"雷电将军",
"早柚",
"珐露珊",
"达达利亚",
"北斗",
"砂糖",
"珊瑚宫心海",
"五郎",
"芭芭拉",
"宵宫",
"卡维",
"神里绫华",
"甘雨"
]

35
avatars_starrail.json Normal file
View File

@ -0,0 +1,35 @@
[
"佩拉",
"罗刹",
"素裳",
"景元",
"刃",
"杰帕德",
"卡芙卡",
"娜塔莎",
"希儿",
"玲可",
"布洛妮娅",
"驭空",
"阿兰",
"虎克",
"彦卿",
"符玄",
"克拉拉",
"青雀",
"三月七",
"瓦尔特",
"银狼",
"卢卡",
"丹恒",
"黑塔",
"希露瓦",
"桑博",
"停云",
"白露",
"姬子",
"丹恒•饮月",
"艾丝妲",
"开拓者·毁灭",
"开拓者·存护"
]

View File

@ -18,7 +18,7 @@ def main(page: Page):
top_view = page.views[-1] top_view = page.views[-1]
page.go(top_view.route) page.go(top_view.route)
page.title = "PropScoreEditor" page.title = "FightPropRuleEditor"
page.vertical_alignment = "center" page.vertical_alignment = "center"
page.horizontal_alignment = "center" page.horizontal_alignment = "center"
page.on_route_change = on_route_change page.on_route_change = on_route_change

View File

@ -1,2 +1,3 @@
flet flet
PyInstaller PyInstaller
httpx

View File

@ -19,6 +19,11 @@ def choose_view(page: Page):
page.go("/edit") page.go("/edit")
show_snack_bar(page, "开始编辑崩坏:星穹铁道遗器有效词条", ft.colors.GREEN) show_snack_bar(page, "开始编辑崩坏:星穹铁道遗器有效词条", ft.colors.GREEN)
def refresh(_e):
Genshin().refresh()
Starrail().refresh()
show_snack_bar(page, "刷新角色列表成功", ft.colors.GREEN)
# View # View
page.views.append( page.views.append(
ft.View( ft.View(
@ -28,7 +33,7 @@ def choose_view(page: Page):
[ [
ft.Container( ft.Container(
content=ft.Text( content=ft.Text(
"PropScoreEditor", "FightPropRuleEditor",
size=50, size=50,
), ),
), ),
@ -42,6 +47,11 @@ def choose_view(page: Page):
icon=ft.icons.LOGIN, icon=ft.icons.LOGIN,
on_click=starrail, on_click=starrail,
), ),
ft.FilledButton(
"Refresh avatars",
icon=ft.icons.LOGIN,
on_click=refresh,
),
], ],
alignment=MainAxisAlignment.CENTER, alignment=MainAxisAlignment.CENTER,
) )

View File

@ -1,89 +1,47 @@
import json import json
import flet as ft import flet as ft
from httpx import get
from pathlib import Path from pathlib import Path
from typing import List, Dict, Optional from typing import List, Dict, Optional
data_path = Path("data") genshin_path = Path("FightPropRule_genshin.json")
data_path.mkdir(exist_ok=True) starrail_path = Path("FightPropRule_starrail.json")
genshin_path = data_path / "genshin.json" genshin_avatars_path = Path("avatars_genshin.json")
starrail_path = data_path / "starrail.json" starrail_avatars_path = Path("avatars_starrail.json")
genshin_api = "https://api.ambr.top/v2/chs/avatar"
starrail_api = "https://api.yatta.top/hsr/v2/cn/avatar"
class Base: class Base:
character: List[str] character: List[str]
type: List[str] type: List[str]
def get_data_from_file(self, path: Path):
if path.exists():
with open(path, "r", encoding="utf-8") as f:
self.character = json.load(f)
else:
self.character = []
def save_data_to_file(self, path: Path):
with open(path, "w", encoding="utf-8") as f:
json.dump(self.character, f, ensure_ascii=False, indent=4)
def get_data_from_api(self, api: str, ignore_id_start: str = None):
if ignore_id_start is None:
ignore_id_start = "-1"
res = get(api)
if res.status_code == 200:
data = res.json()
self.character = list({
i.get("name")
for i in data.get("data", {}).get("items", {}).values()
if not str(i.get("id", 0)).startswith(ignore_id_start)
})
class Genshin(Base): class Genshin(Base):
character = [
'旅行者',
'神里绫华',
'丽莎',
'芭芭拉',
'凯亚',
'迪卢克',
'雷泽',
'安柏',
'温迪',
'香菱',
'北斗',
'行秋',
'',
'凝光',
'可莉',
'钟离',
'菲谢尔',
'班尼特',
'达达利亚',
'诺艾尔',
'七七',
'重云',
'甘雨',
'阿贝多',
'迪奥娜',
'莫娜',
'刻晴',
'砂糖',
'辛焱',
'罗莎莉亚',
'胡桃',
'枫原万叶',
'烟绯',
'宵宫',
'托马',
'优菈',
'雷电将军',
'早柚',
'珊瑚宫心海',
'五郎',
'九条裟罗',
'荒泷一斗',
'八重神子',
'鹿野院平藏',
'夜兰',
'埃洛伊',
'申鹤',
'云堇',
'久岐忍',
'神里绫人',
'柯莱',
'多莉',
'提纳里',
'妮露',
'赛诺',
'坎蒂丝',
'纳西妲',
'莱依拉',
'流浪者',
'珐露珊',
'瑶瑶',
'艾尔海森',
'迪希雅',
'米卡',
'卡维',
'白术',
]
type = [ type = [
'基础血量', '基础血量',
'基础攻击力', '基础攻击力',
@ -116,37 +74,15 @@ class Genshin(Base):
'治疗加成', '治疗加成',
] ]
def __init__(self):
self.get_data_from_file(genshin_avatars_path)
def refresh(self):
self.get_data_from_api(genshin_api)
self.save_data_to_file(genshin_avatars_path)
class Starrail(Base): class Starrail(Base):
character = [
'开拓者·毁灭',
'开拓者·存护',
'三月七',
'丹恒',
'姬子',
'瓦尔特',
'卡芙卡',
'银狼',
'阿兰',
'艾丝妲',
'黑塔',
'布洛妮娅',
'希儿',
'希露瓦',
'杰帕德',
'娜塔莎',
'佩拉',
'克拉拉',
'桑博',
'虎克',
'青雀',
'停云',
'罗刹',
'景元',
'素裳',
'彦卿',
'白露',
]
type = [ type = [
"攻击力百分比", "攻击力百分比",
"攻击力", "攻击力",
@ -171,6 +107,14 @@ class Starrail(Base):
"风属性伤害提高百分比", "风属性伤害提高百分比",
] ]
def __init__(self):
self.get_data_from_file(starrail_avatars_path)
def refresh(self):
self.get_data_from_api(starrail_api, "800")
self.character.extend(['开拓者·毁灭', '开拓者·存护', ])
self.save_data_to_file(starrail_avatars_path)
class Core: class Core:
def __init__(self, path: Path, model: Base): def __init__(self, path: Path, model: Base):