diff --git a/files/helpers/const.py b/files/helpers/const.py index 38c56bc7f..33acd583e 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -678,6 +678,8 @@ AWARDS3 = {} for k, val in AWARDS2.items(): if val['price'] == 300: AWARDS3[k] = val +DOUBLE_XP_ENABLED = -1 # set to unixtime for when DXP begins, -1 to disable + TROLLTITLES = [ "how will @{username} ever recover?", "@{username} BTFO", diff --git a/files/routes/votes.py b/files/routes/votes.py index 84aee852d..ebb8fbe0e 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -72,17 +72,24 @@ def api_vote_post(post_id, new, v): if v.id == post.author.id: coin_delta = 0 + coin_mult = 1 + if DOUBLE_XP_ENABLED > 0: + if not existing and int(time.time()) > DOUBLE_XP_ENABLED: + coin_mult = 2 + elif existing and existing.created_utc > DOUBLE_XP_ENABLED: + coin_mult = 2 + if existing and existing.vote_type == new: return "", 204 if existing: if existing.vote_type == 0 and new != 0: - post.author.coins += coin_delta + post.author.coins += coin_delta * coin_mult post.author.truecoins += coin_delta g.db.add(post.author) existing.vote_type = new g.db.add(existing) elif existing.vote_type != 0 and new == 0: - post.author.coins -= coin_delta + post.author.coins -= coin_delta * coin_mult post.author.truecoins -= coin_delta g.db.add(post.author) g.db.delete(existing) @@ -90,7 +97,7 @@ def api_vote_post(post_id, new, v): existing.vote_type = new g.db.add(existing) elif new != 0: - post.author.coins += coin_delta + post.author.coins += coin_delta * coin_mult post.author.truecoins += coin_delta g.db.add(post.author) @@ -141,17 +148,24 @@ def api_vote_comment(comment_id, new, v): if v.id == comment.author_id: coin_delta = 0 + coin_mult = 1 + if DOUBLE_XP_ENABLED > 0: + if not existing and int(time.time()) > DOUBLE_XP_ENABLED: + coin_mult = 2 + elif existing and existing.created_utc > DOUBLE_XP_ENABLED: + coin_mult = 2 + if existing and existing.vote_type == new: return "", 204 if existing: if existing.vote_type == 0 and new != 0: - comment.author.coins += coin_delta + comment.author.coins += coin_delta * coin_mult comment.author.truecoins += coin_delta g.db.add(comment.author) existing.vote_type = new g.db.add(existing) elif existing.vote_type != 0 and new == 0: - comment.author.coins -= coin_delta + comment.author.coins -= coin_delta * coin_mult comment.author.truecoins -= coin_delta g.db.add(comment.author) g.db.delete(existing) @@ -159,7 +173,7 @@ def api_vote_comment(comment_id, new, v): existing.vote_type = new g.db.add(existing) elif new != 0: - comment.author.coins += coin_delta + comment.author.coins += coin_delta * coin_mult comment.author.truecoins += coin_delta g.db.add(comment.author)