Skip to content

Core: Make output when hinting something with multiple copies show up in a better order #3245

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

Merged
merged 3 commits into from
May 4, 2024
Merged
Changes from 2 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
13 changes: 6 additions & 7 deletions MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -1530,14 +1530,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:
if old_hints and not new_hints:
self.ctx.notify_hints(self.client.team, list(old_hints))
if not new_hints:
self.output("Hint was previously used, no points deducted.")
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]

old_hints = [hint for hint in old_hints]
if not not_found_hints: # everything's been found, no need to pay
can_pay = 1000
elif cost:
Expand All @@ -1549,7 +1548,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
Expand All @@ -1559,6 +1558,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(
Expand All @@ -1572,7 +1572,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

Expand Down
Loading