From f5aa185ec276416e80e505de5b0fb42ee5578271 Mon Sep 17 00:00:00 2001 From: Viv Date: Sat, 3 Jun 2023 09:45:53 -0400 Subject: [PATCH] `constants.py`: Add support for 0-4 course strings --- tja2fumen/constants.py | 14 ++++++++++++++ tja2fumen/parsers.py | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tja2fumen/constants.py b/tja2fumen/constants.py index 152796b..bb99974 100644 --- a/tja2fumen/constants.py +++ b/tja2fumen/constants.py @@ -96,6 +96,20 @@ unknownHeaderSample[76] = 78 unknownHeaderSample[77] = 97 unknownHeaderSample[78] = 188 +NORMALIZE_COURSE = { + '0': 'Easy', + 'Easy': 'Easy', + '1': 'Normal', + 'Normal': 'Normal', + '2': 'Hard', + 'Hard': 'Hard', + '3': 'Oni', + 'Oni': 'Oni', + '4': 'Ura', + 'Ura': 'Ura', + 'Edit': 'Ura' +} + DIFFICULTY_BYTES = { 'Easy': [112, 23], 'Normal': [88, 27], diff --git a/tja2fumen/parsers.py b/tja2fumen/parsers.py index 31473f4..4316ffc 100644 --- a/tja2fumen/parsers.py +++ b/tja2fumen/parsers.py @@ -4,7 +4,7 @@ import re from tja2fumen.utils import readStruct, getBool, shortHex, nameValue, debugPrint, checkValidHeader, validateHeaderMetadata from tja2fumen.constants import ( # TJA constants - HEADER_GLOBAL, HEADER_COURSE, BRANCH_COMMANDS, MEASURE_COMMANDS, COMMAND, + HEADER_GLOBAL, HEADER_COURSE, BRANCH_COMMANDS, MEASURE_COMMANDS, COMMAND, NORMALIZE_COURSE, # Fumen constants branchNames, noteTypes ) @@ -36,7 +36,7 @@ def parseTJA(tja): else: # Check to see if we're starting a new course if parsed['type'] == 'header' and parsed['scope'] == 'course' and parsed['name'] == 'COURSE': - currentCourse = parsed['value'] + currentCourse = NORMALIZE_COURSE[parsed['value']] if currentCourse not in courses.keys(): courses[currentCourse] = [] # Append the line to the current course @@ -85,7 +85,7 @@ def getCourse(tjaHeaders, lines): def parseHeaderMetadata(line): nonlocal headers if line["name"] == 'COURSE': - headers['course'] = line['value'] + headers['course'] = NORMALIZE_COURSE[line['value']] elif line["name"] == 'LEVEL': headers['level'] = int(line['value']) if line['value'] else 0 elif line["name"] == 'SCOREINIT':