
    Ii                    L    S SK Jr  S SKJrJr  S SKJr  \ " S S\5      5       rg)    )annotations)	dataclassfield)DataClassJSONMixinc                      \ rS rSr% SrS\S'   SrS\S'   SrS	\S
'   SrS	\S'   Sr	S	\S'   \
" \S9rS\S'   \
" \S9rS\S'      S       SS jjrSS jrSS jrSS jrSS jrSS jrSrg) PokerBettingRound   a  Track betting state for a single poker betting round.

Attributes:
    order: Player IDs in betting order.
    max_raises: Maximum raises allowed (None for unlimited).
    current_bet: Current amount to call.
    last_raise_size: Size of the last raise.
    raises_count: Number of raises so far.
    bets: Per-player bet amounts for this round.
    acted_since_raise: Players who have acted since the last raise.
z	list[str]orderNz
int | None
max_raisesr   intcurrent_betlast_raise_sizeraises_count)default_factoryzdict[str, int]betsset[str]acted_since_raisec                   Xl         X l        SU l        U R                   Vs0 s H  oDS_M     snU l        U(       a8  UR                  5        H$  u  pEX@R                  ;   d  M  XPR                  U'   M&     [        5       U l        gs  snf )z3Reset round state with optional initial bet values.r   N)r   r   r   r
   r   itemssetr   )selfr   r   initial_betspidamounts         >c:\Users\dbart\PlayPalace11\server\game_utils\poker_betting.pyresetPokerBettingRound.reset   sr     '.'+zz2z!Vz2	+113))#%+IIcN  4 "% 3s   Bc                h    [        SU R                  U R                  R                  US5      -
  5      $ )z.Return the amount needed for a player to call.r   )maxr   r   get)r   	player_ids     r   amount_to_call PokerBettingRound.amount_to_call/   s)    1d&&y!)DDEE    c                P    U R                   c  gU R                  U R                   :  $ )z2Return True if the raise cap has not been reached.T)r   r   )r   s    r   	can_raisePokerBettingRound.can_raise3   s$    ??"  4??22r$   c                r   U R                   R                  US5      U-   U R                   U'   U(       ai  U =R                  S-  sl        U R                   U   U R                  -
  n[	        U R
                  U5      U l        U R                   U   U l        U1U l        gU R                  R                  U5        g)z-Record a bet or raise and update round state.r      N)r   r    r   r   r   r   r   add)r   r!   r   is_raise
raise_sizes        r   
record_betPokerBettingRound.record_bet9   s    #yy}}Y:VC		)"9-0@0@@J#&t';';Z#HD #yy3D&/[D"""&&y1r$   c                    U H6  nX2;   a  M
  U R                   R                  US5      U R                  :w  d  M6    g   U H  nX2;   a  M
  X0R                  ;  d  M    g   g)zAReturn True if all active players have matched the bet and acted.r   FT)r   r    r   r   )r   
active_ids
all_in_idsr   s       r   is_completePokerBettingRound.is_completeE   s^    C yy}}S!$(8(88	  C 000	 
 r$   c                n   U R                   (       d  gSnU(       aC  XR                   ;   a4  U R                   R                  U5      S-   [        U R                   5      -  n[        [        U R                   5      5       H5  nX4-   [        U R                   5      -  nU R                   U   nXb;   d  M3  Us  $    g)z2Return the next active player id in betting order.Nr   r)   )r
   indexlenrange)r   
current_idr0   start_indexiidxr   s          r   next_playerPokerBettingRound.next_playerT   s    zz*

2::++J7!;s4::NKs4::'A?c$**o5C**S/C 
	 (
 r$   )r   r   r   r   r   )r   r   N)r   r   r   r   r   zdict[str, int] | NonereturnNone)r!   strr>   r   )r>   bool)r!   r@   r   r   r+   rA   r>   r?   )r0   r   r1   r   r>   rA   )r8   
str | Noner0   r   r>   rB   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   dictr   r   r   r   r"   r&   r-   r2   r<   __static_attributes__ r$   r   r   r      s    
 !J
!KOSL# 6D.6"'"<x<  .2	'' ' ,	'
 
'"F3
2r$   r   N)
__future__r   dataclassesr   r   mashumaro.mixins.jsonr   r   rK   r$   r   <module>rO      s-    " ( 4 W* W Wr$   