Commits

Anonymous committed 9038883

Fixed some coding errors found by static analysis

Comments (0)

Files changed (17)

FatxFast/camera.py

 class Camera(object):
 
     def __init__(self, size=SCREENSIZE):
-        self.target = False
+        self.target = None
         self.rect = pygame.Rect((0,0), size)
         self.moved = False
         self._force_update = True

FatxFast/fileio.py

         if struct:
             self.resources = struct
         new_score = False
-        scores = ""
+        scores = []
         mode = mode.lower()
         if mode == "classicmode":
             scores = self.resources["classic"]
         if mode == "timedmode":
             scores = self.resources["timed"]
+
+        if not len(scores):
+            return False
+
         pointer = len(scores)-1
-        for oldscore in xrange(len(scores)-1, -1, -1):
+        for oldscore in xrange(pointer, -1, -1):
             if score > scores[oldscore]["points"]:
                 new_score = True
                 pointer = oldscore

FatxFast/gui/buffwidget.py

 __version__ = "1.2.4"
 
 import FatxFast.gui.textwidget as textwidget
-from FatxFast.graphics import load_image
 
 class BuffWidget(textwidget.TextWidget):
     

FatxFast/gui/textwidget.py

     def get_center(self, maxwidth, linesurface):
         return int((maxwidth-linesurface[0].get_width())/2)
     
-    def get_linesurfaces(self, draw_color, *params):
+    def get_linesurfaces(self, *params):
         return [
-            [self.font.render(line.strip(), 1, draw_color, *params),
+            [self.font.render(line.strip(), 1, *params),
                 [0, index*self.font.get_height()]]
             for index, line in enumerate(self._linebuffer)]
             

FatxFast/modes/__init__.py

-__all__ = ["classicmode", "timedmode", "multimode", "practicemode", "mapmode", "demomode"]
+#__all__ = ["classicmode", "timedmode", "multimode", "practicemode", "mapmode", "demomode"]

FatxFast/modes/demomode.py

 __version__ = "1.2.4"
 
 
-from FatxFast.modes import mode
-from FatxFast.objects import character
-
-class DemoMode(mode.GameMode):
-    """DemoScene solves the maze as a 'demo'."""
-    def __init__(self, scene, **kwargs):
-        """Creates a solver character and fetches a linear solution for 
-        the maze"""
-        super(DemoMode, self).__init__(scene, **kwargs)
-        self.scene.playing = False
-    
-    def handle_movement(self, keys):
-        pass
-
-    def create_players(self):
-        self.player1 = self.scene.create_character(character.Ghost, 
-            add_to_world=True)
-        self.camera.follow_target(self.player1)
-
-    def update(self, dt):
-        """Move ghost in a direction which is a solution tile.
-        Every 120ms a tile is removed from the solutions""" 
-        super(DemoMode, self).update(dt)
-        if not self.player1.running:
-            self.scene.end()
-
+#from FatxFast.modes import mode
+#from FatxFast.objects import character
+#
+#class DemoMode(mode.GameMode):
+#    """DemoScene solves the maze as a 'demo'."""
+#    def __init__(self, scene, **kwargs):
+#        """Creates a solver character and fetches a linear solution for 
+#        the maze"""
+#        super(DemoMode, self).__init__(scene, **kwargs)
+#        self.scene.playing = False
+#    
+#    def handle_movement(self, keys):
+#        pass
+#
+#    def create_players(self):
+#        self.player1 = self.scene.create_character(character.Ghost, 
+#            add_to_world=True)
+#        self.camera.follow_target(self.player1)
+#
+#    def update(self, dt):
+#        """Move ghost in a direction which is a solution tile.
+#        Every 120ms a tile is removed from the solutions""" 
+#        super(DemoMode, self).update(dt)
+#        if not self.player1.running:
+#            self.scene.end()
+#

FatxFast/modes/mode.py

     def __init__(self, scene, **kwargs):
 
         if scene.time is None:
-            scene.time = 0
+            scene.time = 0 
+        self.player1 = None
         self.scene = scene 
         self.camera = camera.Camera()
         self.scene.levelsystem.load_level()

FatxFast/modes/multimode.py

 class MultiMode(scoredmode.ScoredMode):
 
     def __init__(self, scene, **kwargs):  
-        self.second_camera = camera.Camera() 
+        self.second_camera = camera.Camera()  
+        self.player2 = None
         super(MultiMode, self).__init__(scene, **kwargs) 
         self.camera.rect.width = (self.camera.rect.width/2)-(tile.TILEWIDTH/2)
         self.second_camera.rect.width = self.camera.rect.width
         super(scoredmode.ScoredMode, self).end(player, text=text)
     
     def keys_held(self):
+        if self.player2 is None:
+            return
         keys = super(MultiMode, self).keys_held()
         player2 = self.player2
         if keys[self.hotkeys["player2-up"]]:

FatxFast/objects/__init__.py

-__all__ = ["entity", "character", "buffs", "items", "triggers", "monsters"]
+#__all__ = ["entity", "character", "buffs", "items", "triggers", "monsters"]

FatxFast/objects/entity.py

         self.observers = []
     
     def detach(self, observer):
-        self.observer.remove(observer)
+        self.observers.remove(observer)
     
     def attach(self, observer):
         self.observers.append(observer)

FatxFast/objects/ghost.py

 # http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
 __author__ = "dryatu (c) 2013"
 __version__ = "1.2.4"
-
-try:
-    from pygame.math import Vector2
-except ImportError:
-    from FatxFast.utils.vector2 import Vector2
-from FatxFast.objects.character import Character
-from FatxFast.tilemap.maze import solver
-
-class Ghost(Character):
-    """Ghost will try to solve the tilemap when iniated. each update iteration
-    will move it one step closer to the finish line."""
-    def __init__(self, gamescene, **kwargs):
-        super(Ghost, self).__init__(gamescene, 
-            animeimage="ghost.png", collides=False, **kwargs)
-        self.solver = solver.BacktrackSolver()
-        self.solver.run(gamescene.tilemap)
-        self.solution = self.solver.get_linear_solution()
-        
-    def update(self, dt):
-        if self._pointer is None and len(self.solution):
-            self._pointer = Vector2(
-                self.gamescene.tilemap.get_coord_position(
-                    self.solution.pop()))
-            dx, dy = self.rect.x-self._pointer.x, self.rect.y-self._pointer.y
-            if dx:
-                self._movement_component = 'x'
-            elif dy:
-                self._movement_component = 'y'
-            if (
-                getattr(self.rect, self._movement_component) <
-                    getattr(self._pointer, self._movement_component)):
-                setattr(self.accelvector, self._movement_component, CHAR_ACCEL)
-            else:
-                setattr(self.accelvector, self._movement_component, -CHAR_ACCEL)
-        if (self._pointer and 
-            getattr(self.accelvector, self._movement_component) < 0):
-            if (getattr(self._pointer, self._movement_component) >= \
-                getattr(self.rect, self._movement_component)):
-                self._pointer = None
-        elif (self._pointer and 
-            getattr(self.accelvector, self._movement_component) < 0):
-            if (getattr(self._pointer, self._movement_component) >= \
-                getattr(self.rect, self._movement_component)):
-                self._pointer = None
-        super(Ghost, self).update(dt)
+#
+#try:
+#    from pygame.math import Vector2
+#except ImportError:
+#    from FatxFast.utils.vector2 import Vector2
+#from FatxFast.objects.character import Character
+#from FatxFast.tilemap.maze import solver
+#
+#class Ghost(Character):
+#    """Ghost will try to solve the tilemap when iniated. each update iteration
+#    will move it one step closer to the finish line."""
+#    def __init__(self, gamescene, **kwargs):
+#        super(Ghost, self).__init__(gamescene, 
+#            animeimage="ghost.png", collides=False, **kwargs)
+#        self.solver = solver.BacktrackSolver()
+#        self.solver.run(gamescene.tilemap)
+#        self.solution = self.solver.get_linear_solution()
+#        
+#    def update(self, dt):
+#        if self._pointer is None and len(self.solution):
+#            self._pointer = Vector2(
+#                self.gamescene.tilemap.get_coord_position(
+#                    self.solution.pop()))
+#            dx, dy = self.rect.x-self._pointer.x, self.rect.y-self._pointer.y
+#            if dx:
+#                self._movement_component = 'x'
+#            elif dy:
+#                self._movement_component = 'y'
+#            if (
+#                getattr(self.rect, self._movement_component) <
+#                    getattr(self._pointer, self._movement_component)):
+#                setattr(self.accelvector, self._movement_component, CHAR_ACCEL)
+#            else:
+#                setattr(self.accelvector, self._movement_component, -CHAR_ACCEL)
+#        if (self._pointer and 
+#            getattr(self.accelvector, self._movement_component) < 0):
+#            if (getattr(self._pointer, self._movement_component) >= \
+#                getattr(self.rect, self._movement_component)):
+#                self._pointer = None
+#        elif (self._pointer and 
+#            getattr(self.accelvector, self._movement_component) < 0):
+#            if (getattr(self._pointer, self._movement_component) >= \
+#                getattr(self.rect, self._movement_component)):
+#                self._pointer = None
+#        super(Ghost, self).update(dt)

FatxFast/scenes/__init__.py

-__all__ = ["scenemanager", "basescene", "menuscenes", "infoscenes"]
+#__all__ = ["scenemanager", "basescene", "menuscenes", "infoscenes"]

FatxFast/scenes/gamescene.py

 
         #self.game.audio.load_sound("coffeedrink.wav")
         self.game.audio.stop_music()
-        self.game.audio.load_music("nicearp.mp3")
-        self.game.audio.play_music(-1) 
+        #self.game.audio.load_music("nicearp.mp3")
+        #self.game.audio.play_music(-1) 
         # Create an empty save if one is not supplied
         if kwargs.get("save") is None:
             self.save = GameSave()
             **self.manager.sceneparser.templates["gamehud"])
         self._mode = None
         self.mode = self.gamemodes[self.save.game["mode"]](self, **kwargs)
-        self.gamemode = self.mode
+        self.gamemode = self._mode
         self.mapmode = mapmode.MapMode(self)
     
     def add_player(self, player, camera):

FatxFast/tilemap/gamemap.py

     def draw_sprites(self, surface, camera):
         self.world.draw(surface, camera)
 
-    def get_tile_by_coordinate(self, pos):
-        return self.get_tile(self.get_tile_position(pos))
-
     @staticmethod
     def get_coord_position(tilepos):
         return (tilepos[0]*tile.TILEWIDTH, tilepos[1]*tile.TILEHEIGHT)

FatxFast/tilemap/maze/maze.py

         # Currently adjustable values: floor widht&height 
         self.west_wall_size = [1, 1]
         self.north_wall_size = [1, 1]
-        self.floor_width = 1
-        self.floor_height = 1
+        self._floor_width = 1
+        self._floor_height = 1
         # Expects this to be in rsc/
         self.tilesheet_imagename = kwargs.get("tileset", "tileset.png")
 

FatxFast/tilemap/maze/solver.py

         self._maze = None
         self._solution = []
         self._des = []
-        self._cell = False
+        self._cell = None
         self._moves = [self._cell]
     
     def get_linear_solution(self):

FatxFast/utils/graphifier.py

         if len(values_cache)-1 == self.max_frames:
             values_cache.pop(0)
         elif (len(values_cache) < self.max_frames or 
-            len(self._value_cache) > self.max_frames):
+            len(values_cache) > self.max_frames):
             values_cache = [0]*self.max_frames
         
         line["line"].set_data(xes, values_cache)