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>
This commit is contained in:
parent
f27d1d635b
commit
d5683c4326
|
@ -688,7 +688,7 @@ class Context:
|
||||||
clients = self.clients[team].get(slot)
|
clients = self.clients[team].get(slot)
|
||||||
if not clients:
|
if not clients:
|
||||||
continue
|
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:
|
for client in clients:
|
||||||
async_start(self.send_msgs(client, client_hints))
|
async_start(self.send_msgs(client, client_hints))
|
||||||
|
|
||||||
|
@ -1529,15 +1529,13 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
|
|
||||||
if hints:
|
if hints:
|
||||||
new_hints = set(hints) - self.ctx.hints[self.client.team, self.client.slot]
|
new_hints = set(hints) - self.ctx.hints[self.client.team, self.client.slot]
|
||||||
old_hints = set(hints) - new_hints
|
old_hints = list(set(hints) - new_hints)
|
||||||
if old_hints:
|
if old_hints and not new_hints:
|
||||||
self.ctx.notify_hints(self.client.team, list(old_hints))
|
self.ctx.notify_hints(self.client.team, 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:
|
if new_hints:
|
||||||
found_hints = [hint for hint in new_hints if hint.found]
|
found_hints = [hint for hint in new_hints if hint.found]
|
||||||
not_found_hints = [hint for hint in new_hints if not 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
|
if not not_found_hints: # everything's been found, no need to pay
|
||||||
can_pay = 1000
|
can_pay = 1000
|
||||||
elif cost:
|
elif cost:
|
||||||
|
@ -1549,7 +1547,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
# By popular vote, make hints prefer non-local placements
|
# By popular vote, make hints prefer non-local placements
|
||||||
not_found_hints.sort(key=lambda hint: int(hint.receiving_player != hint.finding_player))
|
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:
|
while can_pay > 0:
|
||||||
if not not_found_hints:
|
if not not_found_hints:
|
||||||
break
|
break
|
||||||
|
@ -1559,6 +1557,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
self.ctx.hints_used[self.client.team, self.client.slot] += 1
|
self.ctx.hints_used[self.client.team, self.client.slot] += 1
|
||||||
points_available = get_client_points(self.ctx, self.client)
|
points_available = get_client_points(self.ctx, self.client)
|
||||||
|
|
||||||
|
self.ctx.notify_hints(self.client.team, hints)
|
||||||
if not_found_hints:
|
if not_found_hints:
|
||||||
if hints and cost and int((points_available // cost) == 0):
|
if hints and cost and int((points_available // cost) == 0):
|
||||||
self.output(
|
self.output(
|
||||||
|
@ -1572,7 +1571,6 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
self.output(f"You can't afford the hint. "
|
self.output(f"You can't afford the hint. "
|
||||||
f"You have {points_available} points and need at least "
|
f"You have {points_available} points and need at least "
|
||||||
f"{self.ctx.get_hint_cost(self.client.slot)}.")
|
f"{self.ctx.get_hint_cost(self.client.slot)}.")
|
||||||
self.ctx.notify_hints(self.client.team, hints)
|
|
||||||
self.ctx.save()
|
self.ctx.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue