#NEWLINE# def buy_item( self ) : #NEWLINE# #INDENT# 'Attempt to allow player to purchase item' #NEWLINE# item = self . item_to_be_purchased #NEWLINE# self . player_inventory [ 'GOLD' ] [ 'quantity' ] -= item [ 'price' ] #NEWLINE# if ( self . player_inventory [ 'GOLD' ] [ 'quantity' ] < 0 ) : #NEWLINE# #INDENT# self . player_inventory [ 'GOLD' ] [ 'quantity' ] += item [ 'price' ] #NEWLINE# self . state = 'reject' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( self [ 'type' ] in self . player_inventory ) and ( not ( self . name == c . POTION_SHOP ) ) ) : #NEWLINE# #INDENT# self . state = 'hasitem' #NEWLINE# self . player_inventory [ 'GOLD' ] [ 'quantity' ] += item [ 'price' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . notify ( c . CLOTH_BELT ) #NEWLINE# self . state = 'accept' #NEWLINE# self . add_player_item ( item )