Skip to content

Commit df63bd9

Browse files
committed
Fix rating calculation
1 parent e14db42 commit df63bd9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/store/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ export default createStore({
238238
if (daysSinceLastCompletion >= 1) {
239239
//repeat for each day of inactivity
240240
for (let i = 0; i < daysSinceLastCompletion; i++) {
241-
state.user.rating -=
241+
state.user.rating -= Math.max(
242242
Math.sqrt(Math.max(state.user.rating, 0)) *
243-
(1 + Math.log(Math.max(i + 1, 1))) *
244-
(1 + Math.log(Math.max(overdueTasks + 1, 1))); //decrease user rating for each day of inactivity
243+
(1 + Math.log(Math.max(i + 1, 1))) *
244+
(1 + Math.log(Math.max(overdueTasks + 1, 1))),
245+
0,
246+
); //decrease user rating for each day of inactivity
245247
state.user.rating = Math.max(state.user.rating, 0); //make sure rating is not below 0
246248
}
247249
}
@@ -611,13 +613,15 @@ export default createStore({
611613
1,
612614
); //get at least 1 XP when the task is completed
613615
state.user.xp += xpEarned; //get the amount of XP earned based on task difficulty, task priority, task due date, task repetition, task streak, daily streak and task rank multipliers
614-
state.user.rating +=
616+
state.user.rating += Math.max(
615617
(10 + Math.log(Math.max(state.user.rating + 100, 100)) ** 2) *
616618
repeatMultiplier *
617619
dateMultiplier <
618-
1
620+
1
619621
? 1 - dateMultiplier
620-
: (dateMultiplier - 1) / Math.max(state.user.tasksCompletedToday, 1); //get the amount of rating poings earned based on user rating, task repeat multiplier and number of tasks completed today
622+
: (dateMultiplier - 1) / Math.max(state.user.tasksCompletedToday, 1),
623+
0,
624+
); //get the amount of rating poings earned based on user rating, task repeat multiplier and number of tasks completed today
621625
state.user.rating = Math.max(state.user.rating, 0); //make sure user rating is not below 0
622626
const pointsEarned: number = Math.max(
623627
Math.floor(

0 commit comments

Comments
 (0)