Critical Hits now affect boss damage fixes #5429 (#8092)

* Moved critical hit calculation from _addPoints() to _calculateDelta(). Added user as an input argument to _calculateDelta() so for critical hit calculation

* Changed test to expect task value of 1.5 after critical hit

* Revert "Moved critical hit calculation from _addPoints() to _calculateDelta(). Added user as an input argument to _calculateDelta() so for critical hit calculation"

This reverts commit 51b8ab6498.

* Moved critical hit calculation to _changeTaskValue(). Use value stored in user._tmp.crit in _addPoints()

* Test is no longer affected by critical hits

* Removed unneeded comment

* Added WIP test of critical hits

* Want the crit function to return 2 to test critical hits

* Changed crit function to export as a function within an object so that it can be stubbed for testing. References to the crit() function were updated to call crit.crit() instead

* Added test for increased experience on critical hits
This commit is contained in:
Alyssa Batula
2017-01-18 10:11:39 -05:00
committed by Keith Holliday
parent fa024e071b
commit 016447ec77
5 changed files with 43 additions and 11 deletions

View File

@@ -103,11 +103,7 @@ function _subtractPoints (user, task, stats, delta) {
}
function _addPoints (user, task, stats, direction, delta) {
// ===== CRITICAL HITS =====
// allow critical hit only when checking off a task, not when unchecking it:
let _crit = delta > 0 ? crit(user) : 1;
// if there was a crit, alert the user via notification
if (_crit > 1) user._tmp.crit = _crit;
let _crit = user._tmp.crit || 1;
// Exp Modifier
// ===== Intelligence =====
@@ -138,6 +134,12 @@ function _addPoints (user, task, stats, direction, delta) {
function _changeTaskValue (user, task, direction, times, cron) {
let addToDelta = 0;
// ===== CRITICAL HITS =====
// allow critical hit only when checking off a task, not when unchecking it:
let _crit = direction === 'up' ? crit.crit(user) : 1;
// if there was a crit, alert the user via notification
if (_crit > 1) user._tmp.crit = _crit;
// If multiple days have passed, multiply times days missed
_.times(times, () => {
// Each iteration calculate the nextDelta, which is then accumulated in the total delta.
@@ -153,9 +155,9 @@ function _changeTaskValue (user, task, direction, times, cron) {
let prevProgress = user.party.quest.progress.up;
if (task.type === 'todo' || task.type === 'daily') {
user.party.quest.progress.up += nextDelta * (1 + user._statsComputed.str / 200);
user.party.quest.progress.up += nextDelta * _crit * (1 + user._statsComputed.str / 200);
} else if (task.type === 'habit') {
user.party.quest.progress.up += nextDelta * (0.5 + user._statsComputed.str / 400);
user.party.quest.progress.up += nextDelta * _crit * (0.5 + user._statsComputed.str / 400);
}
if (!user._tmp.quest) user._tmp.quest = {};