Ñò
qšuPc           @   s›  d  d k  Z  d  d k l Z l Z l Z l Z l Z l Z l Z d  d k	 l
 Z
 d  d k Te o d  d k l Z n e o d  d k Tn h  a e ƒ  a d a d „  Z d „  Z d	 „  Z d
 „  Z d „  Z e d Z d „  Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d d „ Z# d d „ Z$ d d „ Z% d „  Z& d „  Z' d „  Z( d „  Z) d „  Z* d „  Z+ d „  Z, d  „  Z- d S(!   iÿÿÿÿN(   t	   IS_CLIENTt
   IS_BASEAPPt   IS_WEBt
   IS_CELLAPPt   ARENA_TYPE_XML_PATHt   ARENA_GAMEPLAY_NAMESt   ARENA_GAMEPLAY_IDS(   t   CAMOUFLAGE_KINDS(   t   *(   t   i18ni    c         C   s   d |  >S(   Ni   (    (   t
   gameplayID(    (    s   scripts/common/ArenaType.pyt   getVisibilityMask6   s    c         C   s3   t  g  } t |  ƒ D] } | d t | >q ~ ƒ S(   Ni   (   t   sumt   setR   (   t   gameplayNamest   _[1]t   name(    (    s   scripts/common/ArenaType.pyt   getGameplaysMask;   s    c         C   sD   g  } t  t t ƒ ƒ D]& } t |  d | >@ƒ o | | q q ~ S(   Ni   (   t   xranget   lenR   t   bool(   t   gameplaysMaskR   R
   (    (    s   scripts/common/ArenaType.pyt   getGameplayIDsForMask@   s    c         C   s   t  |  S(   N(   R   (   R
   (    (    s   scripts/common/ArenaType.pyt   getGameplayNameE   s    c         C   s   t  |  S(   N(   R   (   t   gameplayName(    (    s   scripts/common/ArenaType.pyt   getGameplayIDForNameI   s    s   _default_.xmlc          C   s  t  i t d ƒ }  |  d  j o t d t d ‚ n t  i t ƒ } | d  j o t d t ‚ n | d } | d  j p | o t d ‚ n t ƒ  } xm |  i ƒ  D]_ \ } } | i d ƒ } | | j o t d | ‚ n | i	 | ƒ t
 | | i d ƒ | ƒ q¤ Wt t ƒ a d  S(   Ns
   _list_.xmls   Can't open '%s't   gameplayTypess   No defaults for 'gameplayTypes't   ids   Geometry ID=%d is not uniqueR   (   t   ResMgrt   openSectionR   t   Nonet	   Exceptiont   _DEFAULT_XMLR   t   itemst   readIntt   addt   __buildCachet
   readStringR   t   g_gameplayNamest   g_gameplaysMask(   t   rootSectiont
   defaultXmlt   defaultGameplayTypesXmlt   geometriesSett   keyt   valuet
   geometryID(    (    s   scripts/common/ArenaType.pyt   initQ   s$    
	 t	   ArenaTypec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s3   | |  _  | |  _ | d d >| d B|  i d <d  S(   NR
   i   R.   R   (   t   _ArenaType__geometryCfgt   _ArenaType__gameplayCfg(   t   selft   geometryCfgt   gameplayCfg(    (    s   scripts/common/ArenaType.pyt   __init__¾   s    		c         C   s'   | |  i  j o |  i  | S|  i | S(   N(   R2   R1   (   R3   R   (    (    s   scripts/common/ArenaType.pyt   __getattr__Ä   s    (   t   __name__t
   __module__R6   R7   (    (    (    s   scripts/common/ArenaType.pyR0   »   s   	c         C   s�   t  | d } t i | ƒ } | d  j o t d | ‚ n t |  | | | ƒ } xF t | | | ƒ D]2 } t | | ƒ } | t | i	 <t
 i | i ƒ qc Wd  S(   Ns   .xmls   Can't open '%s'(   R   R   R   R   R   t   __readGeometryCfgt   __readGameplayCfgsR0   t   g_cacheR   R&   R#   R   (   R.   t   geometryNameR)   t   sectionNamet   sectionR4   R5   t	   arenaType(    (    s   scripts/common/ArenaType.pyR$   Ë   s     c         C   sÅ  y�h  } |  | d <| | d <t  d | | ƒ | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <t d | | ƒ | d <t p t o# t i t  d | | ƒ ƒ | d <n t o¡ t	 d	 | | ƒ | d	 <t  d
 | | ƒ i
 ƒ  | d
 <t	 d | | ƒ | d <| i d d ƒ | d <| i d d ƒ | d <| i d d ƒ | d <t | | ƒ | d <n t o t d | | t ƒ | d <n | i t | | t ƒ ƒ Wn. t j
 o" } t d | t | ƒ f ‚ n X| S(   NR.   R=   t   geometryt   boundingBoxt   weatherPresetst   vehicleCamouflageKindt   explicitRequestOnlyR   t   umbraEnabledt   defaultReverbPresett   batchingEnableds   water/texScaleg      à?t   waterTexScales   water/freqXg      ð?t
   waterFreqXs   water/freqZt
   waterFreqZt   defaultGroundEffectt   useAdvancedPhysicss   Wrong arena type XML '%s' : %s(   t   __readStringt   __readBoundingBoxt   __readWeatherPresetst   __readVehicleCamouflageKindt
   __readBoolR    R   R	   t
   makeStringt	   __readIntt   stript	   readFloatt   __readDefaultGroundEffectR   t   Falset   updatet   __readCommonCfgt   TrueR   t   str(   R.   R=   R?   R)   t   cfgt   e(    (    s   scripts/common/ArenaType.pyR:   Û   s2    

#c      	   C   sý   yÇ | d d  j o( d } t | ƒ } h | d 6| d 6g S| d p t d ‚ n g  } | d } x_ | d i ƒ  D]M \ } } | | }	 |	 d  j o t d | ‚ n | i t | | |	 ƒ ƒ qu WWn/ t j
 o# }
 t ƒ  t d |  |
 f ‚ n X| S(   NR   t   ctfR
   R   s   no 'gameplayTypes' sections   no defaults for '%s's   Wrong arena type XML '%s' : %s(   R   R   R   R!   t   appendt   __readGameplayCfgt   LOG_CURRENT_EXCEPTION(   R=   R?   R)   R   R
   t   cfgsR*   R   t
   subsectiont   defaultSubsectionR^   (    (    s   scripts/common/ArenaType.pyR;   ÿ   s*    
 
!c         C   sl   y= h  } t  |  ƒ | d <|  | d <| i t | | t ƒ ƒ Wn( t j
 o } t d |  | f ‚ n X| S(   NR
   R   s    wrong gameplay section '%s' : %s(   R   RY   RZ   RX   R   (   R   R?   R)   R]   R^   (    (    s   scripts/common/ArenaType.pyRa     s    
c         C   s0  h  } | p t  d |  | ƒ o! t |  | ƒ \ | d <| d <n | p t  d |  | ƒ o t d |  | ƒ | d <n | p t  d |  | ƒ o t d |  | ƒ | d <n t p t o:| p t  d |  | ƒ o# t i t d |  | ƒ ƒ | d <n | p t  d |  | ƒ o t d |  | ƒ | d <n | p t  d |  | ƒ o t d |  | ƒ | d <n | p t  d |  | ƒ o t d |  | ƒ | d <n | p t  d	 |  | ƒ o t d	 |  | ƒ | d	 <n | p |  i d
 ƒ o |  d
 | d
 <qñn t o4 t	 |  ƒ | d <t
 |  ƒ | d <t |  ƒ | d <n | S(   Nt   minPlayersInTeamt   maxPlayersInTeamt   roundLengtht   winnerIfTimeoutt   descriptiont   minimapt   musict   loadingMusict   ambientSoundt   mapActivitiest   controlPointt   teamBasePositionst   teamSpawnPoints(   t   __hasKeyt   __readMinMaxPlayersInTeamRT   R    R   R	   RS   RN   t   has_keyt   __readControlPointt   __readTeamBasePositionst   __readTeamSpawPoints(   R?   R)   t   raiseIfMissingR]   (    (    s   scripts/common/ArenaType.pyRZ   +  s4    #c         C   s   | i  |  ƒ p | i  |  ƒ S(   N(   Ru   (   R,   t   xmlR)   (    (    s   scripts/common/ArenaType.pyRs   K  s    c         C   s_   | i  |  ƒ o | i |  ƒ S| i  |  ƒ o | i |  ƒ S| d  j	 o | St d |  ‚ d  S(   Ns   missing key '%s'(   Ru   R%   R   R   (   R,   Rz   R)   t   defaultValue(    (    s   scripts/common/ArenaType.pyRN   O  s    c         C   s_   | i  |  ƒ o | i |  ƒ S| i  |  ƒ o | i |  ƒ S| d  j	 o | St d |  ‚ d  S(   Ns   missing key '%s'(   Ru   R"   R   R   (   R,   Rz   R)   R{   (    (    s   scripts/common/ArenaType.pyRT   Z  s    c         C   s_   | i  |  ƒ o | i |  ƒ S| i  |  ƒ o | i |  ƒ S| d  j	 o | St d |  ‚ d  S(   Ns   missing key '%s'(   Ru   t   readBoolR   R   (   R,   Rz   R)   R{   (    (    s   scripts/common/ArenaType.pyRR   e  s    c         C   s_   |  i  d ƒ } |  i  d ƒ } | d | d j p | d | d j o t d ‚ n | | f S(   Ns   boundingBox/bottomLefts   boundingBox/upperRighti    i   s   wrong 'boundingBox' values(   t   readVector2R   (   R?   t
   bottomLeftt
   upperRight(    (    s   scripts/common/ArenaType.pyRO   p  s
    *c         C   s	  |  d } | d  j p | o h d d 6g Sg  } d } xg | i ƒ  D]Y } h  } x' | i ƒ  D] \ } } | i | | <q` W| i | ƒ | | i d d ƒ 7} qG Wd | } d }	 xN | D]F } t | i d d ƒ ƒ }
 |	 |	 |
 | f } | | d <| d }	 q» W| S(   Nt   weatheri    i   t	   rnd_ranget   possibilityg      ð?(   i    i   (   R   t   valuesR!   t   asStringR`   RV   t   floatt   pop(   R?   t
   weatherXMLt   presetst   possibilitySumt	   presetXMLt   presetR,   t   valueXMLt   factort   prev_upper_limitR‚   R�   (    (    s   scripts/common/ArenaType.pyRP   y  s,    
  
 
c         C   s<   |  i  d ƒ } t i | ƒ } | d  j o t d ‚ n | S(   NRD   s0   missing or wrong section 'vehicleCamouflageKind'(   R%   R   t   getR   R   (   R?   t   kindNamet   kind(    (    s   scripts/common/ArenaType.pyRQ   ”  s
    c         C   s|   t  d |  | ƒ } | d j  o t d ‚ n t  d |  | ƒ } | d j  o t d ‚ n | | j  o t d ‚ n | | f S(   NRf   i    s   wrong 'minPlayersInTeam' valueRg   s   wrong 'maxPlayersInTeam' values3   'maxPlayersInTeam' value < 'minPlayersInTeam' value(   RT   R   (   R?   R)   Rf   Rg   (    (    s   scripts/common/ArenaType.pyRt   �  s    c         C   s‹   t  d |  | ƒ i ƒ  } | d j o d  S| i d ƒ d j oG | i d ƒ } x5 t d t | ƒ ƒ D] } | | i ƒ  | | <qe Wn | S(   NRL   t    t   |iÿÿÿÿi    (   RN   RU   R   t   findt   splitR   R   (   R?   R)   t   defaultGroundEfft   i(    (    s   scripts/common/ArenaType.pyRW   ­  s     c         C   s"   |  i  d ƒ o |  i d ƒ Sd  S(   NRp   (   Ru   R}   R   (   R?   (    (    s   scripts/common/ArenaType.pyRv   ¹  s    c      	   C   sÖ   |  d }  |  d  j o h  h  f Sh  h  f } x¡ d	 d
 f D]“ \ } } |  | } | d  j o t d | ‚ n x\ | i ƒ  D]N } y t | i d ƒ } Wn t d | | i f ‚ n X| i | | | <q| Wq; W| S(   NRq   i    t   team1i   t   team2s   missing 'teamBasePositions/%s'i   s*   wrong subsection 'teamBasePositions/%s/%s'(   i    R˜   (   i   R™   (   R   R   Rƒ   t   intR   t	   asVector2(   R?   t	   teamBasest   teamIdxt   teamTagt   sR   (    (    s   scripts/common/ArenaType.pyRw   ¿  s"    
 
  c         C   s‘   |  d }  |  d  j o g  g  f Sg  g  f } x\ d d	 f D]N \ } } |  | } | d  j o t d | ‚ n | | i | i d ƒ ƒ q; W| S(
   NRr   i    R˜   i   R™   s   missing 'teamSpawnPoints/%s't   position(   i    s   team1(   i   s   team2(   R   R   t   extendt   readVector2s(   R?   Rr   R�   Rž   RŸ   (    (    s   scripts/common/ArenaType.pyRx   Ó  s    
 
(.   R   t	   constantsR    R   R   R   R   R   R   t   items.vehiclesR   t   debug_utilst   helpersR	   t	   web_stubsR<   R   R&   R'   R   R   R   R   R   R    R/   t   objectR0   R$   R:   R;   Ra   RZ   Rs   R   RN   RT   RR   RO   RP   RQ   Rt   RW   Rv   Rw   Rx   (    (    (    s   scripts/common/ArenaType.pyt   <module>   sF   4
						
	j		$			 										