Skip to content

Commit

Permalink
fix: get_total_combo_before does not consider Arc note in timing …
Browse files Browse the repository at this point in the history
…groups
  • Loading branch information
Rosemoe committed Sep 11, 2024
1 parent 55a2437 commit 2571e5b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions ArcaeaChartRender/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2571e5b

Please sign in to comment.