Skip to content

Commit

Permalink
feat(xp): convert more cards to v2 format
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Oct 26, 2024
1 parent d44f484 commit 65ebe79
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
20 changes: 11 additions & 9 deletions core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,24 @@ async def get_xp_style(self, user: discord.User) -> str:
@cached(TTLCache(maxsize=10_000, ttl=60))
async def allowed_card_styles(self, user: discord.User):
"""Retourne la liste des styles autorisées pour la carte d'xp de cet utilisateur"""
liste = ["blue", "dark", "green", "grey", "orange",
"purple", "red", "turquoise", "yellow"]
base_styles = [
"blue", "dark", "green", "grey", "orange",
"purple", "red", "turquoise", "yellow"
]
if not self.bot.database_online:
return sorted(liste)
liste2 = []
return sorted(base_styles)
rolebased_styles = []
if await self.bot.get_cog("Admin").check_if_admin(user):
liste2.append("admin")
rolebased_styles.append("admin")
if not self.bot.database_online:
return sorted(liste2)+sorted(liste)
return sorted(rolebased_styles) + sorted(base_styles)
userflags = await self.bot.get_cog("Users").get_userflags(user)
for flag in ("support", "contributor", "partner", "premium"):
if flag in userflags:
liste2.append(flag)
rolebased_styles.append(flag)
for card in await self.bot.get_cog("Users").get_rankcards(user):
liste.append(card)
return sorted(liste2)+sorted(liste)
base_styles.append(card)
return sorted(rolebased_styles) + sorted(base_styles)

async def get_user_languages(self, user: discord.User, limit: int=0):
"""Get the most used languages of an user
Expand Down
55 changes: 55 additions & 0 deletions modules/xp/cards/cards_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,50 @@
"total_xp_with_text": [230, 185, 11]
}
},
"blue": {
"xp_bar": [32, 223, 156],
"texts": {
"username": [158, 206, 250],
"level": [207, 230, 252],
"rank": [158, 206, 250],
"participants": [150, 195, 240],
"xp_to_next_level_with_text": [124, 197, 118],
"total_xp_with_text": [124, 197, 118]
}
},
"orange": {
"xp_bar": [255, 145, 0],
"texts": {
"username": [255, 235, 180],
"level": [255, 175, 0],
"rank": [255, 120, 0],
"participants": [255, 100, 0],
"xp_to_next_level_with_text": [230, 190, 80],
"total_xp_with_text": [230, 190, 80]
}
},
"purple": {
"xp_bar": [104, 38, 217],
"texts": {
"username": [220, 195, 255],
"level": [195, 180, 235],
"rank": [180, 135, 220],
"participants": [150, 110, 195],
"xp_to_next_level_with_text": [190, 160, 230],
"total_xp_with_text": [190, 160, 230]
}
},
"turquoise": {
"xp_bar": [32, 223, 156],
"texts": {
"username": [230, 245, 245],
"level": [235, 245, 245],
"rank": [230, 245, 245],
"participants": [200, 235, 230],
"xp_to_next_level_with_text": [124, 197, 118],
"total_xp_with_text": [124, 197, 118]
}
},
"christmas20": {
"xp_bar": [204, 255, 255],
"texts": {
Expand Down Expand Up @@ -312,6 +356,17 @@
"total_xp_with_text": [255, 255, 255]
}
},
"halloween24": {
"xp_bar": [220, 25, 10],
"texts": {
"username": [255, 153, 51],
"level": [255, 140, 26],
"rank": [255, 140, 26],
"participants": [205, 100, 10],
"xp_to_next_level_with_text": [240, 80, 30],
"total_xp_with_text": [240, 80, 30]
}
},
"premium": {
"xp_bar": [255, 255, 102],
"texts": {
Expand Down
11 changes: 6 additions & 5 deletions modules/xp/cards/cards_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

V1_CARDS = {
"april22",
"blue",
"blurple19",
"blurple20",
"blurple21",
Expand All @@ -15,29 +14,31 @@
"christmas20",
"christmas22",
"dark",
"green",
"grey",
"halloween20",
"halloween21",
"halloween22",
"orange",
"purple",
"rainbow",
"red",
"turquoise",
"yellow",
}

V3_CARDS = {
"admin",
"blue",
"contributor",
"green",
"orange",
"partner",
"premium",
"purple",
"support",
"turquoise",
"blurple23",
"halloween23",
"christmas23",
"april24",
"halloween24",
}

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

0 comments on commit 65ebe79

Please sign in to comment.