Skip to content

Commit

Permalink
Core: Make output when hinting something with multiple copies show up…
Browse files Browse the repository at this point in the history
… in a better order (ArchipelagoMW#3245)

* Make the hint info show up in a better order

* Change how old_hints is modified/done

---------

Co-authored-by: NewSoupVi <[email protected]>
  • Loading branch information
ScipioWright and NewSoupVi authored May 4, 2024
1 parent f27d1d6 commit d5683c4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 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 @@ -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:
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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

Expand Down

0 comments on commit d5683c4

Please sign in to comment.