forked from rDrama/rDrama
1
0
Fork 0

dynamic var to prevent errors that happen when i remove or add event awards

master
Aevann 2023-10-12 21:46:22 +03:00
parent 50ac36c7c3
commit 29099c8976
3 changed files with 100 additions and 26 deletions

View File

@ -324,7 +324,7 @@ class Comment(Base):
@lazy @lazy
def award_count(self, kind, v): def award_count(self, kind, v):
if v and v.poor and kind not in FISTMAS_AWARDS + HOMOWEEN_AWARDS: if v and v.poor:
return 0 return 0
return len([x for x in self.awards if x.kind == kind]) return len([x for x in self.awards if x.kind == kind])

View File

@ -2,9 +2,6 @@ from copy import deepcopy
from files.helpers.config.const import * from files.helpers.config.const import *
FISTMAS_AWARDS = ("fireplace", "snow", "gingerbread", "lights", "frostbite", "candycane")
HOMOWEEN_AWARDS = ("spiders", "fog", "bones", "pumpkin", "stalker", "candy-corn", "ectoplasm", "stab", "upsidedown", "flashlight", "haunt", "jumpscare", "bite", "vax")
#Personal awards are disabled on ghost posts and comments bc they can be used to figure out the identity of the author through https://rdrama.net/badges #Personal awards are disabled on ghost posts and comments bc they can be used to figure out the identity of the author through https://rdrama.net/badges
AWARDS = { AWARDS = {
"fallback": { "fallback": {
@ -19,6 +16,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
### Deprecated ### Deprecated
@ -34,6 +32,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"ghost": { "ghost": {
"kind": "ghost", "kind": "ghost",
@ -47,6 +46,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"nword": { "nword": {
"kind": "nword", "kind": "nword",
@ -60,6 +60,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"fish": { "fish": {
"kind": "fish", "kind": "fish",
@ -73,6 +74,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
@ -89,6 +91,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": IS_FISTMAS() or IS_HOMOWEEN(), "enabled": IS_FISTMAS() or IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
### Fistmas ### Fistmas
@ -104,6 +107,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"snow": { "snow": {
"kind": "snow", "kind": "snow",
@ -117,6 +121,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"gingerbread": { "gingerbread": {
"kind": "gingerbread", "kind": "gingerbread",
@ -130,6 +135,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"lights": { "lights": {
"kind": "lights", "kind": "lights",
@ -143,6 +149,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"frostbite": { "frostbite": {
"kind": "frostbite", "kind": "frostbite",
@ -156,6 +163,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"candycane": { "candycane": {
"kind": "candycane", "kind": "candycane",
@ -169,6 +177,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_FISTMAS(), "enabled": IS_FISTMAS(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"grinch": { "grinch": {
"kind": "grinch", "kind": "grinch",
@ -182,6 +191,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": IS_FISTMAS() and SITE_NAME != "WPD", "enabled": IS_FISTMAS() and SITE_NAME != "WPD",
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
### Homoween ### Homoween
@ -197,6 +207,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"fog": { "fog": {
"kind": "fog", "kind": "fog",
@ -210,6 +221,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"bones": { "bones": {
"kind": "bones", "kind": "bones",
@ -223,6 +235,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"pumpkin": { "pumpkin": {
"kind": "pumpkin", "kind": "pumpkin",
@ -236,6 +249,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"stalker": { "stalker": {
"kind": "stalker", "kind": "stalker",
@ -249,6 +263,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"candy-corn": { "candy-corn": {
"kind": "candy-corn", "kind": "candy-corn",
@ -262,6 +277,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"ectoplasm": { "ectoplasm": {
"kind": "ectoplasm", "kind": "ectoplasm",
@ -275,6 +291,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"stab": { "stab": {
"kind": "stab", "kind": "stab",
@ -288,6 +305,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"upsidedown": { "upsidedown": {
"kind": "upsidedown", "kind": "upsidedown",
@ -301,6 +319,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN() and False, "enabled": IS_HOMOWEEN() and False,
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"flashlight": { "flashlight": {
"kind": "flashlight", "kind": "flashlight",
@ -314,6 +333,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": True,
}, },
"haunt": { "haunt": {
"kind": "haunt", "kind": "haunt",
@ -327,20 +347,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
}, "included_in_lootbox": True,
"jumpscare": {
"kind": "jumpscare",
"title": "Jumpscare",
"description": "???",
"icon": "fas fa-coffin-cross",
"color": "text-purple",
"price": 500,
"deflectable": True,
"cosmetic": False,
"ghost": False,
"enabled": IS_HOMOWEEN(),
"positive": True,
}, },
"vax": { "vax": {
"kind": "vax", "kind": "vax",
@ -354,6 +361,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"bite": { "bite": {
"kind": "bite", "kind": "bite",
@ -367,6 +375,21 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": IS_HOMOWEEN(), "enabled": IS_HOMOWEEN(),
"positive": True, "positive": True,
"included_in_lootbox": False,
},
"jumpscare": {
"kind": "jumpscare",
"title": "Jumpscare",
"description": "???",
"icon": "fas fa-coffin-cross",
"color": "text-purple",
"price": 500,
"deflectable": True,
"cosmetic": False,
"ghost": False,
"enabled": IS_HOMOWEEN(),
"positive": True,
"included_in_lootbox": True,
}, },
"hallowgrinch": { "hallowgrinch": {
"kind": "hallowgrinch", "kind": "hallowgrinch",
@ -380,6 +403,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": IS_HOMOWEEN() and SITE_NAME != "WPD", "enabled": IS_HOMOWEEN() and SITE_NAME != "WPD",
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
### Birthgay/Birthdead ### Birthgay/Birthdead
@ -395,6 +419,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": IS_BIRTHGAY() or IS_BIRTHDEAD(), "enabled": IS_BIRTHGAY() or IS_BIRTHDEAD(),
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
### Standard ### Standard
@ -410,6 +435,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"marsify": { "marsify": {
"kind": "marsify", "kind": "marsify",
@ -423,6 +449,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"emoji": { "emoji": {
"kind": "emoji", "kind": "emoji",
@ -436,6 +463,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"emoji-hz": { "emoji-hz": {
"kind": "emoji-hz", "kind": "emoji-hz",
@ -449,6 +477,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": False, "enabled": False,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"rainbow": { "rainbow": {
"kind": "rainbow", "kind": "rainbow",
@ -462,6 +491,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": not FEATURES['HOUSES'], "enabled": not FEATURES['HOUSES'],
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"sharpen": { "sharpen": {
"kind": "sharpen", "kind": "sharpen",
@ -475,6 +505,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": not FEATURES['HOUSES'], "enabled": not FEATURES['HOUSES'],
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"shit": { "shit": {
"kind": "shit", "kind": "shit",
@ -488,6 +519,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"fireflies": { "fireflies": {
"kind": "fireflies", "kind": "fireflies",
@ -501,6 +533,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"firework": { "firework": {
"kind": "firework", "kind": "firework",
@ -514,6 +547,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"ricardo": { "ricardo": {
"kind": "ricardo", "kind": "ricardo",
@ -527,6 +561,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"tilt": { "tilt": {
"kind": "tilt", "kind": "tilt",
@ -540,6 +575,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"glowie": { "glowie": {
"kind": "glowie", "kind": "glowie",
@ -553,6 +589,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"gold": { "gold": {
"kind": "gold", "kind": "gold",
@ -566,6 +603,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"spider": { "spider": {
"kind": "spider", "kind": "spider",
@ -579,6 +617,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"owoify": { "owoify": {
"kind": "owoify", "kind": "owoify",
@ -592,6 +631,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": not FEATURES['HOUSES'], "enabled": not FEATURES['HOUSES'],
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"flairlock": { "flairlock": {
"kind": "flairlock", "kind": "flairlock",
@ -605,6 +645,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"rehab": { "rehab": {
"kind": "rehab", "kind": "rehab",
@ -618,6 +659,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"namelock": { "namelock": {
"kind": "namelock", "kind": "namelock",
@ -631,6 +673,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"queen": { "queen": {
"kind": "queen", "kind": "queen",
@ -644,6 +687,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"offsitementions": { "offsitementions": {
"kind": "offsitementions", "kind": "offsitementions",
@ -657,6 +701,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"unpin": { "unpin": {
"kind": "unpin", "kind": "unpin",
@ -670,6 +715,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"chud": { "chud": {
"kind": "chud", "kind": "chud",
@ -683,6 +729,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"pin": { "pin": {
"kind": "pin", "kind": "pin",
@ -696,6 +743,7 @@ AWARDS = {
"ghost": True, "ghost": True,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"progressivestack": { "progressivestack": {
"kind": "progressivestack", "kind": "progressivestack",
@ -709,6 +757,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"pizzashill": { "pizzashill": {
"kind": "pizzashill", "kind": "pizzashill",
@ -722,6 +771,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"bird": { "bird": {
"kind": "bird", "kind": "bird",
@ -735,6 +785,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"marsey": { "marsey": {
"kind": "marsey", "kind": "marsey",
@ -748,6 +799,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"ban": { "ban": {
"kind": "ban", "kind": "ban",
@ -761,6 +813,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"unban": { "unban": {
"kind": "unban", "kind": "unban",
@ -774,6 +827,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"deflector": { "deflector": {
"kind": "deflector", "kind": "deflector",
@ -787,6 +841,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"benefactor": { "benefactor": {
"kind": "benefactor", "kind": "benefactor",
@ -800,6 +855,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": FEATURES['MARSEYBUX'], "enabled": FEATURES['MARSEYBUX'],
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"eye": { "eye": {
"kind": "eye", "kind": "eye",
@ -813,6 +869,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"grass": { "grass": {
"kind": "grass", "kind": "grass",
@ -826,6 +883,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"unblockable": { "unblockable": {
"kind": "unblockable", "kind": "unblockable",
@ -839,6 +897,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"pause": { "pause": {
"kind": "pause", "kind": "pause",
@ -852,6 +911,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"unpausable": { "unpausable": {
"kind": "unpausable", "kind": "unpausable",
@ -865,6 +925,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"alt": { "alt": {
"kind": "alt", "kind": "alt",
@ -878,6 +939,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"checkmark": { "checkmark": {
"kind": "checkmark", "kind": "checkmark",
@ -891,6 +953,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
"pride": { "pride": {
"kind": "pride", "kind": "pride",
@ -904,6 +967,7 @@ AWARDS = {
"ghost": False, "ghost": False,
"enabled": True, "enabled": True,
"positive": True, "positive": True,
"included_in_lootbox": False,
}, },
} }
@ -926,6 +990,7 @@ HOUSE_AWARDS = {
"cosmetic": False, "cosmetic": False,
"ghost": False, "ghost": False,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"Femboy": { "Femboy": {
"kind": "Femboy", "kind": "Femboy",
@ -938,6 +1003,7 @@ HOUSE_AWARDS = {
"cosmetic": False, "cosmetic": False,
"ghost": False, "ghost": False,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"Vampire": { "Vampire": {
"kind": "Vampire", "kind": "Vampire",
@ -950,6 +1016,7 @@ HOUSE_AWARDS = {
"cosmetic": False, "cosmetic": False,
"ghost": False, "ghost": False,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"Racist": { "Racist": {
"kind": "Racist", "kind": "Racist",
@ -962,6 +1029,7 @@ HOUSE_AWARDS = {
"cosmetic": False, "cosmetic": False,
"ghost": False, "ghost": False,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
"Edgy": { "Edgy": {
"kind": "Edgy", "kind": "Edgy",
@ -974,6 +1042,7 @@ HOUSE_AWARDS = {
"cosmetic": False, "cosmetic": False,
"ghost": False, "ghost": False,
"positive": False, "positive": False,
"included_in_lootbox": False,
}, },
} }

View File

@ -83,10 +83,7 @@ def buy_award(v, kind, AWARDS):
if kind == "lootbox": if kind == "lootbox":
lootbox_items = [] lootbox_items = []
for _ in range(LOOTBOX_ITEM_COUNT): # five items per lootbox for _ in range(LOOTBOX_ITEM_COUNT): # five items per lootbox
if IS_FISTMAS(): LOOTBOX_CONTENTS = [x["kind"] for x in AWARDS_ENABLED.values() if x["included_in_lootbox"]]
LOOTBOX_CONTENTS = FISTMAS_AWARDS
elif IS_HOMOWEEN():
LOOTBOX_CONTENTS = HOMOWEEN_AWARDS
lb_award = random.choice(LOOTBOX_CONTENTS) lb_award = random.choice(LOOTBOX_CONTENTS)
lootbox_items.append(AWARDS[lb_award]['title']) lootbox_items.append(AWARDS[lb_award]['title'])
lb_award = AwardRelationship(user_id=v.id, kind=lb_award, price_paid=price // LOOTBOX_ITEM_COUNT) lb_award = AwardRelationship(user_id=v.id, kind=lb_award, price_paid=price // LOOTBOX_ITEM_COUNT)
@ -221,7 +218,7 @@ def award_thing(v, thing_type, id):
v.charge_account('coins', awarded_coins, should_check_balance=False) v.charge_account('coins', awarded_coins, should_check_balance=False)
thing.author.pay_account('coins', awarded_coins) thing.author.pay_account('coins', awarded_coins)
elif kind != 'spider': elif kind != 'spider':
if AWARDS[kind]['cosmetic'] and kind not in FISTMAS_AWARDS + HOMOWEEN_AWARDS: if AWARDS[kind]['cosmetic'] and not AWARDS[kind]['included_in_lootbox']:
awarded_coins = int(AWARDS[kind]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT) awarded_coins = int(AWARDS[kind]['price'] * COSMETIC_AWARD_COIN_AWARD_PCT)
else: else:
awarded_coins = 0 awarded_coins = 0
@ -648,14 +645,18 @@ def award_thing(v, thing_type, id):
@limiter.limit("1/hour", key_func=lambda:f'{SITE}-{session.get("lo_user")}') @limiter.limit("1/hour", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@auth_required @auth_required
def trick_or_treat(v): def trick_or_treat(v):
if v.client: abort(403, "Not allowed from the API") if v.client:
abort(403, "Not allowed from the API")
if not IS_HOMOWEEN():
abort(403)
result = random.choice([0,1]) result = random.choice([0,1])
if result == 0: if result == 0:
message = "Trick!" message = "Trick!"
else: else:
award = random.choice(HOMOWEEN_AWARDS) choices = [x["kind"] for x in AWARDS_ENABLED.values() if x["included_in_lootbox"]]
award = random.choice(choices)
award_object = AwardRelationship(user_id=v.id, kind=award) award_object = AwardRelationship(user_id=v.id, kind=award)
g.db.add(award_object) g.db.add(award_object)
@ -668,7 +669,11 @@ def trick_or_treat(v):
@app.post("/jumpscare") @app.post("/jumpscare")
@auth_required @auth_required
def execute_jumpscare(v): def execute_jumpscare(v):
if v.client: abort(403, "Not allowed from the API") if v.client:
abort(403, "Not allowed from the API")
if not IS_HOMOWEEN():
abort(403)
if v.jumpscare > 0: if v.jumpscare > 0:
v.jumpscare -= 1 v.jumpscare -= 1
g.db.add(v) g.db.add(v)