def buy_item(self):
        item = self.item_to_be_purchased

        self.player_inventory['GOLD']['quantity'] -= item['price']

        if self.player_inventory['GOLD']['quantity'] < 0:
            self.player_inventory['GOLD']['quantity'] += item['price']
            self.state = 'reject'
        else:
            if (item['type'] in self.player_inventory and
                        not self.name == c.POTION_SHOP):
                self.state = 'hasitem'
                self.player_inventory['GOLD']['quantity'] += item['price']
            else:
                self.notify(c.CLOTH_BELT)
                self.state = 'accept'
                self.add_player_item(item)
Attempt to allow player to purchase item
dataset/ETHPy150Open justinmeister/The-Stolen-Crown-RPG/data/shopgui.py/Gui.buy_item