From 39fd6cc88224c7bca1bfde244410f9333706bc40 Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Tue, 26 Sep 2023 00:59:46 +0200 Subject: [PATCH 1/6] Add mods to playr.last_np --- app/api/domains/cho.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/api/domains/cho.py b/app/api/domains/cho.py index 17f5ee36..0b69bdb8 100644 --- a/app/api/domains/cho.py +++ b/app/api/domains/cho.py @@ -401,8 +401,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 + if r_match["mods"] is not None: + mods = Mods.from_np(r_match["mods"][1:], mode_vn) + else: + mods = None + player.last_np = { "bmap": bmap, + "mods": mods, "mode_vn": mode_vn, "timeout": time.time() + 300, # /np's last 5mins } @@ -1246,11 +1253,19 @@ 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 + if r_match["mods"] is not None: + mods = Mods.from_np(r_match["mods"][1:], mode_vn) + else: + mods = None + player.last_np = { "bmap": bmap, "mode_vn": mode_vn, + "mods": mods, "timeout": time.time() + 300, # /np's last 5mins } + print(player.last_np) # calculate generic pp values from their /np From c50bfde3c43ea817a3af9d446c5d693d502cb2da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 23:06:21 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- app/api/domains/cho.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/domains/cho.py b/app/api/domains/cho.py index 0b69bdb8..a06fd6ac 100644 --- a/app/api/domains/cho.py +++ b/app/api/domains/cho.py @@ -409,7 +409,7 @@ async def handle(self, player: Player) -> None: player.last_np = { "bmap": bmap, - "mods": mods, + "mods": mods, "mode_vn": mode_vn, "timeout": time.time() + 300, # /np's last 5mins } From 8db60da024e860b19a4db54ba9c0be608d18c6ea Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Tue, 26 Sep 2023 01:50:33 +0200 Subject: [PATCH 3/6] Remove debug print --- app/api/domains/cho.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/api/domains/cho.py b/app/api/domains/cho.py index a06fd6ac..7b93b8e1 100644 --- a/app/api/domains/cho.py +++ b/app/api/domains/cho.py @@ -1265,7 +1265,6 @@ async def handle(self, player: Player) -> None: "mods": mods, "timeout": time.time() + 300, # /np's last 5mins } - print(player.last_np) # calculate generic pp values from their /np From 1b5f97a0f0e41b5a8cefb2f19180983920c9b0a6 Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Tue, 26 Sep 2023 02:05:06 +0200 Subject: [PATCH 4/6] Add typing of mods to LastNp --- app/objects/player.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/objects/player.py b/app/objects/player.py index c2a5d3e7..d8428eca 100644 --- a/app/objects/player.py +++ b/app/objects/player.py @@ -114,6 +114,7 @@ class Status: class LastNp(TypedDict): bmap: Beatmap mode_vn: int + mods: Mods timeout: float From 1cc4e5004d4031c3d8ddc3dfe1bbf7d34be6e258 Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:15:04 +0200 Subject: [PATCH 5/6] Make LastNp.mods noneable --- app/objects/player.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/objects/player.py b/app/objects/player.py index d8428eca..6c70ee9d 100644 --- a/app/objects/player.py +++ b/app/objects/player.py @@ -114,7 +114,7 @@ class Status: class LastNp(TypedDict): bmap: Beatmap mode_vn: int - mods: Mods + mods: Mods | None timeout: float From e047f7b2d11967fa3b51533b53cadb6065292cf4 Mon Sep 17 00:00:00 2001 From: mini <39670899+minisbett@users.noreply.github.com> Date: Thu, 9 Nov 2023 20:25:10 +0100 Subject: [PATCH 6/6] Make mods parsing consistent --- app/api/domains/cho.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/api/domains/cho.py b/app/api/domains/cho.py index 7b93b8e1..a4b5508f 100644 --- a/app/api/domains/cho.py +++ b/app/api/domains/cho.py @@ -402,10 +402,9 @@ async def handle(self, player: Player) -> None: mode_vn = player.status.mode.as_vanilla # parse the mods from regex + mods = None if r_match["mods"] is not None: mods = Mods.from_np(r_match["mods"][1:], mode_vn) - else: - mods = None player.last_np = { "bmap": bmap, @@ -1254,10 +1253,9 @@ async def handle(self, player: Player) -> None: mode_vn = player.status.mode.as_vanilla # parse the mods from regex + mods = None if r_match["mods"] is not None: mods = Mods.from_np(r_match["mods"][1:], mode_vn) - else: - mods = None player.last_np = { "bmap": bmap, @@ -1282,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(