Sell Item
This commit is contained in:
parent
e7857e25e8
commit
c164d563d0
24
mm.py
24
mm.py
@ -104,8 +104,10 @@ def buy_item(item_id):
|
||||
VALUES (?, ?)
|
||||
""", (current_user_id, item_id))
|
||||
|
||||
item_id = cursor.lastrowid
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
return item_id
|
||||
|
||||
def mine(a,b,user_data):
|
||||
source_id,well_name = user_data
|
||||
@ -131,6 +133,15 @@ def destroy(source_id):
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
|
||||
def sell(item_id):
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("DELETE FROM inventory_item WHERE user_id = ? AND id = ?",
|
||||
(current_user_id,item_id))
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
|
||||
def sell_all():
|
||||
cursor = conn.cursor()
|
||||
|
||||
@ -204,12 +215,19 @@ while True:
|
||||
break
|
||||
elif type(event) is tuple:
|
||||
if event[0] == "-UPGRADE-":
|
||||
print("Upgrade")
|
||||
sg.Window.Layout([[sg.Text("IT WORKED")]])
|
||||
print('asdf')
|
||||
elif event[0] == "-SELL-":
|
||||
id = event[1]
|
||||
inv = get_inventory()
|
||||
sell(id)
|
||||
window[("-BUY-",inv[id][0])].update(disabled=False)
|
||||
window[("-IROW-",id)].update(visible=False)
|
||||
elif event[0] == "-BUY-":
|
||||
id = event[1]
|
||||
buy_item(id)
|
||||
item_id = buy_item(id)
|
||||
window[("-BUY-",id)].update(disabled=True)
|
||||
window.extend_layout(window["-COL-"], [inventory_row(id,id,0)])
|
||||
window.extend_layout(window["-COL-"], [inventory_row(item_id,id,0)])
|
||||
elif event[0] == "-DESTROY-":
|
||||
destroy(event[1])
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user