From 69dec16f5505cd4be936c3b75af007f3933026a6 Mon Sep 17 00:00:00 2001 From: TLSM Date: Thu, 19 May 2022 13:41:04 -0400 Subject: [PATCH] Shop badge discount: fix Spender, add Roller disc. The shop discount from Big Spender badges was incorrectly implemented: intended behavior was for 2pp per badge. However, the values in const.py were set as if a user could only have one Spender badge at once, while user.py @ discount was implemented as if they were additive. Since users factually do have multiple big spender badges, the values in const were adjusted to reflect this fact. Also, lootbox Roller badges now each offer a 1pp discount. users.py @ discount was improved to check against the `discounts` keys for appropriate badges, rather than a hardcoded list. --- files/classes/user.py | 2 +- files/helpers/const.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 7913f0b41..83c58f984 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -192,7 +192,7 @@ class User(Base): elif self.patron == 6: discount = 0.65 else: discount = 1 - for badge in [69,70,71,72,73]: + for badge in discounts: if self.has_badge(badge): discount -= discounts[badge] return discount diff --git a/files/helpers/const.py b/files/helpers/const.py index 33acd583e..9e510018d 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -721,11 +721,16 @@ REDDIT_NOTIFS = { } discounts = { + # Big Spender badges, 2pp additive discount each 69: 0.02, - 70: 0.04, - 71: 0.06, - 72: 0.08, - 73: 0.10, + 70: 0.02, + 71: 0.02, + 72: 0.02, + 73: 0.02, + # Lootbox badges, 1pp additive discount each + 76: 0.01, + 77: 0.01, + 78: 0.01, } CF_KEY = environ.get("CF_KEY", "").strip()