parsers.py
: Simplify convoluted P1 copying logic
This commit is contained in:
parent
6ea74ae58b
commit
7aead6f8ef
@ -58,12 +58,6 @@ FUMEN_NOTE_TYPES = {
|
|||||||
# Invert the dict to go from note type to fumen byte values
|
# Invert the dict to go from note type to fumen byte values
|
||||||
FUMEN_TYPE_NOTES = {v: k for k, v in FUMEN_NOTE_TYPES.items()}
|
FUMEN_TYPE_NOTES = {v: k for k, v in FUMEN_NOTE_TYPES.items()}
|
||||||
|
|
||||||
# All combinations of difficulty and single/multiplayer type
|
|
||||||
TJA_COURSE_NAMES = []
|
|
||||||
for difficulty in ['Ura', 'Oni', 'Hard', 'Normal', 'Easy']:
|
|
||||||
for player in ['', 'P1', 'P2']:
|
|
||||||
TJA_COURSE_NAMES.append(difficulty+player)
|
|
||||||
|
|
||||||
# Normalize the various fumen course names into 1 name per difficulty
|
# Normalize the various fumen course names into 1 name per difficulty
|
||||||
NORMALIZE_COURSE = {
|
NORMALIZE_COURSE = {
|
||||||
'0': 'Easy',
|
'0': 'Easy',
|
||||||
@ -79,6 +73,15 @@ NORMALIZE_COURSE = {
|
|||||||
'Edit': 'Ura'
|
'Edit': 'Ura'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fetch the 5 valid course names from NORMALIZE_COURSE's values
|
||||||
|
COURSE_NAMES = list(set(NORMALIZE_COURSE.values()))
|
||||||
|
|
||||||
|
# All combinations of difficulty and single/multiplayer type
|
||||||
|
TJA_COURSE_NAMES = []
|
||||||
|
for difficulty in COURSE_NAMES:
|
||||||
|
for player in ['', 'P1', 'P2']:
|
||||||
|
TJA_COURSE_NAMES.append(difficulty+player)
|
||||||
|
|
||||||
# Map course difficulty to filename IDs (e.g. Oni -> `song_m.bin`)
|
# Map course difficulty to filename IDs (e.g. Oni -> `song_m.bin`)
|
||||||
COURSE_IDS = {
|
COURSE_IDS = {
|
||||||
'Easy': 'e',
|
'Easy': 'e',
|
||||||
|
@ -5,8 +5,8 @@ from copy import deepcopy
|
|||||||
|
|
||||||
from tja2fumen.types import (TJASong, TJAMeasure, TJAData, FumenCourse,
|
from tja2fumen.types import (TJASong, TJAMeasure, TJAData, FumenCourse,
|
||||||
FumenMeasure, FumenBranch, FumenNote, FumenHeader)
|
FumenMeasure, FumenBranch, FumenNote, FumenHeader)
|
||||||
from tja2fumen.constants import (NORMALIZE_COURSE, TJA_NOTE_TYPES,
|
from tja2fumen.constants import (NORMALIZE_COURSE, COURSE_NAMES, BRANCH_NAMES,
|
||||||
BRANCH_NAMES, FUMEN_NOTE_TYPES)
|
TJA_NOTE_TYPES, FUMEN_NOTE_TYPES)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# TJA-parsing functions #
|
# TJA-parsing functions #
|
||||||
@ -128,14 +128,14 @@ def split_tja_lines_into_courses(lines):
|
|||||||
else:
|
else:
|
||||||
parsed_tja.courses[current_course].data.append(line)
|
parsed_tja.courses[current_course].data.append(line)
|
||||||
|
|
||||||
# If a course has no song data, then this is likely because the course has
|
# If a .tja has "STYLE: Double" but no "STYLE: Single", then it will be
|
||||||
# "STYLE: Double" but no "STYLE: Single". To fix this, we copy over the P1
|
# missing data for the "single player" chart. To fix this, we copy over
|
||||||
# chart from "STYLE: Double" to fill the "STYLE: Single" role.
|
# the P1 chart from "STYLE: Double" to fill the "STYLE: Single" role.
|
||||||
for course_name, course in parsed_tja.courses.items():
|
for course_name in COURSE_NAMES:
|
||||||
if not course.data:
|
course_single_player = parsed_tja.courses[course_name]
|
||||||
if course_name+"P1" in parsed_tja.courses.keys():
|
course_player_one = parsed_tja.courses[course_name+"P1"]
|
||||||
parsed_tja.courses[course_name] = \
|
if course_player_one.data and not course_single_player.data:
|
||||||
deepcopy(parsed_tja.courses[course_name+"P1"])
|
parsed_tja.courses[course_name] = deepcopy(course_player_one)
|
||||||
|
|
||||||
# Remove any charts (e.g. P1/P2) not present in the TJA file (empty data)
|
# Remove any charts (e.g. P1/P2) not present in the TJA file (empty data)
|
||||||
for course_name in [k for k, v in parsed_tja.courses.items()
|
for course_name in [k for k, v in parsed_tja.courses.items()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user