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

pull/211/head
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
@lazy
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
@lazy
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
@lazy

View File

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

View File

@ -209,6 +209,11 @@ def award_thing(v, thing_type, id):
send_repeatable_notification(v.id, msg)
author = v
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':
if AWARDS[kind]['cosmetic']:
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)
elif kind == "unpin":
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':
t = thing.stickied_utc - 3600*6
else:
t = thing.stickied_utc - 3600
if thing_type == 'comment':
t = thing.stickied_utc - 3600*6
else:
t = thing.stickied_utc - 3600
if time.time() > t:
thing.stickied = None
thing.stickied_utc = None
cache.delete_memoized(frontlist)
else: thing.stickied_utc = t
g.db.add(thing)
if time.time() > t:
thing.stickied = None
thing.stickied_utc = None
cache.delete_memoized(frontlist)
else: thing.stickied_utc = t
g.db.add(thing)
elif kind == "queen":
if author.chud:
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")