You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/store/index.ts
+45-2Lines changed: 45 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,54 @@ export default createStore({
26
26
(1000*24*60*60);//calculate number of days until the task is due
27
27
constdateMultiplier: number=
28
28
daysToDue<0 ? 0.5 : 1+1/(daysToDue+1);//if task is overdue, xp multiplier is half the amount, else xp multiplier bonus increases when task gets closer to due date
29
+
letrepeatMultiplier: number;//calculate task repetition multiplier based on task repetition occurance and task repetition frequency
30
+
if(task.repeatFrequency==1){
31
+
//if task repetition is daily
32
+
if(task.repeatOften<7){
33
+
//7 days is 1 week
34
+
repeatMultiplier=1+(task.repeatOften-1)/(7-1);//1x xp multiplier for daily tasks (1 day) to 2x xp multiplier for weekly tasks (7 days)
35
+
}elseif(task.repeatOften<30){
36
+
//approximately 30 days is 1 month
37
+
repeatMultiplier=2+(task.repeatOften-7)/(30-7);//2x xp multiplier for weekly tasks (7 days) to 3x xp multiplier for monthly tasks (approximately 30 days)
38
+
}elseif(task.repeatOften<365){
39
+
//approximately 365 days is 1 year
40
+
repeatMultiplier=3+(task.repeatOften-30)/(365-30);//3x xp multiplier for monthly tasks (approximately 30 days) to 4x xp multiplier for yearly tasks (approximately 365 days)
41
+
}else{
42
+
repeatMultiplier=5-365/task.repeatOften;//4x xp multiplier for yearly tasks (approximately 365 days) to 5x xp multiplier for one-time tasks
43
+
}
44
+
}elseif(task.repeatFrequency==2){
45
+
//if task repetition is weekly
46
+
if(task.repeatOften<4){
47
+
//approximately 4 weeks is 1 month
48
+
repeatMultiplier=2+(task.repeatOften-1)/(4-1);//2x xp multiplier for weekly tasks (1 week) to 3x xp multiplier for monthly tasks (approximately 4 weeks)
49
+
}elseif(task.repeatOften<52){
50
+
//approximately 52 weeks is 1 year
51
+
repeatMultiplier=3+(task.repeatOften-4)/(52-4);//3x xp multiplier for monthly tasks (approximately 4 weeks) to 4x xp multiplier for yearly tasks (approximately 52 weeks)
52
+
}else{
53
+
repeatMultiplier=5-52/task.repeatOften;//4x xp multiplier for yearly tasks (approximately 52 weeks) to 5x xp multiplier for one-time tasks
54
+
}
55
+
}elseif(task.repeatFrequency==3){
56
+
//if task repetition is monthly
57
+
if(task.repeatOften<12){
58
+
//12 months is 1 year
59
+
repeatMultiplier=3+(task.repeatOften-1)/(12-1);//3x xp multiplier for monthly tasks (1 month) to 4x xp multiplier for yearly tasks (12 months)
60
+
}else{
61
+
repeatMultiplier=5-12/task.repeatOften;//4x xp multiplier for yearly tasks (12 months) to 5x xp multiplier for one-time tasks
62
+
}
63
+
}elseif(task.repeatFrequency==4){
64
+
//if task repetition is yearly
65
+
repeatMultiplier=5-1/task.repeatOften;//4x xp multiplier for yearly tasks (1 year) to 5x xp multiplier for one-time tasks
66
+
}else{
67
+
//if task repetition is one-time
68
+
repeatMultiplier=5;//get 5x xp multiplier for one-time tasks
0 commit comments