mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Zillion: use "new" settings api and cleaning (#3903)
* Zillion: use "new" settings api and cleaning * python 3.10 typing update * don't separate assignments of item link players
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import Dict, FrozenSet, Mapping, Tuple, List, Counter as _Counter
|
||||
from collections import Counter
|
||||
from collections.abc import Mapping
|
||||
|
||||
from BaseClasses import CollectionState
|
||||
|
||||
@@ -35,7 +36,7 @@ def set_randomizer_locs(cs: CollectionState, p: int, zz_r: Randomizer) -> int:
|
||||
return _hash
|
||||
|
||||
|
||||
def item_counts(cs: CollectionState, p: int) -> Tuple[Tuple[str, int], ...]:
|
||||
def item_counts(cs: CollectionState, p: int) -> tuple[tuple[str, int], ...]:
|
||||
"""
|
||||
the zilliandomizer items that player p has collected
|
||||
|
||||
@@ -44,11 +45,11 @@ def item_counts(cs: CollectionState, p: int) -> Tuple[Tuple[str, int], ...]:
|
||||
return tuple((item_name, cs.count(item_name, p)) for item_name in item_name_to_id)
|
||||
|
||||
|
||||
_cache_miss: Tuple[None, FrozenSet[Location]] = (None, frozenset())
|
||||
_cache_miss: tuple[None, frozenset[Location]] = (None, frozenset())
|
||||
|
||||
|
||||
class ZillionLogicCache:
|
||||
_cache: Dict[int, Tuple[_Counter[str], FrozenSet[Location]]]
|
||||
_cache: dict[int, tuple[Counter[str], frozenset[Location]]]
|
||||
""" `{ hash: (counter_from_prog_items, accessible_zz_locations) }` """
|
||||
_player: int
|
||||
_zz_r: Randomizer
|
||||
@@ -60,7 +61,7 @@ class ZillionLogicCache:
|
||||
self._zz_r = zz_r
|
||||
self._id_to_zz_item = id_to_zz_item
|
||||
|
||||
def cs_to_zz_locs(self, cs: CollectionState) -> FrozenSet[Location]:
|
||||
def cs_to_zz_locs(self, cs: CollectionState) -> frozenset[Location]:
|
||||
"""
|
||||
given an Archipelago `CollectionState`,
|
||||
returns frozenset of accessible zilliandomizer locations
|
||||
@@ -76,7 +77,7 @@ class ZillionLogicCache:
|
||||
return locs
|
||||
|
||||
# print("cache miss")
|
||||
have_items: List[Item] = []
|
||||
have_items: list[Item] = []
|
||||
for name, count in counts:
|
||||
have_items.extend([self._id_to_zz_item[item_name_to_id[name]]] * count)
|
||||
# have_req is the result of converting AP CollectionState to zilliandomizer collection state
|
||||
|
Reference in New Issue
Block a user