mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
implement cron semi-safe mode - cron behaves as normal except boss causes no damage (#7462)
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
"TEST_DB_URI":"mongodb://localhost/habitrpg_test",
|
"TEST_DB_URI":"mongodb://localhost/habitrpg_test",
|
||||||
"NODE_ENV":"development",
|
"NODE_ENV":"development",
|
||||||
"CRON_SAFE_MODE":"false",
|
"CRON_SAFE_MODE":"false",
|
||||||
|
"CRON_SEMI_SAFE_MODE":"false",
|
||||||
"MAINTENANCE_MODE": "false",
|
"MAINTENANCE_MODE": "false",
|
||||||
"SESSION_SECRET":"YOUR SECRET HERE",
|
"SESSION_SECRET":"YOUR SECRET HERE",
|
||||||
"ADMIN_EMAIL": "you@example.com",
|
"ADMIN_EMAIL": "you@example.com",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import _ from 'lodash';
|
|||||||
import nconf from 'nconf';
|
import nconf from 'nconf';
|
||||||
|
|
||||||
const CRON_SAFE_MODE = nconf.get('CRON_SAFE_MODE') === 'true';
|
const CRON_SAFE_MODE = nconf.get('CRON_SAFE_MODE') === 'true';
|
||||||
|
const CRON_SEMI_SAFE_MODE = nconf.get('CRON_SEMI_SAFE_MODE') === 'true';
|
||||||
const shouldDo = common.shouldDo;
|
const shouldDo = common.shouldDo;
|
||||||
const scoreTask = common.ops.scoreTask;
|
const scoreTask = common.ops.scoreTask;
|
||||||
// const maxPMs = 200;
|
// const maxPMs = 200;
|
||||||
@@ -175,6 +176,7 @@ export function cron (options = {}) {
|
|||||||
cron: true,
|
cron: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!CRON_SEMI_SAFE_MODE) {
|
||||||
// Apply damage from a boss, less damage for Trivial priority (difficulty)
|
// Apply damage from a boss, less damage for Trivial priority (difficulty)
|
||||||
user.party.quest.progress.down += delta * (task.priority < 1 ? task.priority : 1);
|
user.party.quest.progress.down += delta * (task.priority < 1 ? task.priority : 1);
|
||||||
// NB: Medium and Hard priorities do not increase damage from boss. This was by accident
|
// NB: Medium and Hard priorities do not increase damage from boss. This was by accident
|
||||||
@@ -185,6 +187,7 @@ export function cron (options = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
task.history.push({
|
task.history.push({
|
||||||
date: Number(new Date()),
|
date: Number(new Date()),
|
||||||
|
|||||||
@@ -517,7 +517,8 @@ schema.statics.bossQuest = async function bossQuest (user, progress) {
|
|||||||
group.quest.progress.hp -= progress.up;
|
group.quest.progress.hp -= progress.up;
|
||||||
// TODO Create a party preferred language option so emits like this can be localized. Suggestion: Always display the English version too. Or, if English is not displayed to the players, at least include it in a new field in the chat object that's visible in the database - essential for admins when troubleshooting quests!
|
// TODO Create a party preferred language option so emits like this can be localized. Suggestion: Always display the English version too. Or, if English is not displayed to the players, at least include it in a new field in the chat object that's visible in the database - essential for admins when troubleshooting quests!
|
||||||
let playerAttack = `${user.profile.name} attacks ${quest.boss.name('en')} for ${progress.up.toFixed(1)} damage.`;
|
let playerAttack = `${user.profile.name} attacks ${quest.boss.name('en')} for ${progress.up.toFixed(1)} damage.`;
|
||||||
let bossAttack = nconf.get('CRON_SAFE_MODE') === 'true' ? `${quest.boss.name('en')} did not attack the party because it was asleep while maintenance was happening.` : `${quest.boss.name('en')} attacks party for ${Math.abs(down).toFixed(1)} damage.`;
|
let bossAttack = nconf.get('CRON_SAFE_MODE') === 'true' || nconf.get('CRON_SEMI_SAFE_MODE') === 'true' ? `${quest.boss.name('en')} does not attack, because it respects the fact that there are some bugs\` \`post-maintenance and it doesn't want to hurt anyone unfairly. It will continue its rampage soon!` : `${quest.boss.name('en')} attacks party for ${Math.abs(down).toFixed(1)} damage.`;
|
||||||
|
// TODO Consider putting the safe mode boss attack message in an ENV var
|
||||||
group.sendChat(`\`${playerAttack}\` \`${bossAttack}\``);
|
group.sendChat(`\`${playerAttack}\` \`${bossAttack}\``);
|
||||||
|
|
||||||
// If boss has Rage, increment Rage as well
|
// If boss has Rage, increment Rage as well
|
||||||
|
|||||||
Reference in New Issue
Block a user