From 4eae149f0703c0601088becd0eeefc018ad727f3 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 29 Mar 2016 02:52:24 -0400 Subject: [PATCH] Teambuilder: Improve search aliases We now support searching by first letter and second word, so for instance "rslide" in addition to "rs" will match "rock slide" We now also support "mega" and "m" as the first word, so "mega scizor" and "mscizor" will match "scizor-mega". --- githooks/build-indexes | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/githooks/build-indexes b/githooks/build-indexes index c735b7669..9c62b1e32 100755 --- a/githooks/build-indexes +++ b/githooks/build-indexes @@ -56,8 +56,19 @@ function requireNoCache(pathSpec) { function generateAlias(id, name, type) { let i = name.lastIndexOf(' '); if (i < 0) i = name.lastIndexOf('-'); - if (name.endsWith('-Mega-X') || name.endsWith('-Mega-Y')) i = name.lastIndexOf('-', i - 1); + if (name.endsWith('-Mega-X') || name.endsWith('-Mega-Y')) { + index.push('mega' + toId(name.slice(0, -7) + name.slice(-1)) + ' ' + type + ' ' + id + ' 0'); + index.push('m' + toId(name.slice(0, -7) + name.slice(-1)) + ' ' + type + ' ' + id + ' 0'); + index.push('mega' + toId(name.slice(-1)) + ' ' + type + ' ' + id + ' ' + toId(name.slice(0, -7)).length); + return; + } + if (name.endsWith('-Mega')) { + index.push('mega' + toId(name.slice(0, -5)) + ' ' + type + ' ' + id + ' 0'); + index.push('m' + toId(name.slice(0, -5)) + ' ' + type + ' ' + id + ' 0'); + return; + } if (name === 'Earthquake') i = 5; + if (name === 'Hariyama') i = 4; if (name === 'Thunderbolt') { i = 7; index.push('tb ' + type + ' ' + id + ' 0'); @@ -71,9 +82,9 @@ function requireNoCache(pathSpec) { } else if (name === 'Hidden Power') { index.push('hp ' + type + ' ' + id + ' 0'); } else if (name.includes(' ')) { - acronym = toId(name.split(' ').map(x => x.charAt(0)).join('')); + acronym = toId(name.split(' ').map((x, i) => i !== 0 ? x : x.charAt(0)).join('')); } else if (name.includes('-') && name.charAt(1) !== '-') { - acronym = toId(name.split('-').map(x => x.charAt(0)).join('')); + acronym = toId(name.split('-').map((x, i) => i !== 0 ? x : x.charAt(0)).join('')); } if (acronym && !(acronym in Tools.data.Aliases) || toId(Tools.data.Aliases[acronym]) !== id) { index.push('' + acronym + ' ' + type + ' ' + id + ' 0');