Ticket #128: new_engine.py.diff

File new_engine.py.diff, 3.2 KB (added by octavio <unix.logic@…>, 9 years ago)
  • scripts/engine.py

     
    5656           @type filename: string 
    5757           @param filename: the name of the file to write to 
    5858           @return: None""" 
    59         fname = '/'.join([path,filename]) 
     59        fname = '/'.join([path, filename]) 
    6060        try: 
    6161            f = open(fname, 'w') 
    6262        except(IOError): 
     
    6565         
    6666        # can't pickle SwigPyObjects 
    6767        behaviours = {} 
    68         behaviour_player = self.game_state.PC.behaviour; 
    69         self.game_state.PC.behaviour = None; 
     68        behaviour_player = self.game_state.PC.behaviour 
     69        self.game_state.PC.behaviour = None 
    7070         
    7171        # Backup the behaviours  
    7272        for map_id in self.game_state.objects: 
     
    7474            for (object_id, npc) in self.game_state.objects[map_id].items(): 
    7575                if npc.trueAttr("NPC"): 
    7676                    behaviours[map_id][object_id] = npc.behaviour 
    77                     npc.behaviour = None; 
     77                    npc.behaviour = None 
    7878         
    7979        # Pickle it  
    8080        pickle.dump(self.game_state, f) 
     
    8282         
    8383        # Restore behaviours 
    8484        for map_id in behaviours: 
    85             for (object_id,behaviour) in behaviours[map_id].items(): 
     85            for (object_id, behaviour) in behaviours[map_id].items(): 
    8686                self.game_state.objects[map_id][object_id].behaviour = \ 
    8787                    behaviours[map_id][object_id] 
    8888                 
     
    167167                                            self.game_state.current_map_name)  
    168168        if ref is None: 
    169169            # no, add it to the game state 
    170             self.game_state.objects[self.game_state.current_map_name][obj.ID] = obj 
     170            self.game_state.objects[self.game_state.current_map_name][obj.ID] \ 
     171                                                                          = obj 
    171172        else: 
    172173            # yes, use the current game state data 
    173174            obj.X = ref.X 
     
    188189           @param ident: ID of object 
    189190           @rtype: boolean 
    190191           @return: Status of result (True/False)""" 
    191         for i in self.game_state.getObjectsFromMap(self.game_state.current_map_name): 
     192        for i in \ 
     193           self.game_state.getObjectsFromMap(self.game_state.current_map_name): 
    192194            if (i.ID == ident): 
    193195                # we found a match 
    194196                return i 
     
    201203           @param obj_id: ID of object 
    202204           @rtype: list 
    203205           @return: List of text and callbacks""" 
    204         actions=[] 
     206        actions = [] 
    205207        # note: ALWAYS check NPC's first! 
    206208        obj = self.game_state.getObjectById(obj_id, \ 
    207209                                            self.game_state.current_map_name) 
     
    277279        self.view.active_map.addPC(self.game_state.PC.behaviour.agent) 
    278280        self.game_state.PC.start() 
    279281 
    280     def handleMouseClick(self,position): 
     282    def handleMouseClick(self, position): 
    281283        """Code called when user left clicks the screen. 
    282284           @type position: fife.ScreenPoint 
    283285           @param position: Screen position of click