Ignore:
Timestamp:
02/03/10 13:21:45 (10 years ago)
Author:
maximinus_parpg
Message:

More clean up of the code.
Finshed first pass.
So should be at least stands compliant.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/actors.py

    r473 r477  
    3030 
    3131class ActorBehaviour (fife.InstanceActionListener): 
    32     """Fife agent listener 
    33     """ 
     32    """Fife agent listener""" 
    3433    def __init__(self, layer): 
    3534        fife.InstanceActionListener.__init__(self) 
     
    3736     
    3837    def attachToLayer(self, agent_ID): 
    39         """ Attaches to a certain layer 
    40             @type agent_ID: String 
    41             @param agent_ID: ID of the layer to attach to. 
    42             @return: None 
    43         """ 
     38        """Attaches to a certain layer 
     39           @type agent_ID: String 
     40           @param agent_ID: ID of the layer to attach to. 
     41           @return: None""" 
    4442        self.agent = self.layer.getInstance(agent_ID) 
    4543        self.agent.addActionListener(self) 
    4644        self.state = _AGENT_STATE_NONE 
    47         self.speed = float(TDS.readSetting("PCSpeed"))-1 # TODO: rework/improve 
     45        # TODO: rework/improve 
     46        self.speed = float(TDS.readSetting("PCSpeed"))-1 
    4847         
    4948    def getX(self): 
     
    6261        pass 
    6362 
    64      
    6563class PCBehaviour (ActorBehaviour): 
    6664    def __init__(self, parent = None, layer = None): 
    67         super(PCBehaviour, self).__init__(layer) 
    68          
     65        super(PCBehaviour, self).__init__(layer)         
    6966        self.parent = parent 
    7067        self.idle_counter = 1 
    71         self.speed = float(TDS.readSetting("PCSpeed")) # TODO: rework/improve 
     68        # TODO: rework/improve 
     69        self.speed = float(TDS.readSetting("PCSpeed")) 
    7270        self.nextAction = None 
    7371        self.agent = None 
     
    7977           @param action: ??? 
    8078           @return: None""" 
    81          
    8279        # First we reset the next behavior  
    8380        act = self.nextAction 
     
    9491             
    9592    def onNewMap(self, layer): 
    96         """Sets the agent onto the new layer. 
    97         """ 
     93        """Sets the agent onto the new layer.""" 
    9894        if self.agent is not None: 
    9995            self.agent.removeActionListener(self) 
     
    110106 
    111107class PlayerCharacter (GameObject, Living, CharStats): 
    112     """ 
    113     PC class 
    114     """ 
     108    """PC class""" 
    115109    def __init__ (self, ID, agent_layer = None, inventory = None, **kwargs): 
    116110        GameObject.__init__( self, ID, **kwargs ) 
     
    135129    def meet(self, npc): 
    136130        """Record that the PC has met a certain NPC 
    137         @type npc: str 
    138         @param npc: The NPC's name or id""" 
     131           @type npc: str 
     132           @param npc: The NPC's name or id""" 
    139133        if npc in self.peopleIknow: 
    140             """raise RuntimeError("I already know %s" % npc) 
    141                we could raise an error here, but should probably be a warn""" 
     134            # we could raise an error here, but should probably be a warn 
     135            # raise RuntimeError("I already know %s" % npc) 
    142136            return 
    143137        self.peopleIknow.add(npc) 
     
    145139    def met(self, npc): 
    146140        """Indicate whether the PC has met this npc before 
    147         @type npc: str 
    148         @param npc: The NPC's name or id 
    149         @return: None""" 
     141           @type npc: str 
     142           @param npc: The NPC's name or id 
     143           @return: None""" 
    150144        return npc in self.peopleIknow 
    151145 
    152146    def createBehaviour(self, layer): 
    153147        """Creates the behaviour for this actor. 
    154             @return None """ 
     148           @return: None""" 
    155149        self.behaviour = PCBehaviour(self, layer) 
    156150     
     
    242236           @type instance: fife.Instance 
    243237           @param instance: self.agent (the NPC listener is listening for this 
    244             instance) 
     238                                        instance) 
    245239           @type action: ??? 
    246240           @param action: ??? 
     
    269263 
    270264class NonPlayerCharacter(GameObject, Living, Scriptable, CharStats): 
    271     """ 
    272     NPC class 
    273     """ 
     265    """NPC class""" 
    274266    def __init__(self, ID, agent_layer=None, name='NPC', \ 
    275267                 text = 'A nonplayer character', inventory = None, **kwargs): 
     
    290282 
    291283    def createBehaviour(self, layer): 
    292         """ Creates the behaviour for this actor. 
    293             @return None """ 
     284        """Creates the behaviour for this actor. 
     285           @return None """ 
    294286        self.behaviour = NPCBehaviour(self, layer) 
    295287 
    296288    def getLocation(self): 
    297         """ Get the NPC's position as a fife.Location object. Basically a 
    298             wrapper. 
    299             @rtype: fife.Location 
    300             @return: the location of the NPC""" 
     289        """Get the NPC's position as a fife.Location object. Basically a 
     290           wrapper. 
     291           @rtype: fife.Location 
     292           @return: the location of the NPC""" 
    301293        return self.behaviour.agent.getLocation() 
    302294     
     
    315307 
    316308    def talk(self, pc): 
    317         """ Makes the NPC ready to talk to the PC 
    318             @return: None""" 
     309        """Makes the NPC ready to talk to the PC 
     310           @return: None""" 
    319311        self.behaviour.state = _AGENT_STATE_TALK 
    320312        self.behaviour.pc = pc.behaviour.agent 
Note: See TracChangeset for help on using the changeset viewer.