@@ -17,8 +17,8 @@ define([ | |||||
}, | }, | ||||
build: function (type, options) { | build: function (type, options) { | ||||
var className = 'ui' + type[0].toUpperCase() + type.substr(1); | |||||
var el = $('.' + className); | |||||
let className = 'ui' + type[0].toUpperCase() + type.substr(1); | |||||
let el = $('.' + className); | |||||
if (el.length > 0) | if (el.length > 0) | ||||
return; | return; | ||||
@@ -31,7 +31,7 @@ define([ | |||||
}, | }, | ||||
onGetTemplate: function (options, template) { | onGetTemplate: function (options, template) { | ||||
var ui = _.create(uiBase, template); | |||||
let ui = $.extend(true, {}, uiBase, template); | |||||
ui.setOptions(options); | ui.setOptions(options); | ||||
ui.render(); | ui.render(); | ||||
ui.el.data('ui', ui); | ui.el.data('ui', ui); | ||||
@@ -52,10 +52,10 @@ define([ | |||||
}, | }, | ||||
update: function () { | update: function () { | ||||
var uis = this.uis; | |||||
var uLen = uis.length; | |||||
for (var i = 0; i < uLen; i++) { | |||||
var u = uis[i]; | |||||
let uis = this.uis; | |||||
let uLen = uis.length; | |||||
for (let i = 0; i < uLen; i++) { | |||||
let u = uis[i]; | |||||
if (u.update) | if (u.update) | ||||
u.update(); | u.update(); | ||||
} | } | ||||
@@ -1,9 +0,0 @@ | |||||
define([ | |||||
], function ( | |||||
) { | |||||
return { | |||||
type: 'aggro' | |||||
}; | |||||
}); |
@@ -18,7 +18,6 @@ let components = [ | |||||
'stats', | 'stats', | ||||
'chest', | 'chest', | ||||
'effects', | 'effects', | ||||
'aggro', | |||||
'quests', | 'quests', | ||||
'events', | 'events', | ||||
'resourceNode', | 'resourceNode', | ||||
@@ -28,7 +27,6 @@ let components = [ | |||||
'chatter', | 'chatter', | ||||
'dialogue', | 'dialogue', | ||||
'trade', | 'trade', | ||||
'prophecies', | |||||
'reputation', | 'reputation', | ||||
'serverActions', | 'serverActions', | ||||
'social', | 'social', | ||||
@@ -50,7 +48,11 @@ define(components, function () { | |||||
if (type === 'lightpatch') | if (type === 'lightpatch') | ||||
type = 'lightPatch'; | type = 'lightPatch'; | ||||
return templates[type]; | |||||
let template = templates[type] || { | |||||
type: type | |||||
}; | |||||
return template; | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -1,9 +0,0 @@ | |||||
define([ | |||||
], function ( | |||||
) { | |||||
return { | |||||
type: 'prophecies' | |||||
}; | |||||
}); |
@@ -82,15 +82,6 @@ Object.defineProperty(Object.prototype, 'has', { | |||||
}); | }); | ||||
window._ = { | window._ = { | ||||
create: function () { | |||||
let result = {}; | |||||
[].slice.call(arguments).forEach(function (a) { | |||||
$.extend(true, result, a); | |||||
}); | |||||
return result; | |||||
}, | |||||
get2dArray: function (w, h, def) { | get2dArray: function (w, h, def) { | ||||
def = def || 0; | def = def || 0; | ||||
@@ -108,15 +99,6 @@ window._ = { | |||||
} | } | ||||
return result; | return result; | ||||
}, | |||||
randWeighted: function (weights) { | |||||
let sample = []; | |||||
weights.forEach(function (w, i) { | |||||
for (let j = 0; j < w; j++) | |||||
sample.push(i); | |||||
}); | |||||
return sample[~~(Math.random() * sample.length)]; | |||||
} | } | ||||
}; | }; | ||||
@@ -72,7 +72,7 @@ define([ | |||||
require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options)); | require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options)); | ||||
}, | }, | ||||
onGetTemplate: function (options, template) { | onGetTemplate: function (options, template) { | ||||
let ui = _.create(uiBase, template); | |||||
let ui = $.extend(true, {}, uiBase, template); | |||||
ui.setOptions(options); | ui.setOptions(options); | ||||
ui.render(); | ui.render(); | ||||
ui.el.data('ui', ui); | ui.el.data('ui', ui); | ||||