diff gamelib/buildings.py @ 415:8f012ef1f64f

Start of ability to serialize game state.
author Simon Cross <hodgestar@gmail.com>
date Sat, 21 Nov 2009 12:55:08 +0000
parents 9096c237928c
children 97dd557504a2
line wrap: on
line diff
--- a/gamelib/buildings.py	Sat Nov 21 12:48:12 2009 +0000
+++ b/gamelib/buildings.py	Sat Nov 21 12:55:08 2009 +0000
@@ -7,6 +7,7 @@
 import imagecache
 import tiles
 import constants
+import serializer
 
 # ignore os.popen3 warning generated by pygame.font.SysFont
 import warnings
@@ -58,7 +59,7 @@
 class BuildingFullError(Exception):
     pass
 
-class Building(Sprite):
+class Building(Sprite, serializer.Simplifiable):
     """Base class for buildings"""
 
     IS_BUILDING = True
@@ -70,6 +71,18 @@
     FLOORS = None
     HENHOUSE = False
 
+    SIMPLIFY = [
+        'pos',
+        'size',
+        'tile_no',
+        '_buy_price',
+        '_sell_price',
+        '_repair_price',
+        '_sun_on',
+        '_broken',
+        '_predators',
+    ]
+
     def __init__(self, pos):
         """Initial image, tile vid position, size and tile number for building."""
         self._set_images()