Coverage for src / beaverbunch / core / player.py: 100.0%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-05 20:45 +0000

1from dataclasses import dataclass 

2from typing import TYPE_CHECKING 

3 

4from beaverbunch.core.hand import Hand 

5 

6if TYPE_CHECKING: 

7 from beaverbunch.core.card import Card 

8 

9 

10@dataclass 

11class Player: 

12 """Represents a player in the game, holding a hand of cards and a name. 

13 

14 Attributes: 

15 name: The name of the player. 

16 hand: The player's hand of cards, which may contain known and unknown cards. 

17 """ 

18 name: str 

19 hand: Hand 

20 

21 def __post_init__(self) -> None: 

22 if not self.name: 

23 raise ValueError("Player name cannot be empty") 

24 

25 def get_points(self) -> int: 

26 """Calculates the total points in the player's hand.""" 

27 return sum(card.points for card in self.hand)