Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set timing window values for easier difficulties #74

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/tja2fumen/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from dataclasses import dataclass, field, fields

from tja2fumen.constants import BRANCH_NAMES
from tja2fumen.constants import BRANCH_NAMES, TIMING_WINDOWS


@dataclass()
Expand Down Expand Up @@ -224,7 +224,7 @@ def set_branch_info(self,
class FumenHeader:
"""Contains all the byte values for a Fumen chart file's header."""
order: str = "<"
b000_b431_timing_windows: Tuple[float, ...] = (25.025, 75.075, 108.422)*36
b000_b431_timing_windows: Tuple[float, ...] = (0.0, 0.0, 0.0)*36
b432_b435_has_branches: int = 0
b436_b439_hp_max: int = 10000
b440_b443_hp_clear: int = 8000
Expand Down Expand Up @@ -292,6 +292,12 @@ def _parse_order(self, raw_bytes: bytes) -> None:
else:
self.order = "<"

def set_timing_windows(self, difficulty: str) -> None:
"""Set the timing window header bytes depending on the difficulty."""
# Note: Ura Oni is equivalent to Oni for timing window behavior
difficulty = 'Oni' if difficulty in ['Ura', 'Edit'] else difficulty
self.b000_b431_timing_windows = TIMING_WINDOWS[difficulty]*36

def set_hp_bytes(self, n_notes: int, difficulty: str, stars: int) -> None:
"""Compute header bytes related to the soul gauge (HP) behavior."""
# Note: Ura Oni is equivalent to Oni for soul gauge behavior
Expand Down
8 changes: 8 additions & 0 deletions src/tja2fumen/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@
'Oni': 'm',
'Ura': 'x',
}

TIMING_WINDOWS = {
# "GOOD" timing "OK" timing "BAD" timing
'Easy': (041.7083358764648, 108.441665649414, 125.125000000000),
'Normal': (041.7083358764648, 108.441665649414, 125.125000000000),
'Hard': (025.0250015258789, 075.075004577637, 108.441665649414),
'Oni': (025.0250015258789, 075.075004577637, 108.441665649414)
}
2 changes: 2 additions & 0 deletions src/tja2fumen/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ def convert_tja_to_fumen(tja: TJACourse) -> FumenCourse:

# Compute the header bytes that dictate the soul gauge bar behavior
fumen.header.set_hp_bytes(total_notes['normal'], tja.course, tja.level)
# Compute the timing windows based on the course
fumen.header.set_timing_windows(tja.course)

# If song has only drumroll branching conditions (also allowing percentage
# conditions that force a level up/level down), then set the header bytes
Expand Down
3 changes: 2 additions & 1 deletion testing/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def test_converted_tja_vs_cached_fumen(id_song, tmp_path, entry_point):
# cannot be expressed in a TJA file. So, we skip checking the
# `branch_point` header values for KAGEKIYO.
if id_song != 'genpe':
for header_property in ['b468_b471_branch_pts_good',
for header_property in ['b000_b431_timing_windows',
'b468_b471_branch_pts_good',
'b472_b475_branch_pts_ok',
'b476_b479_branch_pts_bad',
'b480_b483_branch_pts_drumroll',
Expand Down
Loading