Network: allow filtering checked and missing by text fragment
This commit is contained in:
parent
4c24872264
commit
a61a1f58c6
|
@ -68,14 +68,17 @@ class ClientCommandProcessor(CommandProcessor):
|
||||||
self.output(f"{self.ctx.item_names[item.item]} from {self.ctx.player_names[item.player]}")
|
self.output(f"{self.ctx.item_names[item.item]} from {self.ctx.player_names[item.player]}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _cmd_missing(self) -> bool:
|
def _cmd_missing(self, filter_text = "") -> bool:
|
||||||
"""List all missing location checks, from your local game state"""
|
"""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:
|
if not self.ctx.game:
|
||||||
self.output("No game set, cannot determine missing checks.")
|
self.output("No game set, cannot determine missing checks.")
|
||||||
return False
|
return False
|
||||||
count = 0
|
count = 0
|
||||||
checked_count = 0
|
checked_count = 0
|
||||||
for location, location_id in AutoWorldRegister.world_types[self.ctx.game].location_name_to_id.items():
|
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:
|
if location_id < 0:
|
||||||
continue
|
continue
|
||||||
if location_id not in self.ctx.locations_checked:
|
if location_id not in self.ctx.locations_checked:
|
||||||
|
|
|
@ -1327,27 +1327,41 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
"Sorry, !remaining requires you to have beaten the game on this server")
|
"Sorry, !remaining requires you to have beaten the game on this server")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _cmd_missing(self) -> bool:
|
def _cmd_missing(self, filter_text="") -> bool:
|
||||||
"""List all missing location checks from the server's perspective"""
|
"""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)
|
locations = get_missing_checks(self.ctx, self.client.team, self.client.slot)
|
||||||
|
|
||||||
if locations:
|
if locations:
|
||||||
texts = [f'Missing: {self.ctx.location_names[location]}' for location in locations]
|
names = [self.ctx.location_names[location] for location in locations]
|
||||||
texts.append(f"Found {len(locations)} missing location checks")
|
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)
|
self.output_multiple(texts)
|
||||||
else:
|
else:
|
||||||
self.output("No missing location checks found.")
|
self.output("No missing location checks found.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _cmd_checked(self) -> bool:
|
def _cmd_checked(self, filter_text="") -> bool:
|
||||||
"""List all done location checks from the server's perspective"""
|
"""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)
|
locations = get_checked_checks(self.ctx, self.client.team, self.client.slot)
|
||||||
|
|
||||||
if locations:
|
if locations:
|
||||||
texts = [f'Checked: {self.ctx.location_names[location]}' for location in locations]
|
names = [self.ctx.location_names[location] for location in locations]
|
||||||
texts.append(f"Found {len(locations)} done location checks")
|
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)
|
self.output_multiple(texts)
|
||||||
else:
|
else:
|
||||||
self.output("No done location checks found.")
|
self.output("No done location checks found.")
|
||||||
|
|
Loading…
Reference in New Issue