# HG changeset patch # User Simon Cross # Date 1259274898 0 # Node ID 3ed6c011106dc462ca3928293fd4af717960d870 # Parent 393e30ea016515b468d84967f41f8d84635a21d2 Switch to classmethod decorators. diff -r 393e30ea0165 -r 3ed6c011106d gamelib/animal.py --- 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()) diff -r 393e30ea0165 -r 3ed6c011106d gamelib/buildings.py --- 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': { diff -r 393e30ea0165 -r 3ed6c011106d gamelib/equipment.py --- 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 diff -r 393e30ea0165 -r 3ed6c011106d gamelib/level.py --- 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 diff -r 393e30ea0165 -r 3ed6c011106d gamelib/serializer.py --- 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): """ diff -r 393e30ea0165 -r 3ed6c011106d gamelib/tiles.py --- 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."""