Compare commits

...

5 Commits

Author SHA1 Message Date
CaitSith2
87152f17f5 Merge branch 'main' into show_all_hints 2022-07-02 06:56:15 -07:00
CaitSith2
c1b099d44e Merge branch 'main' into show_all_hints 2022-06-27 02:19:24 -07:00
CaitSith2
d20ade7ff8 Automatically allow spectator slots to see all hints. 2022-06-22 16:18:36 -07:00
CaitSith2
df90ff4ddb Don't need this line. 2022-06-22 04:53:38 -07:00
CaitSith2
a798e8aea2 Add a means to allow a client to opt into seeing ALL hints. 2022-06-22 04:49:31 -07:00
2 changed files with 24 additions and 0 deletions

View File

@@ -110,6 +110,10 @@ class ClientCommandProcessor(CommandProcessor):
self.output("Unreadied.")
asyncio.create_task(self.ctx.send_msgs([{"cmd": "StatusUpdate", "status": state}]), name="send StatusUpdate")
def _cmd_show_all_hints(self):
"""Allows the player to see all hints, not just the ones that apply to them."""
asyncio.create_task(self.ctx.update_show_all_hints("ShowAllHints" not in self.ctx.tags))
def default(self, raw: str):
raw = self.ctx.on_user_say(raw)
if raw:
@@ -402,6 +406,15 @@ class CommonContext:
}
}])
async def update_show_all_hints(self, show_all_hints: bool):
old_tags = self.tags.copy()
if show_all_hints:
self.tags.add("ShowAllHints")
else:
self.tags -= {"ShowAllHints"}
if old_tags != self.tags and self.server and not self.server.socket.closed:
await self.send_msgs([{"cmd": "ConnectUpdate", "tags": self.tags}])
async def update_death_link(self, death_link: bool):
old_tags = self.tags.copy()
if death_link:

View File

@@ -559,12 +559,19 @@ def notify_hints(ctx: Context, team: int, hints: typing.List[NetUtils.Hint], onl
if not hints:
return
concerns = collections.defaultdict(list)
all_hints = collections.defaultdict(list)
for hint in sorted(hints, key=operator.attrgetter('found'), reverse=True):
data = (hint, hint.as_network_message())
for player in ctx.slot_set(hint.receiving_player):
concerns[player].append(data)
if not hint.local and data not in concerns[hint.finding_player]:
concerns[hint.finding_player].append(data)
for slot, clients in ctx.clients[team].items():
if not clients or slot == hint.finding_player or slot in ctx.slot_set(hint.receiving_player) or \
(ctx.games[slot] != "Archipelago" and all(["ShowAllHints" not in client.tags for client in clients])):
continue
for client in [client for client in clients if "ShowAllHints" in client.tags or ctx.games[slot] == "Archipelago"]:
all_hints[client].append(data)
# remember hints in all cases
if not hint.found:
# since hints are bidirectional, finding player and receiving player,
@@ -584,6 +591,10 @@ def notify_hints(ctx: Context, team: int, hints: typing.List[NetUtils.Hint], onl
for client in clients:
asyncio.create_task(ctx.send_msgs(client, client_hints))
for client, hint_data in all_hints.items():
client_hints = [datum[1] for datum in sorted(hint_data)]
asyncio.create_task(ctx.send_msgs(client, client_hints))
def update_aliases(ctx: Context, team: int):
cmd = ctx.dumper([{"cmd": "RoomUpdate",