From 662907473ac506400c0735c934bfca417e9f6019 Mon Sep 17 00:00:00 2001 From: Has Name <65046191+zisis912@users.noreply.github.com> Date: Fri, 28 Jul 2023 01:11:16 +0300 Subject: [PATCH 1/3] add xp getter function --- index.d.ts | 1 + lib/plugins/experience.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/index.d.ts b/index.d.ts index 1b83acbc7..c050cadbb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -503,6 +503,7 @@ export interface Experience { level: number points: number progress: number + getXpPoints: () => number } export interface PhysicsOptions { diff --git a/lib/plugins/experience.js b/lib/plugins/experience.js index 1c8334ac3..dfa2e997d 100644 --- a/lib/plugins/experience.js +++ b/lib/plugins/experience.js @@ -12,4 +12,12 @@ function inject (bot) { bot.experience.progress = packet.experienceBar bot.emit('experience') }) + + bot.experience.getXpPoints() = function () { + let levelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level) + let incrementedLevelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level + 1) + let xpForNextLevel = incrementedLevelToXpPoints - levelToXpPoints + + return Math.floor(levelToXpPoints + bot.experience.progress * xpForNextLevel) + } } From b75b3ccafbb958a95ea5417b3d21d68c6bda62ae Mon Sep 17 00:00:00 2001 From: Has Name <65046191+zisis912@users.noreply.github.com> Date: Fri, 28 Jul 2023 01:17:38 +0300 Subject: [PATCH 2/3] Update experience.js --- lib/plugins/experience.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/experience.js b/lib/plugins/experience.js index dfa2e997d..47049eeb2 100644 --- a/lib/plugins/experience.js +++ b/lib/plugins/experience.js @@ -13,7 +13,7 @@ function inject (bot) { bot.emit('experience') }) - bot.experience.getXpPoints() = function () { + bot.experience.getXpPoints = function () { let levelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level) let incrementedLevelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level + 1) let xpForNextLevel = incrementedLevelToXpPoints - levelToXpPoints From cdd0f5c26e4b2c5c18f0cd838f49693494526990 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 29 Jul 2023 08:31:32 +0000 Subject: [PATCH 3/3] Fix linting errors --- lib/plugins/experience.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/plugins/experience.js b/lib/plugins/experience.js index 47049eeb2..e31e75537 100644 --- a/lib/plugins/experience.js +++ b/lib/plugins/experience.js @@ -14,9 +14,9 @@ function inject (bot) { }) bot.experience.getXpPoints = function () { - let levelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level) - let incrementedLevelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level + 1) - let xpForNextLevel = incrementedLevelToXpPoints - levelToXpPoints + const levelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level) + const incrementedLevelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level + 1) + const xpForNextLevel = incrementedLevelToXpPoints - levelToXpPoints return Math.floor(levelToXpPoints + bot.experience.progress * xpForNextLevel) }