From c8c4bf2d5669fbcb7938e157d2ec8b1e4453b01a Mon Sep 17 00:00:00 2001 From: Lucas <100660343+lulunac27a@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:31:25 -0500 Subject: [PATCH 1/2] Fix rounding errors Sometimes, the points' value that are earned is not exactly an integer because of rounding errors. --- src/view.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view.ts b/src/view.ts index cdbca97..1211473 100644 --- a/src/view.ts +++ b/src/view.ts @@ -284,7 +284,7 @@ export class GamifiedPkmProfileView extends ItemView { updatePoints(newPoints: number) { const pointsValue = this.containerEl.querySelector('#points-value'); if (pointsValue) { - pointsValue.textContent = newPoints.toString(); + pointsValue.textContent = Math.round(newPoints).toString(); } } From bb0aa4a3058e1fe44e2dfaad16d95103151421b5 Mon Sep 17 00:00:00 2001 From: Lucas <100660343+lulunac27a@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:36:46 -0500 Subject: [PATCH 2/2] Fix additional rounding errors The points' values earned by calculating note maturity can return non-integer values because of rounding errors --- src/randomNotificationText.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/randomNotificationText.ts b/src/randomNotificationText.ts index b14a445..1b93855 100644 --- a/src/randomNotificationText.ts +++ b/src/randomNotificationText.ts @@ -218,21 +218,21 @@ const boosterFactorMessage : string[] = [ export function getRandomMessageWeeklyChallenge(points: number): string { const randomIndex = Math.floor(Math.random() * messagesWeeklyChallenge.length); const message = messagesWeeklyChallenge[randomIndex]; - return message.replace("[X]", points.toString()); + return message.replace("[X]", Math.round(points).toString()); } export function getRandomMessageTwoNoteChallenge(points: number): string { const randomIndex = Math.floor(Math.random() * twoNoteMessages.length); const message = twoNoteMessages[randomIndex]; - return message.replace("[X]", points.toString()); + return message.replace("[X]", Math.round(points).toString()); } export function getRandomMessagePoints(points: number): string { const randomIndex = Math.floor(Math.random() * randomPointNotices.length); const message = randomPointNotices[randomIndex]; - return message.replace("[X]", points.toString()); + return message.replace("[X]", Math.round(points).toString()); } export function getRandomMessageBoosterFactor(): string {