fix knight of nights and battle no 1

This commit is contained in:
Anthony Samms
2025-11-13 15:07:03 -05:00
parent 9fe356cde7
commit 5d65f721ad
4 changed files with 44 additions and 68 deletions

View File

@@ -649,65 +649,41 @@ class TJAParser:
branch_balloon_count = count
branch_params = part[13:]
if branch_params[0] == 'r':
# Helper function to find and set drumroll branch params
def set_drumroll_branch_params(note_list, bar_list):
for i in range(len(note_list)-1, -1, -1):
if 5 <= note_list[i].type <= 7 or note_list[i].type == 9:
drumroll_ms = note_list[i].hit_ms
for bar_idx in range(len(bar_list)-1, -1, -1):
if bar_list[bar_idx].hit_ms <= drumroll_ms:
bar_list[bar_idx].branch_params = branch_params
return True
break
return False
def set_branch_params(bar_list: list[Note], branch_params: str, section_bar: Optional[Note]):
if bar_list and len(bar_list) > 1:
section_index = -2
if section_bar and section_bar.hit_ms < self.current_ms:
if section_bar in bar_list:
section_index = bar_list.index(section_bar)
bar_list[section_index].branch_params = branch_params
elif bar_list:
section_index = -1
bar_list[section_index].branch_params = branch_params
elif bar_list == []:
bar_line = Note()
bar_line.pixels_per_frame_x = get_pixels_per_frame(bpm * time_signature * x_scroll_modifier, time_signature*4, self.distance)
bar_line.pixels_per_frame_y = get_pixels_per_frame(bpm * time_signature * y_scroll_modifier, time_signature*4, self.distance)
pixels_per_ms = get_pixels_per_ms(bar_line.pixels_per_frame_x)
# Always try to set in master notes
set_drumroll_branch_params(master_notes.play_notes, master_notes.bars)
bar_line.hit_ms = self.current_ms
if pixels_per_ms == 0:
bar_line.load_ms = bar_line.hit_ms
else:
bar_line.load_ms = bar_line.hit_ms - (self.distance / pixels_per_ms)
bar_line.type = 0
bar_line.display = False
bar_line.gogo_time = gogo_time
bar_line.bpm = bpm
bar_line.branch_params = branch_params
bar_list.append(bar_line)
# If we have existing branches, also apply to them
if branch_m and len(branch_m) > 0:
set_drumroll_branch_params(branch_m[-1].play_notes, branch_m[-1].bars)
if branch_e and len(branch_e) > 0:
set_drumroll_branch_params(branch_e[-1].play_notes, branch_e[-1].bars)
if branch_n and len(branch_n) > 0:
set_drumroll_branch_params(branch_n[-1].play_notes, branch_n[-1].bars)
else:
def set_branch_params(bar_list: list[Note], branch_params: str, section_bar: Optional[Note]):
if bar_list and len(bar_list) > 1:
section_index = -2
if section_bar and section_bar.hit_ms < self.current_ms:
if section_bar in bar_list:
section_index = bar_list.index(section_bar)
bar_list[section_index].branch_params = branch_params
elif bar_list:
section_index = -1
bar_list[section_index].branch_params = branch_params
elif bar_list == []:
bar_line = Note()
bar_line.pixels_per_frame_x = get_pixels_per_frame(bpm * time_signature * x_scroll_modifier, time_signature*4, self.distance)
bar_line.pixels_per_frame_y = get_pixels_per_frame(bpm * time_signature * y_scroll_modifier, time_signature*4, self.distance)
pixels_per_ms = get_pixels_per_ms(bar_line.pixels_per_frame_x)
bar_line.hit_ms = self.current_ms
if pixels_per_ms == 0:
bar_line.load_ms = bar_line.hit_ms
else:
bar_line.load_ms = bar_line.hit_ms - (self.distance / pixels_per_ms)
bar_line.type = 0
bar_line.display = False
bar_line.gogo_time = gogo_time
bar_line.bpm = bpm
bar_line.branch_params = branch_params
bar_list.append(bar_line)
for bars in [curr_bar_list,
branch_m[-1].bars if branch_m else None,
branch_e[-1].bars if branch_e else None,
branch_n[-1].bars if branch_n else None]:
set_branch_params(bars, branch_params, section_bar)
if section_bar:
section_bar = None
for bars in [curr_bar_list,
branch_m[-1].bars if branch_m else None,
branch_e[-1].bars if branch_e else None,
branch_n[-1].bars if branch_n else None]:
set_branch_params(bars, branch_params, section_bar)
if section_bar:
section_bar = None
continue
elif part.startswith('#BRANCHEND'):
curr_note_list = master_notes.play_notes

