Core: use assert correctly (#345)

Core: add some more types to State and add count() method
This commit is contained in:
Fabian Dill
2022-03-26 01:12:54 +01:00
committed by GitHub
parent 902472be32
commit 64ac619b46
6 changed files with 20 additions and 17 deletions

View File

@@ -644,15 +644,18 @@ class CollectionState():
self.events.add(event)
self.collect(event.item, True, event)
def has(self, item: str, player: int, count: int = 1):
def has(self, item: str, player: int, count: int = 1) -> bool:
return self.prog_items[item, player] >= count
def has_all(self, items: Set[str], player: int):
def has_all(self, items: Set[str], player: int) -> bool:
return all(self.prog_items[item, player] for item in items)
def has_any(self, items: Set[str], player: int):
def has_any(self, items: Set[str], player: int) -> bool:
return any(self.prog_items[item, player] for item in items)
def count(self, item: str, player: int) -> int:
return self.prog_items[item, player]
def has_group(self, item_name_group: str, player: int, count: int = 1):
found: int = 0
for item_name in self.world.worlds[player].item_name_groups[item_name_group]: