The Witness: mypy compliance (#3112)
* Make witness apworld mostly pass mypy * Fix all remaining mypy errors except the core ones * I'm a goofy stupid poopoo head * Two more fixes * ruff after merge * Mypy for new stuff * Oops * Stricter ruff rules (that I already comply with :3) * Deprecated ruff thing * wait no i lied * lol super nevermind * I can actually be slightly more specific * lint
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Defines progression, junk and event items for The Witness
|
||||
"""
|
||||
import copy
|
||||
from typing import TYPE_CHECKING, Dict, List, Set
|
||||
from typing import TYPE_CHECKING, Dict, List, Set, cast
|
||||
|
||||
from BaseClasses import Item, ItemClassification, MultiWorld
|
||||
|
||||
@@ -87,7 +87,8 @@ class WitnessPlayerItems:
|
||||
if data.classification == ItemClassification.useful}.items():
|
||||
if item_name in static_witness_items._special_usefuls:
|
||||
continue
|
||||
elif item_name == "Energy Capacity":
|
||||
|
||||
if item_name == "Energy Capacity":
|
||||
self._mandatory_items[item_name] = NUM_ENERGY_UPGRADES
|
||||
elif isinstance(item_data.classification, ProgressiveItemDefinition):
|
||||
self._mandatory_items[item_name] = len(item_data.mappings)
|
||||
@@ -184,15 +185,16 @@ class WitnessPlayerItems:
|
||||
output -= {item for item, weight in inner_item.items() if weight}
|
||||
|
||||
# Sort the output for consistency across versions if the implementation changes but the logic does not.
|
||||
return sorted(list(output))
|
||||
return sorted(output)
|
||||
|
||||
def get_door_ids_in_pool(self) -> List[int]:
|
||||
"""
|
||||
Returns the total set of all door IDs that are controlled by items in the pool.
|
||||
"""
|
||||
output: List[int] = []
|
||||
for item_name, item_data in {name: data for name, data in self.item_data.items()
|
||||
if isinstance(data.definition, DoorItemDefinition)}.items():
|
||||
for item_name, item_data in dict(self.item_data.items()).items():
|
||||
if not isinstance(item_data.definition, DoorItemDefinition):
|
||||
continue
|
||||
output += [int(hex_string, 16) for hex_string in item_data.definition.panel_id_hexes]
|
||||
|
||||
return output
|
||||
@@ -201,18 +203,21 @@ class WitnessPlayerItems:
|
||||
"""
|
||||
Returns the item IDs of symbol items that were defined in the configuration file but are not in the pool.
|
||||
"""
|
||||
return [data.ap_code for name, data in static_witness_items.ITEM_DATA.items()
|
||||
if name not in self.item_data.keys() and data.definition.category is ItemCategory.SYMBOL]
|
||||
return [
|
||||
# data.ap_code is guaranteed for a symbol definition
|
||||
cast(int, data.ap_code) for name, data in static_witness_items.ITEM_DATA.items()
|
||||
if name not in self.item_data.keys() and data.definition.category is ItemCategory.SYMBOL
|
||||
]
|
||||
|
||||
def get_progressive_item_ids_in_pool(self) -> Dict[int, List[int]]:
|
||||
output: Dict[int, List[int]] = {}
|
||||
for item_name, quantity in {name: quantity for name, quantity in self._mandatory_items.items()}.items():
|
||||
for item_name, quantity in dict(self._mandatory_items.items()).items():
|
||||
item = self.item_data[item_name]
|
||||
if isinstance(item.definition, ProgressiveItemDefinition):
|
||||
# Note: we need to reference the static table here rather than the player-specific one because the child
|
||||
# items were removed from the pool when we pruned out all progression items not in the settings.
|
||||
output[item.ap_code] = [static_witness_items.ITEM_DATA[child_item].ap_code
|
||||
for child_item in item.definition.child_item_names]
|
||||
output[cast(int, item.ap_code)] = [cast(int, static_witness_items.ITEM_DATA[child_item].ap_code)
|
||||
for child_item in item.definition.child_item_names]
|
||||
return output
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user