File size: 726 Bytes
e99c9a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import annotations

from dataclasses import dataclass, field

from persistentpoker_bench.cards import Card, cards_to_notation

WinnerAction = str


@dataclass(slots=True)
class PersistentPool:
    cards: list[Card] = field(default_factory=list)

    def append_community_cards(self, community_cards: list[Card] | tuple[Card, ...]) -> None:
        self.cards.extend(community_cards)

    def resolve_for_next_hand(self, winner_action: WinnerAction | None) -> None:
        if winner_action == "reset":
            self.cards.clear()

    def snapshot(self) -> tuple[Card, ...]:
        return tuple(self.cards)

    def notation_snapshot(self) -> tuple[str, ...]:
        return cards_to_notation(self.cards)