add routes for buy ops and integration tests
This commit is contained in:
@@ -94,6 +94,9 @@ api.noTags = noTags;
|
||||
import appliedTags from './libs/appliedTags';
|
||||
api.appliedTags = appliedTags;
|
||||
|
||||
import pickDeep from './libs/pickDeep';
|
||||
api.pickDeep = pickDeep;
|
||||
|
||||
import count from './count';
|
||||
api.count = count;
|
||||
|
||||
@@ -101,11 +104,19 @@ api.count = count;
|
||||
import scoreTask from './ops/scoreTask';
|
||||
import sleep from './ops/sleep';
|
||||
import allocate from './ops/allocate';
|
||||
import buy from './ops/buy';
|
||||
import buyMysterySet from './ops/buyMysterySet';
|
||||
import buyQuest from './ops/buyQuest';
|
||||
import buySpecialSpell from './ops/buySpecialSpell';
|
||||
|
||||
api.ops = {
|
||||
scoreTask,
|
||||
sleep,
|
||||
allocate,
|
||||
buy,
|
||||
buyMysterySet,
|
||||
buySpecialSpell,
|
||||
buyQuest,
|
||||
};
|
||||
|
||||
import handleTwoHanded from './fns/handleTwoHanded';
|
||||
|
||||
+13
-10
@@ -106,15 +106,17 @@ module.exports = function buy (user, req = {}, analytics) {
|
||||
}
|
||||
user.items.gear.owned[item.key] = true;
|
||||
|
||||
if (!message) {
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language);
|
||||
}
|
||||
if (item.last) ultimateGear(user);
|
||||
}
|
||||
|
||||
user.stats.gp -= item.value;
|
||||
|
||||
if (!message) {
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language);
|
||||
}
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('acquire item', {
|
||||
uuid: user._id,
|
||||
@@ -125,11 +127,12 @@ module.exports = function buy (user, req = {}, analytics) {
|
||||
});
|
||||
}
|
||||
|
||||
let buyResp = _.pick(user, splitWhitespace('items achievements stats flags'));
|
||||
if (armoireResp) buyResp.armoire = armoireResp;
|
||||
|
||||
return {
|
||||
data: buyResp,
|
||||
let res = {
|
||||
data: _.pick(user, splitWhitespace('items achievements stats flags')),
|
||||
message,
|
||||
};
|
||||
|
||||
if (armoireResp) res.armoire = armoireResp;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
NotFound,
|
||||
} from '../libs/errors';
|
||||
import _ from 'lodash';
|
||||
|
||||
// buy a quest with gold
|
||||
module.exports = function buyQuest (user, req = {}, analytics) {
|
||||
let key = _.get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
|
||||
|
||||
Reference in New Issue
Block a user