
    sojV                         d dl T d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
  G d de          Ze                                 dS )	    )*N)	BaseModel)	GroupChat)User)
GameStatusc                      e Zd ZU dZ eeddd          Zeez  ed<    ee	j
                  Ze	ez  ed<    edd	
          Zeez  ed<    eed	ddd          Zeez  ed<    ed	          Zeez  ed<    ed	          Zeez  ed<    G d d          Zedede	defd            Zedede	defd            Zedede	dd fd            Zde	fdZdefdZdS )DocQGamez
    Doc Q Game class
    doc_q_game_usersCASCADE)backref	on_delete	on_updateuser)defaultstatusc   T)
max_lengthnullcorrect_choices_indexdoc_q_game_groups_chatsRESTRICT)r   r   r   r   
group_chat)r   
message_idbellyc                       e Zd ZdZdS )DocQGame.Meta
doc_q_gameN)__name__
__module____qualname__db_table     /app/src/model/DocQGame.pyMetar      s        r#   r%   returnc                     t                                                                          t           j        | k    t           j        |k    z                                            S )z
        Get the total amount of wins or losses a user has
        param user: The user
        param status: The status (won or lost)
        return: The total amount of wins or losses
        )r	   selectwherer   r   countr   r   s     r$   get_total_win_or_losszDocQGame.get_total_win_or_loss!   sB     JJVXXUHMT)ho.GHIIUWW		
r#   c                    t                                          t                              t           j                                                t           j        | k    t           j        |k    z                                            S )z
        Get the total amount of belly a user has won or lost
        param user: The user
        param status: The status (won or lost)
        return: The total amount of belly won or lost
        )	r	   r(   fnSUMr   r)   r   r   scalarr+   s     r$   get_total_belly_won_or_lostz$DocQGame.get_total_belly_won_or_lost1   sT     JJVBFF8>**++UHMT)ho.GHII
&((		r#   c                 (   t                                                                          t           j        | k    t           j        |k    z                                t           j                                                                                  S )z
        Get the DocQGame with the max amount of belly won or lost
        param user: The user
        param status: The status (won or lost)
        return: The max amount of belly won or lost
        )	r	   r(   r)   r   r   order_byr   descfirstr+   s     r$   get_max_won_or_lostzDocQGame.get_max_won_or_lost@   s]     JJVXXUHMT)ho.GHIIXhn))++,,UWW	
r#   c                 *    t          | j                  S )zT
        Get the status of the game
        :return: The status of the game
        )r   r   selfs    r$   
get_statuszDocQGame.get_statusQ   s     $+&&&r#   c                     t          t          | j                                      t          j                  d                   dz   S )zX
        Get the correct apple number
        :return: The correct apple number
        r      )intstrr   splitcSTANDARD_SPLIT_CHARr8   s    r$   get_correct_apple_numberz!DocQGame.get_correct_apple_numberY   s:     C23399!:OPPRSTUUXYYYr#   N)r   r   r    __doc__ForeignKeyFieldr   r   __annotations__SmallIntegerFieldr   IN_PROGRESSr   	CharFieldr   r>   r   r   IntegerFieldr   r=   BigIntegerFieldr   r%   staticmethodr,   r1   r6   r:   rB   r"   r#   r$   r	   r	   
   s*          $3?(I$ $ $D$
     .?->zG]-^-^-^FJ**^^^-6Y"4-P-P-P3?PPP.=o)/ / /J	O+    &2\t%<%<%<Jl"<<<#2?#=#=#=E3 ===                
D 
* 
 
 
 
 \
 $ 
 s    \ 
$ 

 
z 
 
 
 \
 'J ' ' ' 'Z# Z Z Z Z Z Zr#   r	   )peewee	constantsr@   src.model.BaseModelr   src.model.GroupChatr   src.model.Userr   src.model.enums.GameStatusr   r	   create_tabler"   r#   r$   <module>rS      s            ) ) ) ) ) ) ) ) ) ) ) )       1 1 1 1 1 1UZ UZ UZ UZ UZy UZ UZ UZp 	       r#   