add lootboxes

pull/83/head
Aevann1 2022-12-19 18:32:13 +02:00
parent 2028216c45
commit 29fa5bcf4d
3 changed files with 18 additions and 9 deletions

View File

@ -135,10 +135,13 @@ function buy(mb) {
success = xhr[0].status >= 200 && xhr[0].status < 300;
showToast(success, getMessageFromJsonData(success, data), true);
if (success) {
document.getElementById('giveaward').disabled=false;
let owned = document.getElementById(`${kind}-owned`)
let ownednum = Number(owned.textContent) + 1;
owned.textContent = ownednum
if (kind != "lootbox")
{
document.getElementById('giveaward').disabled=false;
let owned = document.getElementById(`${kind}-owned`)
let ownednum = Number(owned.textContent) + 1;
owned.textContent = ownednum
}
}
};

View File

@ -1,6 +1,6 @@
from copy import deepcopy
from files.helpers.config.const import FEATURES, SITE_NAME, patron
from files.helpers.config.const import FEATURES, SITE_NAME, patron, HOLIDAY_EVENT
AWARDS = {
"fallback": {
@ -676,7 +676,12 @@ AWARDS_DISABLED = [
]
LOOTBOX_ITEM_COUNT = 5
LOOTBOX_CONTENTS = ["firework", "confetti", "ricardo", "wholesome", "shit", "fireflies", "scooter", "train"]
if HOLIDAY_EVENT:
LOOTBOX_CONTENTS = ["snow", "gingerbread", "lights", "candycane", "fireplace", "frostbite"]
AWARDS_DISABLED.remove('lootbox')
else:
LOOTBOX_CONTENTS = ["firework", "confetti", "ricardo", "wholesome", "shit", "fireflies", "scooter", "train"]
HOUSE_AWARDS = {
"Furry": {

View File

@ -111,6 +111,7 @@ def buy(v:User, award):
elif v.lootboxes_bought == 150:
badge_grant(badge_id=78, user=v)
return {"message": lootbox_msg}
else:
award_object = AwardRelationship(user_id=v.id, kind=award, price_paid=price)
g.db.add(award_object)
@ -128,6 +129,8 @@ def buy(v:User, award):
@is_not_permabanned
@ratelimit_user()
def award_thing(v, thing_type, id):
kind = request.values.get("kind", "").strip()
if thing_type == 'post':
thing = get_post(id)
else:
@ -137,9 +140,7 @@ def award_thing(v, thing_type, id):
if v.shadowbanned: abort(500)
author = thing.author
if author.shadowbanned: abort(404)
kind = request.values.get("kind", "").strip()
AWARDS = deepcopy(AWARDS_ENABLED)
if v.house:
AWARDS[v.house] = HOUSE_AWARDS[v.house]