Skip to content

Commit a3ab558

Browse files
committed
每个角色增加元素属性, 增加协奏判断准确度
1 parent 58e47e2 commit a3ab558

File tree

3 files changed

+56
-39
lines changed

3 files changed

+56
-39
lines changed

src/char/BaseChar.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ class Role(StrEnum):
3030
HEALER = 'Healer' # 治疗者
3131

3232

33+
class Elements(IntEnum):
34+
SPECTRO = 0
35+
ELECTRIC = 1
36+
FIRE = 2
37+
ICE = 3
38+
WIND = 4
39+
HAVOC = 5
40+
41+
3342
role_values = [role for role in Role] # 角色定位枚举值的列表
3443

3544
char_lib_check_marks = ['char_1_lib_check_mark', 'char_2_lib_check_mark',
@@ -39,7 +48,8 @@ class Role(StrEnum):
3948
class BaseChar:
4049
"""角色基类,定义了游戏角色的通用属性和行为。"""
4150

42-
def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_name=None, confidence=1):
51+
def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_name=None, confidence=1,
52+
ring_index=-1):
4353
"""初始化角色基础属性。
4454
4555
Args:
@@ -57,7 +67,7 @@ def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_na
5767
self.sleep_adjust = 0
5868
self.char_name = char_name
5969
self.index = index
60-
self.ring_index = -1 # for con check
70+
self.ring_index = ring_index # for con check
6171
self.last_switch_time = -1
6272
self.last_res = -1
6373
self.last_echo = -1

src/char/CharFactory.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from src.char.Baizhi import Baizhi
2-
from src.char.BaseChar import BaseChar
2+
from src.char.BaseChar import BaseChar, Elements
33
from src.char.Brant import Brant
44
from src.char.Calcharo import Calcharo
55
from src.char.Camellya import Camellya
@@ -30,37 +30,38 @@
3030
from src.char.Zhezhi import Zhezhi
3131

3232
char_dict = {
33-
'char_yinlin': {'cls': Yinlin, 'res_cd': 12, 'echo_cd': 25},
34-
'char_verina': {'cls': Verina, 'res_cd': 12, 'echo_cd': 25},
35-
'char_shorekeeper': {'cls': ShoreKeeper, 'res_cd': 15, 'echo_cd': 25},
36-
'char_taoqi': {'cls': Taoqi, 'res_cd': 15, 'echo_cd': 25},
33+
'char_yinlin': {'cls': Yinlin, 'res_cd': 12, 'echo_cd': 25, 'ring_index': Elements.ELECTRIC},
34+
'char_verina': {'cls': Verina, 'res_cd': 12, 'echo_cd': 25, 'ring_index': Elements.SPECTRO},
35+
'char_shorekeeper': {'cls': ShoreKeeper, 'res_cd': 15, 'echo_cd': 25, 'ring_index': Elements.SPECTRO},
36+
'char_taoqi': {'cls': Taoqi, 'res_cd': 15, 'echo_cd': 25, 'ring_index': Elements.HAVOC},
3737
'char_rover': {'cls': HavocRover, 'res_cd': 12, 'echo_cd': 25},
3838
'char_rover_male': {'cls': HavocRover, 'res_cd': 12, 'echo_cd': 25},
39-
'char_encore': {'cls': Encore, 'res_cd': 10, 'echo_cd': 25},
40-
'char_jianxin': {'cls': Jianxin, 'res_cd': 12, 'echo_cd': 25},
41-
'char_sanhua': {'cls': Sanhua, 'res_cd': 10, 'echo_cd': 25},
42-
'char_sanhua2': {'cls': Sanhua, 'res_cd': 10, 'echo_cd': 25},
43-
'char_jinhsi': {'cls': Jinhsi, 'res_cd': 3, 'echo_cd': 25},
44-
'char_jinhsi2': {'cls': Jinhsi, 'res_cd': 3, 'echo_cd': 25},
45-
'char_yuanwu': {'cls': Yuanwu, 'res_cd': 3, 'echo_cd': 25},
46-
'chang_changli': {'cls': Changli, 'res_cd': 12, 'echo_cd': 25},
47-
'char_chixia': {'cls': Chixia, 'res_cd': 9, 'echo_cd': 25},
48-
'char_danjin': {'cls': Danjin, 'res_cd': 9999999, 'echo_cd': 25},
49-
'char_baizhi': {'cls': Baizhi, 'res_cd': 16, 'echo_cd': 25},
50-
'char_calcharo': {'cls': Calcharo, 'res_cd': 99999, 'echo_cd': 25},
51-
'char_jiyan': {'cls': Jiyan, 'res_cd': 16, 'echo_cd': 25},
52-
'char_mortefi': {'cls': Mortefi, 'res_cd': 14, 'echo_cd': 25},
53-
'char_zhezhi': {'cls': Zhezhi, 'res_cd': 6, 'echo_cd': 25},
54-
'char_xiangliyao': {'cls': Xiangliyao, 'res_cd': 5, 'echo_cd': 25},
55-
'char_camellya': {'cls': Camellya, 'res_cd': 4, 'echo_cd': 25},
56-
'char_youhu': {'cls': Youhu, 'res_cd': 4, 'echo_cd': 25},
57-
'char_carlotta': {'cls': Carlotta, 'res_cd': 10, 'echo_cd': 25},
58-
'char_roccia': {'cls': Roccia, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 20},
59-
'char_phoebe': {'cls': Phoebe, 'res_cd': 12, 'echo_cd': 25, 'liberation_cd': 25},
60-
'char_brant': {'cls': Brant, 'res_cd': 4, 'echo_cd': 25, 'liberation_cd': 24},
61-
'char_cantarella': {'cls': Cantarella, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 25},
62-
'char_zani': {'cls': Zani, 'res_cd': 14, 'echo_cd': 25},
63-
'char_ciaccona': {'cls': Ciaccona, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 20},
39+
'char_encore': {'cls': Encore, 'res_cd': 10, 'echo_cd': 25, 'ring_index': Elements.FIRE},
40+
'char_jianxin': {'cls': Jianxin, 'res_cd': 12, 'echo_cd': 25, 'ring_index': Elements.WIND},
41+
'char_sanhua': {'cls': Sanhua, 'res_cd': 10, 'echo_cd': 25, 'ring_index': Elements.ICE},
42+
'char_sanhua2': {'cls': Sanhua, 'res_cd': 10, 'echo_cd': 25, 'ring_index': Elements.ICE},
43+
'char_jinhsi': {'cls': Jinhsi, 'res_cd': 3, 'echo_cd': 25, 'ring_index': Elements.SPECTRO},
44+
'char_jinhsi2': {'cls': Jinhsi, 'res_cd': 3, 'echo_cd': 25, 'ring_index': Elements.SPECTRO},
45+
'char_yuanwu': {'cls': Yuanwu, 'res_cd': 3, 'echo_cd': 25, 'ring_index': Elements.ELECTRIC},
46+
'chang_changli': {'cls': Changli, 'res_cd': 12, 'echo_cd': 25, 'ring_index': Elements.FIRE},
47+
'char_chixia': {'cls': Chixia, 'res_cd': 9, 'echo_cd': 25, 'ring_index': Elements.FIRE},
48+
'char_danjin': {'cls': Danjin, 'res_cd': 9999999, 'echo_cd': 25, 'ring_index': Elements.HAVOC},
49+
'char_baizhi': {'cls': Baizhi, 'res_cd': 16, 'echo_cd': 25, 'ring_index': Elements.ICE},
50+
'char_calcharo': {'cls': Calcharo, 'res_cd': 99999, 'echo_cd': 25, 'ring_index': Elements.ELECTRIC},
51+
'char_jiyan': {'cls': Jiyan, 'res_cd': 16, 'echo_cd': 25, 'ring_index': Elements.WIND},
52+
'char_mortefi': {'cls': Mortefi, 'res_cd': 14, 'echo_cd': 25, 'ring_index': Elements.FIRE},
53+
'char_zhezhi': {'cls': Zhezhi, 'res_cd': 6, 'echo_cd': 25, 'ring_index': Elements.ICE},
54+
'char_xiangliyao': {'cls': Xiangliyao, 'res_cd': 5, 'echo_cd': 25, 'ring_index': Elements.ELECTRIC},
55+
'char_camellya': {'cls': Camellya, 'res_cd': 4, 'echo_cd': 25, 'ring_index': Elements.HAVOC},
56+
'char_youhu': {'cls': Youhu, 'res_cd': 4, 'echo_cd': 25, 'ring_index': Elements.ICE},
57+
'char_carlotta': {'cls': Carlotta, 'res_cd': 10, 'echo_cd': 25, 'ring_index': Elements.ICE},
58+
'char_roccia': {'cls': Roccia, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 20, 'ring_index': Elements.HAVOC},
59+
'char_phoebe': {'cls': Phoebe, 'res_cd': 12, 'echo_cd': 25, 'liberation_cd': 25, 'ring_index': Elements.SPECTRO},
60+
'char_brant': {'cls': Brant, 'res_cd': 4, 'echo_cd': 25, 'liberation_cd': 24, 'ring_index': Elements.FIRE},
61+
'char_cantarella': {'cls': Cantarella, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 25,
62+
'ring_index': Elements.HAVOC},
63+
'char_zani': {'cls': Zani, 'res_cd': 14, 'echo_cd': 25, 'ring_index': Elements.SPECTRO},
64+
'char_ciaccona': {'cls': Ciaccona, 'res_cd': 10, 'echo_cd': 25, 'liberation_cd': 20, 'ring_index': Elements.WIND},
6465
}
6566

6667
char_names = char_dict.keys()
@@ -83,7 +84,7 @@ def get_char_by_pos(task, box, index, old_char):
8384
name = char.name
8485
cls = info.get('cls')
8586
return cls(task, index, info.get('res_cd'), info.get('echo_cd'), info.get('liberation_cd') or 25,
86-
char_name=name, confidence=char.confidence)
87+
char_name=name, confidence=char.confidence, ring_index=info.get('ring_index', -1))
8788
task.log_info(f'could not find char {index} {info} {highest_confidence}')
8889
if old_char:
8990
return old_char

src/task/BaseCombatTask.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,18 @@ def _ensure_ring_index(self):
568568
int: 协奏值环的颜色索引。
569569
"""
570570
if self.get_current_char().ring_index < 0:
571-
best = self.find_best_match_in_box(self.get_con_box(),
572-
con_templates, 0.1)
573-
if best:
574-
self.get_current_char().ring_index = con_templates.index(best.name)
575-
self.log_debug(
576-
f'_ensure_ring_index {self.get_current_char()} to {self.get_current_char().ring_index} {best.name}')
571+
box = self.get_con_box()
572+
573+
best_index = 0
574+
best_percentage = 0
575+
for i in range(len(con_colors)):
576+
percent = self.calculate_color_percentage(con_colors[i], box)
577+
if percent > best_percentage:
578+
best_percentage = percent
579+
best_index = i
580+
self.get_current_char().ring_index = best_index
581+
self.log_debug(
582+
f'_ensure_ring_index {self.get_current_char()} to {self.get_current_char().ring_index} {con_templates[best_index]}')
577583
return self.get_current_char().ring_index
578584

579585
def get_con_box(self):

0 commit comments

Comments
 (0)