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

feat: add mods to player.last_np #526

Merged
merged 6 commits into from
Feb 12, 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
15 changes: 13 additions & 2 deletions app/api/domains/cho.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,14 @@ async def handle(self, player: Player) -> None:
# use player mode if not specified
mode_vn = player.status.mode.as_vanilla

# parse the mods from regex
mods = None
if r_match["mods"] is not None:
NiceAesth marked this conversation as resolved.
Show resolved Hide resolved
mods = Mods.from_np(r_match["mods"][1:], mode_vn)

player.last_np = {
"bmap": bmap,
"mods": mods,
"mode_vn": mode_vn,
"timeout": time.time() + 300, # /np's last 5mins
}
Expand Down Expand Up @@ -1246,9 +1252,15 @@ async def handle(self, player: Player) -> None:
# use player mode if not specified
mode_vn = player.status.mode.as_vanilla

# parse the mods from regex
mods = None
if r_match["mods"] is not None:
NiceAesth marked this conversation as resolved.
Show resolved Hide resolved
mods = Mods.from_np(r_match["mods"][1:], mode_vn)

player.last_np = {
"bmap": bmap,
"mode_vn": mode_vn,
"mods": mods,
minisbett marked this conversation as resolved.
Show resolved Hide resolved
"timeout": time.time() + 300, # /np's last 5mins
}

Expand All @@ -1268,12 +1280,11 @@ async def handle(self, player: Player) -> None:
# calculate pp for common generic values
pp_calc_st = time.time_ns()

mods = None
if r_match["mods"] is not None:
# [1:] to remove leading whitespace
mods_str = r_match["mods"][1:]
mods = Mods.from_np(mods_str, mode_vn)
else:
mods = None

scores = [
ScoreParams(
Expand Down
1 change: 1 addition & 0 deletions app/objects/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Status:
class LastNp(TypedDict):
bmap: Beatmap
mode_vn: int
mods: Mods | None
timeout: float


Expand Down
Loading