def OnDClick(self, event): gear_raw = self.grid_shop.GetCellValue(event.GetRow(), 0) quantity = 1 item = None for combo in data.list_gear_dict.values(): if gear_raw in combo[0]: item = combo[1](combo[0][gear_raw]) break if item.SHOP: if data.pouch.remove(data.pouchitems.gold, item.VALUE * quantity): Output.buy(quantity, item.NAME, item.VALUE) self.message("Purchased {} {} for {} gold.".format(quantity, item.NAME, item.VALUE * quantity)) data.inventory.add(item, quantity) self._load_buy()
def cmd_purchase(*params): try: if params[1] == "EoCMD": gear_raw = params[0] quantity = 1 else: gear_raw = params[1] quantity = int(params[0]) item = None for combo in data.list_gear_dict.values(): if gear_raw in combo[0]: item = combo[1](combo[0][gear_raw]) break if item.SHOP: if data.pouch.remove(data.pouchitems['gold'], item.VALUE * quantity): Output.buy(quantity, item.NAME, item.VALUE) data.inventory.add(item, quantity) except (AttributeError, ValueError): print("purchase ([quantity]) [gear_name_without_spaces]")