forked from rDrama/rDrama
1
0
Fork 0

make deflector apply to "shit" and "unpin" award

master
Aevann 2023-10-04 13:18:08 +03:00
parent 993dd16d57
commit d1f8162873
3 changed files with 21 additions and 15 deletions

View File

@ -562,12 +562,12 @@ class User(Base):
@property @property
@lazy @lazy
def awards_content_effect(self): def awards_content_effect(self):
return [x for x in self.user_awards if not x['deflectable'] and x['kind'] != 'benefactor'] return [x for x in self.user_awards if x['cosmetic'] or x['kind'] in {"pin", "unpin"}]
@property @property
@lazy @lazy
def awards_author_effect(self): def awards_author_effect(self):
return [x for x in self.user_awards if x not in self.awards_content_effect] return [x for x in self.user_awards if not x['cosmetic'] and x['kind'] not in {"pin", "unpin"}]
@property @property
@lazy @lazy

View File

@ -431,7 +431,7 @@ AWARDS = {
"icon": "fas fa-poop", "icon": "fas fa-poop",
"color": "text-black-50", "color": "text-black-50",
"price": 300, "price": 300,
"deflectable": False, "deflectable": True,
"cosmetic": True, "cosmetic": True,
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
@ -639,7 +639,7 @@ AWARDS = {
"icon": "fas fa-thumbtack fa-rotate--45", "icon": "fas fa-thumbtack fa-rotate--45",
"color": "text-black", "color": "text-black",
"price": 1000, "price": 1000,
"deflectable": False, "deflectable": True,
"cosmetic": False, "cosmetic": False,
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,

View File

@ -209,6 +209,11 @@ def award_thing(v, thing_type, id):
send_repeatable_notification(v.id, msg) send_repeatable_notification(v.id, msg)
author = v author = v
safe_username = f"Your award has been deflected but failed since you're" safe_username = f"Your award has been deflected but failed since you're"
if kind == 'shit':
awarded_coins = int(AWARDS[kind]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT)
v.charge_account('coins', awarded_coins, should_check_balance=False)
thing.author.pay_account('coins', awarded_coins)
elif kind != 'spider': elif kind != 'spider':
if AWARDS[kind]['cosmetic']: if AWARDS[kind]['cosmetic']:
awarded_coins = int(AWARDS[kind]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT) awarded_coins = int(AWARDS[kind]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT)
@ -309,19 +314,20 @@ def award_thing(v, thing_type, id):
cache.delete_memoized(frontlist) cache.delete_memoized(frontlist)
elif kind == "unpin": elif kind == "unpin":
if not thing.stickied_utc: abort(400) if not thing.stickied_utc: abort(400)
if thing.author_id == LAWLZ_ID and SITE_NAME == 'rDrama': abort(403, "You can't unpin lawlzposts!") if not thing.author.deflector:
if thing.author_id == LAWLZ_ID and SITE_NAME == 'rDrama': abort(403, "You can't unpin lawlzposts!")
if thing_type == 'comment': if thing_type == 'comment':
t = thing.stickied_utc - 3600*6 t = thing.stickied_utc - 3600*6
else: else:
t = thing.stickied_utc - 3600 t = thing.stickied_utc - 3600
if time.time() > t: if time.time() > t:
thing.stickied = None thing.stickied = None
thing.stickied_utc = None thing.stickied_utc = None
cache.delete_memoized(frontlist) cache.delete_memoized(frontlist)
else: thing.stickied_utc = t else: thing.stickied_utc = t
g.db.add(thing) g.db.add(thing)
elif kind == "queen": elif kind == "queen":
if author.chud: if author.chud:
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!") abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")