
    Ii3.                     r    S r SSKJr  \(       a  SSKJr  SSKJrJrJr  SSK	J
r
  SSKJrJr   " S	 S
5      rg)z.Mixin providing action set creation for games.    )TYPE_CHECKING   )Player   )Action	ActionSetEditboxInput)Localization)KeybindKeybindStatec                       \ rS rSrSrSSS\4S jrSSS\4S jrSSS\4S jrSS
 jr	SSS\S	-  4S jr
SS jrS\R                  S	SS.S\S\S\\   S\S\S\\   S	-  S\SS	4S jjrS\S\S	-  4S jrSrg	)ActionSetCreationMixin   a  Create standard/lobby action sets and define keybinds.

Games override `create_turn_action_set` to define turn-specific actions.
This mixin also defines the global keybinds used across games.

Expected Game attributes:
    players: list[Player].
    player_action_sets: dict[str, list[ActionSet]].
    _keybinds: dict[str, list[Keybind]].
    get_user(player) -> User | None.
    add_action_set(player, action_set).
playerr   returnc                    U R                  U5      nU(       a  UR                  OSn[        SS9nUR                  [	        S[
        R                  " US5      SSSS	95        UR                  [	        S
[
        R                  " US5      SSS[        SSSS9S95        UR                  [	        S[
        R                  " US5      SSSS	95        UR                  [	        S[
        R                  " US5      SSSSS95        U$ ) z)Create the lobby action set for a player.enlobbyname
start_gamez
start-game_action_start_game_is_start_game_enabled_is_start_game_hiddenidlabelhandler
is_enabled	is_hiddenadd_botzadd-bot_action_add_bot_is_add_bot_enabled_is_add_bot_hiddenzenter-bot-name _bot_input_add_bot)promptdefault	bot_input)r   r   r   r   r    input_request
remove_botz
remove-bot_action_remove_bot_is_remove_bot_enabled_is_remove_bot_hiddentoggle_spectatorspectate_action_toggle_spectator_is_toggle_spectator_enabled_is_toggle_spectator_hidden_get_toggle_spectator_label)r   r   r   r   r    	get_label)get_userlocaler   addr   r
   getr	   selfr   userr7   
action_sets        Jc:\Users\dbart\PlayPalace11\server\game_utils\action_set_creation_mixin.pycreate_lobby_action_set.ActionSetCreationMixin.create_lobby_action_set   s	   }}V$ $$G,
"&&v|<,31	
 	"&&vy9)0.*+2	
 	"&&v|<,31	
 	%"&&vz:2977		
     c           
          U R                  U5      nU(       a  UR                  OSn[        SS9nUR                  [	        S[
        R                  " US5      SSSS	95        U$ )
z5Create the estimate duration action set for a player.r   estimater   estimate_durationzestimate-duration_action_estimate_duration_is_estimate_duration_enabled_is_estimate_duration_hiddenr   r6   r7   r   r8   r   r
   r9   r:   s        r>   create_estimate_action_set1ActionSetCreationMixin.create_estimate_action_setM   s`    }}V$ $$J/
&"&&v/BC3:8	
 rA   c                 v   U R                  U5      nU(       a  UR                  OSn[        SS9nUR                  [	        S[
        R                  " US5      SSSS	S
95        UR                  [	        S[
        R                  " US5      SSSS95        UR                  [	        S[
        R                  " US5      SSSS95        UR                  [	        S[
        R                  " US5      SSSS95        UR                  [	        S[
        R                  " US5      SSSS95        UR                  [	        S [
        R                  " US!5      S"S#S$S95        UR                  [	        S%[
        R                  " US&5      S'S(S)S95        UR                  [	        S*[
        R                  " US+5      S,S-S.S95        U$ )/z7Create the standard action set (F5, save) for a player.r   standardr   show_actionszactions-menu_action_show_actions_menu_is_show_actions_enabled_is_always_hiddenF)r   r   r   r   r    show_in_actions_menu
save_tablez
save-table_action_save_table_is_save_table_enabled_is_save_table_hiddenr   
whose_turnz
whose-turn_action_whose_turn_is_whose_turn_enabled_is_whose_turn_hiddenwhos_at_tablezwhos-at-table_action_whos_at_table_is_whos_at_table_enabled_is_whos_at_table_hiddencheck_scoreszcheck-scores_action_check_scores_is_check_scores_enabled_is_check_scores_hiddencheck_scores_detailedzcheck-scores-detailed_action_check_scores_detailed!_is_check_scores_detailed_enabled _is_check_scores_detailed_hiddenpredict_outcomeszpredict-outcomes_action_predict_outcomes_is_predict_outcomes_enabled_is_predict_outcomes_hidden
leave_gamezleave-table_action_leave_game_is_leave_game_enabled_is_leave_game_hiddenrH   r:   s        r>   create_standard_action_set1ActionSetCreationMixin.create_standard_action_set^   s   }}V$ $$J/
!"&&v~>35-%*		
 	"&&v|<,31	
 	"&&v|<,31	
 	""&&v?/64	
 	!"&&v~>.53	
 	*"&&v/FG7><	
 	%"&&v/AB297	
 	"&&v}=,31	
 rA   Nc           	         U R                  SSS/[        R                  SS9  U R                  SSS/[        R                  SS9  U R                  S	S
S/[        R                  SS9  U R                  SSS/[        R                  SS9  U R                  SSS/[        R                  SS9  U R                  SSS/[        R                  SS9  U R                  SSS/[        R                  U R                  /SS9  U R                  SSS/[        R                  S9  U R                  SSS/[        R
                  SS9  U R                  S S!S"/[        R                  SS9  U R                  S#S$S%/[        R
                  SS9  U R                  S&S'S(/[        R
                  SS9  U R                  S)S*S+/[        R
                  SS9  g,)-z!Define all keybinds for the game.enterz
Start gamer   T)stateinclude_spectatorsbzAdd botr!   zshift+bz
Remove botr+   f3zToggle spectatorr/   zctrl+qzLeave tablerj   escapezActions menurM   zctrl+ezEstimate durationrD   )rr   playersrs   zctrl+sz
Save tablerR   )rr   tz
Whose turnrV   zctrl+wzWho's at the tablerZ   szCheck scoresr^   zshift+szDetailed scoresrb   zctrl+rzPredict outcomesrf   N)define_keybindr   IDLEALWAYShostACTIVE)r;   s    r>   setup_keybinds%ActionSetCreationMixin.setup_keybinds   sC    	N### 	 	
 	K### 	 	
 	N### 	 	
 	 ### 	 	
 	N%%# 	 	
 	%%# 	 	
 	 !##YYK# 	 	
 	Hl\N,J]J]^ 	N%%# 	 	
 	 %%# 	 	
 	%%# 	 	
 	$%%%# 	 	
 	 %%# 	 	
rA   c                     g)zCreate the turn action set for a player.

Override in subclasses to add game-specific turn actions.
Returns None by default (no turn actions).
N )r;   r   s     r>   create_turn_action_set-ActionSetCreationMixin.create_turn_action_set  s     rA   c                    U R                  U5      nU(       a  U R                  X5        U R                  U5      nU R                  X5        [        U S5      (       a"  U R	                  U5      nU R                  X5        U R                  U5      nU R                  X5        U R                  U5      nU R                  X5        g)z:Set up action sets for a player. Called when player joins.optionsN)r   add_action_setr?   hasattrcreate_options_action_setrI   rn   )r;   r   turn_set	lobby_setoptions_setestimate_setstandard_sets          r>   setup_player_actions+ActionSetCreationMixin.setup_player_actions  s     ..v61008	F. 4##88@K4 66v>F166v>F1rA   F)requires_focusrr   rw   rs   keyr   actionsr   rr   rw   rs   c          
          [        UUUUUU=(       d    / US9nXR                  ;  a  / U R                  U'   U R                  U   R                  U5        g)a  
Define a keybind that triggers one or more actions.

Args:
    key: The key combination (e.g., "space", "shift+b", "f5")
    name: Human-readable name for the keybind (e.g., "Roll dice")
    actions: List of action IDs this keybind triggers
    requires_focus: If True, must be focused on a valid menu item
    state: When the keybind is active (NEVER, IDLE, ACTIVE, ALWAYS)
    players: List of player names who can use (empty/None = all)
    include_spectators: Whether spectators can use this keybind
)r   default_keyr   r   rr   rw   rs   N)r   	_keybindsappend)	r;   r   r   r   r   rr   rw   rs   keybinds	            r>   rz   %ActionSetCreationMixin.define_keybind0  sX    . )Mr1
 nn$"$DNN3s""7+rA   	action_idc                     U R                   R                  5        H#  u  p#U H  nXR                  ;   d  M  Us  s  $    M%     g)z-Get the keybind string for an action, if any.N)r   itemsr   )r;   r   r   keybindsr   s        r>   _get_keybind_for_action.ActionSetCreationMixin._get_keybind_for_actionT  s9    !^^113MC#/J $ 4 rA   r   )r   N)r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r?   rI   rn   r   r   r   r   r|   strlistboolrz   r   __static_attributes__r   rA   r>   r   r      s    0h 09 0d i "R Ri Rh[
zX )d:J 2>  %*11$(#(",", ", c	", ", ", cT!", !", 
",H t rA   r   N)r   typingr   
games.baser   r   r   r   r	   messages.localizationr
   server.core.ui.keybindsr   r   r   r   rA   r>   <module>r      s)    4  # 4 4 0 9M MrA   