From a61a1f58c6b41cc121403fb88fcf009eea6f417a Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Wed, 8 Mar 2023 17:53:43 +0100 Subject: [PATCH] Network: allow filtering checked and missing by text fragment --- CommonClient.py | 7 +++++-- MultiServer.py | 30 ++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index afce98d8..4892f69f 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -68,14 +68,17 @@ class ClientCommandProcessor(CommandProcessor): self.output(f"{self.ctx.item_names[item.item]} from {self.ctx.player_names[item.player]}") return True - def _cmd_missing(self) -> bool: - """List all missing location checks, from your local game state""" + def _cmd_missing(self, filter_text = "") -> bool: + """List all missing location checks, from your local game state. + Can be given text, which will be used as filter.""" if not self.ctx.game: self.output("No game set, cannot determine missing checks.") return False count = 0 checked_count = 0 for location, location_id in AutoWorldRegister.world_types[self.ctx.game].location_name_to_id.items(): + if filter_text and filter_text not in location: + continue if location_id < 0: continue if location_id not in self.ctx.locations_checked: diff --git a/MultiServer.py b/MultiServer.py index 258b73c6..ea055b66 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -1327,27 +1327,41 @@ class ClientMessageProcessor(CommonCommandProcessor): "Sorry, !remaining requires you to have beaten the game on this server") return False - def _cmd_missing(self) -> bool: - """List all missing location checks from the server's perspective""" + def _cmd_missing(self, filter_text="") -> bool: + """List all missing location checks from the server's perspective. + Can be given text, which will be used as filter.""" locations = get_missing_checks(self.ctx, self.client.team, self.client.slot) if locations: - texts = [f'Missing: {self.ctx.location_names[location]}' for location in locations] - texts.append(f"Found {len(locations)} missing location checks") + names = [self.ctx.location_names[location] for location in locations] + if filter_text: + names = [name for name in names if filter_text in name] + texts = [f'Missing: {name}' for name in names] + if filter_text: + texts.append(f"Found {len(locations)} missing location checks, displaying {len(names)} of them.") + else: + texts.append(f"Found {len(locations)} missing location checks") self.output_multiple(texts) else: self.output("No missing location checks found.") return True - def _cmd_checked(self) -> bool: - """List all done location checks from the server's perspective""" + def _cmd_checked(self, filter_text="") -> bool: + """List all done location checks from the server's perspective. + Can be given text, which will be used as filter.""" locations = get_checked_checks(self.ctx, self.client.team, self.client.slot) if locations: - texts = [f'Checked: {self.ctx.location_names[location]}' for location in locations] - texts.append(f"Found {len(locations)} done location checks") + names = [self.ctx.location_names[location] for location in locations] + if filter_text: + names = [name for name in names if filter_text in name] + texts = [f'Checked: {name}' for name in names] + if filter_text: + texts.append(f"Found {len(locations)} done location checks, displaying {len(names)} of them.") + else: + texts.append(f"Found {len(locations)} done location checks") self.output_multiple(texts) else: self.output("No done location checks found.")