³ò
Õ%Hc           @   sÅ   d  d k  l Z l Z d  d k Z e d ƒ \ Z Z Z d e f d „  ƒ  YZ	 d e
 f d „  ƒ  YZ xE d D]= Z e d „ Z e d „ Z e e e ƒ Z e e e e ƒ qj Wd e
 f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divt   truedivNi   t   arrayc           B   sk   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   c         C   sR   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | |  | | | q/ ~ ƒ S(   N(   t   coerceR   t   ranget   len(   t   selft   othert   _[1]t   i(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __add__   s    c         C   s   |  | S(   N(    (   R   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __iadd__    s    c         C   sR   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | |  | | | q/ ~ ƒ S(   N(   R   R   R   R   (   R   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __sub__#   s    c         C   sR   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | |  | | | q/ ~ ƒ S(   N(   R   R   R   R   (   R   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __mul__'   s    c         C   sR   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | |  | | | q/ ~ ƒ S(   N(   R   R   R   R   (   R   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __divfloor__+   s    c         C   sW   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | t |  | | | ƒ q/ ~ ƒ S(   N(   R   R   R   R   R    (   R   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __div__/   s    c         C   sW   t  |  | ƒ \ }  } t g  } t t |  ƒ ƒ D] } | t |  | | | ƒ q/ ~ ƒ S(   N(   R   R   R   R   R   (   R   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __truediv__3   s    c         C   s;   t  g  } t t |  ƒ ƒ D] } | t |  | ƒ q ~ ƒ S(   N(   R   R   R   t   int(   R   R   R	   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   integer_part7   s    c         C   s*   x# |  D] } | d j o t  Sq q Wt S(   Ni    (   t   Truet   False(   R   t   element(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __nonzero__:   s
     c         C   sH   t  | ƒ t t f j o! |  t | g t |  ƒ ƒ f Sn |  | f Sd  S(   N(   t   typet   floatR   R   R   (   R   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt
   __coerce__@   s    !c         C   s   d t  t |  ƒ i ƒ  S(   Ns	   array(%s)(   t   superR   t   __str__(   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyR   F   s    (   t   __name__t
   __module__R
   R   R   R   R   R   R   R   R   R   R   (    (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyR      s   										t   Buyable_Classc           B   s;   e  Z d  d „ Z d „  Z e e ƒ Z d „  Z d „  Z RS(   t    c         C   sP   | |  _  |  _ | |  _ | |  _ | |  _ | o | d |  _ n
 d |  _ d  S(   Nt   _R   (   t   namet   idt   descriptiont   _costt   prerequisitest   prefix(   R   R"   R#   t   costR%   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __init__J   s    			c         C   sS   t  |  i ƒ } | t c t i t i i 9<| t c d :<| t c t i 9<| S(   Ni'  (	   R   R$   t   labort   gt   minutes_per_dayt   plt   labor_bonust   cput   seconds_per_day(   R   R'   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   get_costU   s
    c         C   s   t  |  i | i ƒ S(   N(   t   cmpR'   (   R   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   __cmp__^   s    c         C   s–   t  } t |  i ƒ t j p t ‚ xk |  i D]` } | d j o
 t } n | t i j o$ t i | i o | o t Sq q- | p t  Sq- q- W| S(   Nt   OR(	   R   R   R%   t   listt   AssertionErrorR   R*   t   techst   done(   R   t   or_modet   prerequisite(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt	   availabled   s    
 
!(   R   R   R(   R0   t   propertyR'   R2   R:   (    (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyR   I   s
   		t   countt   complete_countt   total_countt   total_complete_countc         C   s"   t  i i |  i |  i d | ƒ S(   NR    (   R*   t   statst   get_statisticR&   R"   (   R   t   stat(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   getw   s    c         C   s%   t  i i |  i |  i d | | ƒ S(   NR    (   R*   R@   t   set_statisticR&   R"   (   R   t   valueRB   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   sety   s    t   Buyablec           B   sn   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z	 d
 d
 d d „ Z d	 „  Z RS(   c         C   s}   | |  _  | i d 7_ | i d 7_ | i |  _ |  _ | i |  _ | i |  _ | i |  _ t	 |  i ƒ |  _
 t |  _ d  S(   Ni   (   R   R<   R>   R"   R!   R#   R%   R'   t
   total_costR   t	   cost_leftR   R7   (   R   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyR(   €   s    	c         C   s
   |  i  i S(    (   R   R:   (   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   <lambda>   s    c         C   sJ   | d j o9 |  i  t |  i t j  o |  i  t c t i 9<qF n d  S(   Ni   (   RI   R.   RH   R*   R/   (   R   t   save_version(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   convert_from’   s    c         C   s5   |  i  t | ƒ 8_  |  i  p |  i ƒ  t Sn t S(   N(   RI   R   t   finishR   R   (   R   t   cost_towards(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   _work_on—   s
    

c         C   sW   |  i  pI t d d d g ƒ |  _ t |  _  |  i i d 7_ |  i i d 7_ n d  S(   Ni    i   (   R7   R   RI   R   R   R=   R?   (   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyRM   ž   s
    
	c         C   s   |  i  |  i S(    (   RH   RI   (   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyRJ   ¥   s    c   	      C   sq   |  i  | } |  i | } |  i | } | | j o |  i | Sn | | } |  i  | | | } | |  i | S(   N(   RH   t	   cost_paidRI   (	   R   t   resourcet   limitingt   available_limitingt	   limit_maxt
   limit_paidt
   limit_leftt   limitt   total_wanted(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt
   get_wanted§   s    
i    c         C   s5  |  i  o d  Sn | d  j o t i i } n | d  j o t i i } n |  i t } t | | ƒ } |  i	 t t | ƒ } t | | ƒ } t |  i	 t
 t | ƒ |  i	 t
 t | ƒ ƒ } t | | ƒ }	 t | |  i	 t t
 |	 ƒ t d |  i t ƒ ƒ }
 t i i | 8_ t i i |
 8_ |  i |
 | |	 g ƒ S(   Ngš™™™™™©?(   R7   t   NoneR*   R,   t   casht   cpu_poolRI   R.   t   minRY   R)   R   RH   RO   (   R   t   cash_availablet   cpu_availablet   timet
   cpu_wantedt   cpu_workt   cash_wantedt   max_cash_flowt   labor_wantedt
   time_spentt	   cash_flow(    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   work_on¹   s$    
c         C   s6   |  i  i d 8_ |  i o |  i  i d 8_ n d  S(   Ni   (   R   R<   R7   R=   (   R   (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyt   destroyÝ   s    
N(   R   R   R(   R;   R:   RL   RO   RM   RP   RY   RZ   Rh   Ri   (    (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pyRG      s   					$(   s   counts   complete_counts   total_counts   total_complete_count(   t   operatorR    R   R*   R   R[   R.   R)   R4   R   t   objectR   RB   RC   RF   R;   t	   stat_propt   setattrRG   (    (    (    s<   /home/phil/rcs/svn/endgame-singularity/trunk/code/buyable.pys   <module>   s   .+ 