Fix PyCharm code inspection warnings
This commit is contained in:
parent
300a58eb14
commit
ade127b026
@ -61,6 +61,9 @@ def process_tja_commands(tja: TJACourse) \
|
|||||||
branch_cond = (float(val1), float(val2))
|
branch_cond = (float(val1), float(val2))
|
||||||
elif branch_type == 'p': # p = Percentage
|
elif branch_type == 'p': # p = Percentage
|
||||||
branch_cond = (float(val1)/100, float(val2)/100)
|
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_type = branch_type
|
||||||
measure_tja_processed.branch_cond = branch_cond
|
measure_tja_processed.branch_cond = branch_cond
|
||||||
elif data.name == 'section':
|
elif data.name == 'section':
|
||||||
@ -96,7 +99,8 @@ def process_tja_commands(tja: TJACourse) \
|
|||||||
# - Case 1: Command happens at the start of a measure;
|
# - Case 1: Command happens at the start of a measure;
|
||||||
# just change the value directly
|
# just change the value directly
|
||||||
if data.pos == 0:
|
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;
|
# - Case 2: Command happens in the middle of a measure;
|
||||||
# start a new sub-measure
|
# start a new sub-measure
|
||||||
else:
|
else:
|
||||||
@ -361,12 +365,16 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
|
|||||||
# If song has only drumroll branching conditions (also allowing percentage
|
# If song has only drumroll branching conditions (also allowing percentage
|
||||||
# conditions that force a level up/level down), then set the header bytes
|
# conditions that force a level up/level down), then set the header bytes
|
||||||
# so that only drumrolls contribute to branching.
|
# so that only drumrolls contribute to branching.
|
||||||
drumroll_only = branch_types and branch_conditions and all(
|
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 == 'r') or
|
||||||
(branch_type == 'p' and cond[0] == 0.0 and cond[1] == 0.0) 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)
|
(branch_type == 'p' and cond[0] > 1.00 and cond[1] > 1.00)
|
||||||
for branch_type, cond in zip(branch_types, branch_conditions)
|
for branch_type, cond in zip(branch_types, branch_conditions)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
if drumroll_only:
|
if drumroll_only:
|
||||||
fumen.header.b468_b471_branch_pts_good = 0
|
fumen.header.b468_b471_branch_pts_good = 0
|
||||||
fumen.header.b484_b487_branch_pts_good_big = 0
|
fumen.header.b484_b487_branch_pts_good_big = 0
|
||||||
@ -377,10 +385,13 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
|
|||||||
|
|
||||||
# Alternatively, if the song has only percentage-based conditions, then set
|
# Alternatively, if the song has only percentage-based conditions, then set
|
||||||
# the header bytes so that only notes and balloons contribute to branching.
|
# the header bytes so that only notes and balloons contribute to branching.
|
||||||
percentage_only = branch_types and all(
|
percentage_only = (
|
||||||
|
branch_types # noqa: branch_types will always be set
|
||||||
|
and all(
|
||||||
(branch_type != 'r')
|
(branch_type != 'r')
|
||||||
for branch_type in branch_types
|
for branch_type in branch_types
|
||||||
)
|
)
|
||||||
|
)
|
||||||
if percentage_only:
|
if percentage_only:
|
||||||
fumen.header.b480_b483_branch_pts_drumroll = 0
|
fumen.header.b480_b483_branch_pts_drumroll = 0
|
||||||
fumen.header.b492_b495_branch_pts_drumroll_big = 0
|
fumen.header.b492_b495_branch_pts_drumroll_big = 0
|
||||||
|
@ -226,6 +226,7 @@ def parse_tja_course_data(course: TJACourse) -> None:
|
|||||||
'DELAY', 'SCROLL', 'BPMCHANGE', 'MEASURE',
|
'DELAY', 'SCROLL', 'BPMCHANGE', 'MEASURE',
|
||||||
'LEVELHOLD', 'SECTION', 'BRANCHSTART']:
|
'LEVELHOLD', 'SECTION', 'BRANCHSTART']:
|
||||||
# Get position of the event
|
# Get position of the event
|
||||||
|
pos = 0
|
||||||
for branch_name in (course.branches.keys()
|
for branch_name in (course.branches.keys()
|
||||||
if current_branch == 'all'
|
if current_branch == 'all'
|
||||||
else [current_branch]):
|
else [current_branch]):
|
||||||
|
@ -42,7 +42,8 @@ def write_fumen(path_out: str, song: FumenCourse) -> None:
|
|||||||
extra_vals = [note.hits, note.hits_padding]
|
extra_vals = [note.hits, note.hits_padding]
|
||||||
else:
|
else:
|
||||||
extra_vals = [note.score_init, note.score_diff * 4]
|
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,
|
write_struct(file, song.header.order,
|
||||||
format_string="ififHHf",
|
format_string="ififHHf",
|
||||||
value_list=note_struct)
|
value_list=note_struct)
|
||||||
|
Loading…
Reference in New Issue
Block a user