
    Ii
                    x    S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  \(       a   \ " S	 S
\	5      5       rg)a   
Player dataclass for Pirates of the Lost Seas.

Contains player state including position, score, gems, leveling system, and skill state.

Inherits from Player which has DataClassJSONMixin, so this class is serializable.
All fields are primitive types or simple serializable dataclasses.
    )annotations)	dataclassfield)TYPE_CHECKING   )Player   )LevelingSystemc                     \ rS rSr% SrSrS\S'   SrS\S'   \" \	S9r
S\S	'   \" S
S9rS\S'   \" \S9rS\S'   \" \S9rS\S'   \" \S9rS\S'   S r\SS j5       r\SS j5       r\SS j5       rSS jrSS jrSS jrS S jrSrg
)!PiratesPlayer   a  
Player state for Pirates of the Lost Seas.

Skill state is stored in simple dicts that serialize easily:
- skill_cooldowns: remaining cooldown turns per skill
- skill_active: remaining active turns for buffs
- skill_uses: remaining uses for limited-use skills

The game object is NEVER stored on this class - it is only passed as a
parameter to methods. This ensures the player remains serializable.
r   intpositionscore)default_factoryz	list[int]gemsN)defaultr
   	_levelingzdict[str, int]skill_cooldownsskill_active
skill_usesc                P    U R                   c  [        U R                  S9U l         gg)z*Initialize the leveling system if not set.N)user_id)r   r
   idselfs    :c:\Users\dbart\PlayPalace11\server\games\pirates\player.py__post_init__PiratesPlayer.__post_init__/   s!    >>!+DGG<DN "    c                    U R                   $ )z(Get the leveling system for this player.)r   r   s    r   levelingPiratesPlayer.leveling4   s     ~~r    c                .    U R                   R                  $ )z#Shortcut to get the player's level.)r   levelr   s    r   r%   PiratesPlayer.level9   s     ~~###r    c                .    U R                   R                  $ )z Shortcut to get the player's XP.)r   xpr   s    r   r(   PiratesPlayer.xp>   s     ~~   r    c                d    U R                   R                  U5        U =R                  U-  sl        g)z6Add a gem to the player's collection and update score.N)r   appendr   )r   gem_type	gem_values      r   add_gemPiratesPlayer.add_gemC   s"    		"

i
r    c                    SUs=::  a  [        U R                  5      :  a  O  gU R                  R                  U5      $ g)z?Remove and return a gem at the given index, or None if invalid.r   N)lenr   pop)r   	gem_indexs     r   
remove_gemPiratesPlayer.remove_gemH   s2    	*C		N* 99==++r    c                2    [        U R                  5      S:  $ )z!Check if the player has any gems.r   )r1   r   r   s    r   has_gemsPiratesPlayer.has_gemsN   s    499~!!r    c                N   ^ [        U4S jU R                   5       5      U l        g)zFRecalculate score from current gems using the provided value function.c              3  4   >#    U  H  nT" U5      v   M     g 7f)N ).0gemget_gem_values     r   	<genexpr>2PiratesPlayer.recalculate_score.<locals>.<genexpr>T   s     Ays++ys   N)sumr   r   )r   r>   s    `r   recalculate_scorePiratesPlayer.recalculate_scoreR   s    AtyyAA
r    )r   r   )returnr
   )rD   r   )r,   r   r-   r   rD   None)r3   r   rD   z
int | None)rD   bool)r>   callablerD   rE   )__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   listr   r   dictr   r   r   r   propertyr"   r%   r(   r.   r4   r7   rB   __static_attributes__r;   r    r   r   r      s    
 HcE3ND1D)1 !&d 3I~3 ',D&AO^A#(#>L.>!&t!<J<=
   $ $ ! ! 
"Br    r   N)rL   
__future__r   dataclassesr   r   typingr   baser   r"   r
   r   r;   r    r   <module>rV      s?    # (    $ >BF >B >Br    