mirror of
https://github.com/webxoss/webxoss-client.git
synced 2024-11-20 05:49:55 +01:00
38 lines
No EOL
712 B
JavaScript
38 lines
No EOL
712 B
JavaScript
'use strict';
|
|
function Searcher () {
|
|
this.rules = [
|
|
ColorRule,
|
|
CrossRule,
|
|
TypeRule,
|
|
RarityRule,
|
|
RiseRule,
|
|
TrapRule,
|
|
AcceRule,
|
|
SkillRule,
|
|
NoBurstRule,
|
|
// LifeBurstRule,
|
|
TimmingRule,
|
|
LimitingRule,
|
|
ClassRule,
|
|
PowerRule,
|
|
LevelRule,
|
|
LimitRule,
|
|
NumberRule,
|
|
IllustRule,
|
|
WxidRule,
|
|
NameRule
|
|
];
|
|
}
|
|
Searcher.prototype.search = function (str) {
|
|
// if (!str) return [];
|
|
var words = str.toLowerCase().split(/\s+/);
|
|
var filters = this.rules.map(function (rule) {
|
|
return rule.parse(words);
|
|
},this);
|
|
var infos = Object.keys(CardInfo).map(function (pid) {
|
|
return CardInfo[pid];
|
|
});
|
|
return filters.reduce(function (results,filter) {
|
|
return results.filter(filter);
|
|
},infos);
|
|
}; |