Skip to content

Commit

Permalink
fix(stats): types and some other things for svelte-check
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Jun 25, 2024
1 parent f2092d0 commit 9cfb8eb
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/webiste.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths: ["src/**", ".github/workflows/website.yml"]

env:
NODE_VERSION: "19"
NODE_VERSION: "21"
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Avatar, Tooltip } from "bits-ui";
import Image from "lucide-svelte/icons/image";
export let piece: ProcessedItem;
export let piece: ProcessedItem | ProcessedPet;
export let isInventory = false;
export let showCount = true;
Expand All @@ -16,7 +16,7 @@
const bgColor = piece.rarity ? getRarityClass(piece.rarity.toLowerCase() as string, "bg") : "bg-background";
const enchanted = isEnchanted(piece as ProcessedItem);
const showNumbers = showCount && piece.Count > 1;
const showNumbers = showCount && (piece as ProcessedItem).Count > 1;
const processedItem = piece as ProcessedItem;
const processedPet = piece as unknown as ProcessedPet;
Expand All @@ -33,7 +33,7 @@
</Avatar.Root>
{#if showNumbers}
<div class="absolute bottom-0.5 right-0.5 text-2xl font-semibold text-white text-shadow-[.1em_.1em_.1em_#000]">
{piece.Count}
{processedItem.Count}
</div>
{/if}
</Tooltip.Trigger>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sections/stats/Accessories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
<span style="color: var(--§6)"> +{accessories.magicalPower.riftPrism} MP</span>
</li>
{/if}
{#if accessories.magicalPower.hegemony > 0}
{#if accessories.magicalPower.hegemony.amount > 0 && accessories.magicalPower.hegemony.rarity !== null}
<li>
<span style="color: var(--§{RARITY_COLORS[accessories.magicalPower.rarities.hegemony.rarity]}">Hegemony Artifact: </span>
<span style="color: var(--§{RARITY_COLORS[accessories.magicalPower.hegemony.rarity]}">Hegemony Artifact: </span>
=
<span style="color: var(--§6)"> +{accessories.magicalPower.hegemony} MP</span>
</li>
Expand Down
5 changes: 2 additions & 3 deletions src/lib/stats/items/stats.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getRawLore } from "$lib/helper";
import type { ProcessedItem } from "$types/stats";
import * as constants from "$constants/constants";
import { getRawLore } from "$lib/helper";
import type { ItemStats } from "$types/processed/profile/stats";
import type { ProcessedItem } from "$types/stats";

export function getStatsFromItem(item: ProcessedItem) {
const regex = /^([A-Za-z ]+): ([+-]([0-9]+(?:,[0-9]{3})*(?:\.[0-9]{0,2})?))/;
Expand All @@ -25,7 +25,6 @@ export function getStatsFromItem(item: ProcessedItem) {
if (statName) {
stats[statName] = 0;

// @ts-expect-error: Object is possibly 'null'.
stats[statName] += statValue;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/stats/missing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ export async function getMissingAccessories(items: Accessories, userProfile: Mem
accessories: activeAccessories.reduce((a, b) => a + helper.getMagicalPower(b.rarity, helper.getId(b)), 0),
abiphone: abiphoneContacts ? Math.floor(abiphoneContacts / 2) : 0,
riftPrism: riftPrism ? 11 : 0,
hegemony: {
rarity: activeAccessories.find((a) => helper.getId(a) === "HEGEMONY")?.rarity ?? null,
amount: helper.getMagicalPower(activeAccessories.find((a) => helper.getId(a) === "HEGEMONY")?.rarity ?? "", "HEGEMONY_ARTIFACT")
},
rarities: {}
};

Expand Down
4 changes: 2 additions & 2 deletions src/lib/stats/player_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function getPlayerStats(profile: Stats) {
}
}

if (profile.slayer.data) {
if (profile.slayer?.data) {
for (const [slayer, data] of Object.entries(profile.slayer.data)) {
const bonusStats = getBonusStat(data.level.level, `slayer_${slayer}`, data.level.maxLevel);

Expand All @@ -106,7 +106,7 @@ export function getPlayerStats(profile: Stats) {
}
}

if (profile.dungeons.level.level > 0) {
if (profile.dungeons?.level?.level !== undefined) {
const bonusStats = getBonusStat(profile.dungeons.level.level, "skill_dungeoneering", 50);

for (const [name, value] of Object.entries(bonusStats)) {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/stats/slayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Member, SlayerBoss } from "$types/global";
import * as constants from "$constants/constants";
import type { Slayer } from "$types/processed/profile/slayer";
import type { Member, SlayerBoss, SlayerData } from "$types/global";

function getKills(slayer: SlayerBoss) {
if (slayer === undefined) {
Expand Down Expand Up @@ -64,7 +63,7 @@ export function getSlayer(userProfile: Member) {
return null;
}

const output = { data: {} } as Slayer;
const output = { data: {} } as SlayerData;
for (const id of constants.SLAYERS) {
const data = slayerData[id];
output.data[id] = {
Expand Down
4 changes: 4 additions & 0 deletions src/types/processed/profile/items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ export type AccessoriesOutput = {
accessories: number;
abiphone: number;
riftPrism: number;
hegemony: {
rarity: string | null;
amount: number;
};
rarities: Record<string, { amount: number; magicalPower: number }>;
};
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/stats.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type Stats = {
mining: MiningStats;
farming: Farming;
fishing: Fishing;
slayer: SlayerData;
slayer: SlayerData | null;
dungeons: DungeonsStats | null;
minions: Minions;
bestiary: BestiaryStats;
Expand Down

0 comments on commit 9cfb8eb

Please sign in to comment.