54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
const MamiEmotes = (function() {
|
|
let emotes = [];
|
|
|
|
const clear = function() {
|
|
emotes = [];
|
|
};
|
|
|
|
const add = function(emote) {
|
|
emotes.push(emote);
|
|
};
|
|
|
|
const addLegacy = function(emoteOld) {
|
|
const emote = {
|
|
url: emoteOld.Image,
|
|
minRank: emoteOld.Hierarchy,
|
|
strings: [],
|
|
};
|
|
for(let i = 0; i < emoteOld.Text.length; ++i)
|
|
emote.strings.push(emoteOld.Text[i].slice(1, -1));
|
|
add(emote);
|
|
};
|
|
|
|
return {
|
|
clear: clear,
|
|
add: add,
|
|
addLegacy: addLegacy,
|
|
load: function(batch) {
|
|
for(const emote of batch)
|
|
add(emote);
|
|
},
|
|
loadLegacy: function(batch) {
|
|
for(const emote of batch)
|
|
addLegacy(emote);
|
|
},
|
|
forEach: function(minRank, callback) {
|
|
for(const emote of emotes)
|
|
if(emote.minRank <= minRank)
|
|
callback(emote);
|
|
},
|
|
findByName: function(minRank, name, returnString) {
|
|
const found = [];
|
|
for(const emote of emotes)
|
|
if(emote.minRank <= minRank) {
|
|
for(const string of emote.strings)
|
|
if(string.indexOf(name) === 0) {
|
|
found.push(returnString ? string : emote);
|
|
break;
|
|
}
|
|
}
|
|
return found;
|
|
},
|
|
};
|
|
})();
|