From de251d0741b908b994ba2791cc470df7f822ad93 Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 5 Sep 2022 02:16:05 +0200 Subject: [PATCH] checking if xp is nan --- backend/src/dal/user.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/dal/user.ts b/backend/src/dal/user.ts index e828fac84..4287bce91 100644 --- a/backend/src/dal/user.ts +++ b/backend/src/dal/user.ts @@ -498,6 +498,7 @@ export async function incrementBananas(uid: string, wpm): Promise { } export async function incrementXp(uid: string, xp: number): Promise { + if (isNaN(xp)) xp = 0; await getUsersCollection().updateOne({ uid }, { $inc: { xp: new Long(xp) } }); } @@ -811,7 +812,7 @@ function buildRewardUpdates( rewards.forEach((reward) => { if (reward.type === "xp") { - totalXp += reward.item; + totalXp += isNaN(reward.item) ? 0 : reward.item; } else if (reward.type === "badge") { newBadges.push(reward.item); }