mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Downgraded coffeescript module to 1.6
This commit is contained in:
163
common/dist/scripts/habitrpg-shared.js
vendored
163
common/dist/scripts/habitrpg-shared.js
vendored
@@ -34,13 +34,13 @@ t = function(string, vars) {
|
|||||||
return func;
|
return func;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Gear (Weapons, Armor, Head, Shield)
|
Gear (Weapons, Armor, Head, Shield)
|
||||||
Item definitions: {index, text, notes, value, str, def, int, per, classes, type}
|
Item definitions: {index, text, notes, value, str, def, int, per, classes, type}
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
classes = ['warrior', 'rogue', 'healer', 'wizard'];
|
classes = ['warrior', 'rogue', 'healer', 'wizard'];
|
||||||
|
|
||||||
@@ -2284,11 +2284,11 @@ gear = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since
|
The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since
|
||||||
they are needed in different froms at different points in the app
|
they are needed in different froms at different points in the app
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.gear = {
|
api.gear = {
|
||||||
tree: gear,
|
tree: gear,
|
||||||
@@ -2328,10 +2328,10 @@ _.each(gearTypes, function(type) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Time Traveler Store, mystery sets need their items mapped in
|
Time Traveler Store, mystery sets need their items mapped in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
_.each(api.mystery, function(v, k) {
|
_.each(api.mystery, function(v, k) {
|
||||||
return v.items = _.where(api.gear.flat, {
|
return v.items = _.where(api.gear.flat, {
|
||||||
@@ -2351,12 +2351,12 @@ api.timeTravelerStore = function(owned) {
|
|||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Potion
|
Potion
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.potion = {
|
api.potion = {
|
||||||
type: 'potion',
|
type: 'potion',
|
||||||
@@ -2366,25 +2366,24 @@ api.potion = {
|
|||||||
key: 'potion'
|
key: 'potion'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Classes
|
Classes
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.classes = classes;
|
api.classes = classes;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Gear Types
|
Gear Types
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.gearTypes = gearTypes;
|
api.gearTypes = gearTypes;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Spells
|
Spells
|
||||||
@@ -2404,7 +2403,8 @@ api.gearTypes = gearTypes;
|
|||||||
so you'll want to iterate over them like: `_.each(target,function(member){...})`
|
so you'll want to iterate over them like: `_.each(target,function(member){...})`
|
||||||
|
|
||||||
Note, user.stats.mp is docked after automatically (it's appended to functions automatically down below in an _.each)
|
Note, user.stats.mp is docked after automatically (it's appended to functions automatically down below in an _.each)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
diminishingReturns = function(bonus, max, halfway) {
|
diminishingReturns = function(bonus, max, halfway) {
|
||||||
if (halfway == null) {
|
if (halfway == null) {
|
||||||
@@ -2760,12 +2760,12 @@ _.each(api.spells, function(spellClass) {
|
|||||||
|
|
||||||
api.special = api.spells.special;
|
api.special = api.spells.special;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Drops
|
Drops
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.dropEggs = {
|
api.dropEggs = {
|
||||||
Wolf: {
|
Wolf: {
|
||||||
@@ -4700,32 +4700,30 @@ $w = api.$w = function(s) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
api.dotSet = function(obj, path, val) {
|
api.dotSet = function(obj, path, val) {
|
||||||
var arr;
|
var arr,
|
||||||
|
_this = this;
|
||||||
arr = path.split('.');
|
arr = path.split('.');
|
||||||
return _.reduce(arr, (function(_this) {
|
return _.reduce(arr, function(curr, next, index) {
|
||||||
return function(curr, next, index) {
|
|
||||||
if ((arr.length - 1) === index) {
|
if ((arr.length - 1) === index) {
|
||||||
curr[next] = val;
|
curr[next] = val;
|
||||||
}
|
}
|
||||||
return curr[next] != null ? curr[next] : curr[next] = {};
|
return curr[next] != null ? curr[next] : curr[next] = {};
|
||||||
};
|
}, obj);
|
||||||
})(this), obj);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
api.dotGet = function(obj, path) {
|
api.dotGet = function(obj, path) {
|
||||||
return _.reduce(path.split('.'), ((function(_this) {
|
var _this = this;
|
||||||
return function(curr, next) {
|
return _.reduce(path.split('.'), (function(curr, next) {
|
||||||
return curr != null ? curr[next] : void 0;
|
return curr != null ? curr[next] : void 0;
|
||||||
};
|
}), obj);
|
||||||
})(this)), obj);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our
|
Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our
|
||||||
syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID
|
syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID
|
||||||
no problem. To maintain sorting, we use these helper functions:
|
no problem. To maintain sorting, we use these helper functions:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.refPush = function(reflist, item, prune) {
|
api.refPush = function(reflist, item, prune) {
|
||||||
if (prune == null) {
|
if (prune == null) {
|
||||||
@@ -4743,19 +4741,19 @@ api.planGemLimits = {
|
|||||||
convCap: 25
|
convCap: 25
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Time / Day
|
Time / Day
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Each time we're performing date math (cron, task-due-days, etc), we need to take user preferences into consideration.
|
Each time we're performing date math (cron, task-due-days, etc), we need to take user preferences into consideration.
|
||||||
Specifically {dayStart} (custom day start) and {timezoneOffset}. This function sanitizes / defaults those values.
|
Specifically {dayStart} (custom day start) and {timezoneOffset}. This function sanitizes / defaults those values.
|
||||||
{now} is also passed in for various purposes, one example being the test scripts scripts testing different "now" times
|
{now} is also passed in for various purposes, one example being the test scripts scripts testing different "now" times
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
sanitizeOptions = function(o) {
|
sanitizeOptions = function(o) {
|
||||||
var dayStart, now, timezoneOffset, _ref;
|
var dayStart, now, timezoneOffset, _ref;
|
||||||
@@ -4805,10 +4803,10 @@ api.dayMapping = {
|
|||||||
6: 's'
|
6: 's'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Absolute diff from "yesterday" till now
|
Absolute diff from "yesterday" till now
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.daysSince = function(yesterday, options) {
|
api.daysSince = function(yesterday, options) {
|
||||||
var o;
|
var o;
|
||||||
@@ -4823,10 +4821,10 @@ api.daysSince = function(yesterday, options) {
|
|||||||
}, o)), 'days'));
|
}, o)), 'days'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Should the user do this taks on this date, given the task's repeat options and user.preferences.dayStart?
|
Should the user do this taks on this date, given the task's repeat options and user.preferences.dayStart?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.shouldDo = function(day, repeat, options) {
|
api.shouldDo = function(day, repeat, options) {
|
||||||
var o, selected;
|
var o, selected;
|
||||||
@@ -4843,24 +4841,24 @@ api.shouldDo = function(day, repeat, options) {
|
|||||||
return selected;
|
return selected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Scoring
|
Scoring
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.tnl = function(lvl) {
|
api.tnl = function(lvl) {
|
||||||
return Math.round(((Math.pow(lvl, 2) * 0.25) + (10 * lvl) + 139.75) / 10) * 10;
|
return Math.round(((Math.pow(lvl, 2) * 0.25) + (10 * lvl) + 139.75) / 10) * 10;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A hyperbola function that creates diminishing returns, so you can't go to infinite (eg, with Exp gain).
|
A hyperbola function that creates diminishing returns, so you can't go to infinite (eg, with Exp gain).
|
||||||
{max} The asymptote
|
{max} The asymptote
|
||||||
{bonus} All the numbers combined for your point bonus (eg, task.value * user.stats.int * critChance, etc)
|
{bonus} All the numbers combined for your point bonus (eg, task.value * user.stats.int * critChance, etc)
|
||||||
{halfway} (optional) the point at which the graph starts bending
|
{halfway} (optional) the point at which the graph starts bending
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.diminishingReturns = function(bonus, max, halfway) {
|
api.diminishingReturns = function(bonus, max, halfway) {
|
||||||
if (halfway == null) {
|
if (halfway == null) {
|
||||||
@@ -4873,13 +4871,13 @@ api.monod = function(bonus, rateOfIncrease, max) {
|
|||||||
return rateOfIncrease * max * bonus / (rateOfIncrease * bonus + max);
|
return rateOfIncrease * max * bonus / (rateOfIncrease * bonus + max);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Preen history for users with > 7 history entries
|
Preen history for users with > 7 history entries
|
||||||
This takes an infinite array of single day entries [day day day day day...], and turns it into a condensed array
|
This takes an infinite array of single day entries [day day day day day...], and turns it into a condensed array
|
||||||
of averages, condensing more the further back in time we go. Eg, 7 entries each for last 7 days; 1 entry each week
|
of averages, condensing more the further back in time we go. Eg, 7 entries each for last 7 days; 1 entry each week
|
||||||
of this month; 1 entry for each month of this year; 1 entry per previous year: [day*7 week*4 month*12 year*infinite]
|
of this month; 1 entry for each month of this year; 1 entry per previous year: [day*7 week*4 month*12 year*infinite]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
preenHistory = function(history) {
|
preenHistory = function(history) {
|
||||||
var newHistory, preen, thisMonth;
|
var newHistory, preen, thisMonth;
|
||||||
@@ -4915,10 +4913,10 @@ preenHistory = function(history) {
|
|||||||
return newHistory;
|
return newHistory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update the in-browser store with new gear. FIXME this was in user.fns, but it was causing strange issues there
|
Update the in-browser store with new gear. FIXME this was in user.fns, but it was causing strange issues there
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
sortOrder = _.reduce(content.gearTypes, (function(m, v, k) {
|
sortOrder = _.reduce(content.gearTypes, (function(m, v, k) {
|
||||||
m[v] = k;
|
m[v] = k;
|
||||||
@@ -4951,21 +4949,21 @@ api.updateStore = function(user) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Content
|
Content
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.content = content;
|
api.content = content;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Misc Helpers
|
Misc Helpers
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.uuid = function() {
|
api.uuid = function() {
|
||||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
||||||
@@ -4982,11 +4980,11 @@ api.countExists = function(items) {
|
|||||||
}), 0);
|
}), 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Even though Mongoose handles task defaults, we want to make sure defaults are set on the client-side before
|
Even though Mongoose handles task defaults, we want to make sure defaults are set on the client-side before
|
||||||
sending up to the server for performance
|
sending up to the server for performance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.taskDefaults = function(task) {
|
api.taskDefaults = function(task) {
|
||||||
var defaults, _ref, _ref1, _ref2;
|
var defaults, _ref, _ref1, _ref2;
|
||||||
@@ -5064,10 +5062,10 @@ api.percent = function(x, y, dir) {
|
|||||||
return Math.max(0, roundFn(x / y * 100));
|
return Math.max(0, roundFn(x / y * 100));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Remove whitespace #FIXME are we using this anywwhere? Should we be?
|
Remove whitespace #FIXME are we using this anywwhere? Should we be?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.removeWhitespace = function(str) {
|
api.removeWhitespace = function(str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@@ -5076,10 +5074,10 @@ api.removeWhitespace = function(str) {
|
|||||||
return str.replace(/\s/g, '');
|
return str.replace(/\s/g, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Encode the download link for .ics iCal file
|
Encode the download link for .ics iCal file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.encodeiCalLink = function(uid, apiToken) {
|
api.encodeiCalLink = function(uid, apiToken) {
|
||||||
var loc, _ref;
|
var loc, _ref;
|
||||||
@@ -5087,10 +5085,10 @@ api.encodeiCalLink = function(uid, apiToken) {
|
|||||||
return encodeURIComponent("http://" + loc + "/v1/users/" + uid + "/calendar.ics?apiToken=" + apiToken);
|
return encodeURIComponent("http://" + loc + "/v1/users/" + uid + "/calendar.ics?apiToken=" + apiToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gold amount from their money
|
Gold amount from their money
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.gold = function(num) {
|
api.gold = function(num) {
|
||||||
if (num) {
|
if (num) {
|
||||||
@@ -5100,10 +5098,10 @@ api.gold = function(num) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Silver amount from their money
|
Silver amount from their money
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.silver = function(num) {
|
api.silver = function(num) {
|
||||||
if (num) {
|
if (num) {
|
||||||
@@ -5113,10 +5111,10 @@ api.silver = function(num) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Task classes given everything about the class
|
Task classes given everything about the class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.taskClasses = function(task, filters, dayStart, lastCron, showCompleted, main) {
|
api.taskClasses = function(task, filters, dayStart, lastCron, showCompleted, main) {
|
||||||
var classes, completed, enabled, filter, repeat, type, value, _ref;
|
var classes, completed, enabled, filter, repeat, type, value, _ref;
|
||||||
@@ -5187,19 +5185,19 @@ api.taskClasses = function(task, filters, dayStart, lastCron, showCompleted, mai
|
|||||||
return classes;
|
return classes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Friendly timestamp
|
Friendly timestamp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.friendlyTimestamp = function(timestamp) {
|
api.friendlyTimestamp = function(timestamp) {
|
||||||
return moment(timestamp).format('MM/DD h:mm:ss a');
|
return moment(timestamp).format('MM/DD h:mm:ss a');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Does user have new chat messages?
|
Does user have new chat messages?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.newChatMessages = function(messages, lastMessageSeen) {
|
api.newChatMessages = function(messages, lastMessageSeen) {
|
||||||
if (!((messages != null ? messages.length : void 0) > 0)) {
|
if (!((messages != null ? messages.length : void 0) > 0)) {
|
||||||
@@ -5208,10 +5206,10 @@ api.newChatMessages = function(messages, lastMessageSeen) {
|
|||||||
return (messages != null ? messages[0] : void 0) && (messages[0].id !== lastMessageSeen);
|
return (messages != null ? messages[0] : void 0) && (messages[0].id !== lastMessageSeen);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
are any tags active?
|
are any tags active?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.noTags = function(tags) {
|
api.noTags = function(tags) {
|
||||||
return _.isEmpty(tags) || _.isEmpty(_.filter(tags, function(t) {
|
return _.isEmpty(tags) || _.isEmpty(_.filter(tags, function(t) {
|
||||||
@@ -5219,10 +5217,10 @@ api.noTags = function(tags) {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Are there tags applied?
|
Are there tags applied?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.appliedTags = function(userTags, taskTags) {
|
api.appliedTags = function(userTags, taskTags) {
|
||||||
var arr;
|
var arr;
|
||||||
@@ -5283,12 +5281,11 @@ api.countTriad = function(pets) {
|
|||||||
return count3;
|
return count3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
User (prototype wrapper to give it ops, helper funcs, and virtuals
|
User (prototype wrapper to give it ops, helper funcs, and virtuals
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5319,7 +5316,8 @@ TODO
|
|||||||
user on the server is a Mongoose model, so we can use prototype - but to do it on the client, we'd probably have to
|
user on the server is a Mongoose model, so we can use prototype - but to do it on the client, we'd probably have to
|
||||||
move to $resource for user
|
move to $resource for user
|
||||||
* Move to $resource!
|
* Move to $resource!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
api.wrap = function(user, main) {
|
api.wrap = function(user, main) {
|
||||||
if (main == null) {
|
if (main == null) {
|
||||||
@@ -6545,11 +6543,11 @@ api.wrap = function(user, main) {
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Because the same op needs to be performed on the client and the server (critical hits, item drops, etc),
|
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
|
we need things to be "random", but technically predictable so that they don't go out-of-sync
|
||||||
*/
|
*/
|
||||||
|
|
||||||
predictableRandom: function(seed) {
|
predictableRandom: function(seed) {
|
||||||
var x;
|
var x;
|
||||||
if (!seed || seed === Math.PI) {
|
if (!seed || seed === Math.PI) {
|
||||||
@@ -6577,11 +6575,11 @@ api.wrap = function(user, main) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get a random property from an object
|
Get a random property from an object
|
||||||
returns random property (the value)
|
returns random property (the value)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
randomVal: function(obj, options) {
|
randomVal: function(obj, options) {
|
||||||
var array, rand;
|
var array, rand;
|
||||||
array = (options != null ? options.key : void 0) ? _.keys(obj) : _.values(obj);
|
array = (options != null ? options.key : void 0) ? _.keys(obj) : _.values(obj);
|
||||||
@@ -6589,13 +6587,13 @@ api.wrap = function(user, main) {
|
|||||||
array.sort();
|
array.sort();
|
||||||
return array[Math.floor(rand * array.length)];
|
return array[Math.floor(rand * array.length)];
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This allows you to set object properties by dot-path. Eg, you can run pathSet('stats.hp',50,user) which is the same as
|
This allows you to set object properties by dot-path. Eg, you can run pathSet('stats.hp',50,user) which is the same as
|
||||||
user.stats.hp = 50. This is useful because in our habitrpg-shared functions we're returning changesets as {path:value},
|
user.stats.hp = 50. This is useful because in our habitrpg-shared functions we're returning changesets as {path:value},
|
||||||
so that different consumers can implement setters their own way. Derby needs model.set(path, value) for example, where
|
so that different consumers can implement setters their own way. Derby needs model.set(path, value) for example, where
|
||||||
Angular sets object properties directly - in which case, this function will be used.
|
Angular sets object properties directly - in which case, this function will be used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dotSet: function(path, val) {
|
dotSet: function(path, val) {
|
||||||
return api.dotSet(user, path, val);
|
return api.dotSet(user, path, val);
|
||||||
},
|
},
|
||||||
@@ -6673,12 +6671,12 @@ api.wrap = function(user, main) {
|
|||||||
return user.items.lastDrop.count++;
|
return user.items.lastDrop.count++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Updates user stats with new stats. Handles death, leveling up, etc
|
Updates user stats with new stats. Handles death, leveling up, etc
|
||||||
{stats} new stats
|
{stats} new stats
|
||||||
{update} if aggregated changes, pass in userObj as update. otherwise commits will be made immediately
|
{update} if aggregated changes, pass in userObj as update. otherwise commits will be made immediately
|
||||||
*/
|
*/
|
||||||
|
|
||||||
autoAllocate: function() {
|
autoAllocate: function() {
|
||||||
return user.stats[(function() {
|
return user.stats[(function() {
|
||||||
var diff, ideal, preference, stats, suggested;
|
var diff, ideal, preference, stats, suggested;
|
||||||
@@ -6783,7 +6781,7 @@ api.wrap = function(user, main) {
|
|||||||
_base[k] = 0;
|
_base[k] = 0;
|
||||||
}
|
}
|
||||||
user.items.quests[k]++;
|
user.items.quests[k]++;
|
||||||
((_base1 = user.flags).levelDrops != null ? _base1.levelDrops : _base1.levelDrops = {})[k] = true;
|
((_base1 = user.flags).levelDrops != null ? (_base1 = user.flags).levelDrops : _base1.levelDrops = {})[k] = true;
|
||||||
if (typeof user.markModified === "function") {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('flags.levelDrops');
|
user.markModified('flags.levelDrops');
|
||||||
}
|
}
|
||||||
@@ -6802,7 +6800,6 @@ api.wrap = function(user, main) {
|
|||||||
return user.flags.freeRebirth = true;
|
return user.flags.freeRebirth = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Cron
|
Cron
|
||||||
@@ -6816,6 +6813,7 @@ api.wrap = function(user, main) {
|
|||||||
And you have to run it every time client connects.
|
And you have to run it every time client connects.
|
||||||
{user}
|
{user}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cron: function(options) {
|
cron: function(options) {
|
||||||
var clearBuffs, daysMissed, expTally, lvl, lvlDiv2, now, perfect, plan, progress, todoTally, _base, _base1, _base2, _base3, _progress, _ref, _ref1, _ref2;
|
var clearBuffs, daysMissed, expTally, lvl, lvlDiv2, now, perfect, plan, progress, todoTally, _base, _base1, _base2, _base3, _progress, _ref, _ref1, _ref2;
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
@@ -6955,7 +6953,7 @@ api.wrap = function(user, main) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((_base1 = (user.history != null ? user.history : user.history = {})).todos != null ? _base1.todos : _base1.todos = []).push({
|
((_base1 = (user.history != null ? user.history : user.history = {})).todos != null ? (_base1 = (user.history != null ? user.history : user.history = {})).todos : _base1.todos = []).push({
|
||||||
date: now,
|
date: now,
|
||||||
value: todoTally
|
value: todoTally
|
||||||
});
|
});
|
||||||
@@ -6965,7 +6963,7 @@ api.wrap = function(user, main) {
|
|||||||
lvl++;
|
lvl++;
|
||||||
expTally += api.tnl(lvl);
|
expTally += api.tnl(lvl);
|
||||||
}
|
}
|
||||||
((_base2 = user.history).exp != null ? _base2.exp : _base2.exp = []).push({
|
((_base2 = user.history).exp != null ? (_base2 = user.history).exp : _base2.exp = []).push({
|
||||||
date: now,
|
date: now,
|
||||||
value: expTally
|
value: expTally
|
||||||
});
|
});
|
||||||
@@ -6978,7 +6976,7 @@ api.wrap = function(user, main) {
|
|||||||
user.markModified('dailys');
|
user.markModified('dailys');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.stats.buffs = perfect ? ((_base3 = user.achievements).perfect != null ? _base3.perfect : _base3.perfect = 0, user.achievements.perfect++, user.stats.lvl < 100 ? lvlDiv2 = Math.ceil(user.stats.lvl / 2) : lvlDiv2 = 50, {
|
user.stats.buffs = perfect ? ((_base3 = user.achievements).perfect != null ? (_base3 = user.achievements).perfect : _base3.perfect = 0, user.achievements.perfect++, user.stats.lvl < 100 ? lvlDiv2 = Math.ceil(user.stats.lvl / 2) : lvlDiv2 = 50, {
|
||||||
str: lvlDiv2,
|
str: lvlDiv2,
|
||||||
int: lvlDiv2,
|
int: lvlDiv2,
|
||||||
per: lvlDiv2,
|
per: lvlDiv2,
|
||||||
@@ -7058,9 +7056,9 @@ api.wrap = function(user, main) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(user, '_statsComputed', {
|
Object.defineProperty(user, '_statsComputed', {
|
||||||
get: function() {
|
get: function() {
|
||||||
var computed;
|
var computed,
|
||||||
computed = _.reduce(['per', 'con', 'str', 'int'], (function(_this) {
|
_this = this;
|
||||||
return function(m, stat) {
|
computed = _.reduce(['per', 'con', 'str', 'int'], function(m, stat) {
|
||||||
m[stat] = _.reduce($w('stats stats.buffs items.gear.equipped.weapon items.gear.equipped.armor items.gear.equipped.head items.gear.equipped.shield'), function(m2, path) {
|
m[stat] = _.reduce($w('stats stats.buffs items.gear.equipped.weapon items.gear.equipped.armor items.gear.equipped.head items.gear.equipped.shield'), function(m2, path) {
|
||||||
var item, val;
|
var item, val;
|
||||||
val = user.fns.dotGet(path);
|
val = user.fns.dotGet(path);
|
||||||
@@ -7072,8 +7070,7 @@ api.wrap = function(user, main) {
|
|||||||
m[stat] += 50;
|
m[stat] += 50;
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
};
|
}, {});
|
||||||
})(this), {});
|
|
||||||
computed.maxMP = computed.int * 2 + 30;
|
computed.maxMP = computed.int * 2 + 30;
|
||||||
return computed;
|
return computed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"aws-sdk": "^2.0.25",
|
"aws-sdk": "^2.0.25",
|
||||||
"bower": "~1.3.12",
|
"bower": "~1.3.12",
|
||||||
"browserify": "~3.30.2",
|
"browserify": "~3.30.2",
|
||||||
"coffee-script": "1.7.1",
|
"coffee-script": "1.6.x",
|
||||||
"coffeeify": "0.6.0",
|
"coffeeify": "0.6.0",
|
||||||
"connect-ratelimit": "0.0.7",
|
"connect-ratelimit": "0.0.7",
|
||||||
"coupon-code": "~0.3.0",
|
"coupon-code": "~0.3.0",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ if (cores!==0 && cluster.isMaster && (isDev || isProd)) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
require('coffee-script/register'); // remove this once we've fully converted over
|
require('coffee-script'); // remove this once we've fully converted over
|
||||||
var express = require("express");
|
var express = require("express");
|
||||||
var http = require("http");
|
var http = require("http");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|||||||
Reference in New Issue
Block a user