Skip to content

Commit 3a39421

Browse files
committed
Add XP multiplier based on active task count
1 parent 36cbbf9 commit 3a39421

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def complete_task(task_id): # complete task from task id
226226
else: # if the task repetition interval is one-time
227227
repeat_multiplier = 5 # get 5x XP multiplier for one-time tasks
228228
user = User.query.first() # get first user
229+
active_tasks = Task.query.filter_by(
230+
completed=False
231+
).count() # get number of active tasks (tasks that are not completed)
229232
if user:
230233
user.add_xp(
231234
round(
@@ -235,6 +238,7 @@ def complete_task(task_id): # complete task from task id
235238
* repeat_multiplier
236239
* (1 + math.log(max(task.times_completed, 1)))
237240
* (1 + math.log(max(user.tasks_completed, 1)))
241+
* (1 + math.log(max(active_tasks, 1)))
238242
)
239243
) # add XP
240244
db.session.commit() # commit database changes

0 commit comments

Comments
 (0)