comparison gamelib/buildings.py @ 439:cf4b020e6385

Start of serializer for buildings and support for reference cycles.
author Simon Cross <hodgestar@gmail.com>
date Sat, 21 Nov 2009 18:34:36 +0000
parents 95b81e917399
children e945c4186ee5
comparison
equal deleted inserted replaced
438:16437cf4a2b8 439:cf4b020e6385
11 11
12 # ignore os.popen3 warning generated by pygame.font.SysFont 12 # ignore os.popen3 warning generated by pygame.font.SysFont
13 import warnings 13 import warnings
14 warnings.filterwarnings("ignore", "os.popen3 is deprecated.") 14 warnings.filterwarnings("ignore", "os.popen3 is deprecated.")
15 15
16 class Place(object): 16 class Place(serializer.Simplifiable):
17 """Space within a building that can be occupied.""" 17 """Space within a building that can be occupied."""
18
19 SIMPLIFY = [
20 'occupant',
21 'building',
22 'offset',
23 ]
18 24
19 def __init__(self, building, offset): 25 def __init__(self, building, offset):
20 self.occupant = None 26 self.occupant = None
21 self.building = building 27 self.building = building
22 self.offset = offset 28 self.offset = offset
38 def get_pos(self): 44 def get_pos(self):
39 bpos = self.building.pos 45 bpos = self.building.pos
40 return (bpos[0] + self.offset[0], bpos[1] + self.offset[1], 46 return (bpos[0] + self.offset[0], bpos[1] + self.offset[1],
41 self.offset[2]) 47 self.offset[2])
42 48
43 class Floor(object): 49 class Floor(serializer.Simplifiable):
44 """A set of places within a building. Places on a 50 """A set of places within a building. Places on a
45 floor are organised into rows and columns. 51 floor are organised into rows and columns.
46 """ 52 """
53
54 SIMPLIFY = [
55 'title',
56 'places',
57 ]
47 58
48 def __init__(self, title, places): 59 def __init__(self, title, places):
49 self.title = title # str 60 self.title = title # str
50 self.places = places # list of lists of places 61 self.places = places # list of lists of places
51 62
79 '_buy_price', 90 '_buy_price',
80 '_sell_price', 91 '_sell_price',
81 '_repair_price', 92 '_repair_price',
82 '_sun_on', 93 '_sun_on',
83 '_broken', 94 '_broken',
84 '_predators', 95 '_floors',
85 ] 96 ]
86 97
87 def __init__(self, pos): 98 def __init__(self, pos):
88 """Initial image, tile vid position, size and tile number for building.""" 99 """Initial image, tile vid position, size and tile number for building."""
89 self._set_images() 100 self._set_images()