-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
Conversation
This should be finished now. If you have any things you want changed let me know. |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
osrparse/utils.py
Outdated
|
||
class APIMod(TypedDict, total=False): | ||
acronym: str | ||
settings: dict |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)).
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): |
There was a problem hiding this comment.
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
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.