Changeset 66:edc15ce8fa30


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

Implement fence selling (a bit hackish, but fine for now).

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/constants.py

    r64 r66  
    2323SELL_PRICE_CHICKEN = 10
    2424BUY_PRICE_FENCE = 50
     25SELL_PRICE_FENCE = 25
    2526
    2627TOOL_SELL_CHICKEN = 1
  • gamelib/gameboard.py

    r65 r66  
    7979    TOOLBAR_WIDTH = 140
    8080
     81    GRASSLAND = tiles.REVERSE_TILE_MAP['grassland']
     82    FENCE = tiles.REVERSE_TILE_MAP['fence']
     83
    8184    def __init__(self):
    8285        self.tv = tiles.FarmVid()
     
    146149
    147150    def buy_fence(self, tile_pos):
    148         if self.tv.get(tile_pos) != tiles.REVERSE_TILE_MAP['grassland']:
     151        if self.tv.get(tile_pos) != self.GRASSLAND:
    149152            return
    150153        if self.cash < constants.BUY_PRICE_FENCE:
     
    152155            return
    153156        self.add_cash(-constants.BUY_PRICE_FENCE)
    154         self.tv.set(tile_pos, tiles.REVERSE_TILE_MAP['fence'])
     157        self.tv.set(tile_pos, self.FENCE)
     158
     159    def sell_fence(self, tile_pos):
     160        if self.tv.get(tile_pos) != self.FENCE:
     161            return
     162        self.add_cash(constants.SELL_PRICE_FENCE)
     163        self.tv.set(tile_pos, self.GRASSLAND)
    155164
    156165    def buy_building(self, tile_pos, building_cls):
     
    163172
    164173    def sell_building(self, tile_pos):
     174        if self.tv.get(tile_pos) == self.FENCE:
     175            return self.sell_fence(tile_pos)
    165176        for building in self.buildings:
    166177            if building.covers(tile_pos):
     
    168179                building.remove(self.tv)
    169180                self.remove_building(building)
     181                break
    170182
    171183    def event(self, e):
Note: See TracChangeset for help on using the changeset viewer.