
    soj~                     R   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 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 d dlmZmZ d dlmZ d dlmZ 	 	 	 d dedej        dedede dede de fdZ!dedej        dede	de f
dZ"dedej        dede	dedede#dz  fdZ$dS )!    )Update)ContextTypes)phrases)
DevilFruit)DevilFruitTrade)User)DevilFruitSource)DevilFruitStatus)IncomeTaxEventType)"DevilFruitTradeValidationException)Keyboard)add_or_remove_bounty)give_devil_fruit_to_userget_recap_text)full_message_send)get_belly_formattedFNupdatecontextdevil_fruitselleradd_delete_buttoninbound_keyboard
show_alertreturnc           	      l  K   	 |j         |k    r>t          t          j                            |                                                    |j        t          j        k    rt          t          j	                  n8# t          $ r+}t          ||j        | |||           d{V  Y d}~dS d}~ww xY wdS )a  
    Validate the trade
    :param update: The update object
    :param context: The context object
    :param devil_fruit: The Devil Fruit
    :param seller: The seller
    :param add_delete_button: Whether to add the delete button
    :param inbound_keyboard: The inbound keyboard
    :param show_alert: Whether to show an alert
    :return: True if the trade is valid, False otherwise
    )r   r   r   r   NFT)ownerr   r   DEVIL_FRUIT_SELL_NO_LONGER_OWNformatget_markdown_mentionstatusr
   	COLLECTED#DEVIL_FRUIT_SELL_NO_LONGER_SELLABLEr   message)r   r   r   r   r   r   r   es           7/app/src/chat/common/screens/screen_devil_fruit_sell.pyvalidate_trader&      s      (&&46==f>Y>Y>[>[\\  
 !1!;;;4W5`aaa < . 	 	 	I-/!
 
 
 	
 	
 	
 	
 	
 	
 	
 uuuuu	 4s   A7A< <
B1 B,,B1buyerdevil_fruit_tradec                   K   	 |j         |j        k     rt          t          j                  |j        |k    rt          t          j                  n7# t          $ r*}t          ||j        | dd           d{V  Y d}~dS d}~ww xY wdS )z
    Validate the buy action
    :param update: The update object
    :param context: The context object
    :param buyer: The buyer
    :param devil_fruit_trade: The Devil Fruit trade
    :return: True if the buy is valid, False otherwise
    T)r   answer_callbackr   NF)	bountypricer   r   %DEVIL_FRUIT_SELL_BUY_NOT_ENOUGH_BELLYgiver#DEVIL_FRUIT_SELL_BUY_CANNOT_BUY_OWNr   r#   )r   r   r'   r(   r$   s        r%   validate_buyr0   @   s      <+1114W5bccc "e++4W5`aaa , .   QYvtPT
 
 
 	
 	
 	
 	
 	
 	
 	
 uuuuu	 4s   AA 
BBBsourcec                   K   t          | |||           d{V sdS t          ||||           t          ||j        d|            d{V  |                                 t          |j        |j        | t          j        |j        d           d{V  |j        }t          j
                            |                                |                                t          |          t          |j                            S )a#  
    Buy the Devil Fruit
    :param update: The update object
    :param context: The context object
    :param buyer: The buyer
    :param devil_fruit_trade: The Devil Fruit trade
    :param devil_fruit: The Devil Fruit
    :param source: The source
    :return: The completed buy text
    N)r(   F)addr   T)r   tax_event_typeevent_idshould_save)r0   r   r   r,   saver.   r   DEVIL_FRUIT_SELLidr   DEVIL_FRUIT_SELL_BUY_SUCCESSr   get_you_markdown_mentionr   r   r   )r   r   r'   r(   r   r1   r   s          r%   buyr<   a   s=     ( fgu6GHHHHHHHH [%K\]]]] u&7&=5QW
X
X
XXXXXXXX	JJLLL ):"%          %*F/66&&((##%%{##-344	      )FNF)%src.tg_compatr   src.tg_compat.extr   	resourcesr   src.model.DevilFruitr   src.model.DevilFruitTrader   src.model.Userr   ,src.model.enums.devil_fruit.DevilFruitSourcer	   ,src.model.enums.devil_fruit.DevilFruitStatusr
   -src.model.enums.income_tax.IncomeTaxEventTyper   src.model.error.CustomExceptionr   src.model.pojo.Keyboardr   src.service.bounty_servicer   src.service.devil_fruit_servicer   r   src.service.message_servicer   src.utils.string_utilsr   DEFAULT_TYPEboolr&   r0   strr<    r=   r%   <module>rQ      s:               * * * * * *       + + + + + + 5 5 5 5 5 5       I I I I I I I I I I I I L L L L L L N N N N N N , , , , , , ; ; ; ; ; ; T T T T T T T T 9 9 9 9 9 9 6 6 6 6 6 6 $!%* **&* * 	*
 * * * 
* * * *Z&  '	
 
   B..&. . '	.
 . . 	4Z. . . . . .r=   