mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-19 04:08:54 +00:00
feat(accessories): add body accessory & better handling of gear sorting
This commit is contained in:
parent
cfb762db58
commit
b93bf8be7f
3 changed files with 19 additions and 35 deletions
33
dist/habitrpg-shared.js
vendored
33
dist/habitrpg-shared.js
vendored
|
|
@ -9186,7 +9186,7 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
|
|||
|
||||
classes = ['warrior', 'rogue', 'healer', 'wizard'];
|
||||
|
||||
gearTypes = ['armor', 'weapon', 'shield', 'head', 'back', 'headAccessory'];
|
||||
gearTypes = ['weapon', 'armor', 'head', 'shield', 'body', 'back', 'headAccessory'];
|
||||
|
||||
events = {
|
||||
winter: {
|
||||
|
|
@ -10264,6 +10264,7 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
|
|||
}
|
||||
}
|
||||
},
|
||||
body: {},
|
||||
back: {
|
||||
base: {
|
||||
0: {
|
||||
|
|
@ -11439,7 +11440,7 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
|
|||
|
||||
},{"lodash":3,"moment":4}],6:[function(require,module,exports){
|
||||
var process=require("__browserify_process");(function() {
|
||||
var $w, api, content, moment, preenHistory, sanitizeOptions, _,
|
||||
var $w, api, content, moment, preenHistory, sanitizeOptions, 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');
|
||||
|
|
@ -11640,6 +11641,11 @@ var process=require("__browserify_process");(function() {
|
|||
*/
|
||||
|
||||
|
||||
sortOrder = _.reduce(content.gearTypes, (function(m, v, k) {
|
||||
m[v] = k;
|
||||
return m;
|
||||
}), {});
|
||||
|
||||
api.updateStore = function(user) {
|
||||
var changes;
|
||||
|
||||
|
|
@ -11647,7 +11653,7 @@ var process=require("__browserify_process");(function() {
|
|||
return;
|
||||
}
|
||||
changes = [];
|
||||
_.each(['weapon', 'armor', 'shield', 'head', 'back', 'headAccessory'], function(type) {
|
||||
_.each(content.gearTypes, function(type) {
|
||||
var found;
|
||||
|
||||
found = _.find(content.gear.tree[type][user.stats["class"]], function(item) {
|
||||
|
|
@ -11664,25 +11670,8 @@ var process=require("__browserify_process");(function() {
|
|||
return ((_ref = v.klass) === 'special' || _ref === 'mystery') && !user.items.gear.owned[v.key] && (typeof v.canOwn === "function" ? v.canOwn(user) : void 0);
|
||||
}));
|
||||
changes.push(content.potion);
|
||||
return _.sortBy(changes, function(item) {
|
||||
switch (item.type) {
|
||||
case 'weapon':
|
||||
return 1;
|
||||
case 'armor':
|
||||
return 2;
|
||||
case 'head':
|
||||
return 3;
|
||||
case 'shield':
|
||||
return 4;
|
||||
case 'back':
|
||||
return 5;
|
||||
case 'headAccessory':
|
||||
return 6;
|
||||
case 'potion':
|
||||
return 7;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
return _.sortBy(changes, function(c) {
|
||||
return sortOrder[c.type];
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ moment = require 'moment'
|
|||
###
|
||||
|
||||
classes = ['warrior', 'rogue', 'healer', 'wizard']
|
||||
gearTypes = ['armor', 'weapon', 'shield', 'head', 'back', 'headAccessory']
|
||||
gearTypes = [ 'weapon', 'armor', 'head', 'shield', 'body', 'back', 'headAccessory']
|
||||
|
||||
events =
|
||||
winter: {start:'2013-12-31',end:'2014-02-01'}
|
||||
|
|
@ -221,6 +221,8 @@ gear =
|
|||
springWarrior: event: events.spring, specialClass: 'warrior', text: 'Egg Shield', notes: "This shield never cracks, no matter how hard you hit it! Adds 7 points to CON. Limited Edition 2014 Spring Gear.", value: 70, con: 7
|
||||
springHealer: event: events.spring, specialClass: 'healer', text: 'Squeaky Ball of Ultimate Protection', notes: "Lets out an obnoxious, continuous squeak when bitten, driving enemies away. Adds 9 points to CON. Limited Edition 2014 Spring Gear.", value: 70, con: 9
|
||||
|
||||
body:{}
|
||||
|
||||
back:
|
||||
base:
|
||||
0: text: "No Back Accessory", notes:'No Back Accessory.', value:0
|
||||
|
|
|
|||
|
|
@ -119,10 +119,12 @@ preenHistory = (history) ->
|
|||
###
|
||||
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,((m,v,k)->m[v]=k;m), {}
|
||||
#sortOrder.potion = _.size(sortOrder) #potion goes last #actually, _.sortBy puts anything else last, so this is unecessary
|
||||
api.updateStore = (user) ->
|
||||
return unless user
|
||||
changes = []
|
||||
_.each ['weapon', 'armor', 'shield', 'head', 'back', 'headAccessory'], (type) ->
|
||||
changes= []
|
||||
_.each content.gearTypes, (type) ->
|
||||
found = _.find content.gear.tree[type][user.stats.class], (item) ->
|
||||
!user.items.gear.owned[item.key]
|
||||
changes.push(found) if found
|
||||
|
|
@ -132,16 +134,7 @@ api.updateStore = (user) ->
|
|||
v.klass in ['special','mystery'] and !user.items.gear.owned[v.key] and v.canOwn?(user)
|
||||
changes.push content.potion
|
||||
# Return sorted store (array)
|
||||
_.sortBy changes, (item) ->
|
||||
switch item.type
|
||||
when 'weapon' then 1
|
||||
when 'armor' then 2
|
||||
when 'head' then 3
|
||||
when 'shield' then 4
|
||||
when 'back' then 5
|
||||
when 'headAccessory' then 6
|
||||
when 'potion' then 7
|
||||
else 8
|
||||
_.sortBy changes, (c)->sortOrder[c.type]
|
||||
|
||||
###
|
||||
------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue