Changeset 60:e2631c8e2cd6


Ignore:
Timestamp:
Aug 31, 2009, 7:10:31 PM (11 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@61
Message:

Implement guard towers (with temporary sprite PNG).

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/constants.py

    r55 r60  
    2424BUY_PRICE_FENCE = 50
    2525BUY_PRICE_HENHOUSE = 100
     26BUY_PRICE_GUARDTOWER = 200
    2627
    2728TOOL_SELL_CHICKEN = 1
     
    2930TOOL_BUY_FENCE = 3
    3031TOOL_BUY_HENHOUSE = 4
     32TOOL_BUY_GUARDTOWER = 5
  • gamelib/gameboard.py

    r57 r60  
    3131        self.add_tool_button("Buy fence", constants.TOOL_BUY_FENCE)
    3232        self.add_tool_button("Buy henhouse", constants.TOOL_BUY_HENHOUSE)
     33        self.add_tool_button("Buy guard tower", constants.TOOL_BUY_GUARDTOWER)
    3334
    3435    def update_cash_counter(self, amount):
     
    8889        self.foxes = []
    8990        self.henhouses = []
     91        self.guardtowers = []
    9092        self.cash = 0
    9193        self.add_cash(constants.STARTING_CASH)
     
    124126        elif self.selected_tool == constants.TOOL_BUY_HENHOUSE:
    125127            self.buy_henhouse(self.tv.screen_to_tile(e.pos))
     128        elif self.selected_tool == constants.TOOL_BUY_GUARDTOWER:
     129            self.buy_guardtower(self.tv.screen_to_tile(e.pos))
    126130
    127131    def get_chicken(self, pos):
     
    157161            self.add_cash(-constants.BUY_PRICE_HENHOUSE)
    158162            self.add_henhouse(henhouse)
     163
     164    def buy_guardtower(self, tile_pos):
     165        if self.cash < constants.BUY_PRICE_GUARDTOWER:
     166            return
     167        guardtower = buildings.GuardTower(tile_pos)
     168        if guardtower.place(self.tv):
     169            self.add_cash(-constants.BUY_PRICE_GUARDTOWER)
     170            self.add_guardtower(guardtower)
    159171
    160172    def event(self, e):
     
    192204        self.tv.sprites.append(henhouse)
    193205
     206    def add_guardtower(self, guardtower):
     207        self.guardtowers.append(guardtower)
     208        self.tv.sprites.append(guardtower)
     209
    194210    def remove_fox(self, fox):
    195211        if fox in self.foxes:
Note: See TracChangeset for help on using the changeset viewer.