changeset 505:3ed6c011106d

Switch to classmethod decorators.
author Simon Cross <hodgestar@gmail.com>
date Thu, 26 Nov 2009 22:34:58 +0000
parents 393e30ea0165
children 3b5717d742b2
files gamelib/animal.py gamelib/buildings.py gamelib/equipment.py gamelib/level.py gamelib/serializer.py gamelib/tiles.py
diffstat 6 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/animal.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/animal.py	Thu Nov 26 22:34:58 2009 +0000
@@ -51,17 +51,17 @@
         self.facing = 'left'
         self.gameboard = gameboard
 
+    @classmethod
     def make(cls):
         """Override default Simplifiable object creation."""
         return cls((0, 0), None)
-    make = classmethod(make)
 
+    @classmethod
     def unsimplify(cls, *args, **kwargs):
         """Override default Simplifiable unsimplification."""
         obj = super(Animal, cls).unsimplify(*args, **kwargs)
         obj.redraw()
         return obj
-    unsimplify = classmethod(unsimplify)
 
     def loop(self, tv, _sprite):
         ppos = tv.tile_to_view(self.pos.to_tile_tuple())
--- a/gamelib/buildings.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/buildings.py	Thu Nov 26 22:34:58 2009 +0000
@@ -130,18 +130,18 @@
         # Create the building somewhere far off screen
         Sprite.__init__(self, self.images['fixed']['day'], (-1000, -1000))
 
+    @classmethod
     def make(cls):
         """Override default Simplifiable object creation."""
         return cls((0, 0))
-    make = classmethod(make)
 
+    @classmethod
     def unsimplify(cls, *args, **kwargs):
         """Override default Simplifiable unsimplification."""
         obj = super(Building, cls).unsimplify(*args, **kwargs)
         obj._set_main_image()
         obj.update_occupant_count()
         return obj
-    unsimplify = classmethod(unsimplify)
 
     def _set_images(self):
         self.images = {'fixed': {
--- a/gamelib/equipment.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/equipment.py	Thu Nov 26 22:34:58 2009 +0000
@@ -27,10 +27,10 @@
         self._name = self.NAME
         self.refresh_ammo()
 
+    @classmethod
     def make(cls):
         """Override default Simplifiable object creation."""
         return cls()
-    make = classmethod(make)
 
     def buy_price(self):
         return self._buy_price
--- a/gamelib/level.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/level.py	Thu Nov 26 22:34:58 2009 +0000
@@ -67,12 +67,12 @@
             self.fox_weightings.append((animal, config.getint('Fox probablities',
                 animal.CONFIG_NAME)))
 
+    @classmethod
     def unsimplify(cls, *args, **kwargs):
         """Override default Simplifiable unsimplification."""
         obj = super(Level, cls).unsimplify(*args, **kwargs)
         obj.__init__(obj.config_name)
         return obj
-    unsimplify = classmethod(unsimplify)
 
     # Utility functions, so we can make things more flexible later
 
--- a/gamelib/serializer.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/serializer.py	Thu Nov 26 22:34:58 2009 +0000
@@ -100,13 +100,14 @@
     # List of attributes which need to be stored and restored
     SIMPLIFY = []
 
+    @classmethod
     def make(cls):
         """
         Create an object of this class without any attributes set.
         """
         return cls.__new__(cls)
-    make = classmethod(make)
 
+    @classmethod
     def unsimplify(cls, value, refs=None):
         """
         Create an object of this class (or a sub-class) from its
@@ -130,7 +131,6 @@
             setattr(obj, attr, unsimplify(value, refs))
 
         return obj
-    unsimplify = classmethod(unsimplify)
 
     def simplify(self, refs=None):
         """
--- a/gamelib/tiles.py	Thu Nov 26 22:28:22 2009 +0000
+++ b/gamelib/tiles.py	Thu Nov 26 22:34:58 2009 +0000
@@ -107,11 +107,12 @@
         tilevid.Tilevid.__init__(self)
         self.sprites = LayeredSprites(['buildings', 'animals', 'animations', 'cursor'], 'animals')
 
+    @classmethod
     def make(cls):
         """Override default Simplifiable object creation."""
         return cls()
-    make = classmethod(make)
 
+    @classmethod
     def unsimplify(cls, *args, **kwargs):
         """Override default Simplifiable unsimplification."""
         obj = serializer.Simplifiable.unsimplify(*args, **kwargs)
@@ -122,7 +123,6 @@
         obj.updates = []
 
         return obj
-    unsimplify = classmethod(unsimplify)
 
     def png_folder_load_tiles(self, path):
         """Load tiles from a folder of PNG files."""