mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* prevent "Zero-day streak" giving a 21-day streak achievement - fixes #2578 * add tests for streak achievements * remove .only from set of tests * refactor(test): fix linting
This commit is contained in:
@@ -238,14 +238,14 @@ module.exports = function scoreTask (options = {}, req = {}) {
|
||||
if (direction === 'up') {
|
||||
task.streak += 1;
|
||||
// Give a streak achievement when the streak is a multiple of 21
|
||||
if (task.streak % 21 === 0) {
|
||||
if (task.streak !== 0 && task.streak % 21 === 0) {
|
||||
user.achievements.streak = user.achievements.streak ? user.achievements.streak + 1 : 1;
|
||||
if (user.addNotification) user.addNotification('STREAK_ACHIEVEMENT');
|
||||
}
|
||||
task.completed = true;
|
||||
} else if (direction === 'down') {
|
||||
// Remove a streak achievement if streak was a multiple of 21 and the daily was undone
|
||||
if (task.streak % 21 === 0) user.achievements.streak = user.achievements.streak ? user.achievements.streak - 1 : 0;
|
||||
if (task.streak !== 0 && task.streak % 21 === 0) user.achievements.streak = user.achievements.streak ? user.achievements.streak - 1 : 0;
|
||||
task.streak -= 1;
|
||||
task.completed = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user