Use itertools.cycle
to repeat over balloons
If branches have the same balloons, then `cycle` will cause the list to be repeated once per branch. However, if branches have different balloons, then assuming that all the balloon values for all branches are listed, the list will be iterated over normally. This
This commit is contained in:
parent
2446c05312
commit
8e8332cd2b
@ -209,7 +209,6 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
|
||||
current_levelhold = False
|
||||
branch_types: List[str] = []
|
||||
branch_conditions: List[Tuple[float, float]] = []
|
||||
course_balloons = tja.balloon.copy()
|
||||
|
||||
# Iterate over pairs of TJA and Fumen measures
|
||||
for idx_m, (measure_tja, measure_fumen) in \
|
||||
@ -334,7 +333,7 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:
|
||||
current_drumroll = note
|
||||
elif note.note_type in ["Balloon", "Kusudama"]:
|
||||
try:
|
||||
note.hits = course_balloons.pop(0)
|
||||
note.hits = next(tja.balloon)
|
||||
except IndexError:
|
||||
warnings.warn(f"Not enough values for 'BALLOON:' "
|
||||
f"({tja.balloon}). Using value=1 to "
|
||||
|
@ -8,6 +8,7 @@ import struct
|
||||
import warnings
|
||||
from copy import deepcopy
|
||||
from typing import BinaryIO, Any, List, Dict, Tuple
|
||||
from itertools import cycle
|
||||
|
||||
from tja2fumen.classes import (TJASong, TJACourse, TJAMeasure, TJAData,
|
||||
FumenCourse, FumenMeasure, FumenBranch,
|
||||
@ -121,7 +122,7 @@ def split_tja_lines_into_courses(lines: List[str]) -> TJASong:
|
||||
elif name_upper == 'BALLOON':
|
||||
if value:
|
||||
balloons = [int(v) for v in value.split(",") if v]
|
||||
parsed_tja.courses[current_course].balloon = balloons
|
||||
parsed_tja.courses[current_course].balloon = cycle(balloons)
|
||||
elif name_upper == 'STYLE':
|
||||
# Reset the course name to remove "P1/P2" that may have been
|
||||
# added by a previous STYLE:DOUBLE chart
|
||||
|
Loading…
x
Reference in New Issue
Block a user