
    Ii                        % S r SSKJrJr  SSKJr  SSKrSSKr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Jr  S	SKJr  S	SKJrJr  S	SKJrJrJrJrJr  S	SKJr  SSK J!r!  Sq"\#\$   S-  \%S'   S\#\$   4S jr&S\#\'   4S jr(S\$\'\#\'   4   4S jr)S\#\'   4S jr*Sq+S\,4S jr-\ " S S\5      5       r.\ " S S\5      5       r/\\ " S S\
5      5       5       r0g)z
Humanity Cards Game Implementation for PlayPalace v11.

A party game where a judge reads a black card prompt and other players
submit white cards to fill in blanks. The judge picks the funniest submission.
    )	dataclassfield)datetimeN)Path   )GamePlayerGameOptions)register_game   )Action	ActionSet
Visibility)	BotHelper)
GameResultPlayerResult)	IntOption
MenuOptionMultiSelectOptionmulti_select_fieldoption_field)Localization)KeybindState_humanity_packsreturnc                      [         cL  [        [        5      R                  S-  n [	        U SSS9 n[
        R                  " U5      q SSS5        [         $ [         $ ! , (       d  f       [         $ = f)z3Load card packs from JSON file. Results are cached.Nzhumanity_packs.jsonrzutf-8)encoding)r   r   __file__parentopenjsonload)
packs_pathfs     >c:\Users\dbart\PlayPalace11\server\games\humanitycards\game.pyload_humanity_packsr'   %   sY     (^**-BB
*cG4"iilO 5? 54s   A
A-c                  F    [        5        V s/ s H  o S   PM	     sn $ s  sn f )zGet list of all pack names.name)r'   )packs    r&   get_pack_namesr+   /   s!    %8%:;%:TL%:;;;s   c                     [        5       n / n/ n/ n/ n/ nU  H  nUR                  5       nUS:X  a$  UR                  U5        UR                  U5        M=  UR                  S5      (       a  SU;   a  UR                  U5        Ml  SU;   a  UR                  U5        M  SU;   d  SU;   d  SU;   d  SU;   d  S	U;   a  UR                  U5        M  S
U;   d  SU;   d  SU;   d  M  UR                  U5        M     U(       d  U (       a  U S   /O/ nU(       d  [	        U5      nSU 0nU(       a  XS'   U(       a  X(S'   U(       a  X8S'   U(       a  XHS'   U(       a  XXS'   U$ )z1Get preset groupings of packs for the options UI.zCAH Base Setzcah:	expansionfamilyholiday	christmasgreetingseasonshanukkah	nostalgia90s2000sr   z	All PacksBase SetzBase + ExpansionszFamily EditionzHoliday PackszNostalgia Packs)r+   lowerappend
startswithlist)		all_namesbase_setbase_plus_expansionsfamily_editionholiday_packsnostalgia_packsr)   r8   groupss	            r&   get_pack_groupsrC   4   s\    I HNMO

>!OOD! ''-f%%+*> ''-!!$'e#U"E!U"  &E!Ue^w%7G""4(% * %.IaL>B#H~9%F%z&:"##1 "/$3 !M    c                  b    [        5       n [        U R                  S[        5       SS 5      5      $ )z,Get default selected packs (Base Set group).r7   N   )rC   r;   getr+   )rB   s    r&   _get_default_packsrH   i   s*    F

:~'7';<==rD   c                       [         S-  q [         $ )z+Generate a unique card ID for this session.rF   )_next_card_id rD   r&   _make_card_idrL   v   s     QMrD   c                   z    \ rS rSr% SrSr\\S'   \" \	S9r
\	\   \S'   Sr\	\   S-  \S'   \" \	S9r\	\   \S	'   S
rg)HumanityCardsPlayer   z%Player state for Humanity Cards game.r   scoredefault_factoryhandNsubmitted_cardsselected_indicesrK   )__name__
__module____qualname____firstlineno____doc__rP   int__annotations__r   r;   rS   dictrT   strrU   __static_attributes__rK   rD   r&   rN   rN      sH    /E3NT2D$t*2(,OT#Y%,"'"=d3i=rD   rN   c                   "   \ rS rSr% Sr\" \" SSSSSSS	S
S95      r\\	S'   \" \" SSSSSSSSS95      r
\\	S'   \" \" \" 5       \SSSS\SS95      r\\   \	S'   \" \" S/ SQSS S!S"S#S$S%S.S&95      r\\	S''   \" \" SSSSS(S)S*S+95      r\\	S,'   S-rg.)/HumanityCardsOptions   z Options for Humanity Cards game.   r      rP   zhc-set-winning-scorezhc-enter-winning-scorezhc-option-changed-winning-scorezhc-desc-winning-score)defaultmin_valmax_val	value_keylabelprompt
change_msgdescriptionwinning_score
         countzhc-set-hand-sizezhc-enter-hand-sizezhc-option-changed-hand-sizezhc-desc-hand-size	hand_sizezhc-set-card-packszhc-option-changed-card-packsrF   Tzhc-desc-card-packs)re   choicesri   rk   min_selectedshow_bulk_actionsrB   rl   
card_packsRotating)rw   RandomMost Recent Winnermodezhc-set-czar-selectionzhc-select-czar-selectionz hc-option-changed-czar-selectionzhc-czar-rotatingzhc-czar-randomzhc-czar-winner)re   rs   rh   ri   rj   rk   choice_labelsczar_selectionzhc-set-num-judgeszhc-enter-num-judgeszhc-option-changed-num-judges)re   rf   rg   rh   ri   rj   rk   
num_judgesrK   N)rV   rW   rX   rY   rZ   r   r   rm   r[   r\   rr   r   r   rH   r+   rC   rv   r;   r^   r   r|   r}   r_   rK   rD   r&   ra   ra      s   *%(+8/		
M3  "$'4+		
Is  /&("%5"",		
JS	  '@)-9.*&6	
NC  #%(5	

J 
rD   ra   c            	       	  ^  \ rS rSr% Sr\" \S9r\\   \	S'   \" \
S9r\
\	S'   Sr\\	S'   \" \S9r\\   \	S'   \" \S9r\\   \	S	'   \" \S9r\\   \	S
'   \" \S9r\\   \	S'   Sr\S-  \	S'   \" \S9r\\   \	S'   Sr\\	S'   \" \S9r\\   \	S'   \" \S9r\\   \	S'   Sr\\	S'   \S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       rSS\S\S\ S\4S jjr!S\\   4S jr"SS  jr#SS!\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)\S\4S* jr(S$\S\ 4S+ jr)S\\   4S, jr*S\\   4S- jr+SS. jr,S/\\   S0\SS4S1 jr-S$\S\.4S2 jr/SU 4S3 jjr0S$\1S4\S\S-  4S5 jr2S$\1S4\S\34S6 jr4S$\1S4\S\4S7 jr5S$\1S4\S\S-  4S8 jr6S$\1S\\7\\4   -  S-  4S9 jr8S$\1S\34S: jr9S$\1S4\S\4S; jr:S$\1S4\S\S-  4S< jr;S$\1S4\S\34S= jr<S$\1S4\S\4S> jr=S$\1S4\SS4S? jr>S$\1S4\S\S-  4S@ jr?S$\1S4\S\34SA jr@S$\1S4\S\4SB jrAS$\1S\\   4SC jrBS$\1S\S-  4SD jrCS$\1S\34SE jrDS$\1S4\SS4SF jrES$\1S\34SG jrFS$\1S4\SS4SH jrGS$\1S4\SS4SI jrHS$\1S\S-  4SJ jrIS$\1S\34SK jrJS$\1S\S-  4SL jrKS$\1S\34SM jrLS$\1S4\S\4SN jrMS$\1SO\SS4SP jrNS$\1S4\SS4SQ jrOS$\1S4\SS4SR jrPS$\1S4\SS4SS jrQS$\1S4\SS4ST jrRS$\1S4\SS4SU jrSS$\1S4\SS4SV jrTS$\1S4\SS4SW jrUS$\1S4\SS4SX jrVS$\1S4\SS4SY jrWS$\1S4\SS4SZ jrXS$\1S4\SS4S[ jrYS$\1S4\SS4S\ jrZS$\1S4\SS4S] jr[S$\1S4\SS4S^ jr\S$\1S4\SS4S_ jr]S$\1S4\SS4S` jr^S$\1S4\SS4Sa jr_S$\1S4\SS4Sb jr`S$\1S4\SS4Sc jraS$\1S4\SS4Sd jrbS$\1S4\SS4Se jrcS$\1S4\SS4Sf jrdS$\1S4\SS4Sg jreS$\1S4\SS4Sh jrfS$\1S4\SS4Si jrgS$\1S4\SS4Sj jrhS$\1S4\SS4Sk jriS$\1S4\SS4Sl jrjS$\1S4\SS4Sm jrkS$\1S4\SS4Sn jrlS$\1S4\SS4So jrmS$\1S4\SS4Sp jrnS$\1S4\SS4Sq jroS$\1S4\SS4Sr jrpS$\1S4\SS4Ss jrqS$\1S4\SS4St jrrS$\1Su\SS4Sv jrsS$\1S4\SS4Sw jrtS$\1S4\SS4Sx jruS$\1S\S-  4Sy jrvS$\1S\S-  4Sz jrwS$\1S4\SS4S{ jrxS$\1S4\SS4S| jrySS} jrzSS~ jr{SS jr|S\SS4S jr}S$\S\S-  4S jr~SU 4S jjrSS jrSS jrS\4S jrS\S\S\\   4S jrSrU =r$ )HumanityCardsGame   z
Humanity Cards party game.

Players take turns as the Card Czar. A black card prompt is read, and
other players submit white cards to fill in the blanks. The Card Czar
picks the funniest submission and that player scores a point.
rQ   playersoptionswaitingphase
white_deck
black_deckwhite_discardblack_discardNcurrent_black_cardjudge_indiceslast_winner_indexsubmissionssubmission_orderr   round_end_ticksr   c                     g)NzCards Against HumanityrK   clss    r&   get_nameHumanityCardsGame.get_name   s    'rD   c                     g)NhumanitycardsrK   r   s    r&   get_typeHumanityCardsGame.get_type   s    rD   c                     g)Nzcategory-party-gamesrK   r   s    r&   get_categoryHumanityCardsGame.get_category   s    %rD   c                     gNr   rK   r   s    r&   get_min_players!HumanityCardsGame.get_min_players   s    rD   c                     gNrn   rK   r   s    r&   get_max_players!HumanityCardsGame.get_max_players   s    rD   	player_idr)   is_botc                     [        XUS9$ )N)idr)   r   )rN   )selfr   r)   r   s       r&   create_playerHumanityCardsGame.create_player  s    "i6JJrD   c                 @    [        U R                  R                  5      $ )z$Get the list of selected pack names.)r;   r   rv   r   s    r&   _get_active_packs#HumanityCardsGame._get_active_packs  s    DLL++,,rD   c                    [        5       n[        U R                  5       5      n/ U l        / U l        / U l        / U l        U H  nUS   U;  a  M  US   nUR                  S/ 5       H>  nUS   R                  S5      nU R                  R                  UU[        5       S.5        M@     UR                  S/ 5       H@  nUS   nUR                  S5      nUS:X  a  S	nU R                  R                  UUUS
.5        MB     M     [        R                  " U R                  5        [        R                  " U R                  5        g)z0Build white and black decks from selected packs.r)   whitetext.)r   r*   r   black_r   rF   )r   pickr*   N)r'   setr   r   r   r   r   rG   rstripr9   rL   rq   randomshuffle)r   packsactive_pack_namesr*   	pack_namecardr   r   s           r&   _build_decksHumanityCardsGame._build_decks  s%   #% 6 6 89DF|#44VI"-F|**3/&& $ )+o . "-F|zz#19D&& $ $ ) . 8 	t't'rD   rq   c                    / n[        U5       H  nU R                  (       dg  U R                  (       aS  [        U R                  5      U l        / U l        [        R
                  " U R                  5        U R                  S5        O  U$ U R                  (       d  M  UR                  U R                  R                  5       5        M     U$ )z>Draw white cards from the deck, reshuffling discard if needed.zhc-deck-reshuffled)	ranger   r   r;   r   r   broadcast_lr9   pop)r   rq   cardsr   s       r&   _draw_whiteHumanityCardsGame._draw_white8  s    uA??%%&*4+=+=&>DO)+D&NN4??3$$%9:  T__0023  rD   c                 H   U R                   (       de  U R                  (       aS  [        U R                  5      U l         / U l        [        R                  " U R                   5        U R                  S5        OgU R                   (       a  U R                   R                  5       $ S$ )z?Draw a black card from the deck, reshuffling discard if needed.zhc-black-deck-reshuffledN)r   r   r;   r   r   r   r   r   s    r&   _draw_blackHumanityCardsGame._draw_blackH  sl    !!"&t'9'9":%'"t/  !;<(,t""$ATArD   playerc                     U R                   R                  [        UR                  5      -
  nUS:  a-  U R	                  U5      nUR                  R                  U5        gg)z)Fill a player's hand up to the hand size.r   N)r   rr   lenrS   r   extend)r   r   neededr   s       r&   _deal_to_hand_size$HumanityCardsGame._deal_to_hand_sizeT  sM    ''#fkk*::A:$$V,EKKu% rD   
