From bea6d82b6196ad51df22fd9a5fb4c0c805334274 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 10 Jun 2022 06:15:37 -0400 Subject: [PATCH] Lottery: fix granted value, zero royalty. grant_lottery_tickets_to_user incorrectly deposited the full ticket value into manager account, not just the net value. Additionally, royalty rate has been set to zero because Chapose won the first lottery and grifting 8% that could instead go into the prize pool seems unwarranted given that. --- files/helpers/const.py | 15 +++++++-------- files/helpers/lottery.py | 16 +++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 89f484119..7bd4d290f 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1037,17 +1037,16 @@ 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 = 1 + LOTTERY_ROYALTY_RATE = 0 LOTTERY_ROYALTY_ACCOUNT_ID = 1387 # (Chapose) LOTTERY_MANAGER_ACCOUNT_ID = 11651 # (Lottershe) -else: - 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 \ No newline at end of file diff --git a/files/helpers/lottery.py b/files/helpers/lottery.py index 18756c43a..f05192aaa 100644 --- a/files/helpers/lottery.py +++ b/files/helpers/lottery.py @@ -92,6 +92,8 @@ def check_if_end_lottery_task(): start_new_lottery_session() return True +def lottery_ticket_net_value(): + return LOTTERY_TICKET_COST - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE def purchase_lottery_tickets(v, quantity=1): if quantity < 1: @@ -107,7 +109,7 @@ def purchase_lottery_tickets(v, quantity=1): v.currently_held_lottery_tickets += quantity v.total_held_lottery_tickets += quantity - net_ticket_value = (LOTTERY_TICKET_COST - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE) * quantity + net_ticket_value = lottery_ticket_net_value() * quantity most_recent_lottery.prize += net_ticket_value most_recent_lottery.tickets_sold += quantity @@ -115,7 +117,7 @@ def purchase_lottery_tickets(v, quantity=1): beneficiary = g.db.query(User).get(LOTTERY_ROYALTY_ACCOUNT_ID) - if beneficiary: + if beneficiary and LOTTERY_ROYALTY_RATE: beneficiary.coins += LOTTERY_ROYALTY_RATE * quantity g.db.commit() @@ -128,16 +130,16 @@ def grant_lottery_proceeds_to_manager(prize_value): if manager: manager.coins += prize_value -def grant_lottery_tickets_to_user(v, amount): +def grant_lottery_tickets_to_user(v, quantity): active_lottery = get_active_lottery() - prize_value = amount * LOTTERY_TICKET_COST + prize_value = lottery_ticket_net_value() * quantity if active_lottery: - v.currently_held_lottery_tickets += amount - v.total_held_lottery_tickets += amount + v.currently_held_lottery_tickets += quantity + v.total_held_lottery_tickets += quantity active_lottery.prize += prize_value - active_lottery.tickets_sold += amount + active_lottery.tickets_sold += quantity grant_lottery_proceeds_to_manager(prize_value)