steamutils 1.4.96 → 1.4.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils.js +37 -0
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -985,3 +985,40 @@ export async function loginWithCredentials({ username, password, timeoutMs = 120
|
|
985
985
|
}
|
986
986
|
});
|
987
987
|
}
|
988
|
+
|
989
|
+
export function calculateAccountXP(currentXp, xpEarnedThisWeek, xpEarned, nextXp) {
|
990
|
+
return (
|
991
|
+
(() => {
|
992
|
+
if (typeof nextXp !== "number" || !Number.isFinite(nextXp)) {
|
993
|
+
return;
|
994
|
+
}
|
995
|
+
|
996
|
+
currentXp = currentXp || 0;
|
997
|
+
if (currentXp === nextXp) {
|
998
|
+
return;
|
999
|
+
}
|
1000
|
+
|
1001
|
+
const update = { currentXp: nextXp };
|
1002
|
+
if (nextXp < currentXp) {
|
1003
|
+
update.xpExceed = Date.now();
|
1004
|
+
}
|
1005
|
+
const resetDay = getBonusXpTimeRefresh().format("YYYY-MM-DD");
|
1006
|
+
const isWeekReset = xpEarnedThisWeek !== resetDay;
|
1007
|
+
let xpEarnedThisRank = nextXp - currentXp;
|
1008
|
+
if (xpEarnedThisRank < 0) {
|
1009
|
+
xpEarnedThisRank += 5000;
|
1010
|
+
}
|
1011
|
+
if (isWeekReset) {
|
1012
|
+
update.xpEarnedThisWeek = resetDay;
|
1013
|
+
update.xpEarned = xpEarnedThisRank;
|
1014
|
+
} else {
|
1015
|
+
update.xpEarned = (xpEarned || 0) + xpEarnedThisRank;
|
1016
|
+
if (xpEarnedThisRank === 0) {
|
1017
|
+
return;
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
return update;
|
1022
|
+
})() || {}
|
1023
|
+
);
|
1024
|
+
}
|