Skip to content

Commit

Permalink
Merge pull request #79 from lulunac27a/patch-1
Browse files Browse the repository at this point in the history
Fix rounding errors
  • Loading branch information
saertna authored Dec 7, 2024
2 parents 1d06cba + bb0aa4a commit bde03e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/randomNotificationText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit bde03e0

Please sign in to comment.