mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* 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:
committed by
Keith Holliday
parent
fa024e071b
commit
016447ec77
@@ -1,4 +1,5 @@
|
||||
import scoreTask from '../../../website/common/script/ops/scoreTask';
|
||||
|
||||
import {
|
||||
generateUser,
|
||||
generateDaily,
|
||||
@@ -11,6 +12,7 @@ import i18n from '../../../website/common/script/i18n';
|
||||
import {
|
||||
NotAuthorized,
|
||||
} from '../../../website/common/script/libs/errors';
|
||||
import crit from '../../../website/common/script/fns/crit';
|
||||
|
||||
let EPSILON = 0.0001; // negligible distance between datapoints
|
||||
|
||||
@@ -142,6 +144,32 @@ describe('shared.ops.scoreTask', () => {
|
||||
expect(ref.beforeUser._id).to.eql(ref.afterUser._id);
|
||||
});
|
||||
|
||||
it('critical hits', () => {
|
||||
let normalUser = ref.beforeUser;
|
||||
expect(normalUser.party.quest.progress.up).to.eql(0);
|
||||
normalUser.party.quest.key = 'gryphon';
|
||||
let critUser = ref.afterUser;
|
||||
expect(critUser.party.quest.progress.up).to.eql(0);
|
||||
critUser.party.quest.key = 'gryphon';
|
||||
let normalTask = todo;
|
||||
let critTask = freshTodo;
|
||||
|
||||
scoreTask({ user: normalUser, task: normalTask, direction: 'up', cron: false });
|
||||
let normalTaskDelta = normalUser.party.quest.progress.up;
|
||||
|
||||
sandbox.stub(crit, 'crit').returns(1.5);
|
||||
scoreTask({ user: critUser, task: critTask, direction: 'up', cron: false });
|
||||
let critTaskDelta = critUser.party.quest.progress.up;
|
||||
crit.crit.restore();
|
||||
|
||||
expect(critUser.stats.hp).to.eql(normalUser.stats.hp);
|
||||
expect(critUser.stats.gp).to.be.greaterThan(normalUser.stats.gp);
|
||||
expect(critUser.stats.mp).to.be.greaterThan(normalUser.stats.mp);
|
||||
expect(critUser.stats.exp).to.be.greaterThan(normalUser.stats.exp);
|
||||
expect(critTask.value).to.eql(normalTask.value);
|
||||
expect(critTaskDelta).to.be.greaterThan(normalTaskDelta);
|
||||
});
|
||||
|
||||
it('and increments quest progress', () => {
|
||||
expect(ref.afterUser.party.quest.progress.up).to.eql(0);
|
||||
ref.afterUser.party.quest.key = 'gryphon';
|
||||
|
||||
Reference in New Issue
Block a user