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

Add LegacyReplaySoloScoreInfo dataclass to Score #45

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

vis256
Copy link
Contributor

@vis256 vis256 commented Oct 9, 2024

Lazer's LegacyScoreDecoder expects a byte array with LegacyReplaySoloScoreInfo score info that is converted to JSON and then LZMA compressed if replay's game version is at least 30000001. This data resides at the end of .osr file and lazer throws an exception if there are no bytes left after reading replay_id/LegacyOnlineID.

@vis256
Copy link
Contributor Author

vis256 commented Oct 14, 2024

This should be finished now. If you have any things you want changed let me know.

Copy link
Owner

@kszlim kszlim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks pretty close, I'll leave it up to @tybug whether to merge or provide more feedback though as he owns this library more than me at this point.

@@ -193,3 +195,66 @@ class LifeBarState:
"""
time: int
life: float

class Statistics(TypedDict, total=False):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always non-total? If all the fields are always present or certain fields are always present, I'd prefer to make those explicitly marked as so with the other fields marked as optional. Probably works better with a dataclass as opposed to TypedDict.

If any random subset of the fields are potentially unavailable then I'm okay with what you're doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazer only types it as a Dictionary<HitResult, int>. Since all possible HitResult values are stored in rulesets (Ruleset.GetValidHitResults()) I could make a separate class for each ruleset?

As for always present fields across all rulesets only miss and great are shared between all of them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep this dataclass ruleset-generic. The statistics are meant to be very general and existing rulesets might start using other judgments in the future, even if they don't now.


class APIMod(TypedDict, total=False):
acronym: str
settings: dict
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a fixed structure?

online_id: int
mods: list[APIMod]
statistics: Statistics
maximum_statistics: Statistics
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are statistics and maximum statistics always a mirror image of each other in terms of structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they are both typed in Lazer as Dictionary<HitResult, int>, but MaximumStatistics are a subset where multiple related judgements are added together (ie in osu!std statistics: miss, meh, ok, great are added together under great in maximum statistics (always the judgement with maximum value)).

osrparse/replay.py Outdated Show resolved Hide resolved
osrparse/replay.py Outdated Show resolved Hide resolved
osrparse/replay.py Outdated Show resolved Hide resolved
@tybug
Copy link
Collaborator

tybug commented Oct 15, 2024

The code looks good (and thanks for taking this on) but there are important semantic and api design decisions to be made here that just require me doing the due diligence of thinking about it. I won't have time to do that for a few weeks - feel free to ping me if it's been longer than that and I haven't come back to this.

@@ -193,3 +195,78 @@ class LifeBarState:
"""
time: int
life: float

class Statistics(TypedDict, total=False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer @DataClass over TypedDict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants