
    soj                         d dl Z d dlmZ d dlT d dlmZ d dlm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)Optional)*)	BaseModel)	GroupChat)User)DevilFruitCategory)DevilFruitStatus)DevilFruitTradeStatusc                      e Zd ZU dZ e            Zeez  ed<    e	d          Z
ee	z  ed<    e	ddd          Zee	z  ed<    eej        	          Zeez  ed
<    eedddd          Zeez  ed<    ed          Zej        ez  ed<    ed          Zej        ez  ed<    ed          Zej        ez  ed<    eedddd          Zeez  ed<    ed          Z ed          Z ed	          Z ed	          Z  G d d          Z!defdZ"e#dede$d          fd            Z%defdZ&defdZ'defdZ(d S )!
DevilFruitz
    DevilFruit class
    category2   )
max_lengthnameT)r   nulluniquemodel)defaultstatusdevil_fruit_ownersRESTRICTCASCADE)r   backref	on_delete	on_updateowner)r   collection_date
eaten_dateexpiration_date devil_fruit_release_groups_chatsrelease_group_chatFc                       e Zd ZdZdS )DevilFruit.Metadevil_fruitN)__name__
__module____qualname__db_table     /app/src/model/DevilFruit.pyMetar#   +   s         r*   r,   returnc                     | j         r| j         d| j          S |                                 t          j        u r
| j         dS t          | j                  S )zF
        Get fruit full name
        :return: Fruit full name
        z	, Model: z SMILE)r   r   get_categoryr   SMILEstrselfs    r+   get_full_namezDevilFruit.get_full_name.   s`    
 : 	7i66$*666"4":::i''''49~~r*   userc                     t                               t           j        | k    t           j        t          j        k              S )zv
        Get the devil fruit eaten by the user
        :param user: The user
        :return: The devil fruit
        )r   get_or_noner   r   r	   EATEN)r5   s    r+   get_by_owner_if_eatenz DevilFruit.get_by_owner_if_eaten;   s5     %%$j&7;K;Q&Q
 
 	
r*   c                 B    ddl m} |                    | j                  S )zr
        Get the average price of the sold fruits of the same category
        :return: The average price
        r   )DevilFruitTrade)src.model.DevilFruitTrader;   get_average_pricer   )r3   r;   s     r+   r=   zDevilFruit.get_average_priceG   s,     	>=====00???r*   c                 *    t          | j                  S )zS
        Get the category of the devil fruit
        :return: The category
        )r   r   r2   s    r+   r/   zDevilFruit.get_categoryQ   s    
 "$-000r*   c                 *    t          | j                  S )zO
        Get the status of the devil fruit
        :return: The status
        )r	   r   r2   s    r+   
get_statuszDevilFruit.get_statusX   s    
  ,,,r*   N))r%   r&   r'   __doc__SmallIntegerFieldr   intr   __annotations__	CharFieldr   r1   r   r	   NEWr   r
   ForeignKeyFieldr   r   DateTimeFieldr   datetimer   r   r   r!   release_dateIntegerFieldrelease_message_idBooleanFieldshould_show_abilitiesis_defectiver,   r4   staticmethodr   r9   r=   r/   r@   r)   r*   r+   r   r      s          *;):)<)<Hc&&<<<%I444D#	/444&Y"4MMME3?MMM8I8I $9 9 9F!$55    %4O4!5W`% % %E4/!    :GD9Q9Q9QOX&6QQQ4AMt4L4L4LJ!M1LLL9FD9Q9Q9QOX&6QQQ6Eo27 7 7	O3    !=d+++L%4000(L777<...L! ! ! ! ! ! ! !s     	
D 	
Xl-C 	
 	
 	
 \	
@3 @ @ @ @10 1 1 1 1-, - - - - - -r*   r   )rI   typingr   peeweesrc.model.BaseModelr   src.model.GroupChatr   src.model.Userr   .src.model.enums.devil_fruit.DevilFruitCategoryr   ,src.model.enums.devil_fruit.DevilFruitStatusr	   1src.model.enums.devil_fruit.DevilFruitTradeStatusr
   r   create_tabler)   r*   r+   <module>rZ      s               ) ) ) ) ) ) ) ) ) ) ) )       M M M M M M I I I I I I S S S S S SO- O- O- O- O- O- O- O-d        r*   