Skip to content

Commit

Permalink
refactor(stats/dungeons): add Blood Mob Kills, SPR & move stats in du…
Browse files Browse the repository at this point in the history
…ngeosn floor
  • Loading branch information
DuckySoLucky committed Jul 14, 2024
1 parent 36211c5 commit d6671a6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/lib/constants/NotEnoughUpdates-REPO
Submodule NotEnoughUpdates-REPO updated 60 files
+103 −1 constants/dyes.json
+30 −1 constants/sacks.json
+5 −1 items/AMBER_NECKLACE.json
+5 −1 items/AMETHYST_GAUNTLET.json
+4 −1 items/ANGLER_DEEP_SEA.json
+4 −1 items/ARMADILLO_MASK.json
+4 −1 items/ARTIFACT_OF_COINS.json
+5 −1 items/AVARICIOUS_CHALICE.json
+5 −1 items/BEACH_BALL_BARN_SKIN.json
+4 −1 items/BEACH_BALL_FLUX.json
+4 −1 items/BEE_MASK.json
+5 −1 items/BLOOD_SOAKED_COINS.json
+5 −1 items/BLOOD_STAINED_COINS.json
+5 −1 items/BROWN_BANDANA.json
+5 −1 items/CARNIVAL_MASK_BAG.json
+5 −1 items/CARNIVAL_TICKET.json
+4 −1 items/CROWN_OF_AVARICE.json
+5 −1 items/DIVAN_POWDER_COATING.json
+22 −0 items/DYE_PORTAL.json
+5 −1 items/EMERALD_ARTIFACT.json
+5 −1 items/FINE_FLOUR.json
+5 −1 items/FRESHLY_MINTED_COINS.json
+4 −1 items/FROG_MASK.json
+5 −1 items/GLEAMING_CRYSTAL.json
+6 −1 items/GLOSSY_GEMSTONE.json
+5 −1 items/GLOSSY_MINERAL_BOOTS.json
+5 −1 items/GLOSSY_MINERAL_CHESTPLATE.json
+5 −1 items/GLOSSY_MINERAL_HELMET.json
+5 −1 items/GLOSSY_MINERAL_LEGGINGS.json
+5 −1 items/GLOSSY_MINERAL_TALISMAN.json
+5 −1 items/GOLDEN_BOUNTY.json
+5 −1 items/GOLDEN_FRAGMENT.json
+4 −1 items/HAMBAGGER_BACKPACK.json
+5 −1 items/JADE_BELT.json
+5 −1 items/LARGE_EVENTS_SACK.json
+5 −1 items/MITHRIL_BELT.json
+5 −1 items/MITHRIL_CLOAK.json
+5 −1 items/MITHRIL_GAUNTLET.json
+5 −1 items/MITHRIL_NECKLACE.json
+4 −1 items/PARROT_MASK.json
+5 −1 items/PARTY_GIFT.json
+5 −1 items/PEST_VEST.json
+5 −1 items/PET_SKIN_BLAZE_PLUSHIE.json
+5 −1 items/PET_SKIN_BLUE_WHALE_PLUSHIE.json
+4 −1 items/PET_SKIN_FLYING_FISH_HARLEQUIN.json
+5 −1 items/PET_SKIN_WOLF_DOGE_PLUSHIE.json
+4 −1 items/REKINDLED_EMBER_BURNING.json
+4 −1 items/RELIC_OF_COINS.json
+4 −1 items/RING_OF_COINS.json
+4 −1 items/SALMON_MASK.json
+5 −1 items/SAND_CASTLE_BARN_SKIN.json
+5 −1 items/SAPPHIRE_CLOAK.json
+5 −1 items/SCAVENGER_ARTIFACT.json
+5 −1 items/SCAVENGER_RING.json
+4 −1 items/STARLIGHT_STARKNIGHT.json
+5 −1 items/TITANIUM_BELT.json
+5 −1 items/TITANIUM_CLOAK.json
+5 −1 items/TITANIUM_GAUNTLET.json
+5 −1 items/TITANIUM_NECKLACE.json
+4 −1 items/ZOMBIE_MASK.json
20 changes: 19 additions & 1 deletion src/lib/stats/bestiary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Member } from "$types/global";
import * as constants from "$constants/constants";
import type { Member } from "$types/global";
import type { BestiaryStats } from "$types/processed/profile/bestiary";

