Reorganize route logic

master
Outrun Colors, LLC 2022-05-29 01:06:39 -05:00
parent bef0b0ff6d
commit 562202b38d
2 changed files with 7 additions and 6 deletions

View File

@ -82,11 +82,11 @@ def start_new_lottery_session(g):
def purchase_lottery_ticket(g, v):
if (v.coins < LOTTERY_TICKET_COST):
return False, f'Lottery tickets cost {LOTTERY_TICKET_COST} dramacoins each.', None
return False, f'Lottery tickets cost {LOTTERY_TICKET_COST} dramacoins each.'
most_recent_lottery = get_active_lottery(g)
if (most_recent_lottery is None):
return False, "There is no active lottery.", None
return False, "There is no active lottery."
v.coins -= LOTTERY_TICKET_COST
v.currently_held_lottery_tickets += 1
@ -104,4 +104,4 @@ def purchase_lottery_ticket(g, v):
g.db.commit()
return True, 'Successfully purchased a lottery ticket!', most_recent_lottery.stats
return True, 'Successfully purchased a lottery ticket!'

View File

@ -30,12 +30,13 @@ def lottery_start(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@auth_required
def lottery_buy(v):
success, message, lottery_stats = purchase_lottery_ticket(g, v)
success, message = purchase_lottery_ticket(g, v)
lottery, participants = get_active_lottery_stats(g)
if success:
return {"message": message, "stats": {"user": v.lottery_stats, "lottery": lottery_stats}}
return {"message": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
else:
return {"error": message, "stats": {"user": v.lottery_stats, "lottery": lottery_stats}}
return {"error": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
@app.get("/lottery/active")