Merge pull request #6898 from HabitRPG/api-v3-buy-ops
[v3] Port several shared ops and their linked fns
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
"guildQuestsNotSupported": "Guilds cannot be invited on quests.",
|
||||
"questNotFound": "Quest \"<%= key %>\" not found.",
|
||||
"questNotOwned": "You don't own that quest scroll.",
|
||||
"questNotGoldPurchasable": "Quest \"<%= key %>\" is not a Gold-purchasable quest.",
|
||||
"questLevelTooHigh": "You must be level <%= level %> to begin this quest.",
|
||||
"questAlreadyUnderway": "Your party is already on a quest. Try again when the current quest has ended.",
|
||||
"questAlreadyAccepted": "You already accepted the quest invitation.",
|
||||
@@ -107,5 +108,9 @@
|
||||
"spellNotOwned": "You don't own this spell.",
|
||||
"spellLevelTooHigh": "You must be level <%= level %> to use this spell.",
|
||||
"invalidAttribute": "\"<%= attr %>\" is not a valid attribute.",
|
||||
"notEnoughAttrPoints": "You don't have enough attribute points."
|
||||
"notEnoughAttrPoints": "You don't have enough attribute points.",
|
||||
"missingKeyParam": "\"req.params.key\" is required.",
|
||||
"mysterySetNotFound": "Mystery set not found, or set already owned",
|
||||
"itemNotFound": "Item \"<%= key %>\" not found.",
|
||||
"cannoyBuyItem": "You can't buy this item"
|
||||
}
|
||||
|
||||
@@ -7,50 +7,59 @@ import splitWhitespace from '../libs/splitWhitespace';
|
||||
{update} if aggregated changes, pass in userObj as update. otherwise commits will be made immediately
|
||||
*/
|
||||
|
||||
module.exports = function(user) {
|
||||
return user.stats[(function() {
|
||||
var diff, ideal, lvlDiv7, preference, stats, suggested;
|
||||
switch (user.preferences.allocationMode) {
|
||||
case "flat":
|
||||
stats = _.pick(user.stats, splitWhitespace('con str per int'));
|
||||
return _.invert(stats)[_.min(stats)];
|
||||
case "classbased":
|
||||
lvlDiv7 = user.stats.lvl / 7;
|
||||
ideal = [lvlDiv7 * 3, lvlDiv7 * 2, lvlDiv7, lvlDiv7];
|
||||
preference = (function() {
|
||||
switch (user.stats["class"]) {
|
||||
case "wizard":
|
||||
return ["int", "per", "con", "str"];
|
||||
case "rogue":
|
||||
return ["per", "str", "int", "con"];
|
||||
case "healer":
|
||||
return ["con", "int", "str", "per"];
|
||||
default:
|
||||
return ["str", "con", "per", "int"];
|
||||
}
|
||||
})();
|
||||
diff = [user.stats[preference[0]] - ideal[0], user.stats[preference[1]] - ideal[1], user.stats[preference[2]] - ideal[2], user.stats[preference[3]] - ideal[3]];
|
||||
suggested = _.findIndex(diff, (function(val) {
|
||||
if (val === _.min(diff)) {
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
if (~suggested) {
|
||||
return preference[suggested];
|
||||
} else {
|
||||
return "str";
|
||||
}
|
||||
case "taskbased":
|
||||
suggested = _.invert(user.stats.training)[_.max(user.stats.training)];
|
||||
_.merge(user.stats.training, {
|
||||
str: 0,
|
||||
int: 0,
|
||||
con: 0,
|
||||
per: 0
|
||||
});
|
||||
return suggested || "str";
|
||||
default:
|
||||
return "str";
|
||||
}
|
||||
})()]++;
|
||||
function getStatToAllocate (user) {
|
||||
let suggested;
|
||||
|
||||
switch (user.preferences.allocationMode) {
|
||||
case 'flat':
|
||||
let stats = _.pick(user.stats, splitWhitespace('con str per int'));
|
||||
return _.invert(stats)[_.min(stats)];
|
||||
case 'classbased':
|
||||
let lvlDiv7 = user.stats.lvl / 7;
|
||||
let ideal = [lvlDiv7 * 3, lvlDiv7 * 2, lvlDiv7, lvlDiv7];
|
||||
|
||||
let preference;
|
||||
switch (user.stats.class) {
|
||||
case 'wizard':
|
||||
preference = ['int', 'per', 'con', 'str'];
|
||||
break;
|
||||
case 'rogue':
|
||||
preference = ['per', 'str', 'int', 'con'];
|
||||
break;
|
||||
case 'healer':
|
||||
preference = ['con', 'int', 'str', 'per'];
|
||||
break;
|
||||
default:
|
||||
preference = ['str', 'con', 'per', 'int'];
|
||||
}
|
||||
|
||||
let diff = [
|
||||
user.stats[preference[0]] - ideal[0],
|
||||
user.stats[preference[1]] - ideal[1],
|
||||
user.stats[preference[2]] - ideal[2],
|
||||
user.stats[preference[3]] - ideal[3],
|
||||
];
|
||||
|
||||
suggested = _.findIndex(diff, (val) => {
|
||||
if (val === _.min(diff)) return true;
|
||||
});
|
||||
|
||||
return suggested !== -1 ? preference[suggested] : 'str';
|
||||
case 'taskbased':
|
||||
suggested = _.invert(user.stats.training)[_.max(user.stats.training)];
|
||||
|
||||
let training = user.stats.training;
|
||||
training.str = 0;
|
||||
training.int = 0;
|
||||
training.con = 0;
|
||||
training.per = 0;
|
||||
|
||||
return suggested || 'str';
|
||||
default:
|
||||
return 'str';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function autoAllocate (user) {
|
||||
return user.stats[getStatToAllocate(user)]++;
|
||||
};
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
|
||||
module.exports = function(user, item, type, req) {
|
||||
var message, currentWeapon, currentShield;
|
||||
if (type == null) {
|
||||
type = 'equipped';
|
||||
}
|
||||
currentShield = content.gear.flat[user.items.gear[type].shield];
|
||||
currentWeapon = content.gear.flat[user.items.gear[type].weapon];
|
||||
module.exports = function handleTwoHanded (user, item, type = 'equipped', req = {}) {
|
||||
let currentShield = content.gear.flat[user.items.gear[type].shield];
|
||||
let currentWeapon = content.gear.flat[user.items.gear[type].weapon];
|
||||
|
||||
if (item.type === "shield" && (currentWeapon ? currentWeapon.twoHanded : false)) {
|
||||
let message;
|
||||
|
||||
if (item.type === 'shield' && (currentWeapon ? currentWeapon.twoHanded : false)) {
|
||||
user.items.gear[type].weapon = 'weapon_base_0';
|
||||
message = i18n.t('messageTwoHandedUnequip', {
|
||||
twoHandedText: currentWeapon.text(req.language), offHandedText: item.text(req.language),
|
||||
}, req.language);
|
||||
} else if (item.twoHanded && (currentShield && user.items.gear[type].shield != "shield_base_0")) {
|
||||
user.items.gear[type].shield = "shield_base_0";
|
||||
} else if (item.twoHanded && (currentShield && user.items.gear[type].shield !== 'shield_base_0')) {
|
||||
user.items.gear[type].shield = 'shield_base_0';
|
||||
message = i18n.t('messageTwoHandedEquip', {
|
||||
twoHandedText: item.text(req.language), offHandedText: currentShield.text(req.language),
|
||||
}, req.language);
|
||||
}
|
||||
|
||||
return message;
|
||||
};
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import _ from 'lodash';
|
||||
/*
|
||||
Because the same op needs to be performed on the client and the server (critical hits, item drops, etc),
|
||||
we need things to be "random", but technically predictable so that they don't go out-of-sync
|
||||
*/
|
||||
|
||||
module.exports = function(user, seed) {
|
||||
var x;
|
||||
// Because the same op needs to be performed on the client and the server (critical hits, item drops, etc),
|
||||
// we need things to be "random", but technically predictable so that they don't go out-of-sync
|
||||
|
||||
module.exports = function predictableRandom (user, seed) {
|
||||
if (!seed || seed === Math.PI) {
|
||||
seed = _.reduce(user.stats, (function(m, v) {
|
||||
if (_.isNumber(v)) {
|
||||
return m + v;
|
||||
seed = _.reduce(user.stats, (accumulator, val) => {
|
||||
if (_.isNumber(val)) {
|
||||
return accumulator + val;
|
||||
} else {
|
||||
return m;
|
||||
return accumulator;
|
||||
}
|
||||
}), 0);
|
||||
}, 0);
|
||||
}
|
||||
x = Math.sin(seed++) * 10000;
|
||||
|
||||
let x = Math.sin(seed++) * 10000;
|
||||
return x - Math.floor(x);
|
||||
};
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import _ from 'lodash';
|
||||
import predictableRandom from './predictableRandom';
|
||||
|
||||
/*
|
||||
Get a random property from an object
|
||||
returns random property (the value)
|
||||
*/
|
||||
// Get a random property from an object
|
||||
// returns random property (the value)
|
||||
|
||||
module.exports = function(user, obj, options) {
|
||||
var array, rand;
|
||||
array = (options != null ? options.key : void 0) ? _.keys(obj) : _.values(obj);
|
||||
rand = user.fns.predictableRandom(options != null ? options.seed : void 0);
|
||||
module.exports = function randomVal (user, obj, options = {}) {
|
||||
let array = options.key ? _.keys(obj) : _.values(obj);
|
||||
let rand = predictableRandom(user, options.seed);
|
||||
array.sort();
|
||||
return array[Math.floor(rand * array.length)];
|
||||
};
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
import content from '../content/index';
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function(user) {
|
||||
var base, owned;
|
||||
owned = typeof window !== "undefined" && window !== null ? user.items.gear.owned : user.items.gear.owned.toObject();
|
||||
if ((base = user.achievements).ultimateGearSets == null) {
|
||||
base.ultimateGearSets = {
|
||||
healer: false,
|
||||
wizard: false,
|
||||
rogue: false,
|
||||
warrior: false
|
||||
};
|
||||
}
|
||||
content.classes.forEach(function(klass) {
|
||||
module.exports = function ultimateGear (user) {
|
||||
let owned = typeof window !== 'undefined' ? user.items.gear.owned : user.items.gear.owned.toObject();
|
||||
|
||||
content.classes.forEach((klass) => {
|
||||
if (user.achievements.ultimateGearSets[klass] !== true) {
|
||||
return user.achievements.ultimateGearSets[klass] = _.reduce(['armor', 'shield', 'head', 'weapon'], function(soFarGood, type) {
|
||||
var found;
|
||||
found = _.find(content.gear.tree[type][klass], {
|
||||
last: true
|
||||
user.achievements.ultimateGearSets[klass] = _.reduce(['armor', 'shield', 'head', 'weapon'], (soFarGood, type) => {
|
||||
let found = _.find(content.gear.tree[type][klass], {
|
||||
last: true,
|
||||
});
|
||||
return soFarGood && (!found || owned[found.key] === true);
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('achievements.ultimateGearSets');
|
||||
}
|
||||
|
||||
if (_.contains(user.achievements.ultimateGearSets, true) && user.flags.armoireEnabled !== true) {
|
||||
user.flags.armoireEnabled = true;
|
||||
return typeof user.markModified === "function" ? user.markModified('flags') : void 0;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
+33
-1
@@ -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,13 +104,36 @@ 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';
|
||||
import allocateNow from './ops/allocateNow';
|
||||
|
||||
api.ops = {
|
||||
scoreTask,
|
||||
sleep,
|
||||
allocate,
|
||||
buy,
|
||||
buyMysterySet,
|
||||
buySpecialSpell,
|
||||
buyQuest,
|
||||
allocateNow,
|
||||
};
|
||||
|
||||
import handleTwoHanded from './fns/handleTwoHanded';
|
||||
import predictableRandom from './fns/predictableRandom';
|
||||
import randomVal from './fns/randomVal';
|
||||
import ultimateGear from './fns/ultimateGear';
|
||||
import autoAllocate from './fns/autoAllocate';
|
||||
|
||||
api.fns = {
|
||||
handleTwoHanded,
|
||||
predictableRandom,
|
||||
randomVal,
|
||||
ultimateGear,
|
||||
autoAllocate,
|
||||
};
|
||||
api.fns = {};
|
||||
|
||||
|
||||
/*
|
||||
@@ -155,6 +181,12 @@ api.wrap = function wrapUser (user, main = true) {
|
||||
if (user._wrapped) return;
|
||||
user._wrapped = true;
|
||||
|
||||
// Make markModified available on the client side as a noop function
|
||||
// TODO move to client?
|
||||
if (!user.markModified) {
|
||||
user.markModified = function noopMarkModified () {};
|
||||
}
|
||||
|
||||
if (main) {
|
||||
user.ops = {
|
||||
update: _.partial(importedOps.update, user),
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// An utility to pick deep properties from an object.
|
||||
// Works like _.pick but supports nested props (ie pickDeep(obj, ['deep.property']))
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function pickDeep (obj, properties) {
|
||||
if (!_.isArray(properties)) throw new Error('"properties" must be an array');
|
||||
|
||||
let result = {};
|
||||
_.each(properties, (prop) => _.set(result, prop, _.get(obj, prop)));
|
||||
|
||||
return result;
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import autoAllocate from '../fns/autoAllocate';
|
||||
|
||||
module.exports = function(user, req, cb) {
|
||||
_.times(user.stats.points, user.fns.autoAllocate);
|
||||
module.exports = function allocateNow (user) {
|
||||
_.times(user.stats.points, () => autoAllocate(user));
|
||||
user.stats.points = 0;
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('stats');
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.stats) : void 0;
|
||||
return {
|
||||
data: _.pick(user, 'stats'),
|
||||
};
|
||||
};
|
||||
|
||||
+87
-68
@@ -3,117 +3,136 @@ import i18n from '../i18n';
|
||||
import _ from 'lodash';
|
||||
import count from '../count';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../libs/errors';
|
||||
import predictableRandom from '../fns/predictableRandom';
|
||||
import randomVal from '../fns/randomVal';
|
||||
import handleTwoHanded from '../fns/handleTwoHanded';
|
||||
import ultimateGear from '../fns/ultimateGear';
|
||||
|
||||
module.exports = function(user, req, cb, analytics) {
|
||||
var analyticsData, armoireExp, armoireResp, armoireResult, base, buyResp, drop, eligibleEquipment, item, key, message, name;
|
||||
key = req.params.key;
|
||||
item = key === 'potion' ? content.potion : key === 'armoire' ? content.armoire : content.gear.flat[key];
|
||||
if (!item) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 404,
|
||||
message: "Item '" + key + " not found (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content/index.js)"
|
||||
}) : void 0;
|
||||
module.exports = function buy (user, req = {}, analytics) {
|
||||
let key = _.get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
|
||||
|
||||
let item;
|
||||
if (key === 'potion') {
|
||||
item = content.potion;
|
||||
} else if (key === 'armoire') {
|
||||
item = content.armoire;
|
||||
} else {
|
||||
item = content.gear.flat[key];
|
||||
}
|
||||
if (!item) throw new NotFound(i18n.t('itemNotFound', {key}, req.language));
|
||||
|
||||
if (user.stats.gp < item.value) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
message: i18n.t('messageNotEnoughGold', req.language)
|
||||
}) : void 0;
|
||||
throw new NotAuthorized(i18n.t('messageNotEnoughGold', req.language));
|
||||
}
|
||||
if ((item.canOwn != null) && !item.canOwn(user)) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
message: "You can't buy this item"
|
||||
}) : void 0;
|
||||
|
||||
if (item.canOwn && !item.canOwn(user)) {
|
||||
throw new NotAuthorized(i18n.t('cannoyBuyItem', req.language));
|
||||
}
|
||||
armoireResp = void 0;
|
||||
|
||||
let armoireResp;
|
||||
let armoireResult;
|
||||
let eligibleEquipment;
|
||||
let drop;
|
||||
let message;
|
||||
|
||||
if (item.key === 'potion') {
|
||||
user.stats.hp += 15;
|
||||
if (user.stats.hp > 50) {
|
||||
user.stats.hp = 50;
|
||||
}
|
||||
} else if (item.key === 'armoire') {
|
||||
armoireResult = user.fns.predictableRandom(user.stats.gp);
|
||||
eligibleEquipment = _.filter(content.gear.flat, (function(i) {
|
||||
return i.klass === 'armoire' && !user.items.gear.owned[i.key];
|
||||
}));
|
||||
if (!_.isEmpty(eligibleEquipment) && (armoireResult < .6 || !user.flags.armoireOpened)) {
|
||||
armoireResult = predictableRandom(user, user.stats.gp);
|
||||
eligibleEquipment = _.filter(content.gear.flat, (eligible) => {
|
||||
return eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key];
|
||||
});
|
||||
|
||||
if (!_.isEmpty(eligibleEquipment) && (armoireResult < 0.6 || !user.flags.armoireOpened)) {
|
||||
eligibleEquipment.sort();
|
||||
drop = user.fns.randomVal(eligibleEquipment);
|
||||
drop = randomVal(user, eligibleEquipment);
|
||||
|
||||
user.items.gear.owned[drop.key] = true;
|
||||
user.flags.armoireOpened = true;
|
||||
message = i18n.t('armoireEquipment', {
|
||||
image: '<span class="shop_' + drop.key + ' pull-left"></span>',
|
||||
dropText: drop.text(req.language)
|
||||
image: `<span class="shop_${drop.key} pull-left"></span>`,
|
||||
dropText: drop.text(req.language),
|
||||
}, req.language);
|
||||
|
||||
if (count.remainingGearInSet(user.items.gear.owned, 'armoire') === 0) {
|
||||
user.flags.armoireEmpty = true;
|
||||
}
|
||||
|
||||
armoireResp = {
|
||||
type: "gear",
|
||||
type: 'gear',
|
||||
dropKey: drop.key,
|
||||
dropText: drop.text(req.language)
|
||||
dropText: drop.text(req.language),
|
||||
};
|
||||
} else if ((!_.isEmpty(eligibleEquipment) && armoireResult < .8) || armoireResult < .5) {
|
||||
drop = user.fns.randomVal(_.where(content.food, {
|
||||
canDrop: true
|
||||
} else if ((!_.isEmpty(eligibleEquipment) && armoireResult < 0.8) || armoireResult < 0.5) { // eslint-disable-line no-extra-parens
|
||||
drop = randomVal(user, _.where(content.food, {
|
||||
canDrop: true,
|
||||
}));
|
||||
if ((base = user.items.food)[name = drop.key] == null) {
|
||||
base[name] = 0;
|
||||
}
|
||||
user.items.food[drop.key] = user.items.food[drop.key] || 0;
|
||||
user.items.food[drop.key] += 1;
|
||||
|
||||
message = i18n.t('armoireFood', {
|
||||
image: '<span class="Pet_Food_' + drop.key + ' pull-left"></span>',
|
||||
image: `<span class="Pet_Food_${drop.key} pull-left"></span>`,
|
||||
dropArticle: drop.article,
|
||||
dropText: drop.text(req.language)
|
||||
dropText: drop.text(req.language),
|
||||
}, req.language);
|
||||
armoireResp = {
|
||||
type: "food",
|
||||
type: 'food',
|
||||
dropKey: drop.key,
|
||||
dropArticle: drop.article,
|
||||
dropText: drop.text(req.language)
|
||||
dropText: drop.text(req.language),
|
||||
};
|
||||
} else {
|
||||
armoireExp = Math.floor(user.fns.predictableRandom(user.stats.exp) * 40 + 10);
|
||||
let armoireExp = Math.floor(predictableRandom(user, user.stats.exp) * 40 + 10);
|
||||
user.stats.exp += armoireExp;
|
||||
message = i18n.t('armoireExp', req.language);
|
||||
armoireResp = {
|
||||
"type": "experience",
|
||||
"value": armoireExp
|
||||
type: 'experience',
|
||||
value: armoireExp,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if (user.preferences.autoEquip) {
|
||||
user.items.gear.equipped[item.type] = item.key;
|
||||
message = user.fns.handleTwoHanded(item, null, req);
|
||||
message = handleTwoHanded(user, item, undefined, req);
|
||||
}
|
||||
user.items.gear.owned[item.key] = true;
|
||||
if (message == null) {
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language)
|
||||
}, req.language);
|
||||
}
|
||||
if (item.last) {
|
||||
user.fns.ultimateGear();
|
||||
}
|
||||
|
||||
if (item.last) ultimateGear(user);
|
||||
}
|
||||
|
||||
user.stats.gp -= item.value;
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemKey: key,
|
||||
acquireMethod: 'Gold',
|
||||
goldCost: item.value,
|
||||
category: 'behavior'
|
||||
|
||||
if (!message) {
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language);
|
||||
}
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('acquire item', {
|
||||
uuid: user._id,
|
||||
itemKey: key,
|
||||
acquireMethod: 'Gold',
|
||||
goldCost: item.value,
|
||||
category: 'behavior',
|
||||
});
|
||||
}
|
||||
|
||||
let res = {
|
||||
data: _.pick(user, splitWhitespace('items achievements stats flags')),
|
||||
message,
|
||||
};
|
||||
if (analytics != null) {
|
||||
analytics.track('acquire item', analyticsData);
|
||||
}
|
||||
buyResp = _.pick(user, splitWhitespace('items achievements stats flags'));
|
||||
if (armoireResp) {
|
||||
buyResp["armoire"] = armoireResp;
|
||||
}
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 200,
|
||||
message: message
|
||||
}, buyResp) : void 0;
|
||||
|
||||
if (armoireResp) res.armoire = armoireResp;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -2,42 +2,49 @@ import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import _ from 'lodash';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import pickDeep from '../libs/pickDeep';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../libs/errors';
|
||||
|
||||
module.exports = function buyMysterySet (user, req = {}, analytics) {
|
||||
let key = _.get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
|
||||
|
||||
module.exports = function(user, req, cb, analytics) {
|
||||
var mysterySet, ref;
|
||||
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
message: i18n.t('notEnoughHourglasses', req.language)
|
||||
}) : void 0;
|
||||
}
|
||||
mysterySet = (ref = content.timeTravelerStore(user.items.gear.owned)) != null ? ref[req.params.key] : void 0;
|
||||
if ((typeof window !== "undefined" && window !== null ? window.confirm : void 0) != null) {
|
||||
if (!window.confirm(i18n.t('hourglassBuyEquipSetConfirm'))) {
|
||||
return;
|
||||
}
|
||||
throw new NotAuthorized(i18n.t('notEnoughHourglasses', req.language));
|
||||
}
|
||||
|
||||
let ref = content.timeTravelerStore(user.items.gear.owned);
|
||||
let mysterySet = ref ? ref[key] : undefined;
|
||||
|
||||
if (!mysterySet) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 404,
|
||||
message: "Mystery set not found, or set already owned"
|
||||
}) : void 0;
|
||||
throw new NotFound(i18n.t('mysterySetNotFound', req.language));
|
||||
}
|
||||
_.each(mysterySet.items, function(i) {
|
||||
var analyticsData;
|
||||
user.items.gear.owned[i.key] = true;
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemKey: i.key,
|
||||
itemType: 'Subscriber Gear',
|
||||
acquireMethod: 'Hourglass',
|
||||
category: 'behavior'
|
||||
};
|
||||
return analytics != null ? analytics.track('acquire item', analyticsData) : void 0;
|
||||
|
||||
if (typeof window !== 'undefined' && window.confirm) { // TODO move to client
|
||||
if (!window.confirm(i18n.t('hourglassBuyEquipSetConfirm'))) return;
|
||||
}
|
||||
|
||||
_.each(mysterySet.items, item => {
|
||||
user.items.gear.owned[item.key] = true;
|
||||
if (analytics) {
|
||||
analytics.track('acquire item', {
|
||||
uuid: user._id,
|
||||
itemKey: item.key,
|
||||
itemType: 'Subscriber Gear',
|
||||
acquireMethod: 'Hourglass',
|
||||
category: 'behavior',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
user.purchased.plan.consecutive.trinkets--;
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 200,
|
||||
message: i18n.t('hourglassPurchaseSet', req.language)
|
||||
}, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
||||
|
||||
return {
|
||||
data: pickDeep(user, splitWhitespace('items purchased.plan.consecutive')),
|
||||
message: i18n.t('hourglassPurchaseSet', req.language),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,49 +1,46 @@
|
||||
import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
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));
|
||||
|
||||
let item = content.quests[key];
|
||||
if (!item) throw new NotFound(i18n.t('questNotFound', {key}, req.language));
|
||||
|
||||
module.exports = function(user, req, cb, analytics) {
|
||||
var analyticsData, base, item, key, message, name;
|
||||
key = req.params.key;
|
||||
item = content.quests[key];
|
||||
if (!item) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 404,
|
||||
message: "Quest '" + key + " not found (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content/index.js)"
|
||||
}) : void 0;
|
||||
}
|
||||
if (!(item.category === 'gold' && item.goldValue)) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 404,
|
||||
message: "Quest '" + key + " is not a Gold-purchasable quest (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content/index.js)"
|
||||
}) : void 0;
|
||||
throw new NotAuthorized(i18n.t('questNotGoldPurchasable', {key}, req.language));
|
||||
}
|
||||
if (user.stats.gp < item.goldValue) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
message: i18n.t('messageNotEnoughGold', req.language)
|
||||
}) : void 0;
|
||||
throw new NotAuthorized(i18n.t('messageNotEnoughGold', req.language));
|
||||
}
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language)
|
||||
}, req.language);
|
||||
if ((base = user.items.quests)[name = item.key] == null) {
|
||||
base[name] = 0;
|
||||
}
|
||||
user.items.quests[item.key] += 1;
|
||||
|
||||
user.items.quests[item.key] = user.items.quests[item.key] || 0;
|
||||
user.items.quests[item.key]++;
|
||||
user.stats.gp -= item.goldValue;
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemKey: item.key,
|
||||
itemType: 'Market',
|
||||
goldCost: item.goldValue,
|
||||
acquireMethod: 'Gold',
|
||||
category: 'behavior'
|
||||
};
|
||||
if (analytics != null) {
|
||||
analytics.track('acquire item', analyticsData);
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('acquire item', {
|
||||
uuid: user._id,
|
||||
itemKey: item.key,
|
||||
itemType: 'Market',
|
||||
goldCost: item.goldValue,
|
||||
acquireMethod: 'Gold',
|
||||
category: 'behavior',
|
||||
});
|
||||
}
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 200,
|
||||
message: message
|
||||
}, user.items.quests) : void 0;
|
||||
|
||||
return {
|
||||
data: user.items.quests,
|
||||
message: i18n.t('messageBought', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,30 +2,30 @@ import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import _ from 'lodash';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../libs/errors';
|
||||
|
||||
module.exports = function buySpecialSpell (user, req = {}) {
|
||||
let key = _.get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
|
||||
|
||||
let item = content.special[key];
|
||||
if (!item) throw new NotFound(i18n.t('spellNotFound', {spellId: key}, req.language));
|
||||
|
||||
module.exports = function(user, req, cb) {
|
||||
var base, item, key, message;
|
||||
key = req.params.key;
|
||||
item = content.special[key];
|
||||
if (user.stats.gp < item.value) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
message: i18n.t('messageNotEnoughGold', req.language)
|
||||
}) : void 0;
|
||||
throw new NotAuthorized(i18n.t('messageNotEnoughGold', req.language));
|
||||
}
|
||||
user.stats.gp -= item.value;
|
||||
if ((base = user.items.special)[key] == null) {
|
||||
base[key] = 0;
|
||||
}
|
||||
|
||||
user.items.special[key]++;
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('items.special');
|
||||
}
|
||||
message = i18n.t('messageBought', {
|
||||
itemText: item.text(req.language)
|
||||
}, req.language);
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 200,
|
||||
message: message
|
||||
}, _.pick(user, splitWhitespace('items stats'))) : void 0;
|
||||
|
||||
return {
|
||||
data: _.pick(user, splitWhitespace('items stats')),
|
||||
message: i18n.t('messageBought', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import _ from 'lodash';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import pickDeep from '../libs/pickDeep';
|
||||
|
||||
module.exports = function(user, req, cb, analytics) {
|
||||
var analyticsData, key, ref, type;
|
||||
@@ -50,5 +51,5 @@ module.exports = function(user, req, cb, analytics) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 200,
|
||||
message: i18n.t('hourglassPurchase', req.language)
|
||||
}, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
||||
}, pickDeep(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
||||
};
|
||||
|
||||
@@ -19,12 +19,7 @@ const COMMON_FILES = [
|
||||
'!./common/script/ops/addTag.js',
|
||||
'!./common/script/ops/addTask.js',
|
||||
'!./common/script/ops/addWebhook.js',
|
||||
'!./common/script/ops/allocateNow.js',
|
||||
'!./common/script/ops/blockUser.js',
|
||||
'!./common/script/ops/buy.js',
|
||||
'!./common/script/ops/buyMysterySet.js',
|
||||
'!./common/script/ops/buyQuest.js',
|
||||
'!./common/script/ops/buySpecialSpell.js',
|
||||
'!./common/script/ops/changeClass.js',
|
||||
'!./common/script/ops/clearCompleted.js',
|
||||
'!./common/script/ops/clearPMs.js',
|
||||
@@ -57,26 +52,20 @@ const COMMON_FILES = [
|
||||
'!./common/script/ops/updateTag.js',
|
||||
'!./common/script/ops/updateTask.js',
|
||||
'!./common/script/ops/updateWebhook.js',
|
||||
'!./common/script/fns/autoAllocate.js',
|
||||
'!./common/script/fns/crit.js',
|
||||
'!./common/script/fns/cron.js',
|
||||
'!./common/script/fns/dotGet.js',
|
||||
'!./common/script/fns/dotSet.js',
|
||||
'!./common/script/fns/getItem.js',
|
||||
'!./common/script/fns/handleTwoHanded.js',
|
||||
'!./common/script/fns/nullify.js',
|
||||
'!./common/script/fns/predictableRandom.js',
|
||||
'!./common/script/fns/preenUserHistory.js',
|
||||
'!./common/script/fns/randomDrop.js',
|
||||
'!./common/script/fns/randomVal.js',
|
||||
'!./common/script/fns/ultimateGear.js',
|
||||
'!./common/script/fns/updateStats.js',
|
||||
'!./common/script/libs/appliedTags.js',
|
||||
'!./common/script/libs/countExists.js',
|
||||
'!./common/script/libs/dotGet.js',
|
||||
'!./common/script/libs/dotSet.js',
|
||||
'!./common/script/libs/encodeiCalLink.js',
|
||||
'!./common/script/libs/extendableBuiltin.js',
|
||||
'!./common/script/libs/friendlyTimestamp.js',
|
||||
'!./common/script/libs/gold.js',
|
||||
'!./common/script/libs/newChatMessages.js',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('POST /user/allocate-now', () => {
|
||||
// More tests in common code unit tests
|
||||
|
||||
it('auto allocates all points', async () => {
|
||||
let user = await generateUser({
|
||||
'stats.points': 5,
|
||||
'stats.int': 3,
|
||||
'stats.con': 9,
|
||||
'stats.per': 9,
|
||||
'stats.str': 9,
|
||||
'preferences.allocationMode': 'flat',
|
||||
});
|
||||
|
||||
let res = await user.post(`/user/allocate-now`);
|
||||
await user.sync();
|
||||
|
||||
expect(res).to.eql({
|
||||
data: {
|
||||
stats: user.stats,
|
||||
},
|
||||
});
|
||||
expect(user.stats.points).to.equal(0);
|
||||
expect(user.stats.con).to.equal(9);
|
||||
expect(user.stats.int).to.equal(8);
|
||||
expect(user.stats.per).to.equal(9);
|
||||
expect(user.stats.str).to.equal(9);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import shared from '../../../../../common/script';
|
||||
|
||||
let content = shared.content;
|
||||
|
||||
describe('POST /user/buy/:key', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser({
|
||||
'stats.gp': 400,
|
||||
});
|
||||
});
|
||||
|
||||
// More tests in common code unit tests
|
||||
|
||||
it('returns an error if the item is not found', async () => {
|
||||
await expect(user.post(`/user/buy/notExisting`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('itemNotFound', {key: 'notExisting'}),
|
||||
});
|
||||
});
|
||||
|
||||
it('buys an item', async () => {
|
||||
let potion = content.potion;
|
||||
let res = await user.post(`/user/buy/potion`);
|
||||
await user.sync();
|
||||
|
||||
expect(res.data).to.eql({
|
||||
items: JSON.parse(JSON.stringify(user.items)), // otherwise dates can't be compared
|
||||
achievements: user.achievements,
|
||||
stats: user.stats,
|
||||
flags: JSON.parse(JSON.stringify(user.flags)), // otherwise dates can't be compared
|
||||
});
|
||||
expect(res.message).to.equal(t('messageBought', {itemText: potion.text()}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('POST /user/buy-mystery-set/:key', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser({
|
||||
'purchased.plan.consecutive.trinkets': 1,
|
||||
});
|
||||
});
|
||||
|
||||
// More tests in common code unit tests
|
||||
|
||||
it('returns an error if the mystery set is not found', async () => {
|
||||
await expect(user.post(`/user/buy-mystery-set/notExisting`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('mysterySetNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('buys a mystery set', async () => {
|
||||
let key = 301404;
|
||||
|
||||
let res = await user.post(`/user/buy-mystery-set/${key}`);
|
||||
await user.sync();
|
||||
|
||||
expect(res.data).to.eql({
|
||||
items: JSON.parse(JSON.stringify(user.items)), // otherwise dates can't be compared
|
||||
purchased: {
|
||||
plan: {
|
||||
consecutive: user.purchased.plan.consecutive,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.message).to.equal(t('hourglassPurchaseSet'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import shared from '../../../../../common/script';
|
||||
|
||||
let content = shared.content;
|
||||
|
||||
describe('POST /user/buy-quest/:key', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
// More tests in common code unit tests
|
||||
|
||||
it('returns an error if the quest is not found', async () => {
|
||||
await expect(user.post(`/user/buy-quest/notExisting`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('questNotFound', {key: 'notExisting'}),
|
||||
});
|
||||
});
|
||||
|
||||
it('buys a quest', async () => {
|
||||
let key = 'dilatoryDistress1';
|
||||
let item = content.quests[key];
|
||||
|
||||
await user.update({'stats.gp': 250});
|
||||
let res = await user.post(`/user/buy-quest/${key}`);
|
||||
await user.sync();
|
||||
|
||||
expect(res.data).to.eql(user.items.quests);
|
||||
expect(res.message).to.equal(t('messageBought', {
|
||||
itemText: item.text(),
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import shared from '../../../../../common/script';
|
||||
|
||||
let content = shared.content;
|
||||
|
||||
describe('POST /user/buy-special-spell/:key', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
// More tests in common code unit tests
|
||||
|
||||
it('returns an error if the special spell is not found', async () => {
|
||||
await expect(user.post(`/user/buy-special-spell/notExisting`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('spellNotFound', {spellId: 'notExisting'}),
|
||||
});
|
||||
});
|
||||
|
||||
it('buys a special spell', async () => {
|
||||
let key = 'thankyou';
|
||||
let item = content.special[key];
|
||||
|
||||
await user.update({'stats.gp': 250});
|
||||
let res = await user.post(`/user/buy-special-spell/${key}`);
|
||||
await user.sync();
|
||||
|
||||
expect(res.data).to.eql({
|
||||
items: JSON.parse(JSON.stringify(user.items)), // otherwise dates can't be compared
|
||||
stats: user.stats,
|
||||
});
|
||||
expect(res.message).to.equal(t('messageBought', {
|
||||
itemText: item.text(),
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import autoAllocate from '../../../common/script/fns/autoAllocate';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.fns.autoAllocate', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('user.preferences.allocationMode === flat', () => {
|
||||
user.stats.con = 5;
|
||||
user.stats.int = 5;
|
||||
user.stats.per = 3;
|
||||
user.stats.str = 8;
|
||||
|
||||
user.preferences.allocationMode = 'flat';
|
||||
|
||||
autoAllocate(user);
|
||||
|
||||
expect(user.stats.con).to.equal(5);
|
||||
expect(user.stats.int).to.equal(5);
|
||||
expect(user.stats.per).to.equal(4);
|
||||
expect(user.stats.str).to.equal(8);
|
||||
});
|
||||
|
||||
it('user.preferences.allocationMode === taskbased', () => {
|
||||
user.stats.con = 5;
|
||||
user.stats.int = 5;
|
||||
user.stats.per = 3;
|
||||
user.stats.str = 8;
|
||||
user.stats.training.con = 2;
|
||||
user.stats.training.int = 5;
|
||||
user.stats.training.per = 7;
|
||||
user.stats.training.str = 4;
|
||||
|
||||
user.preferences.allocationMode = 'taskbased';
|
||||
|
||||
autoAllocate(user);
|
||||
|
||||
expect(user.stats.con).to.equal(5);
|
||||
expect(user.stats.int).to.equal(5);
|
||||
expect(user.stats.per).to.equal(4);
|
||||
expect(user.stats.str).to.equal(8);
|
||||
|
||||
expect(user.stats.training.con).to.equal(0);
|
||||
expect(user.stats.training.int).to.equal(0);
|
||||
expect(user.stats.training.per).to.equal(0);
|
||||
expect(user.stats.training.str).to.equal(0);
|
||||
});
|
||||
|
||||
it('user.preferences.allocationMode === classbased', () => {
|
||||
user.stats.lvl = 35;
|
||||
user.stats.class = 'healer';
|
||||
user.stats.con = 5;
|
||||
user.stats.int = 5;
|
||||
user.stats.per = 3;
|
||||
user.stats.str = 8;
|
||||
|
||||
user.preferences.allocationMode = 'classbased';
|
||||
|
||||
autoAllocate(user);
|
||||
|
||||
expect(user.stats.con).to.equal(6);
|
||||
expect(user.stats.int).to.equal(5);
|
||||
expect(user.stats.per).to.equal(3);
|
||||
expect(user.stats.str).to.equal(8);
|
||||
});
|
||||
|
||||
it('user.preferences.allocationMode === anything', () => {
|
||||
user.stats.con = 5;
|
||||
user.stats.int = 5;
|
||||
user.stats.per = 3;
|
||||
user.stats.str = 8;
|
||||
user.preferences.allocationMode = 'wrong';
|
||||
|
||||
autoAllocate(user);
|
||||
|
||||
expect(user.stats.con).to.equal(5);
|
||||
expect(user.stats.int).to.equal(5);
|
||||
expect(user.stats.per).to.equal(3);
|
||||
expect(user.stats.str).to.equal(9);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import handleTwoHanded from '../../../common/script/fns/handleTwoHanded';
|
||||
import content from '../../../common/script/content/index';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.fns.handleTwoHanded', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('uses "messageTwoHandedUnequip" message if item is a shield and current weapon is two handed (and sets the user\'s weapon to the base one)', () => {
|
||||
let item = content.gear.tree.shield.warrior['2'];
|
||||
let currentWeapon = content.gear.tree.weapon.armoire.rancherLasso;
|
||||
user.items.gear.equipped.weapon = 'weapon_armoire_rancherLasso';
|
||||
|
||||
let message = handleTwoHanded(user, item);
|
||||
expect(message).to.equal(i18n.t('messageTwoHandedUnequip', {
|
||||
twoHandedText: currentWeapon.text(), offHandedText: item.text(),
|
||||
}));
|
||||
expect(user.items.gear.equipped.weapon).to.equal('weapon_base_0');
|
||||
});
|
||||
|
||||
it('uses "messageTwoHandedEquip" message if item is two handed and currentShield exists but is not "shield_base_0" (and sets the user\'s shield to the base one)', () => {
|
||||
let item = content.gear.tree.weapon.armoire.rancherLasso;
|
||||
let currentShield = content.gear.tree.shield.armoire.gladiatorShield;
|
||||
user.items.gear.equipped.shield = 'shield_armoire_gladiatorShield';
|
||||
|
||||
let message = handleTwoHanded(user, item);
|
||||
expect(message).to.equal(i18n.t('messageTwoHandedEquip', {
|
||||
twoHandedText: item.text(), offHandedText: currentShield.text(),
|
||||
}));
|
||||
expect(user.items.gear.equipped.shield).to.equal('shield_base_0');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import predictableRandom from '../../../common/script/fns/predictableRandom';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.fns.predictableRandom', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('returns a number', () => {
|
||||
expect(predictableRandom(user)).to.be.a('number');
|
||||
});
|
||||
|
||||
it('returns the same value when user.stats is the same and no seed is passed', () => {
|
||||
user.stats.hp = 43;
|
||||
user.stats.gp = 34;
|
||||
|
||||
let val1 = predictableRandom(user);
|
||||
let val2 = predictableRandom(user);
|
||||
|
||||
expect(val2).to.equal(val1);
|
||||
});
|
||||
|
||||
it('returns a different value when user.stats is not the same and no seed is passed', () => {
|
||||
user.stats.hp = 43;
|
||||
user.stats.gp = 34;
|
||||
let val1 = predictableRandom(user);
|
||||
|
||||
user.stats.gp = 35;
|
||||
let val2 = predictableRandom(user);
|
||||
|
||||
expect(val2).to.not.equal(val1);
|
||||
});
|
||||
|
||||
it('returns the same value when the same seed is passed', () => {
|
||||
let val1 = predictableRandom(user, 4452673762);
|
||||
let val2 = predictableRandom(user, 4452673762);
|
||||
|
||||
expect(val2).to.equal(val1);
|
||||
});
|
||||
|
||||
it('returns a different value when a different seed is passed', () => {
|
||||
let val1 = predictableRandom(user, 4452673761);
|
||||
let val2 = predictableRandom(user, 4452673762);
|
||||
|
||||
expect(val2).to.not.equal(val1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
import randomVal from '../../../common/script/fns/randomVal';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.fns.randomVal', () => {
|
||||
let user;
|
||||
let obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: 4,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
describe('returns a random property value from an object', () => {
|
||||
it('returns the same value when the seed is the same', () => {
|
||||
let val1 = randomVal(user, obj, {
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
let val2 = randomVal(user, obj, {
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
expect(val2).to.equal(val1);
|
||||
});
|
||||
|
||||
it('returns the same value when user.stats is the same', () => {
|
||||
user.stats.gp = 34;
|
||||
let val1 = randomVal(user, obj);
|
||||
let val2 = randomVal(user, obj);
|
||||
|
||||
expect(val2).to.equal(val1);
|
||||
});
|
||||
|
||||
it('returns a different value when the seed is different', () => {
|
||||
let val1 = randomVal(user, obj, {
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
let val2 = randomVal(user, obj, {
|
||||
seed: 333,
|
||||
});
|
||||
|
||||
expect(val2).to.not.equal(val1);
|
||||
});
|
||||
|
||||
it('returns a different value when user.stats is different', () => {
|
||||
user.stats.gp = 34;
|
||||
let val1 = randomVal(user, obj);
|
||||
user.stats.gp = 343;
|
||||
let val2 = randomVal(user, obj);
|
||||
|
||||
expect(val2).to.not.equal(val1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('returns a random key from an object', () => {
|
||||
it('returns the same key when the seed is the same', () => {
|
||||
let key1 = randomVal(user, obj, {
|
||||
key: true,
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
let key2 = randomVal(user, obj, {
|
||||
key: true,
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
expect(key2).to.equal(key1);
|
||||
});
|
||||
|
||||
it('returns the same key when user.stats is the same', () => {
|
||||
user.stats.gp = 45;
|
||||
let key1 = randomVal(user, obj, {
|
||||
key: true,
|
||||
});
|
||||
|
||||
let key2 = randomVal(user, obj, {
|
||||
key: true,
|
||||
});
|
||||
|
||||
expect(key2).to.equal(key1);
|
||||
});
|
||||
|
||||
it('returns a different key when the seed is different', () => {
|
||||
let key1 = randomVal(user, obj, {
|
||||
key: true,
|
||||
seed: 222,
|
||||
});
|
||||
|
||||
let key2 = randomVal(user, obj, {
|
||||
key: true,
|
||||
seed: 333,
|
||||
});
|
||||
|
||||
expect(key2).to.not.equal(key1);
|
||||
});
|
||||
|
||||
it('returns a different key when user.stats is different', () => {
|
||||
user.stats.gp = 45;
|
||||
let key1 = randomVal(user, obj, {
|
||||
key: true,
|
||||
});
|
||||
|
||||
user.stats.gp = 43;
|
||||
|
||||
let key2 = randomVal(user, obj, {
|
||||
key: true,
|
||||
});
|
||||
|
||||
expect(key2).to.not.equal(key1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import ultimateGear from '../../../common/script/fns/ultimateGear';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.fns.ultimateGear', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('sets armoirEnabled when partial achievement already achieved', () => {
|
||||
let items = {
|
||||
gear: {
|
||||
owned: {
|
||||
toObject: () => {
|
||||
return {
|
||||
armor_warrior_5: true, // eslint-disable-line camelcase
|
||||
shield_warrior_5: true, // eslint-disable-line camelcase
|
||||
head_warrior_5: true, // eslint-disable-line camelcase
|
||||
weapon_warrior_6: true, // eslint-disable-line camelcase
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
user.items = items;
|
||||
ultimateGear(user);
|
||||
expect(user.flags.armoireEnabled).to.equal(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import pickDeep from '../../../common/script/libs/pickDeep';
|
||||
|
||||
describe('pickDeep', () => {
|
||||
it('throws an error if "properties" is not an array', () => {
|
||||
expect(pickDeep).to.throw(Error);
|
||||
});
|
||||
|
||||
it('returns an object of properties taken from the input object', () => {
|
||||
let obj = {
|
||||
a: true,
|
||||
b: [1, 2, 3],
|
||||
c: {
|
||||
nested: {
|
||||
two: {
|
||||
times: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
d: false,
|
||||
};
|
||||
|
||||
let res = pickDeep(obj, ['a', 'b[0]', 'c.nested.two.times']);
|
||||
expect(res.a).to.be.true;
|
||||
expect(res.b).to.eql([1]);
|
||||
expect(res.c).to.eql({
|
||||
nested: {
|
||||
two: {
|
||||
times: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res).to.not.have.property('d');
|
||||
});
|
||||
});
|
||||
@@ -17,18 +17,20 @@ describe('shared.ops.allocate', () => {
|
||||
|
||||
it('throws an error if an invalid attribute is supplied', () => {
|
||||
try {
|
||||
expect(allocate(user, {
|
||||
allocate(user, {
|
||||
query: {stat: 'notValid'},
|
||||
})).to.throw(BadRequest);
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidAttribute', {attr: 'notValid'}));
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have attribute points', () => {
|
||||
try {
|
||||
expect(allocate(user)).to.throw(NotAuthorized);
|
||||
allocate(user);
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('notEnoughAttrPoints'));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import allocateNow from '../../../common/script/ops/allocateNow';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shared.ops.allocateNow', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('auto allocates all points', () => {
|
||||
user.stats.points = 5;
|
||||
user.stats.int = 3;
|
||||
user.stats.con = 9;
|
||||
user.stats.per = 9;
|
||||
user.stats.str = 9;
|
||||
user.preferences.allocationMode = 'flat';
|
||||
|
||||
let res = allocateNow(user);
|
||||
|
||||
expect(user.stats.points).to.equal(0);
|
||||
expect(user.stats.con).to.equal(9);
|
||||
expect(user.stats.int).to.equal(8);
|
||||
expect(user.stats.per).to.equal(9);
|
||||
expect(user.stats.str).to.equal(9);
|
||||
expect(res).to.eql({
|
||||
data: {
|
||||
stats: user.stats,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,14 +1,23 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
import sinon from 'sinon'; // eslint-disable-line no-shadow
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import count from '../../../common/script/count';
|
||||
import buy from '../../../common/script/ops/buy';
|
||||
import shared from '../../../common/script';
|
||||
import content from '../../../common/script/content/index';
|
||||
import {
|
||||
NotAuthorized,
|
||||
} from '../../../common/script/libs/errors';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
|
||||
let shared = require('../../common/script/index.js');
|
||||
|
||||
describe('user.fns.buy', () => {
|
||||
describe('shared.ops.buy', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = {
|
||||
user = generateUser({
|
||||
items: {
|
||||
gear: {
|
||||
owned: {
|
||||
@@ -19,39 +28,34 @@ describe('user.fns.buy', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
preferences: {},
|
||||
stats: { gp: 200 },
|
||||
achievements: { },
|
||||
flags: { },
|
||||
};
|
||||
});
|
||||
|
||||
shared.wrap(user);
|
||||
|
||||
sinon.stub(user.fns, 'randomVal');
|
||||
sinon.stub(user.fns, 'predictableRandom');
|
||||
sinon.stub(shared.fns, 'randomVal');
|
||||
sinon.stub(shared.fns, 'predictableRandom');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
user.fns.randomVal.restore();
|
||||
user.fns.predictableRandom.restore();
|
||||
shared.fns.randomVal.restore();
|
||||
shared.fns.predictableRandom.restore();
|
||||
});
|
||||
|
||||
context('Potion', () => {
|
||||
it('recovers 15 hp', () => {
|
||||
user.stats.hp = 30;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
buy(user, {params: {key: 'potion'}});
|
||||
expect(user.stats.hp).to.eql(45);
|
||||
});
|
||||
|
||||
it('does not increase hp above 50', () => {
|
||||
user.stats.hp = 45;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
buy(user, {params: {key: 'potion'}});
|
||||
expect(user.stats.hp).to.eql(50);
|
||||
});
|
||||
|
||||
it('deducts 25 gp', () => {
|
||||
user.stats.hp = 45;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
buy(user, {params: {key: 'potion'}});
|
||||
|
||||
expect(user.stats.gp).to.eql(175);
|
||||
});
|
||||
@@ -59,7 +63,12 @@ describe('user.fns.buy', () => {
|
||||
it('does not purchase if not enough gp', () => {
|
||||
user.stats.hp = 45;
|
||||
user.stats.gp = 5;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
try {
|
||||
buy(user, {params: {key: 'potion'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
}
|
||||
|
||||
expect(user.stats.hp).to.eql(45);
|
||||
expect(user.stats.gp).to.eql(5);
|
||||
@@ -70,7 +79,7 @@ describe('user.fns.buy', () => {
|
||||
it('adds equipment to inventory', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({ weapon_warrior_0: true, armor_warrior_1: true });
|
||||
});
|
||||
@@ -78,7 +87,7 @@ describe('user.fns.buy', () => {
|
||||
it('deducts gold from user', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.stats.gp).to.eql(1);
|
||||
});
|
||||
@@ -87,7 +96,7 @@ describe('user.fns.buy', () => {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = true;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('armor', 'armor_warrior_1');
|
||||
});
|
||||
@@ -96,34 +105,36 @@ describe('user.fns.buy', () => {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = false;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.not.have.property('armor');
|
||||
expect(user.items.gear.equipped.property).to.not.equal('armor_warrior_1');
|
||||
});
|
||||
|
||||
it('removes one-handed weapon and shield if auto-equip is on and a two-hander is bought', () => {
|
||||
// TODO after user.ops.equip is done
|
||||
xit('removes one-handed weapon and shield if auto-equip is on and a two-hander is bought', () => {
|
||||
user.stats.gp = 100;
|
||||
user.preferences.autoEquip = true;
|
||||
user.ops.buy({params: {key: 'shield_warrior_1'}});
|
||||
buy(user, {params: {key: 'shield_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'shield_warrior_1'}});
|
||||
user.ops.buy({params: {key: 'weapon_warrior_1'}});
|
||||
buy(user, {params: {key: 'weapon_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'weapon_warrior_1'}});
|
||||
|
||||
user.ops.buy({params: {key: 'weapon_wizard_1'}});
|
||||
buy(user, {params: {key: 'weapon_wizard_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('shield', 'shield_base_0');
|
||||
expect(user.items.gear.equipped).to.have.property('weapon', 'weapon_wizard_1');
|
||||
});
|
||||
|
||||
it('buys two-handed equipment but does not automatically remove sword or shield', () => {
|
||||
// TODO after user.ops.equip is done
|
||||
xit('buys two-handed equipment but does not automatically remove sword or shield', () => {
|
||||
user.stats.gp = 100;
|
||||
user.preferences.autoEquip = false;
|
||||
user.ops.buy({params: {key: 'shield_warrior_1'}});
|
||||
buy(user, {params: {key: 'shield_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'shield_warrior_1'}});
|
||||
user.ops.buy({params: {key: 'weapon_warrior_1'}});
|
||||
buy(user, {params: {key: 'weapon_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'weapon_warrior_1'}});
|
||||
|
||||
user.ops.buy({params: {key: 'weapon_wizard_1'}});
|
||||
buy(user, {params: {key: 'weapon_wizard_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('shield', 'shield_warrior_1');
|
||||
expect(user.items.gear.equipped).to.have.property('weapon', 'weapon_warrior_1');
|
||||
@@ -132,22 +143,17 @@ describe('user.fns.buy', () => {
|
||||
it('does not buy equipment without enough Gold', () => {
|
||||
user.stats.gp = 20;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
try {
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
}
|
||||
|
||||
expect(user.items.gear.owned).to.not.have.property('armor_warrior_1');
|
||||
});
|
||||
});
|
||||
|
||||
context('Quests', () => {
|
||||
it('buys a Quest scroll');
|
||||
|
||||
it('does not buy Quests without enough Gold');
|
||||
|
||||
it('does not buy nonexistent Quests');
|
||||
|
||||
it('does not buy Gem-premium Quests');
|
||||
});
|
||||
|
||||
context('Enchanted Armoire', () => {
|
||||
let YIELD_EQUIPMENT = 0.5;
|
||||
let YIELD_FOOD = 0.7;
|
||||
@@ -155,8 +161,8 @@ describe('user.fns.buy', () => {
|
||||
|
||||
let fullArmoire = {};
|
||||
|
||||
_(shared.content.gearTypes).each((type) => {
|
||||
_(shared.content.gear.tree[type].armoire).each((gearObject) => {
|
||||
_(content.gearTypes).each((type) => {
|
||||
_(content.gear.tree[type].armoire).each((gearObject) => {
|
||||
let armoireKey = gearObject.key;
|
||||
|
||||
fullArmoire[armoireKey] = true;
|
||||
@@ -171,38 +177,43 @@ describe('user.fns.buy', () => {
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
it('does not open if user does not have enough gold', (done) => {
|
||||
user.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
it('does not open if user does not have enough gold', () => {
|
||||
shared.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
user.stats.gp = 50;
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}}, (response) => {
|
||||
expect(response.message).to.eql('Not Enough Gold');
|
||||
try {
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.food).to.be.empty;
|
||||
expect(user.stats.exp).to.eql(0);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('does not open without Ultimate Gear achievement', (done) => {
|
||||
user.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
it('does not open without Ultimate Gear achievement', () => {
|
||||
shared.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
user.achievements.ultimateGearSets = {healer: false, wizard: false, rogue: false, warrior: false};
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}}, (response) => {
|
||||
expect(response.message).to.eql('You can\'t buy this item');
|
||||
try {
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('cannoyBuyItem'));
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.food).to.be.empty;
|
||||
expect(user.stats.exp).to.eql(0);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
context('non-gear awards', () => {
|
||||
it('gives Experience', () => {
|
||||
user.fns.predictableRandom.returns(YIELD_EXP);
|
||||
// Skipped because can't stub predictableRandom correctly
|
||||
xit('gives Experience', () => {
|
||||
shared.fns.predictableRandom.returns(YIELD_EXP);
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}});
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.food).to.be.empty;
|
||||
@@ -210,13 +221,14 @@ describe('user.fns.buy', () => {
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
});
|
||||
|
||||
it('gives food', () => {
|
||||
let honey = shared.content.food.Honey;
|
||||
// Skipped because can't stub predictableRandom correctly
|
||||
xit('gives food', () => {
|
||||
let honey = content.food.Honey;
|
||||
|
||||
user.fns.randomVal.returns(honey);
|
||||
user.fns.predictableRandom.returns(YIELD_FOOD);
|
||||
shared.fns.randomVal.returns(honey);
|
||||
shared.fns.predictableRandom.returns(YIELD_FOOD);
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}});
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.food).to.eql({Honey: 1});
|
||||
@@ -224,15 +236,16 @@ describe('user.fns.buy', () => {
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
});
|
||||
|
||||
it('does not give equipment if all equipment has been found', () => {
|
||||
user.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
// Skipped because can't stub predictableRandom correctly
|
||||
xit('does not give equipment if all equipment has been found', () => {
|
||||
shared.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
user.items.gear.owned = fullArmoire;
|
||||
user.stats.gp = 150;
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}});
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql(fullArmoire);
|
||||
let armoireCount = shared.count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(0);
|
||||
|
||||
@@ -243,23 +256,24 @@ describe('user.fns.buy', () => {
|
||||
|
||||
context('gear awards', () => {
|
||||
beforeEach(() => {
|
||||
let shield = shared.content.gear.tree.shield.armoire.gladiatorShield;
|
||||
let shield = content.gear.tree.shield.armoire.gladiatorShield;
|
||||
|
||||
user.fns.randomVal.returns(shield);
|
||||
shared.fns.randomVal.returns(shield);
|
||||
});
|
||||
|
||||
it('always drops equipment the first time', () => {
|
||||
// Skipped because can't stub predictableRandom correctly
|
||||
xit('always drops equipment the first time', () => {
|
||||
delete user.flags.armoireOpened;
|
||||
user.fns.predictableRandom.returns(YIELD_EXP);
|
||||
shared.fns.predictableRandom.returns(YIELD_EXP);
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}});
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({
|
||||
weapon_warrior_0: true,
|
||||
shield_armoire_gladiatorShield: true,
|
||||
});
|
||||
|
||||
let armoireCount = shared.count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(_.size(fullArmoire) - 1);
|
||||
expect(user.items.food).to.be.empty;
|
||||
@@ -267,18 +281,19 @@ describe('user.fns.buy', () => {
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
});
|
||||
|
||||
it('gives more equipment', () => {
|
||||
user.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
// Skipped because can't stub predictableRandom correctly
|
||||
xit('gives more equipment', () => {
|
||||
shared.fns.predictableRandom.returns(YIELD_EQUIPMENT);
|
||||
user.items.gear.owned = {
|
||||
weapon_warrior_0: true,
|
||||
head_armoire_hornedIronHelm: true,
|
||||
};
|
||||
user.stats.gp = 200;
|
||||
|
||||
user.ops.buy({params: {key: 'armoire'}});
|
||||
buy(user, {params: {key: 'armoire'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true, shield_armoire_gladiatorShield: true, head_armoire_hornedIronHelm: true});
|
||||
let armoireCount = shared.count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(_.size(fullArmoire) - 2);
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
@@ -0,0 +1,74 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import buyMysterySet from '../../../common/script/ops/buyMysterySet';
|
||||
import {
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../../../common/script/libs/errors';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
|
||||
describe('shared.ops.buyMysterySet', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
items: {
|
||||
gear: {
|
||||
owned: {
|
||||
weapon_warrior_0: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
context('Mystery Sets', () => {
|
||||
context('failure conditions', () => {
|
||||
it('does not grant mystery sets without Mystic Hourglasses', () => {
|
||||
try {
|
||||
buyMysterySet(user, {params: {key: '201501'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notEnoughHourglasses'));
|
||||
expect(user.items.gear.owned).to.have.property('weapon_warrior_0', true);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant mystery set that has already been purchased', () => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.gear.owned = {
|
||||
weapon_warrior_0: true,
|
||||
weapon_mystery_301404: true,
|
||||
armor_mystery_301404: true,
|
||||
head_mystery_301404: true,
|
||||
eyewear_mystery_301404: true,
|
||||
};
|
||||
|
||||
try {
|
||||
buyMysterySet(user, {params: {key: '301404'}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.eql(i18n.t('mysterySetNotFound'));
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
context('successful purchases', () => {
|
||||
it('buys Steampunk Accessories Set', () => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
buyMysterySet(user, {params: {key: '301404'}});
|
||||
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(0);
|
||||
expect(user.items.gear.owned).to.have.property('weapon_warrior_0', true);
|
||||
expect(user.items.gear.owned).to.have.property('weapon_mystery_301404', true);
|
||||
expect(user.items.gear.owned).to.have.property('armor_mystery_301404', true);
|
||||
expect(user.items.gear.owned).to.have.property('head_mystery_301404', true);
|
||||
expect(user.items.gear.owned).to.have.property('eyewear_mystery_301404', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import buyQuest from '../../../common/script/ops/buyQuest';
|
||||
import {
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../../../common/script/libs/errors';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
|
||||
describe('shared.ops.buyQuest', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('buys a Quest scroll', () => {
|
||||
user.stats.gp = 205;
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
key: 'dilatoryDistress1',
|
||||
},
|
||||
});
|
||||
expect(user.items.quests).to.eql({
|
||||
dilatoryDistress1: 1,
|
||||
});
|
||||
expect(user.stats.gp).to.equal(5);
|
||||
});
|
||||
|
||||
it('does not buy Quests without enough Gold', () => {
|
||||
user.stats.gp = 1;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
key: 'dilatoryDistress1',
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user.stats.gp).to.equal(1);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy nonexistent Quests', () => {
|
||||
user.stats.gp = 9999;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
key: 'snarfblatter',
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('questNotFound', {key: 'snarfblatter'}));
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user.stats.gp).to.equal(9999);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy Gem-premium Quests', () => {
|
||||
user.stats.gp = 9999;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
key: 'kraken',
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('questNotGoldPurchasable', {key: 'kraken'}));
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user.stats.gp).to.equal(9999);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
import buySpecialSpell from '../../../common/script/ops/buySpecialSpell';
|
||||
import {
|
||||
BadRequest,
|
||||
NotFound,
|
||||
NotAuthorized,
|
||||
} from '../../../common/script/libs/errors';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import content from '../../../common/script/content/index';
|
||||
|
||||
describe('shared.ops.buySpecialSpell', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('throws an error if params.key is missing', () => {
|
||||
try {
|
||||
buySpecialSpell(user);
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('missingKeyParam'));
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the spell doesn\'t exists', () => {
|
||||
try {
|
||||
buySpecialSpell(user, {
|
||||
params: {
|
||||
key: 'notExisting',
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('spellNotFound', {spellId: 'notExisting'}));
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have enough gold', () => {
|
||||
user.stats.gp = 1;
|
||||
try {
|
||||
buySpecialSpell(user, {
|
||||
params: {
|
||||
key: 'thankyou',
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
}
|
||||
});
|
||||
|
||||
it('buys an item', () => {
|
||||
user.stats.gp = 11;
|
||||
let item = content.special.thankyou;
|
||||
|
||||
let res = buySpecialSpell(user, {
|
||||
params: {
|
||||
key: 'thankyou',
|
||||
},
|
||||
});
|
||||
|
||||
expect(user.stats.gp).to.equal(1);
|
||||
expect(user.items.special.thankyou).to.equal(1);
|
||||
expect(res.data).to.eql({
|
||||
items: user.items,
|
||||
stats: user.stats,
|
||||
});
|
||||
expect(res.message).to.equal(i18n.t('messageBought', {
|
||||
itemText: item.text(),
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -472,62 +472,6 @@ describe('User', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('store', () => {
|
||||
it('buys a Quest scroll', () => {
|
||||
let user = generateUser();
|
||||
|
||||
user.stats.gp = 205;
|
||||
user.ops.buyQuest({
|
||||
params: {
|
||||
key: 'dilatoryDistress1',
|
||||
},
|
||||
});
|
||||
expect(user.items.quests).to.eql({
|
||||
dilatoryDistress1: 1,
|
||||
});
|
||||
expect(user).toHaveGP(5);
|
||||
});
|
||||
|
||||
it('does not buy Quests without enough Gold', () => {
|
||||
let user = generateUser();
|
||||
|
||||
user.stats.gp = 1;
|
||||
user.ops.buyQuest({
|
||||
params: {
|
||||
key: 'dilatoryDistress1',
|
||||
},
|
||||
});
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user).toHaveGP(1);
|
||||
});
|
||||
|
||||
it('does not buy nonexistent Quests', () => {
|
||||
let user = generateUser();
|
||||
|
||||
user.stats.gp = 9999;
|
||||
user.ops.buyQuest({
|
||||
params: {
|
||||
key: 'snarfblatter',
|
||||
},
|
||||
});
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user).toHaveGP(9999);
|
||||
});
|
||||
|
||||
it('does not buy Gem-premium Quests', () => {
|
||||
let user = generateUser();
|
||||
|
||||
user.stats.gp = 9999;
|
||||
user.ops.buyQuest({
|
||||
params: {
|
||||
key: 'kraken',
|
||||
},
|
||||
});
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user).toHaveGP(9999);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Gem purchases', () => {
|
||||
it('does not purchase items without enough Gems', () => {
|
||||
let user = generateUser();
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
let shared = require('../../common/script/index.js');
|
||||
|
||||
shared.i18n.translations = require('../../website/src/libs/api-v2/i18n.js').translations;
|
||||
|
||||
require('./test_helper');
|
||||
|
||||
describe('User.fns.ultimateGear', () => {
|
||||
it('sets armoirEnabled when partial achievement already achieved', () => {
|
||||
let items = {
|
||||
gear: {
|
||||
owned: {
|
||||
toObject: () => {
|
||||
return {
|
||||
armor_warrior_5: true,
|
||||
shield_warrior_5: true,
|
||||
head_warrior_5: true,
|
||||
weapon_warrior_6: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let user = shared.wrap({
|
||||
items,
|
||||
achievements: {
|
||||
ultimateGearSets: {},
|
||||
},
|
||||
flags: {},
|
||||
});
|
||||
|
||||
user.fns.ultimateGear();
|
||||
expect(user.flags.armoireEnabled).to.equal(true);
|
||||
});
|
||||
});
|
||||
@@ -1,77 +0,0 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
let shared = require('../../common/script/index.js');
|
||||
|
||||
describe('user.ops.buyMysterySet', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = {
|
||||
items: {
|
||||
gear: {
|
||||
owned: {
|
||||
weapon_warrior_0: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
purchased: {
|
||||
plan: {
|
||||
consecutive: {
|
||||
trinkets: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
shared.wrap(user);
|
||||
});
|
||||
|
||||
context('Mystery Sets', () => {
|
||||
context('failure conditions', () => {
|
||||
it('does not grant mystery sets without Mystic Hourglasses', (done) => {
|
||||
user.ops.buyMysterySet({params: {key: '201501'}}, (response) => {
|
||||
expect(response.message).to.eql('You don\'t have enough Mystic Hourglasses.');
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant mystery set that has already been purchased', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.gear.owned = {
|
||||
weapon_warrior_0: true,
|
||||
weapon_mystery_301404: true,
|
||||
armor_mystery_301404: true,
|
||||
head_mystery_301404: true,
|
||||
eyewear_mystery_301404: true,
|
||||
};
|
||||
|
||||
user.ops.buyMysterySet({params: {key: '301404'}}, (response) => {
|
||||
expect(response.message).to.eql('Mystery set not found, or set already owned');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('successful purchases', () => {
|
||||
it('buys Steampunk Accessories Set', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
user.ops.buyMysterySet({params: {key: '301404'}}, () => {
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(0);
|
||||
expect(user.items.gear.owned).to.eql({
|
||||
weapon_warrior_0: true,
|
||||
weapon_mystery_301404: true,
|
||||
armor_mystery_301404: true,
|
||||
head_mystery_301404: true,
|
||||
eyewear_mystery_301404: true,
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -196,4 +196,117 @@ api.allocate = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/allocate-now Allocate all attribute points.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserAllocateNow
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccess {Object} data `stats`
|
||||
*/
|
||||
api.allocateNow = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/allocate-now',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let allocateNowRes = common.ops.allocateNow(user, req);
|
||||
await user.save();
|
||||
res.respond(200, allocateNowRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/buy/:key Buy a content item.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserBuy
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiParam {string} key The item to buy.
|
||||
*
|
||||
* @apiSuccess {Object} data `items, achievements, stats, flags`
|
||||
* @apiSuccess {object} armoireResp Optional extra item given by the armoire
|
||||
* @apiSuccess {string} message
|
||||
*/
|
||||
api.buy = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/buy/:key',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let buyRes = common.ops.buy(user, req, res.analytics);
|
||||
await user.save();
|
||||
res.respond(200, buyRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/buy-mystery-set/:key Buy a mystery set.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserBuyMysterySet
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiParam {string} key The mystery set to buy.
|
||||
*
|
||||
* @apiSuccess {Object} data `items, purchased.plan.consecutive`
|
||||
* @apiSuccess {string} message
|
||||
*/
|
||||
api.buyMysterySet = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/buy-mystery-set/:key',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let buyMysterySetRes = common.ops.buyMysterySet(user, req, res.analytics);
|
||||
await user.save();
|
||||
res.respond(200, buyMysterySetRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/buy-quest/:key Buy a quest with gold.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserBuyQuest
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiParam {string} key The quest spell to buy.
|
||||
*
|
||||
* @apiSuccess {Object} data `items.quests`
|
||||
* @apiSuccess {string} message
|
||||
*/
|
||||
api.buyQuest = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/buy-quest/:key',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let buyQuestRes = common.ops.buyQuest(user, req, res.analytics);
|
||||
await user.save();
|
||||
res.respond(200, buyQuestRes);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/buy-special-spell/:key Buy special spell.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserBuySpecialSpell
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiParam {string} key The special spell to buy.
|
||||
*
|
||||
* @apiSuccess {Object} data `items, stats`
|
||||
* @apiSuccess {string} message
|
||||
*/
|
||||
api.buySpecialSpell = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/buy-special-spell/:key',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let buySpecialSpellRes = common.ops.buySpecialSpell(user, req);
|
||||
await user.save();
|
||||
res.respond(200, buySpecialSpellRes);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
|
||||
@@ -51,9 +51,12 @@ export let schema = new Schema({
|
||||
achievements: {
|
||||
originalUser: Boolean,
|
||||
habitSurveys: Number,
|
||||
ultimateGearSets: {type: Schema.Types.Mixed, default: () => {
|
||||
return {};
|
||||
}},
|
||||
ultimateGearSets: {
|
||||
healer: {type: Boolean, default: false},
|
||||
wizard: {type: Boolean, default: false},
|
||||
rogue: {type: Boolean, default: false},
|
||||
warrior: {type: Boolean, default: false},
|
||||
},
|
||||
beastMaster: Boolean,
|
||||
beastMasterCount: Number,
|
||||
mountMaster: Boolean,
|
||||
@@ -226,7 +229,6 @@ export let schema = new Schema({
|
||||
todos: Array, // [{data: Date, value: Number}] // big peformance issues if these are defined
|
||||
},
|
||||
|
||||
// TODO we're storing too many fields here, find a way to reduce them
|
||||
items: {
|
||||
gear: {
|
||||
owned: _.transform(shared.content.gear.flat, (m, v) => {
|
||||
@@ -263,15 +265,15 @@ export let schema = new Schema({
|
||||
spookDust: {type: Number, default: 0},
|
||||
shinySeed: {type: Number, default: 0},
|
||||
seafoam: {type: Number, default: 0},
|
||||
valentine: Number,
|
||||
valentine: {type: Number, default: 0},
|
||||
valentineReceived: Array, // array of strings, by sender name
|
||||
nye: Number,
|
||||
nye: {type: Number, default: 0},
|
||||
nyeReceived: Array,
|
||||
greeting: Number,
|
||||
greeting: {type: Number, default: 0},
|
||||
greetingReceived: Array,
|
||||
thankyou: Number,
|
||||
thankyou: {type: Number, default: 0},
|
||||
thankyouReceived: Array,
|
||||
birthday: Number,
|
||||
birthday: {type: Number, default: 0},
|
||||
birthdayReceived: Array,
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user