From d5683c43267bbb8f222937b5d2070515ba6b7087 Mon Sep 17 00:00:00 2001 From: Scipio Wright Date: Fri, 3 May 2024 22:28:09 -0400 Subject: [PATCH] Core: Make output when hinting something with multiple copies show up in a better order (#3245) * Make the hint info show up in a better order * Change how old_hints is modified/done --------- Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> --- MultiServer.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index 9ee6a8032c1f..f336a523c310 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -688,7 +688,7 @@ def notify_hints(self, team: int, hints: typing.List[NetUtils.Hint], only_new: b clients = self.clients[team].get(slot) if not clients: continue - client_hints = [datum[1] for datum in sorted(hint_data, key=lambda x: x[0].finding_player == slot)] + client_hints = [datum[1] for datum in sorted(hint_data, key=lambda x: x[0].finding_player != slot)] for client in clients: async_start(self.send_msgs(client, client_hints)) @@ -1529,15 +1529,13 @@ def get_hints(self, input_text: str, for_location: bool = False) -> bool: if hints: new_hints = set(hints) - self.ctx.hints[self.client.team, self.client.slot] - old_hints = set(hints) - new_hints - if old_hints: - self.ctx.notify_hints(self.client.team, list(old_hints)) - if not new_hints: - self.output("Hint was previously used, no points deducted.") + old_hints = list(set(hints) - new_hints) + if old_hints and not new_hints: + self.ctx.notify_hints(self.client.team, old_hints) + self.output("Hint was previously used, no points deducted.") if new_hints: found_hints = [hint for hint in new_hints if hint.found] not_found_hints = [hint for hint in new_hints if not hint.found] - if not not_found_hints: # everything's been found, no need to pay can_pay = 1000 elif cost: @@ -1549,7 +1547,7 @@ def get_hints(self, input_text: str, for_location: bool = False) -> bool: # By popular vote, make hints prefer non-local placements not_found_hints.sort(key=lambda hint: int(hint.receiving_player != hint.finding_player)) - hints = found_hints + hints = found_hints + old_hints while can_pay > 0: if not not_found_hints: break @@ -1559,6 +1557,7 @@ def get_hints(self, input_text: str, for_location: bool = False) -> bool: self.ctx.hints_used[self.client.team, self.client.slot] += 1 points_available = get_client_points(self.ctx, self.client) + self.ctx.notify_hints(self.client.team, hints) if not_found_hints: if hints and cost and int((points_available // cost) == 0): self.output( @@ -1572,7 +1571,6 @@ def get_hints(self, input_text: str, for_location: bool = False) -> bool: self.output(f"You can't afford the hint. " f"You have {points_available} points and need at least " f"{self.ctx.get_hint_cost(self.client.slot)}.") - self.ctx.notify_hints(self.client.team, hints) self.ctx.save() return True