Skip to content

Commit

Permalink
make Player a dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
Expurple committed Nov 1, 2023
1 parent 1e3ea94 commit ae7ef26
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions smawg/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,24 +200,24 @@ def base_n_tokens(self) -> int:
)


@dataclass
class Player:
"""A bunch of "dumb" mutable stats, related to the same player.
Even though these stats are mutated during the game,
they aren't supposed to be directly modified by library users.
"""

def __init__(self, coins: int) -> None:
"""Initialize `Player` with an initial supply of `coins`."""
self.active_ability: Ability | None = None
self.active_race: Race | None = None
self.decline_race: Race | None = None
self.active_regions = dict[int, int]()
"""Dict of controlled regions, in form of `{region: n_tokens}`."""
self.decline_regions = set[int]()
"""A set of regions controlled by a single declined race token."""
self.tokens_on_hand = 0
self.coins = coins
coins: int
tokens_on_hand: int = Field(init_var=False, default=0)
active_ability: Ability | None = Field(init_var=False, default=None)
active_race: Race | None = Field(init_var=False, default=None)
decline_race: Race | None = Field(init_var=False, default=None)
active_regions: dict[int, int] = \
Field(init_var=False, default_factory=dict)
"""Dict of controlled regions, in form of `{region: n_tokens}`."""
decline_regions: set[int] = Field(init_var=False, default_factory=set)
"""A set of regions controlled by a single declined race token."""

def _is_owning(self, region: int) -> bool:
"""Check if `Player` owns the given `region`."""
Expand Down

0 comments on commit ae7ef26

Please sign in to comment.