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

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": {
"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",

View File

@ -535,17 +535,13 @@ 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":
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 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!')

View File

@ -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'

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