diff --git a/play.pokemonshowdown.com/src/battle-dex-search.ts b/play.pokemonshowdown.com/src/battle-dex-search.ts index c1052e43d..2f9d7d8f4 100644 --- a/play.pokemonshowdown.com/src/battle-dex-search.ts +++ b/play.pokemonshowdown.com/src/battle-dex-search.ts @@ -90,6 +90,7 @@ export class DexSearch { } static unselectableResultTypes = ['header', 'html', 'sortpokemon', 'sortmove']; firstPokemonColumn: 'Tier' | 'Number' = 'Number'; + numAbilityCols: 0 | 1 | 2 = 0; /** * Column to sort by. Default is `null`, a smart sort determined by how good @@ -207,7 +208,13 @@ export class DexSearch { this.sortCol = null; } this.typedSearch = this.getTypedSearch(searchType, format, speciesOrSet); - if (this.typedSearch) this.dex = this.typedSearch.dex; + this.numAbilityCols = 0; + if (this.typedSearch) { + this.dex = this.typedSearch.dex; + if (searchType === 'pokemon' && this.dex.gen >= 3 && this.dex.modid !== 'gen7letsgo') { + this.numAbilityCols = this.dex.gen < 5 ? 1 : 2; + } + } } capitalizeFirst(str: string) { diff --git a/play.pokemonshowdown.com/src/battle-searchresults.tsx b/play.pokemonshowdown.com/src/battle-searchresults.tsx index 7af47c832..bd943555b 100644 --- a/play.pokemonshowdown.com/src/battle-searchresults.tsx +++ b/play.pokemonshowdown.com/src/battle-searchresults.tsx @@ -65,18 +65,22 @@ export class PSSearchResults extends preact.Component<{ renderPokemonSortRowHTML(index: number) { const search = this.props.search; const sortCol = search.sortCol; + const abilityWidthClass = search.numAbilityCols === 1 ? 'singleabilitysortcol' : 'abilitysortcol'; return [ `
  • `, ``, ``, ``, - ``, + !search.numAbilityCols ? '' : + ``, ``, ``, ``, - ``, - ``, + search.dex.gen === 1 ? + `` : + `` + + ``, ``, ``, `
  • `, @@ -126,27 +130,28 @@ export class PSSearchResults extends preact.Component<{ `${escapeHTML(search.dex.text.typeName(type))}` ).join('')}`; - if (search.dex.gen >= 3) { + if (search.numAbilityCols) { const ability0 = search.dex.text.get(search.dex.abilities.get(pokemon.abilities['0'])).name; const ability1 = pokemon.abilities['1'] && search.dex.text.get(search.dex.abilities.get(pokemon.abilities['1'])).name; buf += pokemon.abilities['1'] ? `${escapeHTML(ability0)}
    ${escapeHTML(ability1)}
    ` : `${escapeHTML(ability0)}`; - } - if (search.dex.gen >= 5) { - const hiddenAbility = pokemon.abilities['H'] && - search.dex.text.get(search.dex.abilities.get(pokemon.abilities['H'])).name; - const specialAbility = pokemon.abilities['S'] && - search.dex.text.get(search.dex.abilities.get(pokemon.abilities['S'])).name; - if (pokemon.abilities['S']) { - buf += `` + - `${escapeHTML(hiddenAbility || '')}
    ${escapeHTML(specialAbility)}
    `; - } else if (pokemon.abilities['H']) { - buf += `` + - `${escapeHTML(hiddenAbility)}`; - } else { - buf += ``; + + if (search.numAbilityCols >= 2) { + const hiddenAbility = pokemon.abilities['H'] && + search.dex.text.get(search.dex.abilities.get(pokemon.abilities['H'])).name; + const specialAbility = pokemon.abilities['S'] && + search.dex.text.get(search.dex.abilities.get(pokemon.abilities['S'])).name; + if (pokemon.abilities['S']) { + buf += `` + + `${escapeHTML(hiddenAbility || '')}
    ${escapeHTML(specialAbility)}
    `; + } else if (pokemon.abilities['H']) { + buf += `` + + `${escapeHTML(hiddenAbility)}`; + } else { + buf += ``; + } } } diff --git a/play.pokemonshowdown.com/style/battle-search.css b/play.pokemonshowdown.com/style/battle-search.css index 1c6e4bce1..e5db847ef 100644 --- a/play.pokemonshowdown.com/style/battle-search.css +++ b/play.pokemonshowdown.com/style/battle-search.css @@ -334,6 +334,9 @@ .dexlist .abilitysortcol { width: 172px; } +.dexlist .singleabilitysortcol { + width: 86px; +} .dexlist .statsortcol { width: 24px; text-align: right;