1
0
mirror of synced 2024-11-24 05:30:11 +01:00

Fix PyCharm code inspection warnings

This commit is contained in:
Viv 2023-07-30 19:20:39 -04:00
parent 300a58eb14
commit ade127b026
3 changed files with 23 additions and 10 deletions

View File

@ -61,6 +61,9 @@ def process_tja_commands(tja: TJACourse) \
branch_cond = (float(val1), float(val2))
elif branch_type == 'p': # p = Percentage
branch_cond = (float(val1)/100, float(val2)/100)
else:
raise ValueError(f"Invalid #BRANCHSTART type: "
f"'{branch_type}'.")
measure_tja_processed.branch_type = branch_type
measure_tja_processed.branch_cond = branch_cond
elif data.name == 'section':
@ -96,7 +99,8 @@ def process_tja_commands(tja: TJACourse) \
# - Case 1: Command happens at the start of a measure;
# just change the value directly
if data.pos == 0:
setattr(measure_tja_processed, data.name, new_val)
setattr(measure_tja_processed, data.name,
new_val) # noqa: new_val will always be set
# - Case 2: Command happens in the middle of a measure;
# start a new sub-measure
else:
@ -361,11 +365,15 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
# If song has only drumroll branching conditions (also allowing percentage
# conditions that force a level up/level down), then set the header bytes
# so that only drumrolls contribute to branching.
drumroll_only = branch_types and branch_conditions and all(
(branch_type == 'r') or
(branch_type == 'p' and cond[0] == 0.0 and cond[1] == 0.0) or
(branch_type == 'p' and cond[0] > 1.00 and cond[1] > 1.00)
for branch_type, cond in zip(branch_types, branch_conditions)
drumroll_only = (
branch_types # noqa: branch_types will always be set
and branch_conditions # noqa: branch_conditions will always be set
and all(
(branch_type == 'r') or
(branch_type == 'p' and cond[0] == 0.0 and cond[1] == 0.0) or
(branch_type == 'p' and cond[0] > 1.00 and cond[1] > 1.00)
for branch_type, cond in zip(branch_types, branch_conditions)
)
)
if drumroll_only:
fumen.header.b468_b471_branch_pts_good = 0
@ -377,9 +385,12 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
# Alternatively, if the song has only percentage-based conditions, then set
# the header bytes so that only notes and balloons contribute to branching.
percentage_only = branch_types and all(
(branch_type != 'r')
for branch_type in branch_types
percentage_only = (
branch_types # noqa: branch_types will always be set
and all(
(branch_type != 'r')
for branch_type in branch_types
)
)
if percentage_only:
fumen.header.b480_b483_branch_pts_drumroll = 0

View File

@ -226,6 +226,7 @@ def parse_tja_course_data(course: TJACourse) -> None:
'DELAY', 'SCROLL', 'BPMCHANGE', 'MEASURE',
'LEVELHOLD', 'SECTION', 'BRANCHSTART']:
# Get position of the event
pos = 0
for branch_name in (course.branches.keys()
if current_branch == 'all'
else [current_branch]):

View File

@ -42,7 +42,8 @@ def write_fumen(path_out: str, song: FumenCourse) -> None:
extra_vals = [note.hits, note.hits_padding]
else:
extra_vals = [note.score_init, note.score_diff * 4]
note_struct.extend(extra_vals + [note.duration])
note_struct.extend(extra_vals)
note_struct.append(note.duration)
write_struct(file, song.header.order,
format_string="ififHHf",
value_list=note_struct)