Skip to content

Commit

Permalink
fix(stats): slayer icons, dungeons return null if 0 completions, high…
Browse files Browse the repository at this point in the history
…est priority tools
  • Loading branch information
DuckySoLucky committed Jul 21, 2024
1 parent b6b2663 commit 18f2f4e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/lib/constants/slayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ export const SLAYER_XP = {
export const SLAYER_INFO = {
zombie: {
name: "Revenant Horror",
head: "/head/1fc0184473fe882d2895ce7cbc8197bd40ff70bf10d3745de97b6c2a9c5fc78f"
head: "/api/head/1fc0184473fe882d2895ce7cbc8197bd40ff70bf10d3745de97b6c2a9c5fc78f"
},
spider: {
name: "Tarantula Broodfather",
head: "/head/9d7e3b19ac4f3dee9c5677c135333b9d35a7f568b63d1ef4ada4b068b5a25"
head: "/api/head/9d7e3b19ac4f3dee9c5677c135333b9d35a7f568b63d1ef4ada4b068b5a25"
},
wolf: {
name: "Sven Packmaster",
head: "/head/f83a2aa9d3734b919ac24c9659e5e0f86ecafbf64d4788cfa433bbec189e8"
head: "/api/head/f83a2aa9d3734b919ac24c9659e5e0f86ecafbf64d4788cfa433bbec189e8"
},
enderman: {
name: "Voidgloom Seraph",
head: "/head/1b09a3752510e914b0bdc9096b392bb359f7a8e8a9566a02e7f66faff8d6f89e"
head: "/api/head/1b09a3752510e914b0bdc9096b392bb359f7a8e8a9566a02e7f66faff8d6f89e"
},
blaze: {
name: "Inferno Demonlord",
head: "/head/b20657e24b56e1b2f8fc219da1de788c0c24f36388b1a409d0cd2d8dba44aa3b"
head: "/api/head/b20657e24b56e1b2f8fc219da1de788c0c24f36388b1a409d0cd2d8dba44aa3b"
},
vampire: {
name: "Riftstalker Bloodfiend",
head: "/head/5aa29ea961757dc3c90bfabf302c5abe9d308fb4a7d3864e5788ad2cc9160aa2"
head: "/api/head/5aa29ea961757dc3c90bfabf302c5abe9d308fb4a7d3864e5788ad2cc9160aa2"
}
} as Record<string, { name: string; head: string }>;

Expand Down
10 changes: 6 additions & 4 deletions src/lib/sections/stats/skills/farming.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@
<Items>
<div slot="text" class="space-y-2">
<h3 class="text-xl font-semibold">Farming Tools</h3>
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Tool:</span>
<span class={cn(getRarityClass(highestPriorityFarmingTool.rarity ?? "", "text"))}>{highestPriorityFarmingTool.display_name}</span>
</p>
{#if highestPriorityFarmingTool}
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Tool:</span>
<span class={cn(getRarityClass(highestPriorityFarmingTool.rarity ?? "", "text"))}>{highestPriorityFarmingTool.display_name}</span>
</p>
{/if}
</div>
{#each farmingTools as tool}
<Item piece={tool} />
Expand Down
10 changes: 6 additions & 4 deletions src/lib/sections/stats/skills/fishing.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
<Items>
<div slot="text" class="space-y-2">
<h3 class="text-xl font-semibold">Fishing Rods</h3>
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Rod:</span>
<span class={cn(getRarityClass(highestPriorityFishingTool.rarity ?? "", "text"))}>{highestPriorityFishingTool.display_name}</span>
</p>
{#if highestPriorityFishingTool}
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Rod:</span>
<span class={cn(getRarityClass(highestPriorityFishingTool.rarity ?? "", "text"))}>{highestPriorityFishingTool.display_name}</span>
</p>
{/if}
</div>
{#each fishingTools as tool}
<Item piece={tool} />
Expand Down
10 changes: 6 additions & 4 deletions src/lib/sections/stats/skills/mining.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
<Items title="Skills">
<div slot="text" class="space-y-2">
<h3 class="text-xl font-semibold">Mining Tools</h3>
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Tool:</span>
<span class={cn(getRarityClass(highestPriorityMiningTool.rarity ?? "", "text"))}>{highestPriorityMiningTool.display_name}</span>
</p>
{#if highestPriorityMiningTool}
<p class="space-x-0.5 font-bold capitalize leading-6 text-text/60">
<span>Active Tool:</span>
<span class={cn(getRarityClass(highestPriorityMiningTool.rarity ?? "", "text"))}>{highestPriorityMiningTool.display_name}</span>
</p>
{/if}
</div>
{#each miningTools as tool}
<Item piece={tool} />
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getStats(profile: Profile, player: Player): Promise<Stats>
enchanting: stats.getEnchanting(userProfile),
fishing: stats.getFishing(userProfile),
slayer: stats.getSlayer(userProfile),
dungeons: stats.getDungeons(userProfile),
dungeons: stats.getDungeons(userProfile)
minions: stats.getMinions(profile),
bestiary: stats.getBestiary(userProfile),
collections: collections,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/stats/dungeons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function formatCatacombsData(catacombs: Catacombs) {
});
}

if (output.reduce((a, b) => a + b.stats.times_played, 0) === 0) {
return null;
}

return output;
}

Expand Down
4 changes: 2 additions & 2 deletions src/types/processed/profile/dungeons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export type DungeonsStats = {
highestFloorBeatenMaster: number;
bloodMobKills: number;
};
catacombs: CatacombsData[];
master_catacombs: CatacombsData[];
catacombs: CatacombsData[] | null;
master_catacombs: CatacombsData[] | null;
};

export type CatacombsData = {
Expand Down
6 changes: 3 additions & 3 deletions src/types/processed/profile/items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ export type Items = {
highest_priority_weapon: ProcessedItem;
};
farming_tools: {
highest_priority_tool: ProcessedItem;
highest_priority_tool: ProcessedItem | null;
tools: ProcessedItem[];
};
mining_tools: {
highest_priority_tool: ProcessedItem;
highest_priority_tool: ProcessedItem | null;
tools: ProcessedItem[];
};
fishing_tools: {
highest_priority_tool: ProcessedItem;
highest_priority_tool: ProcessedItem | null;
tools: ProcessedItem[];
};
pets: ProcessedItem[];
Expand Down

0 comments on commit 18f2f4e

Please sign in to comment.