
    Ii%                     <   % S r SSKJrJr  SSKJr  SSKrSSKJr   " S S\	\5      r
 " S S	\	\5      r " S
 S\	\5      r " S S\	\5      r0 \R                  S_\R                  S_\R                   S_\R"                  S_\R$                  S_\R&                  S_\R(                  S_\R*                  S_\R,                  S_\R.                  S_\R0                  S_\R2                  S_\R4                  S_\R6                  S_\R8                  S_\R:                  S_\R<                  S_\R>                  S\R@                  S 0Er!\"\	\	4   \#S!'   \R2                  \R4                  \R6                  \R8                  \R:                  1r$\R4                  \R6                  \R8                  \R:                  1r%\R2                  \R<                  \R>                  \R@                  1r&\ " S" S#\5      5       r'\ " S$ S%\5      5       r(S&\'S'\	S(\	4S) jr)S*\*\'   S'\	S(\	4S+ jr+g),z7Card definitions and deck management for Age of Heroes.    )	dataclassfield)EnumN)DataClassJSONMixinc                   $    \ rS rSrSrSrSrSrSrg)CardType
   zCard type enumeration.resourcespecialevent N)	__name__
__module____qualname____firstlineno____doc__RESOURCESPECIALEVENT__static_attributes__r       =c:\Users\dbart\PlayPalace11\server\games\ageofheroes\cards.pyr   r   
   s     HGEr   r   c                   ,    \ rS rSrSrSrSrSrSrSr	Sr
g	)
ResourceType   zStandard resource types.ironwoodgrainstonegoldr   N)r   r   r   r   r   IRONWOODGRAINSTONEGOLDr   r   r   r   r   r      s    "DDEEDr   r   c                   0    \ rS rSrSrSrSrSrSrSr	Sr
S	rg
)SpecialResourceType   z8Special resources for monument building (one per tribe).	limestoneconcretemarblebricks	sandstonegraniter   N)r   r   r   r   r   	LIMESTONECONCRETEMARBLEBRICKS	SANDSTONEGRANITEr   r   r   r   r'   r'      s#    BIHFFIGr   r'   c                   8    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrg)	EventType'   zEvent card types.population_growth
earthquakeeruptionhunger
barbariansolympicsherofortuner   N)r   r   r   r   r   POPULATION_GROWTH
EARTHQUAKEERUPTIONHUNGER
BARBARIANSOLYMPICSHEROFORTUNEr   r   r   r   r6   r6   '   s.    +JHFJHDGr   r6   zageofheroes-resource-ironzageofheroes-resource-woodzageofheroes-resource-grainzageofheroes-resource-stonezageofheroes-resource-goldzageofheroes-special-limestonezageofheroes-special-concretezageofheroes-special-marblezageofheroes-special-brickszageofheroes-special-sandstonezageofheroes-special-granitez#ageofheroes-event-population-growthzageofheroes-event-earthquakezageofheroes-event-eruptionzageofheroes-event-hungerzageofheroes-event-barbarianszageofheroes-event-olympicszageofheroes-event-herozageofheroes-event-fortuneCARD_NAME_KEYSc                       \ rS rSr% Sr\\S'   \\S'   \\S'   S\4S jrS\	4S jr
S\	4S	 jrS\	4S
 jrS\	4S jrS\	4S jrS\	4S jrSrg)Cardh   zA single card in Age of Heroes.id	card_typesubtypereturnc                 V    [         R                  U R                  U R                  5      $ )z.Get the localization key for this card's name.)rH   getrN   selfs    r   get_name_keyCard.get_name_keyp   s    !!$,,==r   c                 <    U R                   [        R                  :H  $ )z*Check if this is a standard resource card.)rM   r   r   rR   s    r   is_resourceCard.is_resourcet   s    ~~!2!222r   c                 <    U R                   [        R                  :H  $ )z-Check if this is a special monument resource.)rM   r   r   rR   s    r   is_special_resourceCard.is_special_resourcex   s    ~~!1!111r   c                 <    U R                   [        R                  :H  $ )zCheck if this is an event card.)rM   r   r   rR   s    r   is_eventCard.is_event|   s    ~~//r   c                 p    U R                   [        R                  :H  =(       a    U R                  [        ;   $ )zBCheck if this event must be played/discarded in preparation phase.)rM   r   r   rN   MANDATORY_EVENTSrR   s    r   is_mandatory_eventCard.is_mandatory_event   s$    ~~/TDLLDT4TTr   c                 p    U R                   [        R                  :H  =(       a    U R                  [        ;   $ )z"Check if this is a disaster event.)rM   r   r   rN   DISASTER_EVENTSrR   s    r   is_disasterCard.is_disaster   s#    ~~/SDLLO4SSr   c                 p    U R                   [        R                  :H  =(       a    U R                  [        ;   $ )z$Check if this is a beneficial event.)rM   r   r   rN   BENEFICIAL_EVENTSrR   s    r   is_beneficial_eventCard.is_beneficial_event   s$    ~~/UDLLDU4UUr   r   N)r   r   r   r   r   int__annotations__strrT   boolrW   rZ   r]   ra   re   ri   r   r   r   r   rJ   rJ   h   sn    )GNL>c >3T 32T 20$ 0UD UTT TVT Vr   rJ   c                      \ rS rSr% Sr\" \S9r\\   \	S'   Sr
