From 13fe17ecb52e1b06202d846948d38d0db9ba4483 Mon Sep 17 00:00:00 2001
From: Shiiyu <40838999+Shiiyu@users.noreply.github.com>
Date: Wed, 16 Oct 2024 10:09:04 -0400
Subject: [PATCH] fix: remove outdated weight systems
---
includes/header.ejs | 2 -
package.json | 1 -
pnpm-lock.yaml | 12 --
public/resources/ts/globals.d.ts | 6 -
src/constants/weight/lily-weight.js | 37 ----
src/constants/weight/senither-weight.js | 266 ------------------------
src/stats/weight.js | 4 -
views/sections/stats/basic_stats.ejs | 62 ------
8 files changed, 390 deletions(-)
delete mode 100644 src/constants/weight/lily-weight.js
delete mode 100644 src/constants/weight/senither-weight.js
diff --git a/includes/header.ejs b/includes/header.ejs
index 547a59c59d..b71f5c0cf1 100644
--- a/includes/header.ejs
+++ b/includes/header.ejs
@@ -64,8 +64,6 @@
Weight Calculations:
diff --git a/package.json b/package.json
index ac6c1bf144..96b6f2267e 100644
--- a/package.json
+++ b/package.json
@@ -65,7 +65,6 @@
"express-session": "^1.17.3",
"fs-extra": "^11.2.0",
"ioredis": "^5.3.2",
- "lilyweight": "^2.7.2",
"lit": "^3.1.1",
"lodash": "^4.17.21",
"micromatch": "^4.0.5",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0b34cbdafe..95817c1434 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -62,9 +62,6 @@ importers:
ioredis:
specifier: ^5.3.2
version: 5.3.2
- lilyweight:
- specifier: ^2.7.2
- version: 2.7.2
lit:
specifier: ^3.1.1
version: 3.1.1
@@ -1693,9 +1690,6 @@ packages:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
- lilyweight@2.7.2:
- resolution: {integrity: sha512-jJJfiq4HFok1iiZ4d77synztcAQQd1FgTYA9/eREPILP99DiyFH8FSDUH1Z8WXAHzeWBrP0xZ5tFceQHVUJ0Xw==}
-
lit-analyzer@2.0.3:
resolution: {integrity: sha512-XiAjnwVipNrKav7r3CSEZpWt+mwYxrhPRVC7h8knDmn/HWTzzWJvPe+mwBcL2brn4xhItAMzZhFC8tzzqHKmiQ==}
hasBin: true
@@ -4326,12 +4320,6 @@ snapshots:
prelude-ls: 1.2.1
type-check: 0.4.0
- lilyweight@2.7.2:
- dependencies:
- node-fetch: 2.6.7
- transitivePeerDependencies:
- - encoding
-
lit-analyzer@2.0.3:
dependencies:
'@vscode/web-custom-data': 0.4.9
diff --git a/public/resources/ts/globals.d.ts b/public/resources/ts/globals.d.ts
index 0940ec15a8..53fbfaece9 100644
--- a/public/resources/ts/globals.d.ts
+++ b/public/resources/ts/globals.d.ts
@@ -305,7 +305,6 @@ declare const calculated: SkyCryptPlayer & {
};
};
};
- dungeonsWeight: number;
journals: {
journal_entries: {
name: string;
@@ -362,7 +361,6 @@ declare const calculated: SkyCryptPlayer & {
unlocked_collections: boolean;
used_classes: boolean;
};
- dungeonsWeight: number;
enchanting: {
experimented: true;
experiments: {
@@ -593,8 +591,6 @@ declare const calculated: SkyCryptPlayer & {
};
purse: number;
rank_prefix: string;
- skillWeight: number;
- slayerWeight: number;
slayer_coins_spent: {
spider: number;
total: number;
@@ -619,7 +615,6 @@ declare const calculated: SkyCryptPlayer & {
currentLevel: number;
maxLevel: number;
progress: number;
- weight: { weight: number; weight_overflow: number };
xp: number;
xpForNext: number;
};
@@ -648,7 +643,6 @@ declare const calculated: SkyCryptPlayer & {
[key in StatName]: number;
};
};
- weight: number;
century_cakes: {
stat: string;
amount: number;
diff --git a/src/constants/weight/lily-weight.js b/src/constants/weight/lily-weight.js
deleted file mode 100644
index 7795bd37ce..0000000000
--- a/src/constants/weight/lily-weight.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import LilyWeight from "lilyweight";
-
-const SKILL_ORDER = ["enchanting", "taming", "alchemy", "mining", "farming", "foraging", "combat", "fishing"];
-const SLAYER_ORDER = ["zombie", "spider", "wolf", "enderman", "blaze"];
-
-/**
- * converts a dungeon floor into a completion map
- * @param {{[key:string]:{stats:{tier_completions:number}}}} floors
- * @returns {{[key:string]:number}}
- */
-function getTierCompletions(floors = {}) {
- return Object.fromEntries(
- Object.entries(floors)
- .map(([key, value]) => {
- if (key === "total" || key === "best") {
- return [];
- }
-
- return [key, value.stats.tier_completions ?? 0];
- })
- .filter(([, value]) => value > 0),
- );
-}
-
-export function calculateLilyWeight(userProfile) {
- const skillLevels = SKILL_ORDER.map((key) => userProfile.skills.skills[key].uncappedLevel);
- const skillXP = SKILL_ORDER.map((key) => userProfile.skills.skills[key].xp);
-
- const cataCompletions = getTierCompletions(userProfile.dungeons?.catacombs?.floors ?? {});
- const masterCataCompletions = getTierCompletions(userProfile.dungeons?.master_catacombs?.floors ?? {});
-
- const cataXP = userProfile.dungeons?.catacombs?.level?.xp ?? 0;
-
- const slayerXP = SLAYER_ORDER.map((key) => userProfile.slayer?.slayers?.[key]?.level?.xp ?? 0);
-
- return LilyWeight.getWeightRaw(skillLevels, skillXP, cataCompletions, masterCataCompletions, cataXP, slayerXP);
-}
diff --git a/src/constants/weight/senither-weight.js b/src/constants/weight/senither-weight.js
deleted file mode 100644
index 38c2f0e1ad..0000000000
--- a/src/constants/weight/senither-weight.js
+++ /dev/null
@@ -1,266 +0,0 @@
-// Weight Calculation by Senither (https://github.com/Senither/)
-
-const level50SkillExp = 55172425;
-const level60SkillExp = 111672425;
-
-// Skill Weight
-const skillWeight = {
- // Maxes out mining at 1,750 points at 60.
- mining: {
- exponent: 1.18207448,
- divider: 259634,
- maxLevel: 60,
- },
- // Maxes out foraging at 850 points at level 50.
- foraging: {
- exponent: 1.232826,
- divider: 259634,
- maxLevel: 50,
- },
- // Maxes out enchanting at 450 points at level 60.
- enchanting: {
- exponent: 0.96976583,
- divider: 882758,
- maxLevel: 60,
- },
- // Maxes out farming at 2,200 points at level 60.
- farming: {
- exponent: 1.217848139,
- divider: 220689,
- maxLevel: 60,
- },
- // Maxes out combat at 1,500 points at level 60.
- combat: {
- exponent: 1.15797687265,
- divider: 275862,
- maxLevel: 60,
- },
- // Maxes out fishing at 2,500 points at level 50.
- fishing: {
- exponent: 1.406418,
- divider: 88274,
- maxLevel: 50,
- },
- // Maxes out alchemy at 200 points at level 50.
- alchemy: {
- exponent: 1.0,
- divider: 1103448,
- maxLevel: 50,
- },
- // Maxes out taming at 500 points at level 50.
- taming: {
- exponent: 1.14744,
- divider: 441379,
- maxLevel: 50,
- },
- // Sets up carpentry and runecrafting without any weight components.
- carpentry: {
- maxLevel: 50,
- },
- runecrafting: {
- maxLevel: 25,
- },
- social: {
- maxLevel: 25,
- },
-};
-
-/**
- * Calculates the weight of a skill based on its skill group, level, and experience.
- *
- * @param {Object} skillGroup - The skill group object containing exponent, divider, and maxLevel properties.
- * @param {number} level - The level of the skill.
- * @param {number} experience - The experience of the skill.
- * @returns {{ weight: number, weight_overflow: number }} The weight and overflow weight of the skill.
- */
-function calcSkillWeight(skillGroup, level, experience) {
- if (!skillGroup.exponent || !skillGroup.divider || !level) {
- return { weight: 0, weight_overflow: 0 };
- }
-
- const maxSkillLevelXP = skillGroup.maxLevel === 60 ? level60SkillExp : level50SkillExp;
-
- let base = Math.pow(level * 10, 0.5 + skillGroup.exponent + level / 100) / 1250;
- base = experience > maxSkillLevelXP ? Math.round(base) : base;
-
- return {
- weight: base,
- weight_overflow:
- experience <= maxSkillLevelXP ? 0 : Math.pow((experience - maxSkillLevelXP) / skillGroup.divider, 0.968),
- };
-}
-
-// Dungeons Weight
-const dungeonsWeight = {
- catacombs: 0.0002149604615,
- healer: 0.0000045254834,
- mage: 0.0000045254834,
- berserk: 0.0000045254834,
- archer: 0.0000045254834,
- tank: 0.0000045254834,
-};
-
-/**
- * Calculates the weight and weight overflow of a dungeon type based on the level and experience.
- * @param {string} type - The type of dungeon.
- * @param {number} level - The level of the dungeon.
- * @param {number} experience - The experience of the dungeon.
- * @returns {{weight: number, weight_overflow: number}} - The weight and weight overflow of the dungeon type.
- */
-function calcDungeonsWeight(type, level, experience) {
- if (type.startsWith("master_")) {
- return { weight: 0, weight_overflow: 0 };
- }
-
- const percentageModifier = dungeonsWeight[type];
- const level50Experience = 569809640;
- const base = Math.pow(level, 4.5) * percentageModifier;
-
- if (experience <= level50Experience) {
- return { weight: base, weight_overflow: 0 };
- }
-
- const remaining = experience - level50Experience;
- const splitter = (4 * level50Experience) / base;
-
- return {
- weight: Math.floor(base),
- weight_overflow: Math.pow(remaining / splitter, 0.968),
- total_weight: Math.floor(base) + Math.pow(remaining / splitter, 0.968),
- };
-}
-
-// Slayer Weight
-const slayerWeight = {
- zombie: {
- divider: 2208,
- modifier: 0.15,
- },
- spider: {
- divider: 2118,
- modifier: 0.08,
- },
- wolf: {
- divider: 1962,
- modifier: 0.015,
- },
- enderman: {
- divider: 1430,
- modifier: 0.017,
- },
-};
-
-/**
- * Calculates the weight of a slayer type based on the experience gained.
- * @param {string} type - The type of slayer.
- * @param {number} experience - The amount of experience gained.
- * @returns {{ weight: number, weight_overflow: number }} The weight and overflow weight of the slayer.
- */
-function calcSlayerWeight(type, experience) {
- const sw = slayerWeight[type];
-
- if (!sw) {
- return { weight: 0, weight_overflow: 0 };
- }
-
- if (!experience || experience <= 1000000) {
- return { weight: experience ? experience / sw.divider : 0, weight_overflow: 0 };
- }
-
- const base = 1000000 / sw.divider;
- let remaining = experience - 1000000;
- let modifier = sw.modifier;
- let overflow = 0;
-
- while (remaining > 0) {
- const left = Math.min(remaining, 1000000);
- overflow += Math.pow(left / (sw.divider * (1.5 + modifier)), 0.942);
- modifier += sw.modifier;
- remaining -= left;
- }
-
- return { weight: base, weight_overflow: overflow };
-}
-
-export function calculateSenitherWeight(profile) {
- const output = {
- overall: 0,
- dungeon: {
- total: 0,
- dungeons: {},
- classes: {},
- },
- skill: {
- total: 0,
- skills: {},
- },
- slayer: {
- total: 0,
- slayers: {},
- },
- };
-
- // skill
- for (const skill in profile.skills.skills) {
- const skillData = profile.skills.skills[skill];
-
- const sw = calcSkillWeight(skillWeight[skill], skillData.unlockableLevelWithProgress, skillData.xp);
-
- output.skill.skills[skill] = {
- weight: sw.weight,
- overflow_weight: sw.weight_overflow,
- total_weight: sw.weight + sw.weight_overflow,
- };
-
- output.skill.total += output.skill.skills[skill].total_weight;
- }
-
- // dungeon weight
- const dungeons = profile.dungeons;
-
- if (dungeons?.catacombs?.visited) {
- const xp = dungeons.catacombs.level;
- const dungeonLevelWithProgress = Math.min(xp.levelWithProgress, 50);
-
- const dungeonsWeight = calcDungeonsWeight("catacombs", dungeonLevelWithProgress, xp.xp);
- output.dungeon.total += dungeonsWeight.weight + dungeonsWeight.weight_overflow ?? 0;
- output.dungeon.dungeons.catacombs = dungeonsWeight;
- }
-
- // dungeon classes
- if (dungeons?.classes?.classes) {
- for (const className of Object.keys(dungeons.classes.classes)) {
- const dungeonClass = dungeons.classes.classes[className];
- const xp = dungeonClass.level;
-
- const levelWithProgress = xp.levelWithProgress;
-
- const classWeight = calcDungeonsWeight(className, levelWithProgress, xp.xp);
-
- output.dungeon.classes[className] = classWeight;
-
- output.dungeon.total += classWeight.weight + classWeight.weight_overflow ?? 0;
- }
- }
-
- // slayer
- for (const slayerName in profile.slayer?.slayers) {
- const slayer = profile.slayer.slayers[slayerName];
-
- const sw = calcSlayerWeight(slayerName, slayer.level.xp);
-
- output.slayer.slayers[slayerName] = {
- weight: sw.weight,
- overflow_weight: sw.weight_overflow,
- total_weight: sw.weight + sw.weight_overflow,
- };
-
- output.slayer.total += output.slayer.slayers[slayerName].total_weight;
- }
-
- output.overall = [output.dungeon.total, output.skill.total, output.slayer.total]
- .filter((x) => x >= 0)
- .reduce((total, value) => total + value);
-
- return output;
-}
diff --git a/src/stats/weight.js b/src/stats/weight.js
index 2128cf5e78..810b8ae218 100644
--- a/src/stats/weight.js
+++ b/src/stats/weight.js
@@ -1,11 +1,7 @@
-import { calculateSenitherWeight } from "../constants/weight/senither-weight.js";
import { calculateFarmingWeight } from "../constants/weight/farming-weight.js";
-import { calculateLilyWeight } from "../constants/weight/lily-weight.js";
export function getWeight(userProfile) {
return {
- senither: calculateSenitherWeight(userProfile),
- lily: calculateLilyWeight(userProfile),
farming: calculateFarmingWeight(userProfile),
};
}
diff --git a/views/sections/stats/basic_stats.ejs b/views/sections/stats/basic_stats.ejs
index 281fe9d440..7f1d30e991 100644
--- a/views/sections/stats/basic_stats.ejs
+++ b/views/sections/stats/basic_stats.ejs
@@ -78,68 +78,6 @@
<% } %>
-
- <% if (calculated.weight) {
- const weightSystems = [
- {
- name: "Senither Weight",
- author: "Senither",
- skill: calculated.weight.senither.skill.total,
- slayer: calculated.weight.senither.slayer.total,
- dungeon: calculated.weight.senither.dungeon.total,
- total: calculated.weight.senither.overall,
- },
- {
- name: "Lily Weight",
- author: "LappySheep",
- skill: calculated.weight.lily.skill.base + calculated.weight.lily.skill.overflow,
- slayer: calculated.weight.lily.slayer,
- dungeon: calculated.weight.lily.catacombs.experience +
- calculated.weight.lily.catacombs.completion.base +
- calculated.weight.lily.catacombs.completion.master,
- total: calculated.weight.lily.total,
- },
- ];
-
- for (weight of weightSystems) {
- if ("runecrafting" in calculated.skills.skills === false) {
- weight.total -= weight.skill;
- weight.skill = 0;
- }
-
- if (weight.total === 0) {
- continue;
- } %>
-
-
-
- <%= weight.name %>:
- <%= parseFloat(Math.round(weight.total)).toLocaleString() %>
-
-
- <% } %>
- <% } %>
-
<% if (calculated.networth.noInventory === false) { %>