From b6b2663d7ac83cc74126dd26ac7aac7186f91f7e Mon Sep 17 00:00:00 2001 From: Gigi <47110839+DarthGigi@users.noreply.github.com> Date: Sat, 20 Jul 2024 15:03:24 +0200 Subject: [PATCH] Add Slayer section to stats page (#20) * feat: Add Slayer section to stats page (WIP) * fix(stats/slayer): incorrect xpForNext * chore: Add Avatar and Image components for Slayer section --------- Co-authored-by: DuckySoLucky --- src/lib/layouts/stats/Main.svelte | 2 + src/lib/sections/stats/Slayer.svelte | 72 ++++++++++++++++++++++++++++ src/lib/stats/slayer.ts | 4 +- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/lib/sections/stats/Slayer.svelte diff --git a/src/lib/layouts/stats/Main.svelte b/src/lib/layouts/stats/Main.svelte index a17bf3c3..8a8ab891 100644 --- a/src/lib/layouts/stats/Main.svelte +++ b/src/lib/layouts/stats/Main.svelte @@ -9,6 +9,7 @@ import Inventory from "$lib/sections/stats/Inventory.svelte"; import Pets from "$lib/sections/stats/Pets.svelte"; import SkillsSection from "$lib/sections/stats/SkillsSection.svelte"; + import Slayer from "$lib/sections/stats/Slayer.svelte"; import Weapons from "$lib/sections/stats/Weapons.svelte"; import type { Stats as StatsType } from "$types/stats"; import { setContext } from "svelte"; @@ -30,6 +31,7 @@ + diff --git a/src/lib/sections/stats/Slayer.svelte b/src/lib/sections/stats/Slayer.svelte new file mode 100644 index 00000000..b0d96392 --- /dev/null +++ b/src/lib/sections/stats/Slayer.svelte @@ -0,0 +1,72 @@ + + +
+

Slayer

+ {#if slayer} + +
+ {#each Object.entries(slayer.data) as [key, value]} + {#if value.level.xp > 0} +
+
+ + + + + + + {value.name} +
+
+ {#each Object.entries(value.kills) as [key, killValue]} +
+ + {#if !isNaN(Number(key))} + Tier {["I", "II", "III", "IV", "V"][Number(key) - 1]} + {:else} + {key} + {/if} + + + {format(killValue)} + +
+ {/each} +
+
+

+ {key} Level {value.level.level} +

+ + +
+
+ {#if value.level.maxed} + {format(value.level.xp)} + {:else} + {format(value.level.xp)} / {format(value.level.xpForNext)} + {/if} + XP +
+
+
+ +
+
+ {/if} + {/each} +
+ + {/if} +
diff --git a/src/lib/stats/slayer.ts b/src/lib/stats/slayer.ts index b76e85aa..a1b9b1eb 100644 --- a/src/lib/stats/slayer.ts +++ b/src/lib/stats/slayer.ts @@ -27,7 +27,7 @@ function getLevel(slayer: string, data: SlayerBoss) { level: 0, maxLevel: 0, xpCurrent: 0, - xpForNext: 0, + xpForNext: constants.SLAYER_XP[slayer] ? constants.SLAYER_XP[slayer]["1"] : 0, maxed: false }; } @@ -37,7 +37,7 @@ function getLevel(slayer: string, data: SlayerBoss) { const maxLevel = Object.keys(constants.SLAYER_XP[slayer]).length; for (const [level, xp] of reversed) { if (data.xp > xp) { - const xpForNext = xp; + const xpForNext = constants.SLAYER_XP[slayer][parseInt(level) + 1]; return { xp: data.xp, xpForNext,