\\	S'   S\S\S	\4S
 jrSS\S	S4S jjrSS jrSS\S	\\   4S jjrS	\S-  4S jrS\S	S4S jrS\\   S	S4S jrS	\4S jrS	\4S jrSS\S\S-  S	\4S jjrSrg)Deck   z4A deck of cards with draw and shuffle functionality.)default_factorycardsr   _next_idrM   rN   rO   c                 X    [        U R                  XS9nU =R                  S-  sl        U$ )zCreate a card with a unique ID.)rL   rM   rN      )rJ   rt   )rS   rM   rN   cards       r   _create_cardDeck._create_card   s%    t}}	Kr   num_playersNc                 T   / U l         [        R                  [        R                  [        R                  [        R
                  /nU HN  n[        S5       H<  nU R                   R                  U R                  [        R                  U5      5        M>     MP     [        S5       HJ  nU R                   R                  U R                  [        R                  [        R                  5      5        ML     SSKJnJn  [        U5      SU nU HR  nXh   n	[        S5       H<  nU R                   R                  U R                  [        R                   U	5      5        M>     MT     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R&                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R(                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R*                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R,                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R.                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R0                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R2                  5      5        ML     [        S5       HJ  nU R                   R                  U R                  [        R"                  [$        R4                  5      5        ML     g)a  Build a standard Age of Heroes deck.

The deck composition matches the original Pascal version (108 cards):
- 12 of each standard resource (Iron, Wood, Grain, Stone) = 48 cards
- 6 Gold cards
- 6 of each special resource (all 6 types) = 36 cards
- Event cards (18 total)
      rv   )TribeTRIBE_SPECIAL_RESOURCEN      )rs   r   r!   r"   r#   r$   rangeappendrx   r   r   r%   stater~   r   listr   r   r6   r@   rA   rB   rC   rD   rE   rF   rG   )
rS   rz   standard_resourcesr
   _r~   r   tribestriber   s
             r   build_standard_deckDeck.build_standard_deck   s    
 	
 +H2Y

!!$"3"3H4E4Ex"PQ  +
 qAJJd//0A0A<CTCTUV 
 	9e\k*E,3G1X

!!$"3"3H4D4Dg"NO   qAJJd//	@[@[\]  qAJJd//	@T@TUV  qAJJd//	@R@RST  qAJJd//	@P@PQR  qAJJd//	@T@TUV  qAJJd//	@R@RST  qAJJd//	OP  qAJJd//	@Q@QRS r   c                 D    [         R                  " U R                  5        g)z$Shuffle the deck using Fisher-Yates.N)randomshufflers   rR   s    r   r   Deck.shuffle   s    tzz"r   countc                     / n[        U5       H@  nU R                  (       d  M  UR                  U R                  R                  S5      5        MB     U$ )z$Draw cards from the top of the deck.r   )r   rs   r   pop)rS   r   drawnr   s       r   draw	Deck.draw   s>    uAzzzTZZ^^A./  r   c                 \    U R                   (       a  U R                   R                  S5      $ g)z,Draw a single card from the top of the deck.r   N)rs   r   rR   s    r   draw_oneDeck.draw_one   s    ::::>>!$$r   rw   c                 :    U R                   R                  U5        g)z%Add a card to the bottom of the deck.N)rs   r   )rS   rw   s     r   addDeck.add   s    

$r   c                 :    U R                   R                  U5        g)zAdd multiple cards to the deck.N)rs   extend)rS   rs   s     r   add_allDeck.add_all   s    

% r   c                 2    [        U R                  5      S:H  $ )zCheck if the deck is empty.r   lenrs   rR   s    r   is_emptyDeck.is_empty   s    4::!##r   c                 ,    [        U R                  5      $ )z$Get the number of cards in the deck.r   rR   s    r   size	Deck.size   s    4::r   c                     SnU R                    H/  nUR                  U:X  d  M  Ub  UR                  U:X  d  M*  US-  nM1     U$ )z+Count cards of a specific type in the deck.r   rv   )rs   rM   rN   )rS   rM   rN   r   rw   s        r   count_by_typeDeck.count_by_type  sA    JJD~~*?dllg&=QJE  r   )rs   )r}   )rO   N)rv   )N)r   r   r   r   r   r   r   rs   rJ   rl   rt   rk   rm   rx   r   r   r   r   r   r   rn   r   r   r   r   r   r   r   rp   rp      s    >d3E4:3Hcc C D CTs CT4 CTJ## d4j $+      !T$Z !D !$$ $c s S4Z 3  r   rp   rw   localerO   c                 L    SSK Jn  UR                  XR                  5       5      $ )z"Get the localized name for a card.r   )Localization)messages.localizationr   rQ   rT   )rw   r   r   s      r   get_card_namer     s    5F$5$5$788r   rs   c                     U (       d  gU  Vs/ s H  n[        X!5      PM     nn[        U5      S:X  a  US   $ [        U5      S:X  a  US    SUS    3$ SR                  USS 5      S	US    3-   $ s  snf )
z3Get a comma-separated list of localized card names. rv   r   r   z and z, Nz, and )r   r   join)rs   r   rw   namess       r   
read_cardsr     s    5:;UT]4(UE;
5zQQx
5zQ(5q
++99U3BZ VE"I;#777 <s   A1),r   dataclassesr   r   enumr   r   mashumaro.mixins.jsonr   rm   r   r   r'   r6   r!   r"   r#   r$   r%   r/   r0   r1   r2   r3   r4   r@   rA   rB   rC   rD   rE   rF   rG   rH   dictrl   r`   rd   rh   rJ   rp   r   r   r   r   r   r   <module>r      s   = (   4sD 3 #t 
T 
"2" 2" 4	"
 4" 2" !!#B"   "@"  <"  <" !!#B" !>" !F"  8!"" 4#"$ 0%"& 8'"( 4)"* NN,2-"S#X 6   	 NN	  !V !V !VH z z zz9 9c 9c 9	8d4j 	8# 	8# 	8r   