
[f)Lc        D   @   s  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z e i   Z d Z d Z dl Z d Z dm Z do Z d Z d a e Z d Z e  Z! d Z" e a# d   Z$ e$   d a% d	 a& d
 a' d a( d   Z) h  Z* h  Z+ h  a, h  a- d   Z. d   Z/ d a0 h  a1 d   Z2 d d  Z3 d   Z4 e  d  Z5 d   Z6 dp dq dr ds f Z7 dt Z8 d   Z9 d   Z: d   Z; d    Z< d!   Z= d"   Z> e d#  Z? d$   Z@ d%   ZA e  d&  ZB e  d'  ZC d( ZD d)   ZE h d* d+ 6d, d( 6ZF d d kG ZG d d kH ZI eJ d- e	 iK d. e	 iK d/ eG iL d0 eM d1 eN d2 eN d3 e iO d4 e iP d5 e iQ d6 e iQ d7 e	 iR d8 e	 iR d9 e iS d: e iS d; e
 iT d< e
 iU d= e
 iU d> e iV d? e iW d@ e iW dA eI iX iY iZ dB eI iX iY i[ dC eI i\ dD eI i]  Z^ dE   Z_ d a` e	 iK dF  aa h  ab dG   Zc dH   Zd dI   Ze dJ   Zf dK   Zg dL   Zh dM dN  Zi h  aj dO   Zk dP   Zl eg   el   h  am dQ dR dS dS g tm dT <dU dV dS dS g tm dW <dX dY dS dS g tm dZ <d[ dS dS dS g tm d\ <h  an d]   Zo d^   Zp h  aq d_   Zr d`   Zs da   Zt db   Zu dc   Zv dd   Zw de   Zx df   Zy du Zz di   Z{ dj   Z| dk   Z} d Z d S(v   s   0.30aiNi   i<   i    t   en_USc          C   s\   xU t  d t  d d d g D]: }  y t i t i |   PWq t i j
 o
 q q Xq Wd  S(   Ns   .UTF-8t    s   en_US.UTF-8R    (   t   languaget   localet	   setlocalet   LC_ALLt   Error(   t   attempt(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   set_localeL   s     s   Default Saves   DejaVuSans.ttfs   acknowtt.ttfs   ../data/c           C   s   t  i   d  S(   N(   t   syst   exit(    (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt	   quit_game`   s    c          C   s  t  o d St i i   p t i i d  d a  d St i i	 t
 d  }  t t i i	 d d   } x(| D] } t | d d  t | d  t j o | d g } n | d } x | D] } t i i	 |  |  } t i i |  p% t i i d |  t i d  q t i i |  } t i | d	  p g  t | d	 <n t | d	 i h | d 6| d
 6 t o t i i d |  q q Wqn Wd S(   sd   
load_sounds() loads all of the sounds in the data/sounds/ directory,
defined in sounds/sounds.dat.
NsD   WARNING: Could not start the mixer, even though sound is requested!
i   t   soundss
   sounds.datt   filenamet   Sounds-   ERROR: Cannot load nonexistent soundfile %s!
t   idt   sounds   D: Loaded soundfile %s
(   s   filename(   t   nosoundt   pygamet   mixert   get_initR	   t   stderrt   writet   ost   patht   joint   data_loct   generic_loadt   check_required_fieldst   typet   listt   isfileR
   R   R   t   has_keyt   appendt   debug(   t	   sound_dirt   sound_class_listt   sound_classt	   filenamesR   t   real_filenameR   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_soundsh   s:    	 
 c         C   sz   t  o d S|  t j o t i i d |   d St i t |   } t o t i i d | d  n | d i   d S(   s5   
play_sound() plays a sound from a particular class.
Ns5   WARNING: Requesting a sound of unavailable class %s!
s   D: Playing sound %s.
R   R   (	   R   R   R	   R   R   t   randomt   choiceR"   t   play(   R%   t   random_sound(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   play_sound   s    i   c       
   C   s  t  o d Sh  a t i i t d d  t i i t t  d  f }  xD|  D]<} t i i |  ox t i	 |  D] \ } } } t i i
 |  \ } } | i   d j o t i |  p g  t | <n x | D] } t |  d j op | d d j p | d d j oN t | i t i i | | |   t o  t i i d	 t | d
  q]q q Wqu qu WqL y t i |  WqL qL XqL Wd S(   s   
load_music() loads music for the game.  It looks in multiple locations:

* music/ in the install directory for E:S; and
* music/ in the save folder.
Ns   ..t   musics   .svni   it   oggt   mp3s   D: Loaded musicfile %s
i(   R   t
   music_dictR   R   R   R   t   get_save_foldert   Truet   isdirt   walkt   splitt   lowerR    t   lenR!   R"   R	   R   R   t   makedirs(   t   music_pathst
   music_patht   roott   dirst   filest   headt   tailt	   file_name(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   load_music   s4       "#(R.   c         C   sS  t  p t t  d j o d  St i |   p d  St t |   d j o d  St i i i   o |  d j o d  S|  d j oD t i i i   t i i i	 t
 i t |    t i i i   n t d j o+ t i i   t t
 i
   d  d a nR t t i i   j o d  Sd a t i i i	 t
 i t |    t i i i   d  S(   Ni    R.   i'  i  (   R   R8   R1   R    R   R   R.   t   get_busyt   stopt   loadR)   R*   R+   t
   delay_timet   timet	   get_tickst   int(   t   musicdir(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   play_music   s&          +  c         C   s!  t  i   \ } } t  i d |  d t i |  } t  i d d  i |  } t |  d j o | d i   o | d t  i d  j o9 | d t  i d  j o | i | d  i | d  S| d t  i d  j o9 | d t  i d  j o | i	 | d  i	 | d  Sn | S(	   Ns   %0.2ft   groupings   %01.1fg?i   i   i    i   (
   R   t	   getlocalet   formatR3   t   decodeR8   t   isdigitt   strt   rstript   lstrip(   t   numbert   locale_namet   encodingt   raw_with_commast   locale_test(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   add_commas   s    %44#c         C   si   t  i   \ } } |  d d j p | o t  i d |  d  i |  St  i d |  d  i |  Sd  S(   Nid   i    s   %.2f%%g      Y@s   %d%%(   R   RM   RN   RO   (   t   raw_percentt	   show_fullRU   RV   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   to_percent	  s    c         C   s0   |  d } | d j o	 |  | S|  d | Sd  S(   Nid   i2   (    (   t   valuet   sub_percent(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   nearest_percent  s    
	i   iU   i   t   detect_str_lowt   detect_str_moderatet   detect_str_hight   detect_str_criticalc         C   s   t  t |    S(   N(   t   danger_level_to_detect_strt   suspicion_to_danger_level(   t	   suspicion(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   suspicion_to_detect_str   s    c         C   s   t  t |  S(   N(   t   stringst   detect_string_names(   t   danger(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyRd   #  s    c         C   s>   |  d j  o d S|  d j  o d S|  d j  o d Sd Sd  S(   Ni	  i    i  i   iL  i   i   (    (   Rf   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyRe   (  s    c         C   s   |  t  t  } t |  S(   N(   t   floatt   seconds_per_dayRY   (   t   amountt   display_cpu(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   to_cpu4  s    c         C   s   d } t  |   } | d j  o t |   } n | d j  o d } d } nG | d j  o d } d } n* | d j  o d } d } n d } d	 } d
 t |   | } | | 7} | S(   NR   i@B i ʚ;t   mil    J)t   bil     I5 t   trt   qus   %3.3f(   t   absRY   Rk   (   Rm   t	   to_returnt
   abs_amountt   divisort   unit(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   to_money:  s$    



c         C   s   t  i d d  } |  | j S(   Ni   i'  (   R)   t   randint(   t   roll_againstt   rand_num(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   roll_percentT  s    c         C   s>   | t  t  } d |  } | | } d | } t i   | j  S(   Ni   (   Rk   Rl   R)   (   t   chance_per_dayt   secondst   portion_of_dayt   inv_chance_per_dayt
   inv_chancet   chance(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   roll_chance]  s
    


c         C   sh   | | } | d j  o t  |  t |  } d } n d } |  | t } |  | t } | | } | | S(   Ni    (   t   current_shareRl   (   t   num_per_dayt   time_of_dayt   seconds_passedt	   last_timet   share_yesterdayt   previously_passedt   current_passedt   passed_this_tick(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR   f  s    
	


c         C   sZ   |  d d j o t  |  d  d S|  d d j o t  |  d  d St  |   d Sd  S(	   Ni<   i0   i   s    daysi   s    hourss    minutesi  (   RQ   (   t   raw_time(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   to_timev  s
    c         c   sJ   xC t  i   D]5 } x, | i D]! } |  o | | f Vq | Vq Wq Wd  S(   N(   t	   locationst   valuest   bases(   t   with_loct   base_loct   base(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt	   all_bases  s     
 c         C   s   t  i i d  o( t o  t  i i t  i d d  } nM t  i i t  i i t   \ } } | i	   d j o t
 d t d  n t  i i | d  } t  i i |  p t  i |  n |  o | S| Sd  S(   Nt   HOMEs   .endgamet   datas	   data_loc=s    breaks get_save_foldert   saves(   R   t   environR    t   force_single_dirR   R   R6   t   normpathR   R7   t
   ValueErrort   existsR9   (   t   just_pref_dirt   pref_dirt   data_subdirt   save_dir(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR2     s     $t   singularity_savefile_r5_prec         C   s   |  a  t   } t i i | |  d  } t | d  } t i t |  t i t	 |  t i t
 |  t i t |  t i t |  t i t |  | i   d  S(   Ns   .savt   w(   t   default_savegame_nameR2   R   R   R   t   opent   cPicklet   dumpt   current_save_versiont   plt
   curr_speedt   techsR   t   eventst   close(   t   savegame_nameR   t   save_loct   savefile(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt	   save_game  s    	i   t   singularity_savefile_r4gp=
ף@t   player_classt   Playert   _reconstructort   objectt   arrayR   t   Locationt   Techt   event_classt   Eventt   groupt   Groupt   Buyable_Classt   BuyableClasst   Baset
   Base_Classt	   BaseClasst   Itemt
   Item_Classt	   ItemClasst   _reconstructt   scalart   ndarrayt   dtypec         C   s  |  d j o
 d GHt  St   } t i i | |  d  } t i i |  d j oD t i i | |   } t i i |  d j o d | d GHt  Sn t | d  } t i |  } d   } | | _	 | i
   } | t j o | i   |  d	 GHt  St | } |  a t   t   t   | i
   a | i
   a | i
   a | i
   a | i
   a | t t j om t i |  x5 t i   D]' } x | i D] }	 |	 i |  qWqWx% t i   D] }
 |
 i |  qWn | i   t S(
   NR   s   No game specified.s   .savi    s   file s    does not exist.t   rc         S   s)   | t  j o	 t  | St |  | f  d  S(   N(   t   save_classest
   SystemExit(   t   module_namet
   class_name(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   find_class  s    	s*    is not a savegame, or is too old to work.(   t   FalseR2   R   R   R   R   R   R   t	   Unpicklert   find_globalRE   t   savefile_translationR   R   t   load_locationst
   load_basest   load_eventsR   R   R   R   R   R   t   convert_fromR   R   R3   (   t   loadgame_nameR   t   load_loct   loadfilet   unpickleR   t   load_version_stringt   load_versiont   locationt   my_baset   tech(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt	   load_game  sR    				
	
 
  
l     QJc         C   s   t  d |  d  } x | D] } | i d  p d |  d GHn | i d  o | d t | d _ n | i d  o | d t | d _ n | i d  oL t | d  t j o | d t | d _ q | d g t | d _ q q Wd  S(   Nt   bases_s   .datR   s   base lacks id in bases_t   namet   descriptiont   flavor(   R   R    t	   base_typet	   base_nameR   R   R   R   (   t   language_strt
   base_arrayR   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_base_defs#  s     c          C   s  h  a  t d  }  x_|  D]W} t | d d  t | d  } | i d	 t  } | d } t |  t j p t |  d
 j o+ t	 i
 i d t |   t	 i d  n g  } | D] } | t |  q ~ } | d } t |  t j p t |  d
 j o+ t	 i
 i d t |   t	 i d  n g  } | D] } | t |  q9~ } | d }	 t |	  t j o+ t	 i
 i d t |	   t	 i d  n h  }
 x3 |	 D]+ } | i d  \ } } t |  |
 | <qW| i d g   } t |  t j o | g } n t | d  t j o | d } n | d g } t i | d d | | | |
 | | | 	 t  | d <q Wt d  t d j o t t  n d  S(   Ns	   bases.datR   t   costt   sizet   allowedt   detect_chancet   maintR   t	   force_cpui   s   Error with cost given: %s
i   s   Error with maint given: %s
s#   Error with detect_chance given: %s
t   :t   preR   R    (   s   idR   s   sizeR   R   R   (   R   R   R   RI   t   getR   R   R   R8   R	   R   R   t   reprR
   R6   R   R   R   R   (   t	   base_listR   t	   base_sizeR   t	   cost_listt   _[1]t   xt
   maint_listt   _[2]t   chance_listt   chance_dictt
   chance_strt   keyR]   t   base_pret   allowed_list(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR   3  sN     

&'
&'
 
c         C   s   t  d |  d  } x | D] } | i d  p d |  d GHn t | d } | i d  o | d | _ n | i d  o | d | _ n | i d  o< t | d  t j o | d | _ q | d g | _ q d g | _ q Wd  S(	   Nt
   locations_s   .datR   s   location lacks id in locations_R   t   hotkeyt   citiesR   (   R   R    R   R   R  R   R   R  (   R   t   location_arrayt   location_defR   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_location_defs{  s     c          C   sH  h  a  t d  }  x
|  D]} t | d d  | d } | d } t |  t j p t |  d j o+ t i i d t	 |   t i
 d  n y t |  d j o* t | d	  t | d  f } t } nM | d	 d
 j o t d | d	  n t | d  t | d  f } t } Wn: t j
 o. t i i d t	 |   t i
 d  n X| i d d  } y t |  } Wn: t j
 o. t i i d t	 |   t i
 d  n X| i d g   } t |  t j o | g } n | i d g   } t |  t j o+ t i i d t	 |   t i
 d  n h  } x | D] }	 |	 i d  \ }
 } |
 i   i   }
 | i   i   } | i   d j o t i |
 | |
 <qL| i   d j o t i |
 | |
 <qLt |  | |
 <qLWt i | | | | |  t  | <| t  | _ q Wt d  t d j o t t  n d  S(   Ns   locations.datR   t   positionR   i   i   s   Error with position given: %s
i   i    t   absolutes   '%s' not understood.t   safetyt   0s   Error with safety given: %s
R   t   modifiers!   Error with modifier(s) given: %s
R   t   bonust   penaltyR    (   s   ids   position(   i   i   (   R   R   R   R   R   R8   R	   R   R   R   R
   RI   R   R   R3   R   R6   R7   t   stripR   t   bonus_levelst   penalty_levelsRk   R   t	   modifiersR  R   (   t   location_infost   location_infoR   R	  R
  R  R   t   modifiers_listt   modifiers_dictt   modifier_strR   R]   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR     sd     

& 
 
 
c           C   s:   t  i i t  o d  St  i i d  o d a d  Sd  S(   NR   s   data/(   R   R   R   R   (    (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   fix_data_dir  s
     c   
      C   sl  t  i   } t i i t |   } y | i t | d   Wn< t j
 o0 } t	 i
 i d | | f  t	 i d  n Xg  } x | i   D] } h  } | | d <x | i |  D] } t |  d j ob | d d j oQ g  } | i | |  i d  D] }	 | t |	 i   d	  q ~ | | d  <q t | i | |  i   d	  | | <q W| i |  q W| S(
   s9  
generic_load() loads a data file.  Data files are all in Python-standard
ConfigParser format.  The 'id' of any object is the section of that object.
Fields that need to be lists are postpended with _list; this is stripped
from the actual name, and the internal entries are broken up by the pipe
("|") character.
R   s!   Cannot open %s for reading! (%s)
i   R   i   it   _listt   |s   UTF-8(   t   ConfigParsert   RawConfigParserR   R   R   R   t   readfpR   t	   ExceptionR	   R   R   R
   t   sectionst   optionsR8   R   R6   t   unicodeR  R!   (
   t   filet   configR   t   reasont   return_listt   item_idt	   item_dictt   optionR   R   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR     s*    	 
 $Js   Unknown typec         C   sV   xO | D]G } | |  j o4 t  i i d | t |   | f  t  i d  q q Wd S(   s  
check_required_fields() will check for the existence of every field in
the list 'fields' in the dictionary 'dict'.  If any do not exist, it
will print an error message and abort.  Part of that error message is
the type of object it is processing; this should be passed in via 'name'.
s   %s %s lacks key %s.
i   N(   R	   R   R   R   R
   (   t   dictt   fieldsR   t   field(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR     s
     #c         C   s   t  d |  d  } x | D] } | i d  p d |  d GHn | i d  o | d t | d _ n | i d  o | d t | d _ n | i d  o | d t | d _ q q Wd  S(   Nt   techs_s   .datR   s   tech lacks id in techs_R   R   t   result(   R   R    R   R   R   R.  (   R   t
   tech_arrayR   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_tech_defs  s     c          C   s  h  a  t d  }  x|  D]} t | d d  | d } t |  t j p t |  d j o+ t i i d t	 |   t i
 d  n g  } | D] } | t |  q ~ } | i d g   } t |  t j o | g } n | i d	  o t | d	  } n d
 } | i d  oy | d } t |  t j p t |  d j o+ t i i d t	 |   t i
 d  n | d
 }	 t | d  }
 n d }	 d
 }
 t i | d d d
 | | | |	 |
  t  | d <q Wt d  t d j o t t  n t o d t t   GHn d  S(   Ns	   techs.datR   R   R   i   s   Error with cost given: %si   R   Rj   i    R   i   s   Error with type given: %s
R   R    s   Loaded %d techs.(   s   ids   cost(   R   R   R   R   R   R8   R	   R   R   R   R
   RI   R   R    R   R   R0  R   R"   (   t	   tech_listt	   tech_nameR   R   R   t	   tech_costt   tech_pret   tech_dangert	   type_listt	   tech_typet   tech_second(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   load_techs)  s@     
&'
&
!
iK   t	   SimulacraR   s   Expert Jobsi2   s   Voice Synthesiss   Intermediate Jobsi   s   Personal Identifications
   Basic Jobsi   s   Menial Jobsc          C   s  h  a  t d  }  x|  D]} t | d d  | d } t |  t j p t |  d j o+ t i i d t	 |   t i
 d  n g  } | D] } | t |  q ~ } | i d g   } t |  t j o | g } n | i d	  oy | d	 } t |  t j p t |  d
 j o+ t i i d t	 |   t i
 d  n | d } t | d  }	 n d } d }	 | i d  o. | d }
 t |
  t j o |
 g }
 qn g  }
 t i | d d | | | |	 |
  t  | d <q Wt d  t d j o t t  n d  S(   Ns	   items.datR   R   R   i   s   Error with cost given: %s
i   R   R   i   s   Error with type given: %s
i    R   t   buildR    (   s   ids   cost(   t   itemsR   R   R   R   R8   R	   R   R   R   R
   RI   R   R    t   itemR   t   load_item_defsR   (   t	   item_listt	   item_nameR   R   R   t	   item_costt   item_preR6  t	   item_typet   item_secondt
   build_list(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt
   load_itemso  s@     
&'
&

!
c         C   s   t  d |  d  } x | D]y } | i d  p d |  d GHn | i d  o | d t | d _ n | i d  o | d t | d _ q q Wd  S(   Nt   items_s   .datR   s   item lacks id in items_R   R   (   R   R    R<  R   R   (   R   t
   item_arrayR@  (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR>    s     c       
   C   s   h  a  t d  }  x |  D] } t | d d  | d } t |  t j p t |  d	 j o+ t i i d
 t	 |   t i
 d  n t | d  t | d  f } t i | d d | d | t | d  t | d   t  | d <q Wt   d  S(   Ns
   events.datR   R   R   R.  R   t   uniqueR   i   s   Error with results given: %s
i   i    R   (   s   ids   types   alloweds   results   chances   unique(   R   R   R   R   R   R8   R	   R   R   R   R
   RQ   RI   t   eventR   t   load_event_defs(   t
   event_listt
   event_namet   result_listt   event_result(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyR     s&     

& c          C   s/  h  }  t  i i t d  p8 t  i i t d t d  p t  i i t d  o d GHt i d  n t d t d  } x | D] } | i d  p d t d GHq n | i d	  p d
 t d GHq n | i d  o | d t	 | d _
 n | i d	  o | d	 t	 | d _ q q Wd  S(   Ns
   events.datt   events_s   .dats   events_en_US.dats!   event files are missing. Exiting.i   R   s   event lacks id in events_R   s"   event lacks description in events_(   R   R   R   R   R   R	   R
   R   R    R   R   R   (   t
   event_defst   event_arrayRM  (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyRK    s&      c   	      C   sO  t  d |  d  } x4| D],} | d d j oy x| D]j } | d j o | d a q9 | d j o | d a q9 | d j o! t i i d  t i d  q9 q9 Wq | d d	 j oNx| D]?} | d
 j o | d
 t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o | d t d d <q | d j o t i i d  q q Wq | d d j o t i	 |  q | d d j o$ t
 i	 |  t i i
 i	 t
  q | d d j o g  } | D] } | d j o | | q}q}~ } x | D]o } | | } t |  t j p t |  d j o+ t i i d t |   t i d  n | | t | <qWq t i i d | d  t i d  q Wd  S(   Nt   strings_s   .datR   t   fontst   font0t   font1s'   Unexpected font entry in strings file.
i   t   jobst
   job_experts   Expert Jobsi   t	   job_inters   Intermediate Jobst	   job_basics
   Basic Jobst
   job_menials   Menial Jobst   job_expert_namei   t   job_inter_namet   job_basic_namet   job_menial_names&   Unexpected job entry in strings file.
Rh   t   buttonst   helps   Invalid help entry %s.s   Invalid string section %s.(   R   RU  RV  R	   R   R   R
   RW  Rh   t   updateR`  t   graphicst   gR   R   R8   R   t   help_strings(	   t   langt   string_listt   string_sectiont   string_entryR   R   t	   help_keyst   help_keyt
   help_entry(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_string_defs  sd       2 
&c           C   sf   t  i i t d t d  p t  i i t d  o d GHt i d  n t d  t t  d  S(   NRS  s   .dats   strings_en_US.dats"   string files are missing. Exiting.i   R    (   R   R   R   R   R   R	   R
   Rm  (    (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   load_strings/  s     
c          c   s   t  d t d }  t i i |   p
 d GHd  St |   } | i   d g } d } xd | o\ | i d  i d  } | o# | d d j o | | d 7} qW | o | Vd } qW qW W| o	 | Vn d  S(	   Nt   intro_s   .dats   Intro is missing.  Skipping.R   i    s   utf-8R  i   (	   R   R   R   R   R   R   t	   readlinest   popRO   (   t   intro_file_namet
   intro_filet	   raw_introt   segmentt   line(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt	   get_intro9  s"     c   	      C   s  d a  t i d |  d d |  a |  d j  o% d t _ d t _ d t _ d	 } n|  d j  o% d t _ d
 t _ d t _ d } n |  d j o n |  d j  o? d t _ d t _ d } x t i i   D] } d | _	 q Wn |  d j o? d t _ d t _ d } x_ t i i   D] } d | _	 qWn< d t _ d t _ d } x  t i i   D] } d | _	 qXW|  d j o' x$ t i i   D] } | | _
 qWn t   t   t   |  d j  o t d i   n |  d j  o t d i   n g  } t i   D] } | i   o | | qq~ } t i |  i t i d t d d t  t i } t |  t |  j p t  t i |  xH t |  D]: \ } } | | | _ t  o d | i! | | f GHqqWt" a# d  S(   Ni   i2   id   t
   difficultyi   i   i	  i  iX  i  i,  i(#  i   i*  i   i  i:  i   i2  i  i N  t   Socioanalyticss   Advanced Socioanalyticss   University Computers   Stolen Computer Timet   builts   %s gets modifiers %s($   R   t   playerR   R   t   interest_ratet   labor_bonust   grace_multipliert   groupsR   t   discover_suspiciont   discover_bonusR   R   R9  R   t   finishR   t	   availableR)   R*   t   add_baseR   R   R   R3   R   t   modifier_setsR8   t   AssertionErrort   shufflet	   enumerateR  R"   R   R   t   intro_shown(	   Rx  R  R   R   t   locR   R  t   it   open_loc(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   new_gameO  sr    			
			
		 		 		  8	  c          C   sV   t  d i o
 d }  n7 t  d i o
 d }  n t  d i o
 d }  n d }  |  d S(	   NR:  t   Experts   Voice Synthesist   Intermediates   Personal Identificationt   Basict   Menials    Jobs(   R   t   done(   t   level(    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   get_job_level  s    


c           C   s1   t  i i t  t  i i t  t  i i   d  S(   N(   Rc  Rd  t
   load_fontsR   t   load_imagest
   init_alpha(    (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   init_graphics_system  s    i   i   c          C   sl   t  o d  Sy* t i i   t i i d d d t  Wn/ t j
 o# }  t i i	 d |   d a  n Xd  S(   Ni  ii   s/   Failure starting sound system. Disabling. (%s)
i   (
   R   R   R   t   quitt   initt   soundbufR  R	   R   R   (   R%  (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   reinit_mixer  s     c          C   sS   g  }  t  i t  D]8 } | i d  o" | i d  o |  | d d !q q ~  S(   NRS  s   .dati   i(   R   t   listdirR   t
   startswitht   endswith(   R   RA   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   available_languages  s    c          C   s   g  }  t  i t    } x | D]x } | d d j oa | d j oT t |  d j o | d d j o | d  } n | |  j o |  i |  q q q W|  S(   Ni    t   .t   CVSi   is   .sav(   R   R  R2   R8   R!   (   t
   save_namest	   all_filesRA   (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   get_save_names  s     $i  i  i  iQ (   i    i    i   (   iU   i    i   (   i   i    iU   (   i   i    i    (   R`   Ra   Rb   Rc   i   (   t   versionR  R   R   t   os.pathR   R)   R	   R   R{  R   R   R=  RJ  R   t   buyablet
   statisticst
   graphics.gRc  t
   Statisticst   statst   hours_per_dayt   minutes_per_hourt   minutes_per_dayt   seconds_per_minutet   seconds_per_hourRl   t   cheaterR   R3   t   daynightR"   R   R   R   R  R   R   RU  RV  R   R   Rh   R`  Re  R   R(   R-   RF   R1   RB   RK   RY   R\   R_   t   danger_colorsRi   Rg   Rd   Re   Ro   Ry   R}   R   R   R   R   R2   R   R   R   t   copy_regt   numpy.core.multiarrayt   numpyR*  R   R   R   R   R   R   R   R   R   R   R   R   R   t   coret
   multiarrayR   R   R   R   R   R   R   R   R   R   R   R  R   R  R   R   R   R0  R9  RW  R<  RF  R>  R   R   RK  Rm  Rn  Rw  R  R  R  R  R  R  R  t   Nonet
   map_screen(    (    (    s?   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/g.pyt   <module>   s   `			4		.			 												
																			A		H		I		,		<	8				F	
		L			
		