From 88ac7b7eacefed498e209c8eba19fdfad56f4693 Mon Sep 17 00:00:00 2001 From: Viv Date: Sat, 10 Feb 2024 13:26:36 -0500 Subject: [PATCH] `parsers.py`: Allow songs with `LEVEL:` <1 and >10 --- src/tja2fumen/parsers.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tja2fumen/parsers.py b/src/tja2fumen/parsers.py index 6270481..35041f5 100644 --- a/src/tja2fumen/parsers.py +++ b/src/tja2fumen/parsers.py @@ -98,10 +98,11 @@ def split_tja_lines_into_courses(lines: List[str]) -> TJASong: current_course = NORMALIZE_COURSE[value] current_course_basename = current_course elif name_upper == 'LEVEL': - if value not in ['1', '2', '3', '4', '5', - '6', '7', '8', '9', '10']: - raise ValueError(f"Invalid LEVEL value: '{value}") - parsed_tja.courses[current_course].level = int(value) + if not value.isdigit(): + raise ValueError(f"Invalid LEVEL value: '{value}'") + # restrict to 1 <= level <= 10 + parsed_level = min(max(int(value), 1), 10) + parsed_tja.courses[current_course].level = parsed_level elif name_upper == 'SCOREINIT': parsed_tja.courses[current_course].score_init = \ int(value.split(",")[-1]) if value else 0