forked from rDrama/rDrama
Merge branch 'frost' of https://github.com/Aevann1/Drama into frost
commit
22f3749df3
|
@ -58,11 +58,6 @@ def end_lottery_session():
|
|||
|
||||
active_lottery.is_active = False
|
||||
|
||||
manager = g.db.query(User).get(AUTOPOLLER_ID)
|
||||
|
||||
if manager:
|
||||
manager.coins -= active_lottery.prize
|
||||
|
||||
g.db.commit()
|
||||
|
||||
return True, f'{winning_user.username} won {active_lottery.prize} dramacoins!'
|
||||
|
@ -73,7 +68,9 @@ def start_new_lottery_session():
|
|||
|
||||
lottery = Lottery()
|
||||
epoch_time = int(time.time())
|
||||
one_week_from_now = epoch_time + 60 * 60 * 24 * 7
|
||||
# Subtract 4 minutes from one week so cronjob interval doesn't cause the
|
||||
# time to drift toward over multiple weeks.
|
||||
one_week_from_now = epoch_time + 60 * 60 * 24 * 7 - (4 * 60)
|
||||
lottery.ends_at = one_week_from_now
|
||||
lottery.is_active = True
|
||||
|
||||
|
@ -113,18 +110,10 @@ def purchase_lottery_tickets(v, quantity=1):
|
|||
most_recent_lottery.prize += net_ticket_value
|
||||
most_recent_lottery.tickets_sold += quantity
|
||||
|
||||
grant_lottery_proceeds_to_manager(net_ticket_value)
|
||||
|
||||
g.db.commit()
|
||||
|
||||
return True, f'Successfully purchased {quantity} lottery tickets!'
|
||||
|
||||
def grant_lottery_proceeds_to_manager(prize_value):
|
||||
manager = g.db.query(User).get(AUTOPOLLER_ID)
|
||||
|
||||
if manager:
|
||||
manager.coins += prize_value
|
||||
|
||||
def grant_lottery_tickets_to_user(v, quantity):
|
||||
active_lottery = get_active_lottery()
|
||||
prize_value = lottery_ticket_net_value() * quantity
|
||||
|
@ -136,6 +125,4 @@ def grant_lottery_tickets_to_user(v, quantity):
|
|||
active_lottery.prize += prize_value
|
||||
active_lottery.tickets_sold += quantity
|
||||
|
||||
grant_lottery_proceeds_to_manager(prize_value)
|
||||
|
||||
g.db.commit()
|
|
@ -677,7 +677,8 @@ CREATE TABLE public.users (
|
|||
currently_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||
total_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||
total_lottery_winnings integer DEFAULT 0 NOT NULL,
|
||||
can_gamble boolean DEFAULT true NOT NULL
|
||||
can_gamble boolean DEFAULT true NOT NULL,
|
||||
offsitementions boolean DEFAULT false NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue