Skip to content

Commit

Permalink
Add has_all_counts and has_any_counts
Browse files Browse the repository at this point in the history
  • Loading branch information
NewSoupVi committed Mar 11, 2024
1 parent 5fecb7f commit 24c732c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,14 @@ def has_any(self, items: Iterable[str], player: int) -> bool:
"""Returns True if at least one item name of items is in state at least once."""
return any(self.prog_items[player][item] for item in items)

def has_all_counts(self, item_counts: Dict[str, int], player: int) -> bool:
"""Returns True if each item name is in the state at least as many times as specified."""
return all(self.prog_items[player][item] >= count for item, count in item_counts.items())

def has_any_count(self, item_counts: Dict[str, int], player: int) -> bool:
"""Returns True if at least one item name is in the state at least as many times as specified."""
return any(self.prog_items[player][item] >= count for item, count in item_counts.items())

def count(self, item: str, player: int) -> int:
return self.prog_items[player][item]

Expand Down

0 comments on commit 24c732c

Please sign in to comment.