View File

@@ -499,7 +499,7 @@ class BoxManager:
def update(self, current_time_ms: float, is_2p: bool):
self.is_2p = is_2p
if self.is_2p:
self.box_locations = ["SONG_SELECT_2P", "SETTINGS"]
self.box_locations = ["SONG_SELECT_2P", "PRACTICE_SELECT", "SETTINGS"]
for i, box in enumerate(self.boxes):
box.location = self.box_locations[i]
self.fade_out.update(current_time_ms)

View File

@@ -416,14 +416,13 @@ class Player:
self.play_notes = deque(sorted(self.play_notes))
self.draw_note_list = deque(sorted(self.draw_note_list, key=lambda x: x.load_ms))
self.draw_bar_list = deque(sorted(self.draw_bar_list, key=lambda x: x.load_ms))
timing_threshold = current_ms - Player.TIMING_BAD
total_don = [note for note in self.play_notes if note.type in {1, 3}]
total_kat = [note for note in self.play_notes if note.type in {2, 4}]
total_other = [note for note in self.play_notes if note.type not in {1, 2, 3, 4}]
self.don_notes = deque([note for note in total_don if note.hit_ms > timing_threshold])
self.kat_notes = deque([note for note in total_kat if note.hit_ms > timing_threshold])
self.other_notes = deque([note for note in total_other if note.hit_ms > timing_threshold])
self.don_notes = deque([note for note in total_don if note.hit_ms > current_ms])
self.kat_notes = deque([note for note in total_kat if note.hit_ms > current_ms])
self.other_notes = deque([note for note in total_other if note.hit_ms > current_ms])
def get_result_score(self):
"""Returns the score, good count, ok count, bad count, max combo, and total drumroll"""
@@ -485,11 +484,10 @@ class Player:
end_roll = -1
note_lists = [
self.current_notes_draw,
self.branch_n[0].draw_notes if self.branch_n else [],
self.branch_e[0].draw_notes if self.branch_e else [],
self.branch_m[0].draw_notes if self.branch_m else [],
self.draw_note_list if self.draw_note_list else []
self.other_notes,
self.branch_m[0].play_notes if self.branch_m else [],
self.branch_e[0].play_notes if self.branch_e else [],
self.branch_n[0].play_notes if self.branch_n else [],
]
end_roll = -1
@@ -897,7 +895,8 @@ class Player:
self.branch_indicator.level_down('normal')
self.branch_m.pop(0)
self.branch_e.pop(0)
logger.info(f"Branch set to {self.branch_indicator.difficulty} based on conditions {self.branch_condition_count}, {e_req, m_req}")
if self.branch_indicator is not None:
logger.info(f"Branch set to {self.branch_indicator.difficulty} based on conditions {self.branch_condition_count}, {e_req, m_req}")
self.branch_condition_count = 0
def update(self, ms_from_start: float, current_time: float, background: Optional[Background]):

View File

@@ -256,6 +256,7 @@ class PracticeGameScreen(GameScreen):
tex.draw_texture('practice', 'playing', index=int(self.player_1.player_number)-1, fade=0.5)
tex.draw_texture('practice', 'progress_bar_bg')
if self.paused:
tex.draw_texture('practice', 'paused', fade=0.5)
progress = min((self.scrobble_time + self.scrobble_move.attribute - self.bars[0].hit_ms) / self.player_1.end_time, 1)
else:
progress = min(self.current_ms / self.player_1.end_time, 1)