forked from rDrama/rDrama
better grinch code
parent
7e670c236c
commit
0726fc8324
|
@ -155,6 +155,9 @@ class User(Base):
|
|||
lifetimedonated_visible = Column(Boolean, default=False)
|
||||
blacklisted_by = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
if IS_EVENT():
|
||||
grinch = Column(Boolean, default=SITE_NAME != 'rDrama')
|
||||
|
||||
if IS_HOMOWEEN():
|
||||
zombie = Column(Integer, default=0, nullable=False) # > 0 vaxxed; < 0 zombie
|
||||
jumpscare = Column(Integer, default=0)
|
||||
|
@ -259,18 +262,6 @@ class User(Base):
|
|||
|
||||
return (succeeded, charged_coins)
|
||||
|
||||
|
||||
if IS_FISTMAS():
|
||||
@property
|
||||
@lazy
|
||||
def can_toggle_event_music(self):
|
||||
return SITE_NAME != 'rDrama' or self.has_badge(91)
|
||||
elif IS_HOMOWEEN():
|
||||
@property
|
||||
@lazy
|
||||
def can_toggle_event_music(self):
|
||||
return SITE_NAME != 'rDrama' or self.has_badge(185)
|
||||
|
||||
if IS_EVENT():
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -78,7 +78,21 @@ AWARDS = {
|
|||
},
|
||||
|
||||
|
||||
### Fistmas and Homoween
|
||||
### Shared
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"price": 100,
|
||||
"deflectable": True,
|
||||
"cosmetic": False,
|
||||
"ghost": False,
|
||||
"enabled": IS_EVENT() and SITE_NAME == "rDrama",
|
||||
"negative": False,
|
||||
"included_in_lootbox": False,
|
||||
},
|
||||
"lootbox": {
|
||||
"kind": "lootbox",
|
||||
"title": "Lootbox",
|
||||
|
@ -95,20 +109,6 @@ AWARDS = {
|
|||
},
|
||||
|
||||
### Fistmas
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"price": 100,
|
||||
"deflectable": True,
|
||||
"cosmetic": False,
|
||||
"ghost": False,
|
||||
"enabled": IS_FISTMAS() and SITE_NAME != "WPD",
|
||||
"negative": False,
|
||||
"included_in_lootbox": False,
|
||||
},
|
||||
"fireplace": {
|
||||
"kind": "fireplace",
|
||||
"title": "Fireplace",
|
||||
|
@ -195,20 +195,6 @@ AWARDS = {
|
|||
},
|
||||
|
||||
### Homoween
|
||||
"hallowgrinch": {
|
||||
"kind": "hallowgrinch",
|
||||
"title": "Hallowgrinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-orange",
|
||||
"price": 100,
|
||||
"deflectable": True,
|
||||
"cosmetic": False,
|
||||
"ghost": False,
|
||||
"enabled": IS_HOMOWEEN() and SITE_NAME != "WPD",
|
||||
"negative": False,
|
||||
"included_in_lootbox": False,
|
||||
},
|
||||
"stalker": {
|
||||
"kind": "stalker",
|
||||
"title": "Stalker",
|
||||
|
|
|
@ -535,60 +535,56 @@ def award_thing(v, thing_type, id):
|
|||
emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none()
|
||||
if not emoji:
|
||||
abort(404, f'an Emoji with the name "{award.note}" was not found!')
|
||||
elif IS_FISTMAS():
|
||||
if kind == "grinch":
|
||||
if v.id == author.id:
|
||||
session['event_music'] = False
|
||||
elif kind == "candycane":
|
||||
if obj.is_effortpost:
|
||||
abort(403, f'Effortposts are protected from the {award_title} award!')
|
||||
elif IS_HOMOWEEN():
|
||||
if kind == "hallowgrinch":
|
||||
if v.id == author.id:
|
||||
session['event_music'] = False
|
||||
elif kind in {"ectoplasm", "candy-corn", "stab"}:
|
||||
if obj.is_effortpost:
|
||||
abort(403, f'Effortposts are protected from the {award_title} award!')
|
||||
elif kind == "spider":
|
||||
if author.spider: author.spider += 86400
|
||||
else: author.spider = int(time.time()) + 86400
|
||||
badge_grant(user=author, badge_id=179, notify=False)
|
||||
elif kind == "bite":
|
||||
if author.zombie < 0:
|
||||
author = v
|
||||
elif kind == "grinch":
|
||||
author.grinch = True
|
||||
if v.id == author.id:
|
||||
session['event_music'] = False
|
||||
elif kind == "candycane":
|
||||
if obj.is_effortpost:
|
||||
abort(403, f'Effortposts are protected from the {award_title} award!')
|
||||
elif kind in {"ectoplasm", "candy-corn", "stab"}:
|
||||
if obj.is_effortpost:
|
||||
abort(403, f'Effortposts are protected from the {award_title} award!')
|
||||
elif kind == "spider":
|
||||
if author.spider: author.spider += 86400
|
||||
else: author.spider = int(time.time()) + 86400
|
||||
badge_grant(user=author, badge_id=179, notify=False)
|
||||
elif kind == "bite":
|
||||
if author.zombie < 0:
|
||||
author = v
|
||||
|
||||
if author.zombie == 0:
|
||||
author.zombie = -1
|
||||
badge_grant(user=author, badge_id=181)
|
||||
|
||||
award_object = AwardRelationship(user_id=author.id, kind='bite')
|
||||
g.db.add(award_object)
|
||||
send_repeatable_notification(author.id,
|
||||
"As the zombie virus washes over your mind, you feel the urge "
|
||||
"to… BITE YUMMY BRAINS :marseyzombie:<br>"
|
||||
"You receive a free **Zombie Bite** award: pass it on!")
|
||||
|
||||
elif author.zombie > 0:
|
||||
author.zombie -= 1
|
||||
if author.zombie == 0:
|
||||
author.zombie = -1
|
||||
badge_grant(user=author, badge_id=181)
|
||||
send_repeatable_notification(author.id, "You are no longer **VAXXMAXXED**! Time for another booster!")
|
||||
|
||||
award_object = AwardRelationship(user_id=author.id, kind='bite')
|
||||
g.db.add(award_object)
|
||||
send_repeatable_notification(author.id,
|
||||
"As the zombie virus washes over your mind, you feel the urge "
|
||||
"to… BITE YUMMY BRAINS :marseyzombie:<br>"
|
||||
"You receive a free **Zombie Bite** award: pass it on!")
|
||||
|
||||
elif author.zombie > 0:
|
||||
author.zombie -= 1
|
||||
if author.zombie == 0:
|
||||
send_repeatable_notification(author.id, "You are no longer **VAXXMAXXED**! Time for another booster!")
|
||||
|
||||
badge = author.has_badge(182)
|
||||
if badge: g.db.delete(badge)
|
||||
elif kind == "vax":
|
||||
if author.zombie < 0:
|
||||
author.zombie = 0
|
||||
send_repeatable_notification(author.id, "You are no longer **INFECTED**! Praise Fauci!")
|
||||
|
||||
badge = author.has_badge(181)
|
||||
badge = author.has_badge(182)
|
||||
if badge: g.db.delete(badge)
|
||||
elif author.zombie >= 0:
|
||||
author.zombie += 2
|
||||
author.zombie = min(author.zombie, 10)
|
||||
elif kind == "vax":
|
||||
if author.zombie < 0:
|
||||
author.zombie = 0
|
||||
send_repeatable_notification(author.id, "You are no longer **INFECTED**! Praise Fauci!")
|
||||
|
||||
badge_grant(user=author, badge_id=182)
|
||||
elif kind == "jumpscare":
|
||||
author.jumpscare += 1
|
||||
badge = author.has_badge(181)
|
||||
if badge: g.db.delete(badge)
|
||||
elif author.zombie >= 0:
|
||||
author.zombie += 2
|
||||
author.zombie = min(author.zombie, 10)
|
||||
|
||||
badge_grant(user=author, badge_id=182)
|
||||
elif kind == "jumpscare":
|
||||
author.jumpscare += 1
|
||||
|
||||
author = obj.author
|
||||
if v.id != author.id:
|
||||
|
|
|
@ -194,7 +194,7 @@ def settings_personal_post(v):
|
|||
session["nsfw_warnings"] = int(request.values.get("nsfw_warnings") == 'true')
|
||||
|
||||
elif not updated and IS_EVENT() and request.values.get("event_music", v.event_music) != v.event_music:
|
||||
if not v.can_toggle_event_music:
|
||||
if not v.grinch:
|
||||
abort(403, "You need to award yourself the grinch award to be able to disable event music!")
|
||||
updated = True
|
||||
session['event_music'] = request.values.get("event_music", v.event_music) == 'true'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
alter table users add column grinch bool default false not null;
|
||||
alter table users alter column grinch drop default;
|
||||
update users set grinch=true where id in (select user_id from badges where badge_id in (91,185));
|
Loading…
Reference in New Issue