function getBestiaryMobs(
Expand Down Expand Up @@ -35,6 +35,24 @@ function getBestiaryMobs(
return output;
}

export function getBestiaryFamily(userProfile: Member, mobName: string) {
const bestiary = userProfile.bestiary.kills || {};
const family = Object.values(constants.BESTIARY)
.flatMap((category) => category.mobs)
.find((mob) => mob.name === mobName);

if (family === undefined) {
return null;
}

const output = getBestiaryMobs(bestiary, [family]);
if (!output.length) {
return null;
}

return output[0];
}

export function getBestiary(userProfile: Member) {
const bestiary = userProfile.bestiary.kills || {};

Expand Down
54 changes: 36 additions & 18 deletions src/lib/stats/dungeons.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as constants from "$constants/constants";
import * as helper from "$lib/helper";
import type { BestRun, Catacombs, Member, Skill } from "$types/global";
import { getBestiaryFamily } from "./bestiary";
import { getLevelByXp } from "./leveling/leveling";

function getDungeonClasses(userProfile: Member) {
Expand Down Expand Up @@ -85,6 +86,22 @@ function getBestRun(catacombs: Catacombs, floorId: number) {
};
}

function getSecrets(catacombs: Member["dungeons"]) {
const secretsFound = catacombs.secrets ?? 0;
const totalRuns =
Object.keys(catacombs?.dungeon_types?.catacombs?.tier_completions || {})
.filter((key) => key !== "total")
.reduce((a, b) => a + (catacombs?.dungeon_types?.catacombs?.tier_completions[b] || 0), 0) +
Object.keys(catacombs?.dungeon_types?.master_catacombs?.tier_completions || {})
.filter((key) => key !== "total")
.reduce((a, b) => a + (catacombs?.dungeon_types?.master_catacombs?.tier_completions[b] || 0), 0);

return {
found: secretsFound,
secretsPerRun: secretsFound / totalRuns
};
}

function formatCatacombsData(catacombs: Catacombs) {
const type = catacombs.experience ? "catacombs" : "master_catacombs";

Expand All @@ -94,22 +111,20 @@ function formatCatacombsData(catacombs: Catacombs) {
output.push({
name: floor.name,
texture: floor.texture,

times_played: catacombs.times_played?.[floor.id] ?? 0,
tier_completions: catacombs.tier_completions?.[floor.id] ?? 0,
milestone_completions: catacombs.milestone_completions?.[floor.id] ?? 0,
best_score: catacombs.best_score?.[floor.id] ?? 0,

mobs_killed: catacombs.mobs_killed?.[floor.id] ?? 0,
watcher_kills: catacombs.watcher_kills?.[floor.id] ?? 0,
most_mobs_killed: catacombs.most_mobs_killed?.[floor.id] ?? 0,

fastest_time: catacombs.fastest_time?.[floor.id] ?? 0,
fastest_time_s: catacombs.fastest_time?.[floor.id] ?? 0,
fastest_time_s_plus: catacombs.fastest_time_s_plus?.[floor.id] ?? 0,

most_healing: catacombs.most_healing?.[floor.id] ?? 0,
most_damage: getMostDamage(catacombs, floor.id),
stats: {
times_played: catacombs.times_played?.[floor.id] ?? 0,
tier_completions: catacombs.tier_completions?.[floor.id] ?? 0,
milestone_completions: catacombs.milestone_completions?.[floor.id] ?? 0,
best_score: catacombs.best_score?.[floor.id] ?? 0,
mobs_killed: catacombs.mobs_killed?.[floor.id] ?? 0,
watcher_kills: catacombs.watcher_kills?.[floor.id] ?? 0,
most_mobs_killed: catacombs.most_mobs_killed?.[floor.id] ?? 0,
fastest_time: catacombs.fastest_time?.[floor.id] ?? 0,
fastest_time_s: catacombs.fastest_time?.[floor.id] ?? 0,
fastest_time_s_plus: catacombs.fastest_time_s_plus?.[floor.id] ?? 0,
most_healing: catacombs.most_healing?.[floor.id] ?? 0,
most_damage: getMostDamage(catacombs, floor.id),
},
best_run: getBestRun(catacombs, floor.id)
});
}
Expand All @@ -133,8 +148,11 @@ export function getDungeons(userProfile: Member) {
classAverageWithProgress: Object.values(dungeonClasses).reduce((a, b) => a + b.levelWithProgress, 0) / Object.keys(dungeonClasses).length,
totalClassExp: Object.values(userProfile.dungeons.player_classes).reduce((a, b) => a + b.experience, 0)
},
secrets: {
found: userProfile.dungeons.secrets
stats: {
secrets: getSecrets(userProfile.dungeons),
highestFloorBeatenNormal: userProfile.dungeons.dungeon_types.catacombs.highest_tier_completed ?? 0,
highestFloorBeatenMaster: userProfile.dungeons.dungeon_types.master_catacombs.highest_tier_completed ?? 0,
bloodMobKills: getBestiaryFamily(userProfile, "Undead")?.kills ?? 0
},
catacombs: formatCatacombsData(userProfile.dungeons.dungeon_types.catacombs),
master_catacombs: formatCatacombsData(userProfile.dungeons.dungeon_types.master_catacombs)
Expand Down
40 changes: 24 additions & 16 deletions src/types/processed/profile/dungeons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ export type DungeonsStats = {
classAverageWithProgress: number;
totalClassExp: number;
};
secrets: {
found: number;
stats: {
secrets: {
found: number;
secretsPerRun: number;
};
highestFloorBeatenNormal: number;
highestFloorBeatenMaster: number;
bloodMobKills: number;
};
catacombs: CatacombsData[];
master_catacombs: CatacombsData[];
Expand All @@ -19,20 +25,22 @@ export type DungeonsStats = {
export type CatacombsData = {
name: string;
texture: string;
times_played: number;
tier_completions: number;
milestone_completions: number;
best_score: number;
mobs_killed: number;
watcher_kills: number;
most_mobs_killed: number;
fastest_time: number;
fastest_time_s: number;
fastest_time_s_plus: number;
most_healing: number;
most_damage: {
damage: number;
type: string;
stats: {
times_played: number;
tier_completions: number;
milestone_completions: number;
best_score: number;
mobs_killed: number;
watcher_kills: number;
most_mobs_killed: number;
fastest_time: number;
fastest_time_s: number;
fastest_time_s_plus: number;
most_healing: number;
most_damage: {
damage: number;
type: string;
};
};
best_run: {
grade: string;
Expand Down

0 comments on commit d6671a6

Please sign in to comment.