def spend_money(self, gold=0, silver=0, copper=0): ihave = price_in_copper(*self.money_tuple()) price = price_in_copper(gold, silver, copper) remains = ihave - price if remains < 0: return False else: self.put('inventory/money', convert_money(remains)) return True
def sell_price(self, gold, copper, silver): price = price_in_copper(gold, silver, copper) cha = int(self.get('attributes/cha', 1)) price = (price / 2) + ((price / 100) * cha) money = convert_money(price) return (int(money['gold']), int(money['silver']), int(money['copper']))
def tile_objects(self, x, y): tile = self.tile(x, y) if not tile(): return items = tile.load('items') npc = tile.load('npc') for item in items: yield ('items', item) money = self.getmoney(x, y) if price_in_copper(*money): m = {'view': []} if money[0]: #TODO - select a new gold icon and put here in the proper format. m['view'].append('Money.png:0:1') if money[1]: m['view'].append('Money.png:3:1') if money[2]: m['view'].append('Money.png:0:0') yield 'money', m if npc is not None: yield('npc', npc)
def gain_money(self, gold=0, silver=0, copper=0): total_gained = price_in_copper(gold, silver, copper) my_total = price_in_copper(*self.money_tuple()) my_total += total_gained self.put('inventory/money', convert_money(my_total))