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.
master
Snakes 2022-05-19 13:41:04 -04:00
parent 0608e0ce9d
commit 69dec16f55
2 changed files with 10 additions and 5 deletions

View File

@ -192,7 +192,7 @@ class User(Base):
elif self.patron == 6: discount = 0.65 elif self.patron == 6: discount = 0.65
else: discount = 1 else: discount = 1
for badge in [69,70,71,72,73]: for badge in discounts:
if self.has_badge(badge): discount -= discounts[badge] if self.has_badge(badge): discount -= discounts[badge]
return discount return discount

View File

@ -721,11 +721,16 @@ REDDIT_NOTIFS = {
} }
discounts = { discounts = {
# Big Spender badges, 2pp additive discount each
69: 0.02, 69: 0.02,
70: 0.04, 70: 0.02,
71: 0.06, 71: 0.02,
72: 0.08, 72: 0.02,
73: 0.10, 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() CF_KEY = environ.get("CF_KEY", "").strip()