From 79e0d5cba2ff5567c8ca20a18b0b74fa8b9a2419 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 23 Oct 2013 18:25:41 +0200 Subject: [PATCH] upgrade browseridy to 2.34.x and grunt build --- dist/habitrpg-shared.js | 90 ++++++++++++++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index c6032b0cd1..2f63e0cced 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -53,7 +53,7 @@ process.chdir = function (dir) { }; },{}],2:[function(require,module,exports){ -var global=self;/** +var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};/** * @license * Lo-Dash 1.3.1 (Custom Build) * Build: `lodash modern -o ./dist/lodash.js` @@ -7347,6 +7347,7 @@ if(typeof module != 'undefined' && module.exports){ obj.revive = function(user, options) { var candidate, loseThisItem, owned, paths; + if (options == null) { options = {}; } @@ -7396,6 +7397,7 @@ if(typeof module != 'undefined' && module.exports){ obj.tnl = function(level) { var value; + if (level >= 100) { value = 0; } else { @@ -7415,6 +7417,7 @@ if(typeof module != 'undefined' && module.exports){ obj.expModifier = function(value, weaponStr, level, priority) { var exp, str, strMod, totalStr; + if (priority == null) { priority = '!'; } @@ -7437,6 +7440,7 @@ if(typeof module != 'undefined' && module.exports){ obj.hpModifier = function(value, armorDef, helmDef, shieldDef, level, priority) { var def, defMod, hp, totalDef; + if (priority == null) { priority = '!'; } @@ -7455,6 +7459,7 @@ if(typeof module != 'undefined' && module.exports){ obj.gpModifier = function(value, modifier, priority, streak, user) { var afterStreak, streakBonus, val; + if (priority == null) { priority = '!'; } @@ -7481,6 +7486,7 @@ if(typeof module != 'undefined' && module.exports){ obj.taskDeltaFormula = function(currentValue, direction) { var delta; + if (currentValue < -47.27) { currentValue = -47.27; } else if (currentValue > 21.27) { @@ -7499,7 +7505,8 @@ if(typeof module != 'undefined' && module.exports){ randomDrop = function(user, delta, priority, streak, options) { - var acceptableDrops, chanceMultiplier, drop, paths, rarity, reachedDropLimit, _base, _base1, _base2, _ref1; + var acceptableDrops, chanceMultiplier, drop, paths, rarity, reachedDropLimit, _base, _base1, _base2, _ref1, _ref2, _ref3, _ref4; + if (streak == null) { streak = 0; } @@ -7507,7 +7514,7 @@ if(typeof module != 'undefined' && module.exports){ options = {}; } paths = options.paths || {}; - if ((_base = user.items).lastDrop == null) { + if ((_ref1 = (_base = user.items).lastDrop) == null) { _base.lastDrop = { date: +moment().subtract('d', 1), count: 0 @@ -7521,11 +7528,11 @@ if(typeof module != 'undefined' && module.exports){ chanceMultiplier = Math.abs(delta); chanceMultiplier *= obj.priorityValue(priority); chanceMultiplier += streak; - if (((_ref1 = user.flags) != null ? _ref1.dropsEnabled : void 0) && Math.random() < (.05 * chanceMultiplier)) { + if (((_ref2 = user.flags) != null ? _ref2.dropsEnabled : void 0) && Math.random() < (.05 * chanceMultiplier)) { rarity = Math.random(); if (rarity > .5) { drop = helpers.randomVal(pets); - ((_base1 = user.items).eggs != null ? (_base1 = user.items).eggs : _base1.eggs = []).push(drop); + ((_ref3 = (_base1 = user.items).eggs) != null ? _ref3 : _base1.eggs = []).push(drop); paths['items.eggs'] = true; drop.type = 'Egg'; drop.dialog = "You've found a " + drop.text + " Egg! " + drop.notes; @@ -7541,11 +7548,12 @@ if(typeof module != 'undefined' && module.exports){ acceptableDrops = ['Base', 'White', 'Desert']; } acceptableDrops = hatchingPotions.filter(function(hatchingPotion) { - var _ref2; - return _ref2 = hatchingPotion.name, __indexOf.call(acceptableDrops, _ref2) >= 0; + var _ref4; + + return _ref4 = hatchingPotion.name, __indexOf.call(acceptableDrops, _ref4) >= 0; }); drop = helpers.randomVal(acceptableDrops); - ((_base2 = user.items).hatchingPotions != null ? (_base2 = user.items).hatchingPotions : _base2.hatchingPotions = []).push(drop.name); + ((_ref4 = (_base2 = user.items).hatchingPotions) != null ? _ref4 : _base2.hatchingPotions = []).push(drop.name); paths['items.hatchingPotions'] = true; drop.type = 'HatchingPotion'; drop.dialog = "You've found a " + drop.text + " Hatching Potion! " + drop.notes; @@ -7558,7 +7566,8 @@ if(typeof module != 'undefined' && module.exports){ }; obj.score = function(user, task, direction, options) { - var addPoints, calculateDelta, cron, delta, exp, gp, hp, lvl, num, paths, priority, streak, subtractPoints, times, type, value, _ref1, _ref2, _ref3; + var addPoints, calculateDelta, cron, delta, exp, gp, hp, lvl, num, paths, priority, streak, subtractPoints, times, type, value, _ref1, _ref2, _ref3, _ref4; + if (options == null) { options = {}; } @@ -7589,6 +7598,7 @@ if(typeof module != 'undefined' && module.exports){ } return _.times(times, function() { var nextDelta; + nextDelta = obj.taskDeltaFormula(value, direction); if (adjustvalue) { value += nextDelta; @@ -7598,6 +7608,7 @@ if(typeof module != 'undefined' && module.exports){ }; addPoints = function() { var weaponStr; + weaponStr = items.getItem('weapon', user.items.weapon).strength; exp += obj.expModifier(delta, weaponStr, user.stats.lvl, priority) / 2; if (streak) { @@ -7608,6 +7619,7 @@ if(typeof module != 'undefined' && module.exports){ }; subtractPoints = function() { var armorDef, headDef, shieldDef; + armorDef = items.getItem('armor', user.items.armor).defense; headDef = items.getItem('head', user.items.head).defense; shieldDef = items.getItem('shield', user.items.shield).defense; @@ -7622,7 +7634,7 @@ if(typeof module != 'undefined' && module.exports){ subtractPoints(); } if (task.value !== value) { - (task.history != null ? task.history : task.history = []).push({ + ((_ref4 = task.history) != null ? _ref4 : task.history = []).push({ date: +(new Date), value: value }); @@ -7639,7 +7651,15 @@ if(typeof module != 'undefined' && module.exports){ addPoints(); if (direction === 'up') { streak = streak ? streak + 1 : 1; + if ((streak % 21) === 0) { + user.achievements.streak = user.achievements.streak ? user.achievements.streak + 1 : 1; + paths["achievements.streak"] = true; + } } else { + if ((streak % 21) === 0) { + user.achievements.streak = user.achievements.streak ? user.achievements.streak - 1 : 0; + paths["achievements.streak"] = true; + } streak = streak ? streak - 1 : 0; } task.streak = streak; @@ -7690,7 +7710,8 @@ if(typeof module != 'undefined' && module.exports){ updateStats = function(user, newStats, options) { - var gp, paths, tnl; + var gp, paths, tnl, _ref1; + if (options == null) { options = {}; } @@ -7733,7 +7754,7 @@ if(typeof module != 'undefined' && module.exports){ paths['stats.lvl'] = true; paths['stats.gp'] = true; paths['stats.hp'] = true; - if (user.flags == null) { + if ((_ref1 = user.flags) == null) { user.flags = {}; } if (!user.flags.customizationsNotification && (user.stats.exp > 10 || user.stats.lvl > 1)) { @@ -7771,7 +7792,8 @@ if(typeof module != 'undefined' && module.exports){ obj.cron = function(user, options) { - var daysMissed, expTally, lvl, now, paths, todoTally, _base, _base1, _ref1; + var daysMissed, expTally, lvl, now, paths, todoTally, _base, _base1, _ref1, _ref2, _ref3, _ref4; + if (options == null) { options = {}; } @@ -7794,7 +7816,8 @@ if(typeof module != 'undefined' && module.exports){ } todoTally = 0; user.todos.concat(user.dailys).forEach(function(task) { - var absVal, completed, id, repeat, scheduleMisses, type; + var absVal, completed, id, repeat, scheduleMisses, type, _ref2; + if (!task) { return; } @@ -7805,6 +7828,7 @@ if(typeof module != 'undefined' && module.exports){ scheduleMisses = 0; _.times(daysMissed, function(n) { var thatDay; + thatDay = moment(now).subtract('days', n + 1); if (helpers.shouldDo(thatDay, repeat, user.preferences)) { return scheduleMisses++; @@ -7821,7 +7845,7 @@ if(typeof module != 'undefined' && module.exports){ } switch (type) { case 'daily': - (task.history != null ? task.history : task.history = []).push({ + ((_ref2 = task.history) != null ? _ref2 : task.history = []).push({ date: +(new Date), value: task.value }); @@ -7843,7 +7867,7 @@ if(typeof module != 'undefined' && module.exports){ return paths["tasks." + task.id + ".value"] = true; } }); - ((_base = (user.history != null ? user.history : user.history = {})).todos != null ? (_base = (user.history != null ? user.history : user.history = {})).todos : _base.todos = []).push({ + ((_ref2 = (_base = ((_ref3 = user.history) != null ? _ref3 : user.history = {})).todos) != null ? _ref2 : _base.todos = []).push({ date: now, value: todoTally }); @@ -7853,7 +7877,7 @@ if(typeof module != 'undefined' && module.exports){ lvl++; expTally += obj.tnl(lvl); } - ((_base1 = user.history).exp != null ? (_base1 = user.history).exp : _base1.exp = []).push({ + ((_ref4 = (_base1 = user.history).exp) != null ? _ref4 : _base1.exp = []).push({ date: now, value: expTally }); @@ -7883,6 +7907,7 @@ var process=require("__browserify_process");(function() { sanitizeOptions = function(o) { var dayStart, now, timezoneOffset, _ref; + dayStart = o.dayStart && (0 <= (_ref = +o.dayStart) && _ref <= 24) ? +o.dayStart : 0; timezoneOffset = o.timezoneOffset ? +o.timezoneOffset : +moment().zone(); now = o.now ? moment(o.now).zone(timezoneOffset) : moment(+(new Date)).zone(timezoneOffset); @@ -7895,6 +7920,7 @@ var process=require("__browserify_process");(function() { startOfWeek = function(options) { var o; + if (options == null) { options = {}; } @@ -7904,6 +7930,7 @@ var process=require("__browserify_process");(function() { startOfDay = function(options) { var o; + if (options == null) { options = {}; } @@ -7928,6 +7955,7 @@ var process=require("__browserify_process");(function() { daysSince = function(yesterday, options) { var o; + if (options == null) { options = {}; } @@ -7944,6 +7972,7 @@ var process=require("__browserify_process");(function() { shouldDo = function(day, repeat, options) { var o, selected, yesterday; + if (options == null) { options = {}; } @@ -7968,6 +7997,7 @@ var process=require("__browserify_process");(function() { uuid = function() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) { var r, v; + r = Math.random() * 16 | 0; v = (c === "x" ? r : r & 0x3 | 0x8); return v.toString(16); @@ -7977,7 +8007,8 @@ var process=require("__browserify_process");(function() { module.exports = { uuid: uuid, taskDefaults: function(task, filters) { - var defaults, self; + var defaults, self, _ref; + if (filters == null) { filters = {}; } @@ -8006,13 +8037,14 @@ var process=require("__browserify_process");(function() { }) }; _.defaults(task, defaults); - if (task.value == null) { + if ((_ref = task.value) == null) { task.value = task.type === 'reward' ? 10 : 0; } return task; }, newUser: function(isDerby) { var defaultTags, defaultTasks, guid, newUser, repeat, tag, task, userSchema, _i, _j, _len, _len1; + if (isDerby == null) { isDerby = false; } @@ -8175,16 +8207,19 @@ var process=require("__browserify_process");(function() { dotSet: function(path, val, obj) { var arr, err; + if (~path.indexOf('undefined')) { return; } try { arr = path.split('.'); return _.reduce(arr, function(curr, next, index) { + var _ref; + if ((arr.length - 1) === index) { curr[next] = val; } - return curr[next] != null ? curr[next] : curr[next] = {}; + return (_ref = curr[next]) != null ? _ref : curr[next] = {}; }, obj); } catch (_error) { err = _error; @@ -8198,6 +8233,7 @@ var process=require("__browserify_process");(function() { }, dotGet: function(path, obj) { var err; + if (~path.indexOf('undefined')) { return void 0; } @@ -8227,6 +8263,7 @@ var process=require("__browserify_process");(function() { randomVal: function(obj) { var count, key, result, val; + result = void 0; count = 0; for (key in obj) { @@ -8253,6 +8290,7 @@ var process=require("__browserify_process");(function() { username: function(auth, override) { var fb, _ref; + if (override) { return override; } @@ -8277,6 +8315,7 @@ var process=require("__browserify_process");(function() { encodeiCalLink: function(uid, apiToken) { var loc, _ref; + loc = (typeof window !== "undefined" && window !== null ? window.location.host : void 0) || (typeof process !== "undefined" && process !== null ? (_ref = process.env) != null ? _ref.BASE_URL : void 0 : void 0) || ''; return encodeURIComponent("http://" + loc + "/v1/users/" + uid + "/calendar.ics?apiToken=" + apiToken); }, @@ -8286,6 +8325,7 @@ var process=require("__browserify_process");(function() { equipped: function(type, item, preferences, backerTier) { var armorSet, gender; + if (item == null) { item = 0; } @@ -8382,6 +8422,7 @@ var process=require("__browserify_process");(function() { taskClasses: function(task, filters, dayStart, lastCron, showCompleted, main) { var classes, completed, enabled, filter, repeat, type, value, _ref; + if (showCompleted == null) { showCompleted = false; } @@ -8475,6 +8516,7 @@ var process=require("__browserify_process");(function() { appliedTags: function(userTags, taskTags) { var arr; + arr = []; _.each(userTags, function(t) { if (t == null) { @@ -8495,6 +8537,7 @@ var process=require("__browserify_process");(function() { }, totalStr: function(level, weapon) { var str; + if (weapon == null) { weapon = 0; } @@ -8506,6 +8549,7 @@ var process=require("__browserify_process");(function() { }, totalDef: function(level, armor, head, shield) { var totalDef; + if (armor == null) { armor = 0; } @@ -8526,6 +8570,7 @@ var process=require("__browserify_process");(function() { }, itemStat: function(type, item) { var i; + if (item == null) { item = 0; } @@ -8549,6 +8594,7 @@ var process=require("__browserify_process");(function() { hydrate: function(spec) { var hydrated, keys, _this = this; + if (_.isObject(spec) && !_.isArray(spec)) { hydrated = {}; keys = _.keys(spec).concat(_.keys(spec.__proto__)); @@ -8925,6 +8971,7 @@ try { module.exports.buyItem = function(user, type, options) { var nextItem; + if (options == null) { options = {}; } @@ -8957,9 +9004,11 @@ try { module.exports.updateStore = function(user) { var changes; + changes = {}; _.each(['weapon', 'armor', 'shield', 'head'], function(type) { var i, showNext, _ref, _ref1, _ref2; + i = ~~(((_ref = user.items) != null ? _ref[type] : void 0) || 0) + 1; showNext = true; if (i === items[type].length - 1) { @@ -8987,6 +9036,7 @@ try { module.exports.getItem = function(type, index) { var i; + if (index == null) { index = 0; } diff --git a/package.json b/package.json index de5f67a026..40aac6f134 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "habitrpg-shared", "version": "0.0.0", "dependencies": { - "browserify": "~2.14.1", + "browserify": "~2.34.3", "coffeeify": "0.4.0", "coffee-script": "1.6.2", "relative-date": "~1.1.1",