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]}")
 | 
			
		||||
        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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue