mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
WIP(teams): don't damage leader for incomplete team Dailies
This commit is contained in:
@@ -104,6 +104,7 @@ function _gainMP (user, val) {
|
|||||||
// ===== CONSTITUTION =====
|
// ===== CONSTITUTION =====
|
||||||
// TODO Decreases HP loss from bad habits / missed dailies by 0.5% per point.
|
// TODO Decreases HP loss from bad habits / missed dailies by 0.5% per point.
|
||||||
function _subtractPoints (user, task, stats, delta) {
|
function _subtractPoints (user, task, stats, delta) {
|
||||||
|
if (task.group.id && !task.userId) return stats.hp;
|
||||||
let conBonus = 1 - statsComputed(user).con / 250;
|
let conBonus = 1 - statsComputed(user).con / 250;
|
||||||
if (conBonus < 0.1) conBonus = 0.1;
|
if (conBonus < 0.1) conBonus = 0.1;
|
||||||
|
|
||||||
|
|||||||
@@ -352,17 +352,18 @@ export async function cron (options = {}) {
|
|||||||
if (!user.party.quest.progress.down) user.party.quest.progress.down = 0;
|
if (!user.party.quest.progress.down) user.party.quest.progress.down = 0;
|
||||||
|
|
||||||
tasksByType.dailys.forEach(task => {
|
tasksByType.dailys.forEach(task => {
|
||||||
|
const isTeamBoardTask = task.group.id && !task.userId;
|
||||||
if (
|
if (
|
||||||
task.group.assignedDate
|
!isTeamBoardTask && task.group.assignedDate
|
||||||
&& moment(task.group.assignedDate).isAfter(user.auth.timestamps.updated)
|
&& moment(task.group.assignedDate).isAfter(user.auth.timestamps.updated)
|
||||||
) return;
|
) return;
|
||||||
const { completed } = task;
|
const { completed } = task;
|
||||||
// Deduct points for missed Daily tasks
|
// Deduct points for missed Daily tasks
|
||||||
let EvadeTask = 0;
|
let evadeTask = 0;
|
||||||
let scheduleMisses = daysMissed;
|
let scheduleMisses = daysMissed;
|
||||||
|
|
||||||
if (completed) {
|
if (completed) {
|
||||||
dailyChecked += 1;
|
if (!isTeamBoardTask) dailyChecked += 1;
|
||||||
if (!atLeastOneDailyDue) { // only bother checking until the first thing is found
|
if (!atLeastOneDailyDue) { // only bother checking until the first thing is found
|
||||||
const thatDay = moment(now).subtract({ days: daysMissed });
|
const thatDay = moment(now).subtract({ days: daysMissed });
|
||||||
atLeastOneDailyDue = shouldDo(thatDay.toDate(), task, user.preferences);
|
atLeastOneDailyDue = shouldDo(thatDay.toDate(), task, user.preferences);
|
||||||
@@ -377,15 +378,15 @@ export async function cron (options = {}) {
|
|||||||
if (shouldDo(thatDay.toDate(), task, user.preferences)) {
|
if (shouldDo(thatDay.toDate(), task, user.preferences)) {
|
||||||
atLeastOneDailyDue = true;
|
atLeastOneDailyDue = true;
|
||||||
scheduleMisses += 1;
|
scheduleMisses += 1;
|
||||||
if (user.stats.buffs.stealth) {
|
if (user.stats.buffs.stealth && !isTeamBoardTask) {
|
||||||
user.stats.buffs.stealth -= 1;
|
user.stats.buffs.stealth -= 1;
|
||||||
EvadeTask += 1;
|
evadeTask += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (multiDaysCountAsOneDay) break;
|
if (multiDaysCountAsOneDay) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scheduleMisses > EvadeTask) {
|
if (scheduleMisses > evadeTask) {
|
||||||
// The user did not complete this due Daily
|
// The user did not complete this due Daily
|
||||||
// (but no penalty if cron is running in safe mode).
|
// (but no penalty if cron is running in safe mode).
|
||||||
if (CRON_SAFE_MODE) {
|
if (CRON_SAFE_MODE) {
|
||||||
@@ -411,7 +412,7 @@ export async function cron (options = {}) {
|
|||||||
user,
|
user,
|
||||||
task,
|
task,
|
||||||
direction: 'down',
|
direction: 'down',
|
||||||
times: multiDaysCountAsOneDay ? 1 : scheduleMisses - EvadeTask,
|
times: multiDaysCountAsOneDay ? 1 : scheduleMisses - evadeTask,
|
||||||
cron: true,
|
cron: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user