From 8b1baafddfbeb926eac92d86c812a65af2834675 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 30 May 2022 23:02:40 +0200 Subject: [PATCH] SC2: send ItemLink messages to ingame as well --- CommonClient.py | 7 +++++++ Starcraft2Client.py | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index b31c4509..5fb42971 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -299,6 +299,13 @@ class CommonContext: await self.disconnect() self.server_task = asyncio.create_task(server_loop(self, address), name="server loop") + def slot_concerns_self(self, slot) -> bool: + if slot == self.slot: + return True + if slot in self.slot_info: + return self.slot in self.slot_info[slot].group_members + return False + def on_print(self, args: dict): logger.info(args["text"]) diff --git a/Starcraft2Client.py b/Starcraft2Client.py index f8994d26..120da014 100644 --- a/Starcraft2Client.py +++ b/Starcraft2Client.py @@ -115,13 +115,12 @@ class SC2Context(CommonContext): self.mission_req_table[mission] = MissionInfo(**slot_req_table[mission]) if cmd in {"PrintJSON"}: - noted = False if "receiving" in args: - if args["receiving"] == self.slot: + if self.slot_concerns_self(args["receiving"]): self.announcements.append(args["data"]) - noted = True - if not noted and "item" in args: - if args["item"].player == self.slot: + return + if "item" in args: + if self.slot_concerns_self(args["item"].player): self.announcements.append(args["data"]) def run_gui(self):