Skip to content

Commit

Permalink
feat(stats): add skill icons
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Dec 15, 2024
1 parent c751f25 commit 9b384c0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/Skillbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Tooltip.Trigger class="group-data-[maxed=true]:shine absolute bottom-0 left-0 z-20 flex size-9 items-center justify-center rounded-full p-1 drop-shadow group-data-[maxed=false]:bg-icon group-data-[maxed=true]:bg-maxed">
<Avatar.Root class="select-none">
<!-- TODO: Add minecraft icons -->
<Avatar.Image class="pointer-events-none" />
<Avatar.Image class="pointer-events-none" src={skillData.texture} />
<Avatar.Fallback>
<BarChartHorizontal class="pointer-events-none size-6" />
</Avatar.Fallback>
Expand Down
21 changes: 21 additions & 0 deletions src/lib/server/constants/skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,24 @@ export const SKYBLOCK_XP = {
export const COSMETIC_SKILLS = ["runecrafting", "social"];

export const INFINITE = ["dungeoneering", "skyblock_level"];

export const SKILL_ICONS = {
skyblock_level: "/api/head/2e2cc42015e6678f8fd49ccc01fbf787f1ba2c32bcf559a015332fc5db50",
farming: "/api/item/GOLDEN_HOE",
combat: "/api/item/STONE_SWORD",
fishing: "/api/item/FISHING_ROD",
alchemy: "/api/item/BREWING_STAND",
runecrafting: "/api/item/MAGMA_CREAM",
taming: "/api/item/SPAWN_EGG",
mining: "/api/item/STONE_PICKAXE",
foraging: "/api/item/SAPLING:3",
enchanting: "/api/item/ENCHANTING_TABLE",
carpentry: "/api/item/CRAFTING_TABLE",
social: "/api/item/EMERALD",
dungeoneering: "/api/head/964e1c3e315c8d8fffc37985b6681c5bd16a6f97ffd07199e8a05efbef103793",
healer: "/api/potion/normal/10",
mage: "/api/item/BLAZE_ROD",
archer: "/api/item/BOW",
berserk: "/api/item/IRON_SWORD",
tank: "/api/item/LEATHER_CHESTPLATE"
} as Record<string, string>;
2 changes: 1 addition & 1 deletion src/lib/server/stats/dungeons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getDungeonClasses(userProfile: Member) {

return Object.keys(userProfile.dungeons.player_classes).reduce(
(acc: Record<string, Skill>, key) => {
acc[key] = getLevelByXp(userProfile.dungeons.player_classes[key].experience, { type: "dungeoneering" });
acc[key] = getLevelByXp(userProfile.dungeons.player_classes[key].experience, { type: "dungeoneering", texture: key });

return acc;
},
Expand Down
4 changes: 3 additions & 1 deletion src/lib/server/stats/leveling/leveling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function getXpTable(type: string): { [key: number]: number } {
* @param {number} xp The experience points to calculate level information from.
* @param {Object} [extra={}] Additional options for level calculation.
* @param {string} [extra.type] The ID of the skill (used to determine xp table and default cap).
* @param {string} [extra.texture] The ID of the texture to use for the skill.
* @param {number} [extra.cap] Override for the highest level the player can reach.
*/
export function getLevelByXp(
Expand Down Expand Up @@ -110,7 +111,8 @@ export function getLevelByXp(
uncappedLevel,
levelWithProgress,
unlockableLevelWithProgress,
maxed
maxed,
texture: constants.SKILL_ICONS[extra.texture ?? extra.type]
// maxExperience
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/processed/profile/skills.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type Extra = {
type: string;
cap?: number;
texture?: string;
};

export type Skill = {
Expand All @@ -15,6 +16,7 @@ export type Skill = {
levelWithProgress: number;
unlockableLevelWithProgress: number;
rank?: number;
texture: string;
};

export type Skills = {
Expand Down

0 comments on commit 9b384c0

Please sign in to comment.