Merge branch 'develop' into api-v3

This commit is contained in:
Matteo Pagliazzi
2016-01-13 18:39:44 +01:00
335 changed files with 13066 additions and 11799 deletions

View File

@@ -9,7 +9,7 @@ import {
} from './constants';
import * as statHelpers from './statHelpers';
var $w, _, api, content, i18n, moment, preenHistory, sortOrder,
var $w, _, api, content, i18n, preenHistory, moment, sortOrder,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
moment = require('moment');
@@ -120,7 +120,6 @@ preenHistory = function(history) {
return newHistory;
};
/*
Preen 3-day past-completed To-Dos from Angular & mobile app
*/
@@ -2271,41 +2270,56 @@ api.wrap = function(user, main) {
}
})()]++;
},
updateStats: function(stats, req, analytics) {
updateStats (stats, req, analytics) {
let allocatedStatPoints;
let totalStatPoints;
let experienceToNextLevel;
if (stats.hp <= 0) {
return user.stats.hp = 0;
user.stats.hp = 0;
return user.stats.hp;
}
user.stats.hp = stats.hp;
user.stats.gp = stats.gp >= 0 ? stats.gp : 0;
var experienceToNextLevel = api.tnl(user.stats.lvl);
experienceToNextLevel = api.tnl(user.stats.lvl);
if (stats.exp >= experienceToNextLevel) {
user.stats.exp = stats.exp;
while (stats.exp >= experienceToNextLevel) {
stats.exp -= experienceToNextLevel;
user.stats.lvl++;
experienceToNextLevel = api.tnl(user.stats.lvl);
user.stats.hp = 50;
var userTotalStatPoints = user.stats.str + user.stats.int + user.stats.con + user.stats.per;
if (userTotalStatPoints >= MAX_STAT_POINTS) {
continue;
experienceToNextLevel = api.tnl(user.stats.lvl);
user.stats.hp = MAX_HEALTH;
allocatedStatPoints = user.stats.str + user.stats.int + user.stats.con + user.stats.per;
totalStatPoints = allocatedStatPoints + user.stats.points;
if (totalStatPoints >= MAX_STAT_POINTS) {
continue; // eslint-disable-line no-continue
}
if (user.preferences.automaticAllocation) {
user.fns.autoAllocate();
} else {
user.stats.points = user.stats.lvl - userTotalStatPoints;
user.stats.points = user.stats.lvl - allocatedStatPoints;
totalStatPoints = user.stats.points + allocatedStatPoints;
if (totalStatPoints > MAX_STAT_POINTS) {
user.stats.points = MAX_STAT_POINTS - allocatedStatPoints;
}
if (user.stats.points < 0) {
user.stats.points = 0;
}
}
}
}
user.stats.exp = stats.exp;
if (user.flags == null) {
user.flags = {};
}
user.flags = user.flags || {};
if (!user.flags.customizationsNotification && (user.stats.exp > 5 || user.stats.lvl > 1)) {
user.flags.customizationsNotification = true;
}