Skip to content

Commit bf23cf3

Browse files
committed
Fix rounding errors when calculating level based on XP
1 parent 277fa99 commit bf23cf3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default createStore({
2222
);
2323
const xp = Math.max(task.difficulty * task.priority, 1); //get at least 1 xp when the task is completed
2424
state.user.xp += xp;
25-
state.user.level = Math.floor(Math.pow(state.user.xp, 1 / 3)); //calculate level based on how many xp
25+
state.user.level = Math.floor(Math.pow(state.user.xp, 1 / 3 + 5e-16)); //calculate level based on how many xp
2626
state.user.progress =
2727
((state.user.xp - Math.pow(state.user.level, 3)) /
2828
(Math.pow(state.user.level + 1, 3) - Math.pow(state.user.level, 3))) *

0 commit comments

Comments
 (0)