forked from rDrama/rDrama
1
0
Fork 0

better grinch code

master
Aevann 2023-12-01 21:31:45 +02:00
parent 7e670c236c
commit 0726fc8324
5 changed files with 67 additions and 91 deletions

View File

@ -155,6 +155,9 @@ class User(Base):
lifetimedonated_visible = Column(Boolean, default=False) lifetimedonated_visible = Column(Boolean, default=False)
blacklisted_by = Column(Integer, ForeignKey("users.id")) blacklisted_by = Column(Integer, ForeignKey("users.id"))
if IS_EVENT():
grinch = Column(Boolean, default=SITE_NAME != 'rDrama')
if IS_HOMOWEEN(): if IS_HOMOWEEN():
zombie = Column(Integer, default=0, nullable=False) # > 0 vaxxed; < 0 zombie zombie = Column(Integer, default=0, nullable=False) # > 0 vaxxed; < 0 zombie
jumpscare = Column(Integer, default=0) jumpscare = Column(Integer, default=0)
@ -259,18 +262,6 @@ class User(Base):
return (succeeded, charged_coins) 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(): if IS_EVENT():
@property @property
@lazy @lazy

View File

@ -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": { "lootbox": {
"kind": "lootbox", "kind": "lootbox",
"title": "Lootbox", "title": "Lootbox",
@ -95,20 +109,6 @@ AWARDS = {
}, },
### Fistmas ### 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": { "fireplace": {
"kind": "fireplace", "kind": "fireplace",
"title": "Fireplace", "title": "Fireplace",
@ -195,20 +195,6 @@ AWARDS = {
}, },
### Homoween ### 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": { "stalker": {
"kind": "stalker", "kind": "stalker",
"title": "Stalker", "title": "Stalker",

View File

@ -535,60 +535,56 @@ def award_thing(v, thing_type, id):
emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none() emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none()
if not emoji: if not emoji:
abort(404, f'an Emoji with the name "{award.note}" was not found!') abort(404, f'an Emoji with the name "{award.note}" was not found!')
elif IS_FISTMAS(): elif kind == "grinch":
if kind == "grinch": author.grinch = True
if v.id == author.id: if v.id == author.id:
session['event_music'] = False session['event_music'] = False
elif kind == "candycane": elif kind == "candycane":
if obj.is_effortpost: if obj.is_effortpost:
abort(403, f'Effortposts are protected from the {award_title} award!') abort(403, f'Effortposts are protected from the {award_title} award!')
elif IS_HOMOWEEN(): elif kind in {"ectoplasm", "candy-corn", "stab"}:
if kind == "hallowgrinch": if obj.is_effortpost:
if v.id == author.id: abort(403, f'Effortposts are protected from the {award_title} award!')
session['event_music'] = False elif kind == "spider":
elif kind in {"ectoplasm", "candy-corn", "stab"}: if author.spider: author.spider += 86400
if obj.is_effortpost: else: author.spider = int(time.time()) + 86400
abort(403, f'Effortposts are protected from the {award_title} award!') badge_grant(user=author, badge_id=179, notify=False)
elif kind == "spider": elif kind == "bite":
if author.spider: author.spider += 86400 if author.zombie < 0:
else: author.spider = int(time.time()) + 86400 author = v
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: if author.zombie == 0:
author.zombie = -1 send_repeatable_notification(author.id, "You are no longer **VAXXMAXXED**! Time for another booster!")
badge_grant(user=author, badge_id=181)
award_object = AwardRelationship(user_id=author.id, kind='bite') badge = author.has_badge(182)
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)
if badge: g.db.delete(badge) if badge: g.db.delete(badge)
elif author.zombie >= 0: elif kind == "vax":
author.zombie += 2 if author.zombie < 0:
author.zombie = min(author.zombie, 10) author.zombie = 0
send_repeatable_notification(author.id, "You are no longer **INFECTED**! Praise Fauci!")
badge_grant(user=author, badge_id=182) badge = author.has_badge(181)
elif kind == "jumpscare": if badge: g.db.delete(badge)
author.jumpscare += 1 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 author = obj.author
if v.id != author.id: if v.id != author.id:

View File

@ -194,7 +194,7 @@ def settings_personal_post(v):
session["nsfw_warnings"] = int(request.values.get("nsfw_warnings") == 'true') 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: 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!") abort(403, "You need to award yourself the grinch award to be able to disable event music!")
updated = True updated = True
session['event_music'] = request.values.get("event_music", v.event_music) == 'true' session['event_music'] = request.values.get("event_music", v.event_music) == 'true'

View File

@ -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));