From b592102566cf914659f3b9badacdc32b04c1518f Mon Sep 17 00:00:00 2001 From: Zickles <76439587+Zickles@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:46:47 -0400 Subject: [PATCH] feat(pets): add pets section (#2) --- src/lib/components/Item.svelte | 11 ++-- src/lib/layouts/stats/Main.svelte | 2 + src/lib/sections/stats/Pets.svelte | 98 ++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/lib/sections/stats/Pets.svelte diff --git a/src/lib/components/Item.svelte b/src/lib/components/Item.svelte index ebd6a9176..5d33a7e70 100644 --- a/src/lib/components/Item.svelte +++ b/src/lib/components/Item.svelte @@ -7,7 +7,7 @@ export let piece: Item; - const itemNameHtml = renderLore(piece.tag.display.Name ?? piece.display_name ?? "???"); + const itemNameHtml = renderLore((piece.tag.display && piece.tag.display.Name) ?? piece.display_name ?? "???"); const isMulticolor = (itemNameHtml.match(/<\/span>/g) || []).length > 1; const bgColor = getRarityClass(piece.rarity as string, "bg"); const enchanted = isEnchanted(piece); @@ -37,9 +37,12 @@

- {#each piece.tag.display.Lore as lore} - {@html renderLore(lore)} - {/each} + {#if piece.tag.display && piece.tag.display.Lore} + {#each piece.tag.display.Lore as lore} + {@html renderLore(lore)} + {/each} + {/if} +
diff --git a/src/lib/layouts/stats/Main.svelte b/src/lib/layouts/stats/Main.svelte index 835ae4d68..37a32e0b3 100644 --- a/src/lib/layouts/stats/Main.svelte +++ b/src/lib/layouts/stats/Main.svelte @@ -7,6 +7,7 @@ import Weapons from "$lib/sections/stats/Weapons.svelte"; import type { FullProfile } from "$lib/types/globals"; import { setContext } from "svelte"; + import Pets from "$lib/sections/stats/Pets.svelte"; export let profile; export let profiles; @@ -22,6 +23,7 @@ + diff --git a/src/lib/sections/stats/Pets.svelte b/src/lib/sections/stats/Pets.svelte new file mode 100644 index 000000000..2e87d8429 --- /dev/null +++ b/src/lib/sections/stats/Pets.svelte @@ -0,0 +1,98 @@ + + + +
+ + + +
+

Pet score is calculated based on how many unique pets you have and the rarity of these pets.

+
+

You gain an additional score for each max level pet you have!

+
+ + {#each Object.entries(PET_REWARDS) as [score, data]} + + + + {/each} +
{score} Score: +{data.magic_find} Magic Find + + {#if data.magic_find === pets.pet_score.amount} + « + {/if} + +
+
+
+ + + +
+ + {@const activePet = pets.pets.find(pet => pet.active === true)} + {#if activePet !== undefined} +
+
+ +
+

{activePet.rarity} {activePet.display_name}

+

Level {activePet.level.level}

+
+
+

+ Bonus: + + TODO: Add bonus +

+
+ {/if} +
+ {@const uniquePets = _.uniqBy(pets.pets, 'type')} + {@const otherPets = pets.pets.filter(pet => !uniquePets.includes(pet))} + + {#each uniquePets as pet} + {#if !pet.active} +
+ +

LVL {pet.level.level}

+
+ {/if} + {/each} +
+ + + +

Show More Pets

+
+
+ + + {#each otherPets as pet} +
+ +

LVL {pet.level.level}

+
+ {/each} +
+
+
+