
    Ii                         S r SSKJrJr  SSKJr  SSKJr  SSKJ	r	J
r
  SSKrSSKJr  \	(       a  S	S
KJr   " S S\5      r " S S\5      r\ " S S5      5       r " S S\5      rS\4S jrS\S\4S jrg)z-Abstract User class that games interact with.    )ABCabstractmethod)	dataclass)Enum)TYPE_CHECKINGAnyN   )Localization   UserPreferencesc                   $    \ rS rSrSrSrSrSrSrg)EscapeBehavior   z$How the escape key behaves in menus.keybindselect_last_optionescape_event N)	__name__
__module____qualname____firstlineno____doc__KEYBINDSELECT_LASTESCAPE_EVENT__static_attributes__r       5c:\Users\dbart\PlayPalace11\server\core\users\base.pyr   r      s    .G&K!Lr   r   c                   (    \ rS rSrSrSrSrSrSrSr	g)	
TrustLevel   z'User trust level for permission checks.r   r      r	   r   N)
r   r   r   r   r   BANNEDUSERADMINSERVER_OWNERr   r   r   r   r!   r!      s    1FDELr   r!   c                   j    \ rS rSr% Sr\\S'   Sr\S-  \S'   Sr\S-  \S'   S\	\\
4   \-  4S jrS	rg)
MenuItem    z&A menu item with text and optional ID.textNidsoundreturnc                     U R                   c  U R                  bH  SU R                  0nU R                   b  U R                   US'   U R                  b  U R                  US'   U$ U R                  $ )z<Serialize menu item to a dict or string for client payloads.r+   r,   r-   )r,   r-   r+   )selfdatas     r   to_dictMenuItem.to_dict(   s`    77$**"8DII&Dww"!WWT
zz% $

WKyyr   r   )r   r   r   r   r   str__annotations__r,   r-   dictr   r2   r   r   r   r   r)   r)       s?    0
IBd
E3:	c3h#- 	r   r)   c                      \ rS rSrSr\\S\4S j5       5       r\\S\4S j5       5       r	\\S\4S j5       5       r
\S\4S j5       r\S6S j5       r\S7S	\S
\SS4S jj5       rS7S\S
\SS4S jjr\S8S\S\S\S\SS4
S jj5       r\S9S\S\SS4S jj5       r\S:S j5       r\S;S\S\S\SS4S jj5       r\S:S j5       r\S\R0                  SSSSS.S \S!\\\-     S"\S#\S$\S-  S%\S&\S'\SS4S( jj5       r\   S<S \S!\\\-     S$\S-  S)\S-  S'\SS4S* jj5       r\S \SS4S+ j5       r\ S=SSS,.S-\S.\S/\S0\S1\SS4S2 jjj5       r\S-\SS4S3 j5       r\S:S4 j5       r S5r!g)>User4   z
Abstract base class for users.

Games interact with this interface, never with network code directly.
Implementations include NetworkUser (real players), TestUser (for testing),
and Bot (AI players).
r.   c                     g)z+The user's unique identifier (UUID string).Nr   r0   s    r   uuid	User.uuid=        	r   c                     g)zThe user's display name.Nr   r;   s    r   usernameUser.usernameC   r>   r   c                     g)z6The user's locale for localization (e.g., 'en', 'es').Nr   r;   s    r   localeUser.localeI   r>   r   c                 "    [         R                  $ )z;The user's trust level. Defaults to USER if not overridden.)r!   r%   r;   s    r   trust_levelUser.trust_levelO   s     r   c                     SSK Jn  U" 5       $ )z;The user's preferences. Returns defaults if not overridden.r   r   )preferencesr   )r0   r   s     r   rI   User.preferencesT   s     	1  r   r+   bufferNc                     g)z
Send a text message to be displayed and spoken via TTS.

Args:
    text: The message text.
    buffer: Which buffer to route the message to (misc, activity, chats).
Nr   )r0   r+   rK   s      r   speak
User.speak[        	r   
message_idc                 j    [         R                  " U R                  U40 UD6nU R                  XB5        g)z
Send a localized message to be displayed and spoken via TTS.

Args:
    message_id: The message ID from the .ftl file.
    buffer: Which buffer to route the message to (misc, activity, chats).
    **kwargs: Variables to substitute into the message.
N)r
   getrC   rM   )r0   rP   rK   kwargsr+   s        r   speak_lUser.speak_lf   s+     ZB6B

4 r   namevolumepanpitchc                     g)z
Play a sound effect.

Args:
    name: Sound filename.
    volume: Volume 0-100.
    pan: Pan -100 to 100.
    pitch: Pitch 0-200, where 100 is normal.
Nr   )r0   rV   rW   rX   rY   s        r   
play_soundUser.play_soundr   s     	r   Tloopingc                     g)za
Play background music.

Args:
    name: Music filename.
    looping: Whether to loop the music.
Nr   )r0   rV   r]   s      r   
play_musicUser.play_music   rO   r   c                     g)zStop background music.Nr   r;   s    r   
stop_musicUser.stop_music        	r   loopintrooutroc                     g)z
Play ambient background sound.

Args:
    loop: Looping ambient sound filename.
    intro: Optional intro sound played once before loop.
    outro: Optional outro sound played when stopping.
Nr   )r0   re   rf   rg   s       r   play_ambienceUser.play_ambience   s     	r   c                     g)zStop ambient background sound.Nr   r;   s    r   stop_ambienceUser.stop_ambience   rd   r   Fr   )multiletterescape_behaviorpositiongrid_enabled
grid_widthplay_selection_soundmenu_iditemsrn   ro   rp   rq   rr   rs   c                    g)a  
Display a menu to the user.

Args:
    menu_id: String identifier for this menu.
    items: List of menu items (strings or MenuItem objects).
    multiletter: Enable type-to-search navigation.
    escape_behavior: How escape key behaves (see EscapeBehavior enum).
    position: 1-based position to select (None for first item).
    grid_enabled: Enable grid navigation mode.
    grid_width: Number of columns in grid mode.
    play_selection_sound: Play the selection sound for the focused item.
Nr   )	r0   rt   ru   rn   ro   rp   rq   rr   rs   s	            r   	show_menuUser.show_menu   s    4 	r   selection_idc                     g)a  
Update an existing menu's items.

Args:
    menu_id: The menu to update.
    items: New list of items.
    position: Optional new position (1-based).
    selection_id: Optional item ID to focus on.
    play_selection_sound: If True, client plays selection sound at new focus.
Nr   )r0   rt   ru   rp   ry   rs   s         r   update_menuUser.update_menu   s    & 	r   c                     g)z8
Remove a menu.

Args:
    menu_id: The menu to remove.
Nr   )r0   rt   s     r   remove_menuUser.remove_menu        	r   )	multiline	read_onlyinput_idpromptdefault_valuer   r   c                    g)a  
Display an editbox to the user.

Args:
    input_id: String identifier for this editbox.
    prompt: Prompt text to display.
    default_value: Default text in the editbox.
    multiline: Whether to use a multiline editbox.
    read_only: Whether the editbox is read-only.
Nr   )r0   r   r   r   r   r   s         r   show_editboxUser.show_editbox   s    ( 	r   c                     g)z@
Remove an editbox.

Args:
    input_id: The editbox to remove.
Nr   )r0   r   s     r   remove_editboxUser.remove_editbox   r   r   c                     g)zClear all menus and editboxes.Nr   r;   s    r   clear_uiUser.clear_ui   rd   r   r   )r.   r   )misc)d   r   r   )T)r.   N) r   )NNF)r   )"r   r   r   r   r   propertyr   r4   r<   r@   rC   r!   rF   rI   rM   rT   intr[   boolr_   rb   ri   rl   r   r   listr)   rw   r{   r~   r   r   r   r   r   r   r   r8   r8   4   sP    c    #        Z   ! ! # s   
!# 
!s 
!$ 
! 
s 
C 
C 
C 
Z^ 
 
 s T T     	# 	c 	s 	D 	 	    !*8*@*@#"%* C(N#
  ( *   # 
 6 
  $#'%* C(N# *	
 Dj # 
 ( 3 4   
  	    	   
 * s t    r   r8   r.   c                  >    [        [        R                  " 5       5      $ )zGenerate a new UUID string.)r4   uuid_moduleuuid4r   r   r   generate_uuidr     s    {  "##r   rV   c                 t    [         R                  " S5      n[        [         R                  " USU  35      5      $ )zGenerate a deterministic UUID for a virtual bot based on its name.

This ensures virtual bots have consistent UUIDs across server restarts
so their game stats persist properly.
z$a1b2c3d4-e5f6-7890-abcd-ef1234567890zvirtual_bot:)r   UUIDr4   uuid5)rV   	namespaces     r   generate_virtual_bot_uuidr     s4       !GHI{  l4&,ABCCr   )r   abcr   r   dataclassesr   enumr   typingr   r   r<   r   messages.localizationr
   rI   r   r   r!   r)   r8   r4   r   r   r   r   r   <module>r      s    3 # !  %  1,"T "    &J3 JZ$s $
DC DC Dr   