From 3e365484fdd901116666c7ebcbf9cca1b1f26490 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Jun 2022 15:30:25 +0200 Subject: [PATCH] refactor lottery a little bit + expand it to all of marsey's empire --- files/helpers/const.py | 17 +++-------------- files/helpers/lottery.py | 11 +++-------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 3423d2313..45981faca 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1049,17 +1049,6 @@ linefeeds_regex = re.compile("([^\n])\n([^\n])", flags=re.A) def make_name(*args, **kwargs): return request.base_url -# Lottery -LOTTERY_ENABLED = False -LOTTERY_TICKET_COST = 0 -LOTTERY_SINK_RATE = 0 -LOTTERY_ROYALTY_RATE = 0 -LOTTERY_ROYALTY_ACCOUNT_ID = 0 -LOTTERY_MANAGER_ACCOUNT_ID = 0 -if SITE_NAME == 'rDrama': - LOTTERY_ENABLED = True - LOTTERY_TICKET_COST = 12 - LOTTERY_SINK_RATE = 3 - LOTTERY_ROYALTY_RATE = 0 - LOTTERY_ROYALTY_ACCOUNT_ID = 1387 # (Chapose) - LOTTERY_MANAGER_ACCOUNT_ID = 11651 # (Lottershe) +LOTTERY_ENABLED = True +LOTTERY_TICKET_COST = 12 +LOTTERY_SINK_RATE = 3 \ No newline at end of file diff --git a/files/helpers/lottery.py b/files/helpers/lottery.py index f05192aaa..41cee53fb 100644 --- a/files/helpers/lottery.py +++ b/files/helpers/lottery.py @@ -58,7 +58,7 @@ def end_lottery_session(): active_lottery.is_active = False - manager = g.db.query(User).get(LOTTERY_MANAGER_ACCOUNT_ID) + manager = g.db.query(User).get(AUTOPOLLER_ID) if manager: manager.coins -= active_lottery.prize @@ -93,7 +93,7 @@ def check_if_end_lottery_task(): return True def lottery_ticket_net_value(): - return LOTTERY_TICKET_COST - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE + return LOTTERY_TICKET_COST - LOTTERY_SINK_RATE def purchase_lottery_tickets(v, quantity=1): if quantity < 1: @@ -115,17 +115,12 @@ def purchase_lottery_tickets(v, quantity=1): grant_lottery_proceeds_to_manager(net_ticket_value) - beneficiary = g.db.query(User).get(LOTTERY_ROYALTY_ACCOUNT_ID) - - if beneficiary and LOTTERY_ROYALTY_RATE: - beneficiary.coins += LOTTERY_ROYALTY_RATE * quantity - 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(LOTTERY_MANAGER_ACCOUNT_ID) + manager = g.db.query(User).get(AUTOPOLLER_ID) if manager: manager.coins += prize_value