# HG changeset patch # User Neil Muller # Date 1251804014 0 # Node ID 8241386a165118c65cbfb12894f210fcc9d88950 # Parent 7d043a21012147ca43f136311a1612745065374e Add chicken counter diff -r 7d043a210121 -r 8241386a1651 gamelib/gameboard.py --- a/gamelib/gameboard.py Tue Sep 01 11:18:08 2009 +0000 +++ b/gamelib/gameboard.py Tue Sep 01 11:20:14 2009 +0000 @@ -6,6 +6,7 @@ import data import tiles +import icons import constants import buildings import animal @@ -26,8 +27,16 @@ gui.Table.__init__(self, **params) self.gameboard = gameboard self.cash_counter = OpaqueLabel("Groats: ", color=constants.FG_COLOR) + self.chicken_counter = OpaqueLabel(" ", color=constants.FG_COLOR) + self.killed_foxes = OpaqueLabel(" ", color=constants.FG_COLOR) self.tr() self.add(self.cash_counter) + self.tr() + self.td(icons.CHKN_ICON, align=-1) + self.add(self.chicken_counter) + self.tr() + self.td(icons.KILLED_FOX, align=-1) + self.add(self.killed_foxes) self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN) self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG) self.add_tool_button("Sell building", constants.TOOL_SELL_BUILDING) @@ -48,6 +57,14 @@ self.cash_counter.update_value("Groats: %s" % amount) self.repaint() + def update_chicken_counter(self, number): + self.chicken_counter.update_value(" %s" % number) + self.repaint() + + def update_fox_counter(self, number): + self.killed_foxes.update_value(" %s" % number) + self.repaint() + def add_tool_button(self, text, tool): button = gui.Button(text) button.connect(gui.CLICK, lambda: self.gameboard.set_selected_tool(tool)) @@ -91,6 +108,7 @@ GRASSLAND = tiles.REVERSE_TILE_MAP['grassland'] FENCE = tiles.REVERSE_TILE_MAP['fence'] + WOODLAND = tiles.REVERSE_TILE_MAP['woodland'] BROKEN_FENCE = tiles.REVERSE_TILE_MAP['broken fence'] def __init__(self): @@ -105,6 +123,7 @@ self.foxes = [] self.buildings = [] self.cash = 0 + self.killed_foxes = 0 self.add_cash(constants.STARTING_CASH) self.fix_buildings() @@ -233,6 +252,7 @@ def add_chicken(self, chicken): self.chickens.append(chicken) self.tv.sprites.append(chicken) + self.toolbar.update_chicken_counter(len(self.chickens)) def add_fox(self, fox): self.foxes.append(fox) @@ -251,6 +271,7 @@ if chick in self.chickens: self.chickens.remove(chick) self.tv.sprites.remove(chick) + self.toolbar.update_chicken_counter(len(self.chickens)) def remove_building(self, building): if building in self.buildings: