mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-30 14:52:36 -05:00
Show species-specific items in teambuilder
This commit is contained in:
@@ -970,13 +970,14 @@ class Item implements Effect {
|
||||
readonly zMove: string | true | null;
|
||||
readonly zMoveType: TypeName | '';
|
||||
readonly zMoveFrom: string;
|
||||
readonly zMoveUser: string[] | null;
|
||||
readonly zMoveUser: readonly string[] | null;
|
||||
readonly onPlate: TypeName;
|
||||
readonly onMemory: TypeName;
|
||||
readonly onDrive: TypeName;
|
||||
readonly fling: any;
|
||||
readonly naturalGift: any;
|
||||
readonly isPokeball: boolean;
|
||||
readonly itemUser?: readonly string[];
|
||||
|
||||
constructor(id: ID, name: string, data: any) {
|
||||
if (!data || typeof data !== 'object') data = {};
|
||||
@@ -1003,6 +1004,7 @@ class Item implements Effect {
|
||||
this.fling = data.fling || null;
|
||||
this.naturalGift = data.naturalGift || null;
|
||||
this.isPokeball = !!data.isPokeball;
|
||||
this.itemUser = data.itemUser;
|
||||
|
||||
if (!this.gen) {
|
||||
if (this.num >= 577) {
|
||||
|
||||
@@ -1052,8 +1052,25 @@ class BattleItemSearch extends BattleTypedSearch<'item'> {
|
||||
}
|
||||
return table.itemSet;
|
||||
}
|
||||
getBaseResults() {
|
||||
return this.getDefaultResults();
|
||||
getBaseResults(): SearchRow[] {
|
||||
if (!this.species) return this.getDefaultResults();
|
||||
const speciesName = this.dex.getSpecies(this.species).name;
|
||||
const results = this.getDefaultResults();
|
||||
const speciesSpecific: SearchRow[] = [];
|
||||
for (const row of results) {
|
||||
if (row[0] !== 'item') continue;
|
||||
if (this.dex.getItem(row[1]).itemUser?.includes(speciesName)) {
|
||||
speciesSpecific.push(row);
|
||||
}
|
||||
}
|
||||
if (speciesSpecific.length) {
|
||||
return [
|
||||
['header', "Specific to " + speciesName],
|
||||
...speciesSpecific,
|
||||
...results,
|
||||
];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
filter(row: SearchRow, filters: string[][]) {
|
||||
if (!filters) return true;
|
||||
|
||||
Reference in New Issue
Block a user