Skip to content

Commit

Permalink
feat(event): add christmas 2023 xp card
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Nov 19, 2023
1 parent e474b6d commit 8e1cd51
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions events-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
}
},
"christmas-2023": {
"begin": "2023-11-01",
"begin": "2023-12-01",
"end": "2023-12-31",
"type": "christmas",
"icon": "https://zrunner.me/cdn/halloween_2023.png",
Expand Down Expand Up @@ -252,7 +252,7 @@
"lutin",
"cookie"
],
"probability": 0.91
"probability": 0.1
}
}
}
2 changes: 1 addition & 1 deletion fcts/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def cardpreview_autocomplete_style(self, inter: discord.Interaction, curre
async def profile_card(self, ctx: MyContext, style: args.CardStyle):
"""Change your xp card style.
..Example profile card christmas20
..Example profile card christmas23
..Doc user.html#change-your-xp-card"""
if style is None and len(ctx.view.buffer.split(' ')) > 2:
Expand Down
15 changes: 8 additions & 7 deletions libs/bot_events/subcogs/christmas_subcog.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ async def collect_cmd(self, ctx):
else:
await ctx.send(txt)
# add points (and potentially grant reward rank card)
if gifts:
await self.db_add_collect(ctx.author.id, sum(item["points"] for item in gifts))
await self.db_add_collect(ctx.author.id, sum(item["points"] for item in gifts))

@acached(60*2) # cache for 2min
async def today(self):
return dt.datetime.now(dt.timezone.utc).date()
# return dt.date(2023, 12, 1)
Expand Down Expand Up @@ -262,11 +262,12 @@ async def db_add_collect(self, user_id: int, points: int):
"""Add collect points to a user"""
if not self.bot.database_online or self.bot.current_event is None:
return
query = "INSERT INTO `event_points` (`user_id`, `collect_points`, `beta`) VALUES (%s, %s, %s) \
ON DUPLICATE KEY UPDATE collect_points = collect_points + VALUE(`collect_points`), \
last_collect = CURRENT_TIMESTAMP();"
async with self.bot.db_query(query, (user_id, points, self.bot.beta)):
pass
if points:
query = "INSERT INTO `event_points` (`user_id`, `collect_points`, `beta`) VALUES (%s, %s, %s) \
ON DUPLICATE KEY UPDATE collect_points = collect_points + VALUE(`collect_points`), \
last_collect = CURRENT_TIMESTAMP();"
async with self.bot.db_query(query, (user_id, points, self.bot.beta)):
pass
if cog := self.bot.get_cog("BotEvents"):
try:
await cog.reload_event_rankcard(user_id)
Expand Down
1 change: 1 addition & 0 deletions libs/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class RankCardsFlag:
1 << 11: "christmas22",
1 << 12: "blurple23",
1 << 13: "halloween23",
1 << 14: "christmas23",
}

def flags_to_int(self, flags: list) -> int:
Expand Down
11 changes: 11 additions & 0 deletions libs/xp_cards/cards_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,17 @@
"total_xp_with_text": [255, 140, 26]
}
},
"christmas23": {
"xp_bar": [255, 153, 204],
"texts": {
"username": [255, 255, 255],
"level": [255, 255, 255],
"rank": [255, 255, 255],
"participants": [255, 255, 255],
"xp_to_next_level_with_text": [255, 255, 255],
"total_xp_with_text": [255, 255, 255]
}
},
"premium": {
"xp_bar": [255, 255, 102],
"texts": {
Expand Down
4 changes: 3 additions & 1 deletion libs/xp_cards/cards_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import os

from libs.xp_cards.card_types import CardData, CardMetaData, TextData, TextMetaData, ColorsData
from libs.xp_cards.card_types import (CardData, CardMetaData, ColorsData,
TextData, TextMetaData)

V1_CARDS = {
"april22",
Expand Down Expand Up @@ -35,6 +36,7 @@
"support",
"blurple23",
"halloween23",
"christmas23"
}

JSON_DATA_FILE = os.path.dirname(__file__) + "/cards_data.json"
Expand Down

0 comments on commit 8e1cd51

Please sign in to comment.