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 (?, ?)
|
VALUES (?, ?)
|
||||||
""", (current_user_id, item_id))
|
""", (current_user_id, item_id))
|
||||||
|
|
||||||
|
item_id = cursor.lastrowid
|
||||||
conn.commit()
|
conn.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
return item_id
|
||||||
|
|
||||||
def mine(a,b,user_data):
|
def mine(a,b,user_data):
|
||||||
source_id,well_name = user_data
|
source_id,well_name = user_data
|
||||||
@ -131,6 +133,15 @@ def destroy(source_id):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
cursor.close()
|
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():
|
def sell_all():
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
@ -204,12 +215,19 @@ while True:
|
|||||||
break
|
break
|
||||||
elif type(event) is tuple:
|
elif type(event) is tuple:
|
||||||
if event[0] == "-UPGRADE-":
|
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-":
|
elif event[0] == "-BUY-":
|
||||||
id = event[1]
|
id = event[1]
|
||||||
buy_item(id)
|
item_id = buy_item(id)
|
||||||
window[("-BUY-",id)].update(disabled=True)
|
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-":
|
elif event[0] == "-DESTROY-":
|
||||||
destroy(event[1])
|
destroy(event[1])
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user