comparison gamelib/gameboard.py @ 408:02a6de5629d6

Levels can include starting equipment
author Neil Muller <drnlmuller@gmail.com>
date Sat, 21 Nov 2009 09:40:29 +0000
parents ae3cee7a1337
children bdc4757e0497
comparison
equal deleted inserted replaced
407:bdc8bc78a796 408:02a6de5629d6
300 self.add_cash(level.starting_cash) 300 self.add_cash(level.starting_cash)
301 self.day, self.night = True, False 301 self.day, self.night = True, False
302 302
303 self.fix_buildings() 303 self.fix_buildings()
304 304
305 cdata = { 305 cdata = {}
306 1 : (self.add_start_chickens, None), 306 for tn in equipment.EQUIP_MAP:
307 } 307 cdata[tn] = (self.add_start_chickens, tn)
308 308
309 self.tv.run_codes(cdata, (0,0,width,height)) 309 self.tv.run_codes(cdata, (0,0,width,height))
310 310
311 def get_top_widget(self): 311 def get_top_widget(self):
312 return self.top_widget 312 return self.top_widget
935 935
936 def add_cash(self, amount): 936 def add_cash(self, amount):
937 self.cash += amount 937 self.cash += amount
938 self.toolbar.update_cash_counter(self.cash) 938 self.toolbar.update_cash_counter(self.cash)
939 939
940 def add_start_chickens(self, _map, tile, _value): 940 def add_start_chickens(self, _map, tile, value):
941 """Add chickens as specified by the code layer""" 941 """Add chickens as specified by the code layer"""
942 chick = animal.Chicken((tile.tx, tile.ty)) 942 chick = animal.Chicken((tile.tx, tile.ty))
943 for equip_cls in equipment.EQUIP_MAP[value]:
944 item = equip_cls()
945 chick.equip(item)
943 self.add_chicken(chick) 946 self.add_chicken(chick)
944 947
945 def _choose_fox(self, (x, y)): 948 def _choose_fox(self, (x, y)):
946 fox_cls = misc.WeightedSelection(self.level.fox_weightings).choose() 949 fox_cls = misc.WeightedSelection(self.level.fox_weightings).choose()
947 return fox_cls((x, y)) 950 return fox_cls((x, y))