Changeset 79:8241386a1651


Ignore:
Timestamp:
Sep 1, 2009, 11:20:14 AM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@80
Message:

Add chicken counter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gamelib/gameboard.py

    r77 r79  
    77import data
    88import tiles
     9import icons
    910import constants
    1011import buildings
     
    2728        self.gameboard = gameboard
    2829        self.cash_counter = OpaqueLabel("Groats:                ", color=constants.FG_COLOR)
     30        self.chicken_counter = OpaqueLabel("         ", color=constants.FG_COLOR)
     31        self.killed_foxes = OpaqueLabel("         ", color=constants.FG_COLOR)
    2932        self.tr()
    3033        self.add(self.cash_counter)
     34        self.tr()
     35        self.td(icons.CHKN_ICON, align=-1)
     36        self.add(self.chicken_counter)
     37        self.tr()
     38        self.td(icons.KILLED_FOX, align=-1)
     39        self.add(self.killed_foxes)
    3140        self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN)
    3241        self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG)
     
    4756    def update_cash_counter(self, amount):
    4857        self.cash_counter.update_value("Groats: %s" % amount)
     58        self.repaint()
     59
     60    def update_chicken_counter(self, number):
     61        self.chicken_counter.update_value("  %s" % number)
     62        self.repaint()
     63
     64    def update_fox_counter(self, number):
     65        self.killed_foxes.update_value("  %s" % number)
    4966        self.repaint()
    5067
     
    92109    GRASSLAND = tiles.REVERSE_TILE_MAP['grassland']
    93110    FENCE = tiles.REVERSE_TILE_MAP['fence']
     111    WOODLAND = tiles.REVERSE_TILE_MAP['woodland']
    94112    BROKEN_FENCE = tiles.REVERSE_TILE_MAP['broken fence']
    95113
     
    106124        self.buildings = []
    107125        self.cash = 0
     126        self.killed_foxes = 0
    108127        self.add_cash(constants.STARTING_CASH)
    109128
     
    234253        self.chickens.append(chicken)
    235254        self.tv.sprites.append(chicken)
     255        self.toolbar.update_chicken_counter(len(self.chickens))
    236256
    237257    def add_fox(self, fox):
     
    252272            self.chickens.remove(chick)
    253273            self.tv.sprites.remove(chick)
     274            self.toolbar.update_chicken_counter(len(self.chickens))
    254275
    255276    def remove_building(self, building):
Note: See TracChangeset for help on using the changeset viewer.