get_type_effectiveness
Calculate type effectiveness multipliers for Pokemon battles by analyzing attack types against defending Pokemon types to inform strategic decisions.
Instructions
Calculate type effectiveness multiplier for an attack against a Pokemon's types.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| attack_type | Yes | The attacking move's type (e.g., 'electric', 'fire') | |
| defend_types | Yes | List of the defending Pokemon's types (e.g., ['water', 'flying']) |
Implementation Reference
- src/pokemon_server.py:334-362 (handler)Main handler for the get_type_effectiveness tool. Extracts arguments, calls the data loader's method for computation, determines descriptive text based on multiplier, and returns formatted TextContent response.elif name == "get_type_effectiveness": attack_type = arguments["attack_type"] defend_types = arguments["defend_types"] multiplier = loader.get_type_effectiveness(attack_type, defend_types) # Describe the effectiveness if multiplier == 0: desc = "No effect (immune)" elif multiplier == 0.25: desc = "Not very effective (0.25x)" elif multiplier == 0.5: desc = "Not very effective (0.5x)" elif multiplier == 1: desc = "Normal effectiveness (1x)" elif multiplier == 2: desc = "Super effective (2x)" elif multiplier == 4: desc = "Super effective (4x)" else: desc = f"{multiplier}x" response = f"""## Type Effectiveness **{attack_type.capitalize()}** vs **{'/'.join(t.capitalize() for t in defend_types)}** **Multiplier:** {multiplier}x **Result:** {desc} """ return [TextContent(type="text", text=response)]
- src/pokemon_server.py:244-258 (schema)Input schema definition specifying required parameters: attack_type (string) and defend_types (array of strings).inputSchema={ "type": "object", "properties": { "attack_type": { "type": "string", "description": "The attacking move's type (e.g., 'electric', 'fire')" }, "defend_types": { "type": "array", "items": {"type": "string"}, "description": "List of the defending Pokemon's types (e.g., ['water', 'flying'])" } }, "required": ["attack_type", "defend_types"] }
- src/pokemon_server.py:241-259 (registration)Tool registration in the @server.list_tools() callback, including name, description, and input schema.Tool( name="get_type_effectiveness", description="Calculate type effectiveness multiplier for an attack against a Pokemon's types.", inputSchema={ "type": "object", "properties": { "attack_type": { "type": "string", "description": "The attacking move's type (e.g., 'electric', 'fire')" }, "defend_types": { "type": "array", "items": {"type": "string"}, "description": "List of the defending Pokemon's types (e.g., ['water', 'flying'])" } }, "required": ["attack_type", "defend_types"] } ),
- src/data_loader.py:114-141 (helper)Core computation function in PokemonDataLoader class. Loads typechart data if needed, normalizes types to lowercase, and multiplies effectiveness factors from typechart for each defending type.def get_type_effectiveness( self, attack_type: str, defend_types: list[str] ) -> float: """ Calculate type effectiveness multiplier. Args: attack_type: The attacking move's type defend_types: List of defending Pokemon's types Returns: Effectiveness multiplier (0, 0.25, 0.5, 1, 2, 4) """ self.load_all() attack_type = attack_type.lower() defend_types = [t.lower() for t in defend_types] multiplier = 1.0 # Type chart maps defending type -> attacking type -> multiplier for defend_type in defend_types: type_data = self.typechart.get(defend_type, {}) eff = type_data.get(attack_type, 1.0) multiplier *= eff return multiplier