³ò
hHOc           @   s`   d  Z  d d k l Z d d k l Z d d k l Z d d k l Z d e f d „  ƒ  YZ d S(	   sj   
$Rev: 611 $
$LastChangedBy: satoon101 $
$LastChangedDate: 2012-01-10 16:51:16 -0500 (Tue, 10 Jan 2012) $
iÿÿÿÿ(   t   GG_Leader_Disconnect(   t   GG_New_Leader(   t   GG_Leader_LostLevel(   t   GG_Tied_Leadert   LeaderManagerc           B   s   e  Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z RS(   sX   Dictionary-based class that stores player levels for keeping track of
    leaders.

    c         O   s-   d |  i  j o t i |  ƒ |  _ n |  i S(   Nt   _the_instance(   t   __dict__t   dictt   __new__R   (   t   clst   pt   k(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR      s    c         C   s   t  |  i ƒ  d g ƒ S(   sc   Read-only property that returns the highest level from the
        dictionary of players.

        i   (   t   maxt   values(   t   self(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyt   leaderlevel!   s    c         C   sC   |  i  } g  } |  i ƒ  D]" } |  | | j o | | q q ~ S(   sM   Read-only property that returns a list of current leaders' userids.

        (   R   t   keys(   R   R   t   _[1]t   x(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyt   current)   s    	c         C   sÎ   | i  } | i } |  i } |  i | ƒ o@ | | j o |  i | ƒ qÊ | | j  o |  i | ƒ qÊ n` | | j o | d j o |  i | ƒ n5 | | j o |  i | ƒ n |  i | t | ƒ ƒ d S(   sX   Checks to see if the leader manager needs to update the leader
        status.

        i   N(	   t   useridt   levelR   t	   is_leadert   _new_or_same_leadert   _lost_leadert   _tied_leadert   _update_levelt   int(   R   t   ggPlayerR   R   R   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyt   check4   s    			c         C   s   | |  i  j S(   s0   Checks to see if the userid is a current leader.(   R   (   R   R   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR   V   s    c         C   s   |  i  ƒ  d S(   s6   Resets the LeaderManager for a clean start of GunGame.N(   t   clear(   R   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyt   resetZ   s    c         C   s3   |  i  d j o | d j o d Sn | |  | <d S(   s(   Adds userid and level to the dictionary.i   N(   R   (   R   R   R   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR   b   s    c         C   sh   |  i  ƒ  } |  i | i | i ƒ |  i  ƒ  } t d | i d | i d | d | d |  i ƒ } | i ƒ  S(   s)   Adds a leader to the current leader list.R   t   levelert   leaderst   old_leaderst   leader_level(   t   _get_leader_stringR   R   R   R   R   t   fire(   R   R   R"   t   new_leaderst   gg_tied_leader(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR   j   s    	c         C   s¡   |  i  | i ƒ p t d t d t ƒ ‚ n |  i ƒ  } |  i | i | i ƒ |  i ƒ  } |  i } t d | i d | i d | d | d | ƒ } | i ƒ  d S(	   s/   Removes a player from the current leaders list.s0   Unable to remove "%s" from the current leaders. s(   The userid "%s" is not a current leader.R   R    R!   R"   R#   N(	   R   R   t
   ValueErrorR$   R   R   R   R   R%   (   R   R   R"   R&   t   leaderLevelt   gg_leader_lostlevel(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR   }   s    			c         C   sh   |  i  ƒ  } |  i | i | i ƒ |  i  ƒ  } t d | i d | i d | d | d |  i ƒ } | i ƒ  S(   s8   Sets the current leader list as the new leader's userid.R   R    R!   R"   R#   (   R$   R   R   R   R   R   R%   (   R   R   R"   R&   t   gg_new_leader(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR   •   s    	c      
   C   s¥   d d k  } | i d | ƒ o d Sn |  i | ƒ p |  i | ƒ d Sn |  i ƒ  } |  i | ƒ |  i ƒ  } |  i } t d | d | d | d | ƒ } | i ƒ  S(   s%   Handles the disconnection of players.iÿÿÿÿNR   R!   R"   R#   (   t   est   existsR   t   _remove_useridR$   R   R    R%   (   R   R   R,   R"   R&   R)   t   gg_leader_disconnect(    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyt   disconnected_leader¨   s    		c         C   s   | |  j o |  | =n d S(   sX   Removes all relations of the userid from the LeaderManager
        dictionary.

        N(    (   R   R   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR.   Ä   s    c         C   sL   d i  g  } |  i D] } | t | ƒ q ~ ƒ } | o | n d } | S(   s{   Returns a comma separated value string of the current leaders'
        userids or a string of None if no leaders.

        t   ,t   None(   t   joinR   t   str(   R   R   R   R&   (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR$   Í   s    4(   t   __name__t
   __module__t   __doc__R   t   propertyR   R   R   R   R   R   R   R   R   R0   R.   R$   (    (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pyR      s   		"									N(   R7   t   gungame51.core.eventsR    R   R   R   R   R   (    (    (    sY   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/leaders/__init__.pys   <module>   s
   