ó
    I†ÖiD  ã                   óB   • S r SSKJr  \(       a  SSKJr   " S S5      rg)zîRound timer utility for managing delays between rounds.

This is a stateless helper that operates on serialized Game fields:
- game.round_timer_state: "idle", "counting", or "paused"
- game.round_timer_ticks: Remaining ticks in countdown
é    )ÚTYPE_CHECKINGé   )ÚGamec                   óÖ   • \ rS rSrSrSrSrSr  SSSS\S	\	4S
 jjr
\S\4S j5       r\S\4S j5       r\S\4S j5       rSS\S-  SS4S jjrSS jrSS\	S-  SS4S jjrSS jrSrg)ÚRoundTransitionTimeré   a“  Manage delays between rounds using serialized game fields.

The timer is stateless; all data lives on the Game instance. The host can
pause/resume the countdown via the pause key.

Usage:
    self._round_timer = RoundTransitionTimer(self)
    self._round_timer.start()
    self._round_timer.on_tick()

    # Override in your game:
    def on_round_timer_ready(self) -> None:
        self._start_round()
ÚidleÚcountingÚpausedÚgamer   Údelay_secondsÚpause_messagec                 óB   • Xl         [        US-  5      U l        X0l        g)z½
Initialize the round timer.

Args:
    game: The game instance.
    delay_seconds: Seconds to wait between rounds (default 15).
    pause_message: Localization key for pause announcement.
é   N)Ú_gameÚintÚ_delay_ticksÚ_pause_message)Úselfr   r   r   s       Ú<c:\Users\dbart\PlayPalace11\server\game_utils\round_timer.pyÚ__init__ÚRoundTransitionTimer.__init__#   s!   € ð Œ
Ü °Ñ 2Ó3ˆÔØ+Õó    Úreturnc                 ó`   • U R                   R                  U R                  U R                  4;   $ )z3Check if the timer is running (counting or paused).)r   Úround_timer_stateÚCOUNTINGÚPAUSED©r   s    r   Ú	is_activeÚRoundTransitionTimer.is_active5   s&   € ð z‰z×+Ñ+°·±¸t¿{¹{Ð/KÑKÐKr   c                 óH   • U R                   R                  U R                  :H  $ )zCheck if the timer is paused.)r   r   r   r   s    r   Ú	is_pausedÚRoundTransitionTimer.is_paused:   s   € ð z‰z×+Ñ+¨t¯{©{Ñ:Ð:r   c                 ó:   • U R                   R                  S-   S-  $ )z#Get remaining seconds (rounded up).é   r   )r   Úround_timer_ticksr   s    r   Úremaining_secondsÚ&RoundTransitionTimer.remaining_seconds?   s   € ð —
‘
×,Ñ,¨rÑ1°bÑ8Ð8r   Nc                 ó²   • Ub  [        US-  5      U R                  l        OU R                  U R                  l        U R                  U R                  l        g)ze
Start the countdown timer.

Args:
    delay_seconds: Override the default delay for this countdown.
Nr   )r   r   r'   r   r   r   )r   r   s     r   ÚstartÚRoundTransitionTimer.startD   sB   € ð Ñ$Ü+.¨}¸rÑ/AÓ+BˆDJ‰JÕ(à+/×+<Ñ+<ˆDJ‰JÔ(Ø'+§}¡}ˆ
‰
Õ$r   c                 ó\   • U R                   U R                  l        SU R                  l        g)z/Stop the timer without triggering the callback.r   N)ÚIDLEr   r   r'   r   s    r   ÚstopÚRoundTransitionTimer.stopQ   s   € à'+§y¡yˆ
‰
Ô$Ø'(ˆ
‰
Õ$r   Úplayer_namec                 ó´  • U R                   R                  U R                  :X  aI  U R                  U R                   l        U R                   R	                  U R
                  U=(       d    SS9  gU R                   R                  U R                  :X  aG  U R                  U R                   l        SU R                   l        U R                   R                  5         gg)zä
Toggle pause state. Called when host presses 'p'.

- If counting: pause the timer
- If paused: skip remaining time and start next round
- If idle: do nothing

Args:
    player_name: Name of the player who triggered the action.
Ú )Úplayerr   N)	r   r   r   r   Úbroadcast_lr   r.   r'   Úon_round_timer_ready)r   r1   s     r   Útoggle_pauseÚ!RoundTransitionTimer.toggle_pauseV   s“   € ð :‰:×'Ñ'¨4¯=©=Ó8à+/¯;©;ˆDJ‰JÔ(ØJ‰J×"Ñ" 4×#6Ñ#6¸{×?PÈbÐ"ÒQØZ‰Z×)Ñ)¨T¯[©[Ó8à+/¯9©9ˆDJ‰JÔ(Ø+,ˆDJ‰JÔ(ØJ‰J×+Ñ+Õ-ð	 9r   c                 ó,  • U R                   R                  U R                  :w  a  gU R                   =R                  S-  sl        U R                   R                  S::  a6  U R                  U R                   l        U R                   R                  5         gg)z5Called every game tick. Decrements timer if counting.Né   r   )r   r   r   r'   r.   r6   r   s    r   Úon_tickÚRoundTransitionTimer.on_tickk   si   € à:‰:×'Ñ'¨4¯=©=Ó8Øà
‰
×$Ò$¨Ñ)Õ$ð :‰:×'Ñ'¨1Ó,Ø+/¯9©9ˆDJ‰JÔ(ØJ‰J×+Ñ+Õ-ð -r   )r   r   r   )g      .@zround-timer-paused)N)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r.   r   r   ÚfloatÚstrr   ÚpropertyÚboolr    r#   r   r(   r+   r/   r7   r;   Ú__static_attributes__© r   r   r   r      sÍ   † ñð  €DØ€HØ€Fð
  $Ø1ñ	,àð,ð ð,ð õ	,ð$ ðL˜4ó Ló ðLð ð;˜4ó ;ó ð;ð ð9 3ó 9ó ð9ñ5 5¨4¡<ð 5¸4õ 5ô)ñ
.¨¨d©
ð .¸dõ .÷*
.r   r   N)rA   Útypingr   Ú
games.baser   r   rG   r   r   Ú<module>rJ      s!   ðñõ !æÝ!÷g.ò g.r   