black_textwhite_cardsc                     UnU H7  nUR                  S5      nSU;   a  UR                  SUS5      nM/  USU 3-  nM9     U$ )z8Replace underscores in black card with white card texts.r   r   rF    )r   replace)r   r   r   result	card_textinserts         r&   _fill_in_blanks!HumanityCardsGame._fill_in_blanks[  sQ    $I%%c*Ff}VQ7AfX,& % rD   r   c                 &    UR                  SS5      $ )z:Replace underscores with 'blank' for screen reader speech.r   blank)r   )r   r   s     r&   _speech_friendly_black(HumanityCardsGame._speech_friendly_blackg  s    ||C))rD   c                     U R                  5       nU R                   H2  nU[        U5      :  d  M  X#   R                  UR                  :X  d  M2    g   g)z/Check if a player is one of the current judges.TF)get_active_playersr   r   r   )r   r   activeidxs       r&   	_is_judgeHumanityCardsGame._is_judgeo  sE    ((*%%CS[ V[^^vyy%@ & rD   c                     U R                  5       n/ nU R                   H'  nU[        U5      :  d  M  UR                  X   5        M)     U$ )zGet all current judge players.)r   r   r   r9   )r   r   judgesr   s       r&   _get_judgesHumanityCardsGame._get_judgesw  sF    ((*%%CS[ fk* & rD   c                     U R                  5        Vs1 s H  oR                  iM     nnU R                  5        Vs/ s H  o3R                  U;  d  M  UPM     sn$ s  snf s  snf )z!Get all non-judge active players.)r   r   r   )r   j	judge_idsps       r&   _get_non_judges!HumanityCardsGame._get_non_judges  sT    #'#3#3#56#5aTT#5	6224N4aI8M4NN 7Ns   AA!A!c                    U R                  5       n[        U R                  R                  [	        U5      S-
  5      nUS:  a  SnU R                  R
                  nUS:X  a>  [        [        [	        U5      5      5      n[        R                  " U5        USU U l
        gUS:X  a  U R                  S:  a  U R                  [	        U5      :  a  U R                  /U l
        US:  an  [        S[	        U5      5       HT  n[	        U R                  5      U:  a    gU R                  U-   [	        U5      -  nU R                  R                  U5        MV     ggU R                  X5        gU R                  X5        g)zESelect judge(s) for the current round based on czar_selection option.rF   rx   Nry   r   )r   minr   r}   r   r|   r;   r   r   r   r   r   r9   _select_judges_rotating)r   r   r}   rz   indicesoffsetr   s          r&   _select_judges HumanityCardsGame._select_judges  s<   ((*00#f+/B
>J||**85V-.GNN7#!(*!5D))%%*t/E/EF/S&*&<&<%=">"'3v;"7t112j@!#55>#f+M**11#6	 #8 " ,,V@ ((<rD   r   r}   c                    U R                   (       d	  S/U l         O&U R                   S   S-   [        U5      -  nU/U l         [        U R                   5      U:  ae  U R                   S   S-   [        U5      -  nX@R                   ;   a  gU R                   R                  U5        [        U R                   5      U:  a  Md  gg)z8Rotating judge selection: advance from current position.r   rF   r   N)r   r   r9   )r   r   r}   firstnext_idxs        r&   r   )HumanityCardsGame._select_judges_rotating  s    !!"#D ''*Q.#f+=E"'D $$$%
2**2.2c&kAH---%%h/	 $$$%
2rD   c                    U R                  U5      nU(       a  UR                  OSn[        SS9n[        S5       H.  nUR	                  [        SU 3SUS-    3SU 3S	S
SSSS95        M0     UR	                  [        SSSSSSSS95        [        S5       H-  nUR	                  [        SU 3SUS-    3SU 3SSSSS95        M/     UR	                  [        S[        R                  " US5      SS S!S"S#S95        UR	                  [        S$[        R                  " US%S&SS'9S(S)S*S+S,95        UR	                  [        S-[        R                  " US.5      S/S0S1S#S295        UR	                  [        S3[        R                  " US45      S5S6S7S#S295        UR	                  [        S8[        R                  " US95      S:S6S;S<95        U$ )=z(Create the turn action set for a player.enturnr)   rp   toggle_card_Card rF   _action_toggle_card__is_toggle_card_enabled_is_toggle_card_hidden_get_toggle_card_label_get_toggle_card_soundF)r   ri   handler
is_enabled	is_hidden	get_label	get_soundshow_in_actions_menujudge_prompt_headerChoose the best card_action_noop_is_judge_prompt_header_enabled_is_judge_prompt_header_hidden_get_judge_prompt_header_label)r   ri   r  r  r  r  r
  rd   judge_pick_Submission _action_judge_pick__is_judge_pick_enabled_is_judge_pick_hidden_get_judge_pick_labelview_submissionhc-preview-submission_action_view_submission_is_view_submission_enabled_is_view_submission_hidden_get_view_submission_labelTsubmit_cardshc-submit-cardsr   selectedrequired_action_submit_cards_is_submit_enabled_is_submit_hidden_get_submit_label)r   ri   r  r  r  r  view_black_cardzhc-view-black-card_action_view_black_card_is_view_enabled_is_view_hidden)r   ri   r  r  r  r
  view_scoreszhc-view-scores_action_view_scores_is_view_scores_enabled_is_view_scores_hiddenwhose_judgezhc-whose-judge_action_whose_judge_is_whose_judge_hidden)r   ri   r  r  r  )get_userlocaler   r   addr   r   rG   )r   r   userr2  
action_setis         r&   create_turn_action_set(HumanityCardsGame.create_turn_action_set  s   }}V$ $$F+
 rANN%aS)!!a%/21#68666).	  	(,&<::%*
	
 rANN$QC('Aw/1!5755).
  	$"&&v/FG1866%)
	
 	!"&&v/@1WXY./--		
 	$"&&v/CD1-+%)		
 	 "&&v/?@-42%)		
 	 "&&v/?@-42	
 rD   c                   > [         TU ]  5         [        S5       H>  n[        US-   S-  5      nU R	                  USUS-    3SU 3/[
        R                  S9  M@     U R	                  SSS/[
        R                  S9  U R	                  S	S
S/[
        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  g)z!Define all keybinds for the game.rn   rF   zToggle card r   )statespacezSubmit cardsr  czView promptr&  T)r:  include_spectatorsvzView submissionr  szView scoresr*  r   zWho is judgingr.  N)supersetup_keybindsr   r^   define_keybindr   ACTIVE)r   r6  key	__class__s      r&   rA   HumanityCardsGame.setup_keybinds&  sC     rAq1ul#Cq1ug&s#$"))	     	%%	 	 	
 	%%# 	 	
 	%%	 	 	
 	O%%# 	 	
 	O%%# 	 	
rD   	action_idc                 "   U R                   S:w  a  gUR                  (       a  gUnU R                  U5      (       a  gUR                  b  gU R                  S:w  a  g[        UR                  S5      5      nU[        UR                  5      :  a  gg )Nplayingaction-not-playingaction-spectatorhc-already-submitted
submittingr   )	statusis_spectatorr   rT   r   r[   removeprefixr   rS   r   r   rG  hcpr   s        r&   r  )HumanityCardsGame._is_toggle_card_enabledc  s}    ;;)#'%#)>>#%*)::%')((89#chh-'rD   c                    U R                   S:w  d  U R                  S:w  a  [        R                  $ UR                  (       a  [        R                  $ UnU R                  U5      (       a  [        R                  $ UR                  b  [        R                  $ [        UR                  S5      5      nU[        UR                  5      :  a  [        R                  $ [        R                  $ )NrI  rM  r   )rN  r   r   HIDDENrO  r   rT   r[   rP  r   rS   VISIBLErQ  s        r&   r  (HumanityCardsGame._is_toggle_card_hiddent  s    ;;)#tzz\'A$$$$$$#)>>#$$$*$$$)((89#chh-$$$!!!rD   c                 h   Un[        UR                  S5      5      nU[        UR                  5      :  a  SUS-    3$ UR                  U   nU R	                  U5      nU(       a  UR
                  OSnXCR                  ;   a  [        R                  " USUS   S9$ [        R                  " USUS   S9$ )	Nr   r   rF   r   zhc-card-selectedr   r   zhc-card-not-selected)	r[   rP  r   rS   r1  r2  rU   r   rG   )r   r   rG  rR  r   r   r4  r2  s           r&   r  (HumanityCardsGame._get_toggle_card_label  s    #))((89#chh-37)$$xx}}}V$ $$&&&##F,>T&\RR(>T&\RRrD   c                 \    Un[        UR                  S5      5      nXCR                  ;   a  gg )Nr   !game_humanitycards/cardselect.ogg)r[   rP  rU   rQ  s        r&   r  (HumanityCardsGame._get_toggle_card_sound  s.    #))((89&&&6rD   c                 <   U R                   S:w  a  gUR                  (       a  gUnU R                  U5      (       a  gUR                  b  gU R                  S:w  a  gU R
                  (       a  U R
                  S   OSn[        UR                  5      U:w  a  SS	U04$ g )
NrI  rJ  rK  rL  rM  r   rF   hc-wrong-card-countrq   )rN  rO  r   rT   r   r   r   rU   )r   r   rR  r!  s       r&   r#  $HumanityCardsGame._is_submit_enabled  s    ;;)#'%#)>>#%*)::%'6:6M6M4**62STs##$0)GX+>??rD   c                 N   U R                   S:w  d  U R                  S:w  a  [        R                  $ UR                  (       a  [        R                  $ UnU R                  U5      (       a  [        R                  $ UR                  b  [        R                  $ [        R                  $ )NrI  rM  )rN  r   r   rU  rO  r   rT   rV  r   r   rR  s      r&   r$  #HumanityCardsGame._is_submit_hidden  s~    ;;)#tzz\'A$$$$$$#)>>#$$$*$$$!!!rD   c                     UnU R                  U5      nU(       a  UR                  OSnU R                  (       a  U R                  S   OSn[        R                  " US[        UR                  5      US9$ )Nr   r   rF   r  r  )r1  r2  r   r   rG   r   rU   )r   r   rG  rR  r4  r2  r!  s          r&   r%  #HumanityCardsGame._get_submit_label  sg    #)}}V$ $$6:6M6M4**62ST--.	
 	
rD   c                     U R                   S:w  a  gUnU R                  U5      (       d  gU R                  S:w  a  g[        UR	                  S5      5      nU[        U R                  5      :  a  gg )NrI  rJ  rK  judgingr  )rN  r   r   r[   rP  r   r   rQ  s        r&   r  (HumanityCardsGame._is_judge_pick_enabled  se    ;;)#'#)~~c""%::"')((78#d++,,'rD   c                 X   U R                   S:w  d  U R                  S:w  a  [        R                  $ UnU R	                  U5      (       d  [        R                  $ [        UR                  S5      5      nU[        U R                  5      :  a  [        R                  $ [        R                  $ )NrI  rg  r  )
rN  r   r   rU  r   r[   rP  r   r   rV  rQ  s        r&   r  'HumanityCardsGame._is_judge_pick_hidden  s    ;;)#tzzY'>$$$#)~~c""$$$)((78#d++,,$$$!!!rD   c                 t   [        UR                  S5      5      nU[        U R                  5      :  a~  U R                  U   nU[        U R                  5      :  aV  U R                  U   nU R
                  (       a"  U R                  U R
                  S   US   5      $ SR                  US   5      $ SUS-    3$ )Nr  r   r   , r  rF   )r[   rP  r   r   r   r   r   join)r   r   rG  r   sub_idxsubs         r&   r  'HumanityCardsGame._get_judge_pick_label  s    )((78T**++++C0GT--..&&w/**//0G0G0OQTU\Q]^^yyW..S1WI&&rD   c                     g)z&No-op handler for static text actions.NrK   r   r   rG  s      r&   r  HumanityCardsGame._action_noop  s    rD   c                     g NrK   rr  s      r&   r  1HumanityCardsGame._is_judge_prompt_header_enabled  s    rD   c                     U R                   S:w  d  U R                  S:w  a  [        R                  $ UnU R	                  U5      (       d  [        R                  $ [        R
                  $ NrI  rg  )rN  r   r   rU  r   rV  )r   r   rG  rR  s       r&   r  0HumanityCardsGame._is_judge_prompt_header_hidden  sQ    ;;)#tzzY'>$$$#)~~c""$$$!!!rD   c                 l    U R                   (       a#  U R                  U R                   S   5      nSU 3$ g)Nr   z#Choose the best card that matches: r  )r   r   )r   r   rG  prompt_texts       r&   r  0HumanityCardsGame._get_judge_prompt_header_label  s6    ""55d6M6Mf6UVK8FF%rD   c                 6   / nU R                    H  nU[        U R                  5      :  d  M  U R                  U   nU R                  (       a#  U R	                  U R                  S   US   5      nOSR                  US   5      nUR                  U5        M     U$ )z(Get submission options for judge's menu.r   r   rl  )r   r   r   r   r   rm  r9   )r   r   r   r   ro  filleds         r&   _get_submission_options)HumanityCardsGame._get_submission_options  s    ((CS))**&&s+**!11$2I2I&2QSVW^S_`F!YYs7|4Fv& ) rD   c                 &    U R                   S:w  a  gg NrI  rJ  rN  r   r   s     r&   r,  )HumanityCardsGame._is_view_scores_enabled      ;;)#'rD   c                 b    U R                   S:w  a  [        R                  $ [        R                  $ )NrI  )rN  r   rU  rV  r  s     r&   r-  (HumanityCardsGame._is_view_scores_hidden  s&    ;;)#$$$!!!rD   c                    U R                  U5      nU(       d  g[        U R                  5       S SS9nU Vs/ s H  oUR                   SUR                   3PM     nnUR                  SR                  U5      S-   5        gs  snf )zView the current scores.Nc                     U R                   $ ru  rP   r   s    r&   <lambda>7HumanityCardsGame._action_view_scores.<locals>.<lambda>!      !''rD   TrD  reverse: . r   r1  sortedr   r)   rP   speakrm  r   r   rG  r4  sorted_playersr   partss          r&   r+  %HumanityCardsGame._action_view_scores  sz    }}V$##%!

 2@@AFF82aggY'@

499U#c)* A   $Bc                 "    [         R                  $ ru  )r   rU  r  s     r&   r0  (HumanityCardsGame._is_whose_judge_hidden+  s       rD   c                 J   U R                  U5      nU(       d  gU R                  5       n[        U5      S:X  a   UR                  SUS   R                  SSS9  gU(       aD  SR                  S USS  5       5      nUR                  SUS   R                  [        U5      US9  gg)	z&Announce who the current judge(s) are.NrF   hc-judge-isr    r   rq   othersrl  c              3   8   #    U  H  oR                   v   M     g 7fru  r   .0r   s     r&   	<genexpr>8HumanityCardsGame._action_whose_judge.<locals>.<genexpr>8       :z!vvz   )r1  r   r   speak_lr)   rm  )r   r   rG  r4  r   r  s         r&   r/  %HumanityCardsGame._action_whose_judge/  s    }}V$!!#v;!LLvay~~QrLRYY:vabz::FLLvay~~S[Y_L` rD   c                    U R                  U5      nU(       d  gU R                  5       nSR                  S U 5       5      nU R                  S:X  ap  U R	                  5        Vs/ s H  ofR
                  b  M  UR                  PM     nnU(       a   UR                  SSR                  U5      S9  gUR                  SUS9  gU R                  S	:X  a  UR                  SUS9  gUR                  S
5        gs  snf )z6Override default whose_turn to show submission status.Nrl  c              3   8   #    U  H  oR                   v   M     g 7fru  r   r  s     r&   r  7HumanityCardsGame._action_whose_turn.<locals>.<genexpr>B  s     71r  rM  zhc-waiting-for)nameszhc-all-submitted-waiting-judge)judgerg  zgame-no-turn)r1  r   rm  r   r   rT   r)   r  )r   r   rG  r4  r   judge_namesr   r   s           r&   _action_whose_turn$HumanityCardsGame._action_whose_turn;  s    }}V$!!#ii777::%'+';';'=['=!ARARvqvv'=G[-TYYw5GH=[QZZ9$LL9LMLL( \s   $C58C5c                 &    U R                   S:w  a  gg r  r  r  s     r&   r(  "HumanityCardsGame._is_view_enabledP  r  rD   c                     U R                   S:w  d  U R                  c  [        R                  $ UnU R                  S:X  a&  U R                  U5      (       a  [        R                  $ [        R                  $ rx  )rN  r   r   rU  r   r   rV  rb  s      r&   r)  !HumanityCardsGame._is_view_hiddenU  s\    ;;)#t'>'>'F$$$#)::"t~~c':':$$$!!!rD   c                     U R                   S:w  a  gUnU R                  U5      (       a  gU R                  S:w  a  U R                  S:w  a  gUR                  c  UR                  (       d  gg )NrI  rJ  rK  rM  rg  hc-select-cards-first)rN  r   r   rT   rU   rb  s      r&   r  -HumanityCardsGame._is_view_submission_enabled^  s\    ;;)#'#)>>#%::%$**	*A'&s/C/C*rD   c                     U R                   S:w  a  [        R                  $ U R                  S;  a  [        R                  $ UnU R	                  U5      (       a  [        R                  $ [        R
                  $ )NrI  )rM  rg  )rN  r   rU  r   r   rV  rb  s      r&   r  ,HumanityCardsGame._is_view_submission_hiddenk  s_    ;;)#$$$::66$$$#)>>#$$$!!!rD   c                     UnU R                  U5      nU(       a  UR                  OSnUR                  b  [        R                  " US5      $ [        R                  " US5      $ )Nr   zhc-view-submissionr  )r1  r2  rT   r   rG   )r   r   rG  rR  r4  r2  s         r&   r  ,HumanityCardsGame._get_view_submission_labelu  sV    #)}}V$ $$*##F,@AA(?@@rD   indexc                    UnU R                   S:w  d  UR                  b  gU R                  U5      (       a  gU[        UR                  5      :  a  gU R
                  (       a  U R
                  S   OSnU R                  U5      nX#R                  ;   a4  UR                  R                  U5        U(       a  UR                  S5        Og[        UR                  5      U:  a  UR                  R                  S5        UR                  R                  U5        U(       a  UR                  S5        U R                  U5        g)z%Toggle card selection for submission.rM  Nr   rF   z#game_humanitycards/cardunselect.oggr   r\  )r   rT   r   r   rS   r   r1  rU   remove
play_soundr   r9   rebuild_player_menu)r   r   r  rR  r!  r4  s         r&   _toggle_cardHumanityCardsGame._toggle_card  s    #)::%)<)<)H>>#CM!6:6M6M4**62ST}}V$(((  ''. EF3''(H4$$((+  ''. CD  (rD   c                 (    U R                  US5        g Nr   r  rr  s      r&   _action_toggle_card_0'HumanityCardsGame._action_toggle_card_0      &!$rD   c                 (    U R                  US5        g NrF   r  rr  s      r&   _action_toggle_card_1'HumanityCardsGame._action_toggle_card_1  r  rD   c                 (    U R                  US5        g Nr   r  rr  s      r&   _action_toggle_card_2'HumanityCardsGame._action_toggle_card_2  r  rD   c                 (    U R                  US5        g r   r  rr  s      r&   _action_toggle_card_3'HumanityCardsGame._action_toggle_card_3  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_4'HumanityCardsGame._action_toggle_card_4  r  rD   c                 (    U R                  US5        g Nro   r  rr  s      r&   _action_toggle_card_5'HumanityCardsGame._action_toggle_card_5  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_6'HumanityCardsGame._action_toggle_card_6  r  rD   c                 (    U R                  US5        g Nrc   r  rr  s      r&   _action_toggle_card_7'HumanityCardsGame._action_toggle_card_7  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_8'HumanityCardsGame._action_toggle_card_8  r  rD   c                 (    U R                  US5        g N	   r  rr  s      r&   _action_toggle_card_9'HumanityCardsGame._action_toggle_card_9  r  rD   c                 (    U R                  US5        g r   r  rr  s      r&   _action_toggle_card_10(HumanityCardsGame._action_toggle_card_10      &"%rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_11(HumanityCardsGame._action_toggle_card_11  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_12(HumanityCardsGame._action_toggle_card_12  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_13(HumanityCardsGame._action_toggle_card_13  r  rD   c                 (    U R                  US5        g N   r  rr  s      r&   _action_toggle_card_14(HumanityCardsGame._action_toggle_card_14  r  rD   c                 (    U R                  US5        g r  _judge_pickrr  s      r&   _action_judge_pick_0&HumanityCardsGame._action_judge_pick_0      #rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_1&HumanityCardsGame._action_judge_pick_1  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_2&HumanityCardsGame._action_judge_pick_2  r  rD   c                 (    U R                  US5        g r   r  rr  s      r&   _action_judge_pick_3&HumanityCardsGame._action_judge_pick_3  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_4&HumanityCardsGame._action_judge_pick_4  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_5&HumanityCardsGame._action_judge_pick_5  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_6&HumanityCardsGame._action_judge_pick_6  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_7&HumanityCardsGame._action_judge_pick_7  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_8&HumanityCardsGame._action_judge_pick_8  r  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_9&HumanityCardsGame._action_judge_pick_9  r  rD   c                 (    U R                  US5        g r   r  rr  s      r&   _action_judge_pick_10'HumanityCardsGame._action_judge_pick_10      $rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_11'HumanityCardsGame._action_judge_pick_11  r/  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_12'HumanityCardsGame._action_judge_pick_12  r/  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_13'HumanityCardsGame._action_judge_pick_13  r/  rD   c                 (    U R                  US5        g r  r  rr  s      r&   _action_judge_pick_14'HumanityCardsGame._action_judge_pick_14  r/  rD   c                 (    U R                  US5        g )Nrp   r  rr  s      r&   _action_judge_pick_15'HumanityCardsGame._action_judge_pick_15  r/  rD   c                 (    U R                  US5        g )N   r  rr  s      r&   _action_judge_pick_16'HumanityCardsGame._action_judge_pick_16  r/  rD   c                 (    U R                  US5        g )N   r  rr  s      r&   _action_judge_pick_17'HumanityCardsGame._action_judge_pick_17  r/  rD   c                 (    U R                  US5        g )N   r  rr  s      r&   _action_judge_pick_18'HumanityCardsGame._action_judge_pick_18  r/  rD   c                 (    U R                  US5        g )N   r  rr  s      r&   _action_judge_pick_19'HumanityCardsGame._action_judge_pick_19  r/  rD   c                 @   UnU R                   S:w  d  UR                  b  gU R                  U5      (       a  gU R                  (       a  U R                  S   OSn[	        UR
                  5      U:w  a)  U R                  U5      nU(       a  UR                  SUS9  g/ nUR
                   HA  nU[	        UR                  5      :  d  M  UR                  U   nUR                  US   5        MC     Xcl        [        UR
                  SS	9 HT  nU[	        UR                  5      :  d  M  UR                  R                  U5      n	U R                  R                  U	5        MV     / Ul        U R                  S
[        R                  " SS5       S35        U R                  U5      nU(       a  UR                  S5        U R!                  5       n
[#        S U
 5       5      n[	        U
5      nU R%                  SUUS9  U R'                  5         X:  a  U R)                  5         gg)zSubmit selected cards.rM  Nr   rF   r_  rq   r   T)r  zgame_humanitycards/submitr   .oggzhc-submittedc              3   B   #    U  H  oR                   c  M  Sv   M     g 7fr  )rT   )r  r   s     r&   r  9HumanityCardsGame._action_submit_cards.<locals>.<genexpr>4  s     UA7H7Haas   	zhc-submission-progress)	submittedtotal)r   rT   r   r   r   rU   r1  r  rS   r9   r  r   r   r  r   randintr   sumr   rebuild_all_menus_start_judging)r   r   rG  rR  r!  r4  submitted_textsr   r   removed
non_judgessubmitted_countrU  s                r&   r"  &HumanityCardsGame._action_submit_cards  s   #)::%)<)<)H>>#6:6M6M4**62STs##$0==(D2(C ''CS]"xx}&&tF|4 (
 . #..=CS]"((,,s+""))'2 >
  " 	3FNN1a4H3INO}}V$LL( ))+
UUUJ$% 	 	
 	  #! $rD   
pick_indexc                   ^ U R                   S:w  a  gUnU R                  U5      (       d  gU[        U R                  5      :  a  gU R                  U   nU[        U R                  5      :  a  gU R                  U   nU R                  US   5      mT(       d  gTnU=R                  S-  sl        U R                  5       n[        U4S j[        U5       5       S5      U l
        U R                  U R                  (       a  U R                  S   OSUS	   5      nU R                  S
[        R                  " SS5       S35        U R!                  STR"                  UR                  S9  U R!                  STR"                  US9  U R!                  S5        U R                   H  n	U	S   TR$                  :X  a  M  U R                  U	S   5      n
U
(       d  M5  U R                  U R                  (       a  U R                  S   OSU	S	   5      nU R!                  SU
R"                  US9  M     U R                  S[        R                  " SS5       S35        UR                  U R&                  R(                  :  a  U R+                  U5        gSU l         SU l        U R                  (       a,  U R.                  R1                  U R                  5        SU l        U R3                  5         g)z.Judge picks a submission by its display index.rg  Nr   rF   c              3   d   >#    U  H%  u  pUR                   TR                   :X  d  M!  Uv   M'     g 7fru  )r   )r  r6  r   winners      r&   r  0HumanityCardsGame._judge_pick.<locals>.<genexpr>Y  s)     &\5FTQ!$$RXR[R[J[qq5Fs    0	0r   r   r  r   zgame_humanitycards/judgechoicer   rQ  zhc-winner-announcement)r   rP   zhc-submission-reveal)r   r   zhc-all-submissionszgame_cards/drawr  	round_endd   )r   r   r   r   r   get_player_by_idrP   r   next	enumerater   r   r   r  r   rV  r   r)   r   r   rm   	_end_gamer   r   r9   rX  )r   r   r_  rR  
actual_idxwinning_sub	hc_winnerr   winning_textro  
sub_playerr~  rb  s               @r&   r  HumanityCardsGame._judge_pickB  s   ::"#)~~c""T2233**:6
T--..&&z2&&{;'?@)/	 	1((*!%&\Yv5F&\^`!a ++/3/F/FD##F+B 
 	,V^^Aq-A,B$G	
 	$;;// 	 	
 	";; 	 	
 	-.##C;699,..s;/?@Jz--7;7N7ND++F3TVL   *%?? !  $  	/&..A*>)?tDE ??dll888NN9% %DJ#&D  &&""))$*A*AB*.'""$rD   c                     U R                  U5      nU(       a  U R                  (       d  gU R                  U R                  S   5      nUR                  SUS9  g)z#View the current black card prompt.Nr   hc-black-cardrY  )r1  r   r   r  )r   r   rG  r4  r   s        r&   r'  )HumanityCardsGame._action_view_black_card  sI    }}V$422**4+B+B6+JK_40rD   c                 F   UnU R                  U5      nU(       d  gUR                  bK  U R                  (       a:  U R                  U R                  S   UR                  5      nUR	                  SUS9  gUR
                  (       a  U R                  (       av  UR
                   Vs/ s H/  of[        UR                  5      :  d  M  UR                  U   S   PM1     nnU R                  U R                  S   U5      nUR	                  SUS9  gUR	                  S5        gs  snf )z6View the player's submitted or in-progress submission.Nr   zhc-your-submissionrY  zhc-preview-submission-textr  )r1  rT   r   r   r  rU   r   rS   )r   r   rG  rR  r4  r~  r6  r   s           r&   r  )HumanityCardsGame._action_view_submission  s    #)}}V$*t/F/F))$*A*A&*I3K^K^_FLL-FL;!!d&=&=252F2F\2FQcRURZRZmJ[(SXXa[(2FE\))$*A*A&*I5QFLL5FLCLL01	 ]s   $DDc                 &    U R                   S:w  a  gg r  r  r  s     r&   _is_check_scores_enabled*HumanityCardsGame._is_check_scores_enabled  r  rD   c                 &    U R                   S:w  a  gg r  r  r  s     r&   !_is_check_scores_detailed_enabled3HumanityCardsGame._is_check_scores_detailed_enabled  r  rD   c                    U R                  U5      nU(       d  g [        U R                  5       S SS9nU Vs/ s H  oUR                   SUR                   3PM     nnUR                  SR                  U5      S-   5        g s  snf )Nc                     U R                   $ ru  r  r  s    r&   r  8HumanityCardsGame._action_check_scores.<locals>.<lambda>  r  rD   Tr  r  r  r   r  r  s          r&   _action_check_scores&HumanityCardsGame._action_check_scores  sz    }}V$##%!

 2@@AFF82aggY'@

499U#c)* Ar  c                     U R                  U5      nU(       d  g [        U R                  5       S SS9nU Vs/ s H  nUR                   SUR                   S3PM!     nnU R                  X5        g s  snf )Nc                     U R                   $ ru  r  r  s    r&   r  AHumanityCardsGame._action_check_scores_detailed.<locals>.<lambda>  r  rD   Tr  r  z points)r1  r  r   r)   rP   
status_box)r   r   rG  r4  r  r   liness          r&   _action_check_scores_detailed/HumanityCardsGame._action_check_scores_detailed  s|    }}V$##%!
 $
# vvhb	)# 	 
 	&	
s   &A2c                 T   SU l         SU l        SU l        / U l        SU l        U R                  5         U R                  5       n[        U5      U R                  R                  -  n[        U R                  5      U:  a  U R                  S5        U H!  nUnSUl        / Ul        SUl        / Ul        M#     U R                  S5        U R                  SU R                  R                  S	9  U H  nUnU R!                  U5        M     U R#                  S
5        U R%                  5         g)zCalled when the game starts.rI  Tr   r   hc-not-enough-cardsNzhc-game-startingzhc-dealing-cardsrP  zgame_3cardpoker/mus.ogg)rN  game_activeroundr   r   r   r   r   r   rr   r   r   rP   rS   rT   rU   r   
play_music_start_round)r   active_playerstotal_whites_neededr   hps        r&   on_startHumanityCardsGame.on_start  s   
!# 	002 ".1DLL4J4JJt"5523  A&'BBHBG!%B"$B   	+,+4<<3I3IJA&'B##B'  
 	12 	rD   c                    U =R                   S-  sl         SU l        / U l        / U l        U R	                  S5        U R                  5       nU H$  nUnSUl        / Ul        U R                  U5        M&     U R                  5         U R                  5       U l        U R                  (       d"  U R                  S5        U R                  5         gU R                  R                  SS5      nU R                  SU R                   S9  U R                  5       n[!        U5      S:X  a   U R                  S	US
   R"                  SSS9  OCSR%                  S USS  5       5      nU R                  S	US
   R"                  [!        U5      US9  U R'                  U R                  S   5      nU R                  SUS9  US:  a  U R                  SUS9  U R)                  5        H-  nU R+                  U5      nU(       d  M  UR-                  SUS9  M/     U HX  nUR.                  (       d  M  U R1                  U5      (       a  M.  [2        R4                  " U[6        R8                  " SS5      S9  MZ     U R;                  5         g)zStart a new round.rF   rM  zgame_3cardpoker/roundstart.oggNr  r   zhc-round-start)r  r  r   r  r  rl  c              3   8   #    U  H  oR                   v   M     g 7fru  r   r  s     r&   r  1HumanityCardsGame._start_round.<locals>.<genexpr>,  r  r  r   rq  rY  zhc-black-card-pickrP  zhc-select-cardsrd   (   ticks)r  r   r   r   r  r   rT   rU   r   r   r   r   r   finish_gamerG   r   r   r)   rm  r   r   r1  r  r   r   r   jolt_botr   rV  rX  )	r   r  r   r  
pick_countr   r  r   r4  s	            r&   r  HumanityCardsGame._start_round  s6   

a
!
 " 	89002  A&'B!%B"$B##B'   	 #'"2"2"4&&23,,00;
 	)< !!#v;!]6!9>>SUVYY:vabz::F]6!9>>V]cd 001H1H1PQ
z:>1D %%'A==#Dt.jA (  Axxxq 1 1""1FNN2r,BC   	 rD   c                    SU l         / U l        U R                  5        HM  nUR                  c  M  U R                  R	                  UR
                  [        UR                  5      S.5        MO     [        [        [        U R                  5      5      5      U l	        [        R                  " U R                  5        U R                  S5        U R                  S5        U R                  5        H@  nUR                  (       d  M  [         R"                  " U[        R$                  " SS5      S9  MB     U R'                  5         g)	zTransition to judging phase.rg  N)r   r   zgame_humanitycards/judging.oggzhc-judging-start   2   r  )r   r   r   rT   r9   r   r;   r   r   r   r   r   r  r   r   r   r   r  rV  rX  )r   r   r   s      r&   rY   HumanityCardsGame._start_judgingB  s    
 %%'A  ,  ''%&TT!%a&7&7!8 ( !%U3t/?/?+@%A Bt,,-89+, !!#Axxx""1FNN2r,BC $ 	 rD   rb  c                 ~    U R                  S5        U R                  USSUR                  S9  U R                  5         g)z%End the game and announce the winner.zgame_humanitycards/win.oggz
hc-you-winzhc-game-winnerr  N)r  broadcast_personal_lrP   r  )r   rb  s     r&   ri  HumanityCardsGame._end_game_  s@    45!!,,	 	" 	
 	rD   c                    U R                   S:X  a  U R                  U5      (       d  UR                  b  gU R                  (       a  U R                  S   OSn[	        UR
                  5      U:  aa  [        [	        UR                  5      5       Vs/ s H  o3UR
                  ;  d  M  UPM     nnU(       a  [        R                  " U5      nSU 3$ [	        UR
                  5      U:X  a  ggs  snf )zBot AI decision making.rM  Nr   rF   r   r  )
r   r   rT   r   r   rU   r   rS   r   choice)r   r   r!  r6  	availabler   s         r&   	bot_thinkHumanityCardsGame.bot_thinkn  s    ::%dnnV.D.D%%1:>:Q:Qt..v6WXH 6**+h6(-c&++.>(?d(?1FLcLcCcQ(?	d!==3D)$00 6**+x7% es   C,'C,c                 V  > [         TU ]  5         U R                  (       d  gU R                  S:X  a6  U =R                  S-  sl        U R                  S::  a  U R                  5         gU R                  S:X  a  U R                  5         gU R                  S:X  a  U R                  5         gg)zCalled every tick.Nrd  rF   r   rM  rg  )r@  on_tickr  r   r   r  _process_submission_bots_process_judging_bots)r   rE  s    r&   r  HumanityCardsGame.on_tick  s     ::$  A% ##q(!!# ::%))+ZZ9$&&( %rD   c                 
  ^  T R                    Hr  nUR                  (       a  UR                  (       a  M'  UnT R                  U5      (       d  UR                  b  MN  [
        R                  " UU4U 4S jjU4U 4S jjS9  Mt     g)z0Process all bot actions during submission phase.Nc                 &   > TR                  U 5      $ ru  )r  )r   r   s    r&   r  <HumanityCardsGame._process_submission_bots.<locals>.<lambda>  s    t~~a'8rD   c                 &   > TR                  X5      $ ru  )execute_action)rG  r   r   s     r&   r  r    s    t7J7J17XrD   )think_fn
execute_fn)r   r   rO  r   rT   r   process_bot_actionrb  s   `  r&   r  *HumanityCardsGame._process_submission_bots  sb    llF==F$7$7'-C~~c""c&9&9&E(("%8/5X #rD   c                    U R                  5        H  nUR                  (       d  M  UR                  S:  a  U=R                  S-  sl        M=  UR                  (       a&  UR                  nSUl        U R	                  X5        Mt  U R
                  (       d  M  [        R                  " S[        U R
                  5      S-
  5      nSU 3Ul        M     g)z/Process judge bot actions during judging phase.r   rF   Nr  )	r   r   bot_think_ticksbot_pending_actionr  r   r   rV  r   )r   r  rG  r   s       r&   r  'HumanityCardsGame._process_judging_bots  s    %%'E<<$$q(%%*%''!44	+/(##E5 $$$~~aT-B-B)Ca)GH-8+?(# (rD   c                 (   U R                  5       n[        US SS9n0 nU H  nUnUR                  X4R                  '   M     U(       a  US   OSn[	        U R                  5       [        R                  " 5       R                  5       U R                  U Vs/ s H8  n[        UR                  UR                  UR                  [        USS5      S9PM:     snU(       a  UR                  OSU(       a  UR                  OSUU R                  S	.S
9$ s  snf )zBuild the game result.c                     U R                   $ ru  r  r  s    r&   r  5HumanityCardsGame.build_game_result.<locals>.<lambda>  r  rD   Tr  r   Nis_virtual_botF)r   player_namer   r  )winner_namewinner_scorefinal_scoresrounds_played)	game_type	timestampduration_ticksplayer_resultscustom_data)r   r  rP   r)   r   r   r   now	isoformatsound_scheduler_tickr   r   r   getattrr  )r   r  r  r  r   r  rb  s          r&   build_game_result#HumanityCardsGame.build_game_result  s    002!
 A&'B#%88L    '5"$mmolln..044 ( (A dd !88#*1.>#F	 ( /5v{{$06A ,!%	
 	
s   ?Dr   r2  c                     [         R                  " US5      /nUR                  R                  S0 5      n[        UR	                  5       S5       H!  u  nu  pgUR                  U SU SU 35        M#     U$ )zFormat the end screen.zgame-final-scores-headerr  rF   r  r  )r   rG   r  rh  itemsr9   )r   r   r2  r  r  r6  r)   rP   s           r&   format_end_screen#HumanityCardsGame.format_end_screen  sv    !!&*DEF))--nbA ),*<*<*> BA}LLA3bb01 !C rD   )r   r   r   r  r   r   r   r  r   rN  r   r   r   r   )F)r   N)rF   )rV   rW   rX   rY   rZ   r   r;   r   rN   r\   ra   r   r   r^   r   r]   r   r   r   r   r   r[   r   r   r   r   classmethodr   r   r   r   r   boolr   r   r   r   r   r   r   r   r   r   r   r   r   r   r7  rA  r	   r  r   r  r  r  tupler#  r$  r%  r  r  r  r  r  r  r  r  r,  r-  r+  r0  r/  r  r(  r)  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r!  r$  r'  r*  r-  r1  r4  r7  r:  r=  rA  rE  rI  rM  r"  r  r'  r  rv  ry  r~  r  r  r  rY  ri  r  r  r  r  r   r  r  r_   __classcell__)rE  s   @r&   r   r      s,
    */t)DGT%&D$):N$OG!O E3"48JT
8"48JT
8 %d ;M4:; %d ;M4:;&*t*$T:M49:s#D9Kd9"'"=d3i=OS( ( (    &S & &      Ks K# Kt KPc K-49 -'(R T$Z  
BTD[ 
B&)< & &
# 
DI 
# 
*3 *3 * 3  T"56 O&9!: O
=<0d3F.G 0UX 0]a 0(m-@ mY m^7
zf  t ""V " "
 "
SV 
S 
S 
SV  d
  C%T	:J4JT4Q "
" 
": 
"

 

3 

3 

 V  d
 	"F 	"s 	"z 	"	'F 	's 	's 	'6 c d f  QTW[Q[ "V " "PZ "&V & &PS &f c "f t 
"V "
 "
+& +S +T +"!V !
 !
a& 
aS 
aT 
a) )C )D )*v #* 
"f " "& S4Z " "J "A AC AC A)6 )# )$ )8%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %&V & & &&V & & &&V & & &&V & & &&V & & &$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $$6 $c $d $%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %%F %s %t %5"6 5"c 5"d 5"nR%& R%c R%d R%h1f 1 1 12f 2 2 2,v #* 
 3: 

+6 
+c 
+d 
+'F 's 't '&%N<!|!:	 3 	 	 3 d
 ()(@2#
: #
J
 C DI  rD   r   )1rZ   dataclassesr   r   r   r"   r   pathlibr   baser   r	   r
   registryr   game_utils.actionsr   r   r   game_utils.bot_helperr   game_utils.game_resultr   r   game_utils.optionsr   r   r   r   r   messages.localizationr   server.core.ui.keybindsr   r   r;   r]   r\   r'   r^   r+   rC   rH   rJ   r[   rL   rN   ra   r   rK   rD   r&   <module>r     s   )     , , $ ? ? . >  2 0 &*dd" )T$Z <S	 <
2c49n- 2j>DI > s  >& > > @; @ @P T T  TrD   