diff --git a/files/classes/user.py b/files/classes/user.py index 209dbe93b3..9c8fcd81a0 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -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 diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index 2b9ed6aa6b..07524f5681 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -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", diff --git a/files/routes/awards.py b/files/routes/awards.py index df35e0bbf4..74a2fb347f 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -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:
" + "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:
" - "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: diff --git a/files/routes/settings.py b/files/routes/settings.py index d38c331adb..ab8c7677ec 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -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' diff --git a/migrations/20231201-better-grinch-code.sql b/migrations/20231201-better-grinch-code.sql new file mode 100644 index 0000000000..e1922f77a2 --- /dev/null +++ b/migrations/20231201-better-grinch-code.sql @@ -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));