Skip to content

Commit d43a96e

Browse files
committed
Add comments and make comments easier to read and format HTML by adding lines after each task values
1 parent 174791c commit d43a96e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/TodoList.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
v-bind:class="{
1515
overdue: new Date(todo.dueDate + ' 23:59:59.999') < new Date(),
1616
}"
17-
>{{ todo.task }}: Streak: {{ todo.streak }} Due
18-
{{ todo.dueDate }} Priority: {{ todo.priority }} Difficulty:
19-
{{ todo.difficulty }} Repeat:
17+
>{{ todo.task }}: <br />Streak: {{ todo.streak }} <br />Due date:
18+
{{ todo.dueDate }} <br />Priority: {{ todo.priority }}
19+
<br />Difficulty: {{ todo.difficulty }} <br />Repeat:
2020
<span v-if="todo.repeatFrequency != 5">{{ todo.repeatOften }}</span
2121
>&nbsp;<span v-if="todo.repeatFrequency == 1">Day</span
2222
><span v-if="todo.repeatFrequency == 2">Week</span
@@ -27,7 +27,7 @@
2727
>s</span
2828
></span
2929
>
30-
<!--don't show if one-time task is completed--><button
30+
<!--don't show complete button if one-time task is completed--><button
3131
v-if="!todo.completed"
3232
@click="completeTodo(todo.newId)"
3333
>

src/store/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default createStore({
3333
daysToDue < 0 ? -3 / (daysToDue - 1) : 1 + 1 / (daysToDue + 1); //if task is overdue, xp multiplier is less than 1 that decreases over time when task is overdue, else xp multiplier bonus increases (more than 1) when task gets closer to due date
3434
let streakMultiplier: number; //calculate task streak multiplier based on task streak, if task is completed before the due date then the streak increases else if the task is completed overdue (after the due date) reset task streak to 0
3535
let repeatMultiplier: number; //calculate task repetition multiplier based on task repetition occurance and task repetition frequency
36+
//calculate task repeition multiplier
3637
if (task.repeatFrequency == 1) {
3738
//if task repetition is daily
3839
if (task.repeatOften < 7) {
@@ -73,15 +74,17 @@ export default createStore({
7374
//if task repetition is one-time
7475
repeatMultiplier = 5; //get 5x xp multiplier for one-time tasks
7576
}
77+
//calculate task streak
7678
if (daysToDue < 0) {
7779
//if task is overdue
7880
task.streak = 0; //reset task streak to 0
7981
} else {
8082
//if task is completed before due date (not overdue)
8183
task.streak++; //increase task streak
8284
}
83-
if (task.streak == 0) {
84-
streakMultiplier = 1; //1x task streak multiplier
85+
//calculate task streak multiplier
86+
if (task.streak == 0 || task.repeatFreqnency == 5) {
87+
streakMultiplier = 1; //1x task streak multiplier if task streak is 0 or completed a one-time task
8588
} else if (task.streak < 5) {
8689
streakMultiplier = 1.1 + 0.05 * (task.streak - 1); //1.1x task streak multiplier from 1 streak plus 0.05x streak multiplier for each task streak
8790
} else if (task.streak < 10) {
@@ -101,6 +104,7 @@ export default createStore({
101104
} else {
102105
streakMultiplier = 3; //3x task streak multiplier from 1000 task streak
103106
}
107+
//calculate amount of xp earned when task is completed
104108
const xp: number = Math.max(
105109
Math.floor(
106110
task.difficulty *

0 commit comments

Comments
 (0)