From 2571e5bf307fbb6302dc1f91879167e8310a4db0 Mon Sep 17 00:00:00 2001 From: Rosemoe <2073412493@qq.com> Date: Wed, 11 Sep 2024 14:54:18 +0800 Subject: [PATCH] fix: `get_total_combo_before` does not consider `Arc` note in timing groups --- ArcaeaChartRender/element.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ArcaeaChartRender/element.py b/ArcaeaChartRender/element.py index 792a66a..ab36443 100644 --- a/ArcaeaChartRender/element.py +++ b/ArcaeaChartRender/element.py @@ -60,10 +60,11 @@ def __init__(self, header_dict: dict, command_list: list['Command']): self.density_factor = float(self.header_dict.get(AffToken.Keyword.timing_point_density_factor, 1.0)) # cache these lists for calculate combo self._connected_arc_list = self._get_connected_arc_list() - self._hold_list = list(self.get_command_list_for_type(Hold, True, True)) - self._tap_list = list(self.get_command_list_for_type(Tap, True, True)) - self._arctap_list = list(self.get_command_list_for_type(ArcTap, True, True)) - self._flick_list = list(self.get_command_list_for_type(Flick, True, True)) + self._hold_list = list(self.get_command_list_for_type(Hold, False, True)) + self._tap_list = list(self.get_command_list_for_type(Tap, False, True)) + self._arctap_list = list(self.get_command_list_for_type(ArcTap, False, True)) + self._flick_list = list(self.get_command_list_for_type(Flick, False, True)) + self._timing_group_list = list(self.get_command_list_for_type(TimingGroup, False, True)) def _get_note_bpm(self, note: 'Note') -> 'Timing': """Returns which bpm (Timing) interval the note is in.""" @@ -194,17 +195,21 @@ def get_combo_of(self, type_: Type['Note']): def get_total_combo_before(self, t: int) -> int: """Return the total combo before given time.""" result = 0 - # single note + # single note in current group result += sum( note.get_interval()[0] <= t - 25 - for note in chain(self._tap_list, self._arctap_list, self._flick_list) + for note in chain(self._tap_list,self._arctap_list, self._flick_list) ) - # long note + # long note in current group result += sum( (min(t, note.t2) - note.t1) / (note.t2 - note.t1) * self.get_long_note_combo([note]) for note in chain(self._hold_list, self._connected_arc_list) if t > note.t1 != note.t2 ) + # note in subgroup + result += sum( + group.get_total_combo_before(t) for group in self._timing_group_list + ) return int(result) @@ -602,6 +607,13 @@ def get_combo_of(self, type_: Type['Note']): Return 0 if 'type_list' contains 'noinput'. """ return 0 if 'noinput' in self.type_list else super().get_combo_of(type_) + + def get_total_combo_before(self, t: int) -> int: + """ + Return the total combo before given time. + Return 0 if 'type_list' contains 'noinput'. + """ + return 0 if 'noinput' in self.type_list else super().get_total_combo_before(t) def get_command_list_for_type( self,