Spaces:
Runtime error
Runtime error
ango
commited on
Commit
·
d26e0de
1
Parent(s):
c145eab
5.15 commit
Browse files- gr/app.py → app.py +0 -0
- gr/components/combat.py +6 -5
- gr/components/equipments.py +4 -4
- gr/scripts/combat.py +53 -45
- gr/scripts/top.py +2 -1
- utils/analyzer.py +5 -2
- utils/parser.py +1 -1
gr/app.py → app.py
RENAMED
File without changes
|
gr/components/combat.py
CHANGED
@@ -13,20 +13,21 @@ class CombatComponent:
|
|
13 |
|
14 |
with gr.Tab("属性"):
|
15 |
with gr.Row():
|
16 |
-
self.init_attribute = gr.Textbox("初始属性")
|
17 |
-
self.final_attribute = gr.Textbox("增益后属性")
|
18 |
with gr.Tab("伤害总结"):
|
|
|
19 |
self.skill_select = gr.Dropdown(label="选择技能")
|
20 |
self.status_select = gr.Dropdown(label="选择增益")
|
21 |
with gr.Row():
|
22 |
self.damage_detail = gr.Textbox(label="伤害细节")
|
23 |
-
self.
|
24 |
with gr.Tab("战斗统计"):
|
25 |
with gr.Row():
|
26 |
self.summary = gr.DataFrame(label="战斗总结", headers=["技能/次数", "命中/%", "会心/%", "伤害/%"], scale=3)
|
27 |
with gr.Column(scale=1):
|
28 |
-
self.dps = gr.Textbox("每秒伤害")
|
29 |
-
self.gradient = gr.Textbox("属性收益")
|
30 |
|
31 |
|
32 |
|
|
|
13 |
|
14 |
with gr.Tab("属性"):
|
15 |
with gr.Row():
|
16 |
+
self.init_attribute = gr.Textbox(label="初始属性")
|
17 |
+
self.final_attribute = gr.Textbox(label="增益后属性")
|
18 |
with gr.Tab("伤害总结"):
|
19 |
+
self.details = gr.State({})
|
20 |
self.skill_select = gr.Dropdown(label="选择技能")
|
21 |
self.status_select = gr.Dropdown(label="选择增益")
|
22 |
with gr.Row():
|
23 |
self.damage_detail = gr.Textbox(label="伤害细节")
|
24 |
+
self.damage_gradient = gr.Textbox(label="属性收益")
|
25 |
with gr.Tab("战斗统计"):
|
26 |
with gr.Row():
|
27 |
self.summary = gr.DataFrame(label="战斗总结", headers=["技能/次数", "命中/%", "会心/%", "伤害/%"], scale=3)
|
28 |
with gr.Column(scale=1):
|
29 |
+
self.dps = gr.Textbox(label="每秒伤害")
|
30 |
+
self.gradient = gr.Textbox(label="属性收益", lines=10)
|
31 |
|
32 |
|
33 |
|
gr/components/equipments.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import json
|
2 |
import os
|
3 |
|
4 |
-
from assets.constant import POSITION_MAP, STONES_POSITIONS, EQUIPMENTS_DIR, ENCHANTS_DIR, STONES_DIR, MAX_STONE_ATTR
|
5 |
-
|
6 |
-
from assets.constant import
|
7 |
import gradio as gr
|
8 |
|
9 |
|
@@ -30,7 +30,7 @@ class EquipmentComponent:
|
|
30 |
self.special_enchant = gr.Checkbox(label="大附魔")
|
31 |
|
32 |
with gr.Row():
|
33 |
-
self.strength_level = gr.Dropdown(label="精炼等级")
|
34 |
|
35 |
self.embed_levels = []
|
36 |
for i in range(EMBED_POSITIONS[self.position]):
|
|
|
1 |
import json
|
2 |
import os
|
3 |
|
4 |
+
from assets.constant import POSITION_MAP, STONES_POSITIONS, EQUIPMENTS_DIR, ENCHANTS_DIR, STONES_DIR, MAX_STONE_ATTR
|
5 |
+
from assets.constant import EMBED_POSITIONS, MAX_STRENGTH_LEVEL, MAX_EMBED_LEVEL, MAX_STONE_LEVEL
|
6 |
+
from assets.constant import SPECIAL_ENCHANT_POSITIONS
|
7 |
import gradio as gr
|
8 |
|
9 |
|
|
|
30 |
self.special_enchant = gr.Checkbox(label="大附魔")
|
31 |
|
32 |
with gr.Row():
|
33 |
+
self.strength_level = gr.Dropdown(choices=list(range(MAX_STRENGTH_LEVEL + 1)), label="精炼等级")
|
34 |
|
35 |
self.embed_levels = []
|
36 |
for i in range(EMBED_POSITIONS[self.position]):
|
gr/scripts/combat.py
CHANGED
@@ -20,10 +20,10 @@ def attribute_content(display_attrs, attribute):
|
|
20 |
for attr, name in display_attrs.items():
|
21 |
value = getattr(attribute, attr)
|
22 |
if isinstance(value, int):
|
23 |
-
content.append(
|
24 |
else:
|
25 |
-
content.append(
|
26 |
-
return content
|
27 |
|
28 |
|
29 |
def summary_content(summary: Dict[str, Detail], total_damage):
|
@@ -51,16 +51,18 @@ def gradient_content(gradients, total_damage):
|
|
51 |
|
52 |
|
53 |
def detail_content(detail: Detail):
|
54 |
-
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"
|
60 |
-
"
|
61 |
])
|
62 |
|
63 |
-
|
|
|
|
|
64 |
|
65 |
|
66 |
def combat_script(
|
@@ -69,7 +71,7 @@ def combat_script(
|
|
69 |
# consumables: Consumables, bonuses: Bonuses
|
70 |
combat_component: CombatComponent,
|
71 |
):
|
72 |
-
def formulate(target_level, duration):
|
73 |
combat_update = {}
|
74 |
record = parser.current_records
|
75 |
school = parser.current_school
|
@@ -107,45 +109,51 @@ def combat_script(
|
|
107 |
combat_update[combat_component.dps] = gr.update(value=round(total.expected_damage / duration))
|
108 |
|
109 |
combat_update[combat_component.gradient] = gradient_content(total.gradients, total.expected_damage)
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
combat_update[combat_component.summary] = summary_content(summary, total.expected_damage)
|
115 |
return combat_update
|
116 |
|
117 |
combat_component.formulate.click(
|
118 |
formulate,
|
119 |
-
[combat_component.target_level, combat_component.combat_duration
|
|
|
120 |
[combat_component.init_attribute, combat_component.final_attribute,
|
121 |
-
combat_component.dps, combat_component.gradient, combat_component.summary
|
|
|
|
|
|
|
122 |
)
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
# detail_widget.damage_detail.set_content(damage_content)
|
146 |
-
# detail_widget.gradient_detail.set_content(gradient_content)
|
147 |
-
# else:
|
148 |
-
# detail_widget.damage_detail.table.clear()
|
149 |
-
# detail_widget.gradient_detail.table.clear()
|
150 |
-
#
|
151 |
-
# dashboard_widget.detail_widget.status_combo.combo_box.currentTextChanged.connect(set_detail)
|
|
|
20 |
for attr, name in display_attrs.items():
|
21 |
value = getattr(attribute, attr)
|
22 |
if isinstance(value, int):
|
23 |
+
content.append(name.ljust(10, FULL_SPACE) + str(value))
|
24 |
else:
|
25 |
+
content.append(name.ljust(10, FULL_SPACE) + f"{round(value * 100, 2)}%")
|
26 |
+
return "\n".join(content)
|
27 |
|
28 |
|
29 |
def summary_content(summary: Dict[str, Detail], total_damage):
|
|
|
51 |
|
52 |
|
53 |
def detail_content(detail: Detail):
|
54 |
+
damage_detail = "\n".join([
|
55 |
+
"命中伤害".ljust(10) + f"{round(detail.damage)}",
|
56 |
+
"会心伤害".ljust(10) + f"{round(detail.critical_damage)}",
|
57 |
+
"期望伤害".ljust(10) + f"{round(detail.expected_damage)}",
|
58 |
+
"期望会心".ljust(10) + f"{round(detail.critical_strike * 100, 2)}%",
|
59 |
+
"实际会心".ljust(10) + f"{round(detail.actual_critical_strike * 100, 2)}%",
|
60 |
+
"统计数量".ljust(10) + f"{detail.count}"
|
61 |
])
|
62 |
|
63 |
+
damage_gradient = gradient_content(detail.gradients, detail.expected_damage)
|
64 |
+
|
65 |
+
return damage_detail, damage_gradient
|
66 |
|
67 |
|
68 |
def combat_script(
|
|
|
71 |
# consumables: Consumables, bonuses: Bonuses
|
72 |
combat_component: CombatComponent,
|
73 |
):
|
74 |
+
def formulate(target_level, duration, skill, status):
|
75 |
combat_update = {}
|
76 |
record = parser.current_records
|
77 |
school = parser.current_school
|
|
|
109 |
combat_update[combat_component.dps] = gr.update(value=round(total.expected_damage / duration))
|
110 |
|
111 |
combat_update[combat_component.gradient] = gradient_content(total.gradients, total.expected_damage)
|
112 |
+
|
113 |
+
combat_update[combat_component.details] = details
|
114 |
+
combat_update[combat_component.skill_select] = gr.update(choices=list(details))
|
115 |
+
if skill_detail := details.get(skill, {}):
|
116 |
+
combat_update[combat_component.status_select] = gr.update(choices=[""] + list(skill_detail))
|
117 |
+
if detail := skill_detail.get(status):
|
118 |
+
damage_detail, damage_gradient = detail_content(detail)
|
119 |
+
combat_update[combat_component.damage_detail] = gr.update(value=damage_detail)
|
120 |
+
combat_update[combat_component.damage_gradient] = gr.update(value=damage_gradient)
|
121 |
+
else:
|
122 |
+
combat_update[combat_component.damage_detail] = gr.update(value="")
|
123 |
+
combat_update[combat_component.damage_gradient] = gr.update(value="")
|
124 |
|
125 |
combat_update[combat_component.summary] = summary_content(summary, total.expected_damage)
|
126 |
return combat_update
|
127 |
|
128 |
combat_component.formulate.click(
|
129 |
formulate,
|
130 |
+
[combat_component.target_level, combat_component.combat_duration,
|
131 |
+
combat_component.skill_select, combat_component.status_select],
|
132 |
[combat_component.init_attribute, combat_component.final_attribute,
|
133 |
+
combat_component.dps, combat_component.gradient, combat_component.summary,
|
134 |
+
combat_component.details, combat_component.skill_select, combat_component.status_select,
|
135 |
+
combat_component.damage_detail, combat_component.damage_gradient
|
136 |
+
]
|
137 |
)
|
138 |
|
139 |
+
def skill_changed(skill, details):
|
140 |
+
if skill not in details:
|
141 |
+
return None
|
142 |
+
return gr.update(choices=[""] + list(details[skill]))
|
143 |
+
|
144 |
+
combat_component.skill_select.change(
|
145 |
+
skill_changed, [combat_component.skill_select, combat_component.details], combat_component.status_select
|
146 |
+
)
|
147 |
+
|
148 |
+
def status_changed(skill, status, details):
|
149 |
+
if skill not in details:
|
150 |
+
return None, None
|
151 |
+
if status not in details[skill]:
|
152 |
+
return None, None
|
153 |
+
damage_detail, damage_gradient = detail_content(details[skill][status])
|
154 |
+
return gr.update(value=damage_detail), gr.update(value=damage_gradient)
|
155 |
+
|
156 |
+
combat_component.status_select.change(
|
157 |
+
status_changed, [combat_component.skill_select, combat_component.status_select, combat_component.details],
|
158 |
+
[combat_component.damage_detail, combat_component.damage_gradient]
|
159 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gr/scripts/top.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import json
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
@@ -59,7 +60,7 @@ def top_script(
|
|
59 |
return [None] * 4
|
60 |
result = json.load(open(file_path, encoding="utf-8"))
|
61 |
|
62 |
-
file_name = result['file_name'].split(".jcl")[0] + ".json"
|
63 |
json.dump(result, open(file_name, "w", encoding="utf-8"), ensure_ascii=False)
|
64 |
|
65 |
result['records'] = unserialize(result['records'])
|
|
|
1 |
import json
|
2 |
+
import os
|
3 |
|
4 |
import gradio as gr
|
5 |
|
|
|
60 |
return [None] * 4
|
61 |
result = json.load(open(file_path, encoding="utf-8"))
|
62 |
|
63 |
+
file_name = os.path.basename(result['file_name']).split(".jcl")[0] + ".json"
|
64 |
json.dump(result, open(file_name, "w", encoding="utf-8"), ensure_ascii=False)
|
65 |
|
66 |
result['records'] = unserialize(result['records'])
|
utils/analyzer.py
CHANGED
@@ -127,8 +127,11 @@ def analyze_details(record, duration: int, attribute: Attribute, school: School)
|
|
127 |
|
128 |
buffs = add_buffs(current_buffs, snapshot_buffs, target_buffs, attribute, skill)
|
129 |
buffs = concat_buffs(buffs)
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
sub_buffs(current_buffs, snapshot_buffs, target_buffs, attribute, skill)
|
133 |
|
134 |
detail.critical_count += len(critical_timeline)
|
|
|
127 |
|
128 |
buffs = add_buffs(current_buffs, snapshot_buffs, target_buffs, attribute, skill)
|
129 |
buffs = concat_buffs(buffs)
|
130 |
+
if buffs in skill_detail:
|
131 |
+
detail = skill_detail[buffs]
|
132 |
+
else:
|
133 |
+
detail = skill_detail[buffs] = Detail(*skill(attribute))
|
134 |
+
detail.gradients = analyze_gradients(skill, attribute)
|
135 |
sub_buffs(current_buffs, snapshot_buffs, target_buffs, attribute, skill)
|
136 |
|
137 |
detail.critical_count += len(critical_timeline)
|
utils/parser.py
CHANGED
@@ -418,7 +418,7 @@ class Parser(BaseParser):
|
|
418 |
def __call__(self, file_name):
|
419 |
self.file_name = os.path.basename(file_name)
|
420 |
self.reset()
|
421 |
-
lines = open(file_name).readlines()
|
422 |
rows = []
|
423 |
for line in lines:
|
424 |
row = line.split("\t")
|
|
|
418 |
def __call__(self, file_name):
|
419 |
self.file_name = os.path.basename(file_name)
|
420 |
self.reset()
|
421 |
+
lines = open(file_name, encoding="gbk").readlines()
|
422 |
rows = []
|
423 |
for line in lines:
|
424 |
row = line.split("\t")
|