diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index 1cab9cdd8..9d1b81ca6 100644 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -37,6 +37,7 @@ // details 'change .detailsform input': 'detailsChange', + 'change .detailsform select': 'detailsChange', 'click .changeform' : 'altForm', 'click .altform' : 'altForm', @@ -2392,6 +2393,26 @@ buf += ''; } + if (this.curTeam.gen > 2) { + buf += '
'; + } + + if (this.curTeam.gen > 6) { + buf += '
'; + } + buf += ''; if (template.otherForms && template.baseSpecies !== 'Unown') { buf += ''; @@ -2424,6 +2445,7 @@ delete set.shiny; } + // gender var gender = this.$chart.find('input[name=gender]:checked').val(); if (gender === 'M' || gender === 'F') { set.gender = gender; @@ -2431,6 +2453,22 @@ delete set.gender; } + // pokeball + var pokeball = this.$chart.find('select[name=pokeball]').val(); + if (pokeball && Dex.forGen(this.curTeam.gen).getItem(pokeball).isPokeball) { + set.pokeball = pokeball; + } else { + delete set.pokeball; + } + + // HP type + var hpType = this.$chart.find('select[name=hptype]').val(); + if (hpType && exports.BattleTypeChart[hpType]) { + set.hpType = hpType; + } else { + delete set.hpType; + } + // update details cell var buf = ''; var GenderChart = { diff --git a/src/battle-dex-data.ts b/src/battle-dex-data.ts index 0e3d5123d..70f32fab7 100644 --- a/src/battle-dex-data.ts +++ b/src/battle-dex-data.ts @@ -940,6 +940,7 @@ class Item implements Effect { readonly onDrive: TypeName; readonly fling: any; readonly naturalGift: any; + readonly isPokeball: boolean; constructor(id: ID, name: string, data: any) { if (!data || typeof data !== 'object') data = {}; @@ -965,6 +966,7 @@ class Item implements Effect { this.onDrive = data.onDrive || ''; this.fling = data.fling || null; this.naturalGift = data.naturalGift || null; + this.isPokeball = !!data.isPokeball; if (!this.gen) { if (this.num >= 577) { diff --git a/src/battle-dex.ts b/src/battle-dex.ts index 4c1bb4fa7..fdff836e3 100644 --- a/src/battle-dex.ts +++ b/src/battle-dex.ts @@ -215,6 +215,8 @@ const Dex = new class implements ModdedDex { readonly statNames: ReadonlyArray = ['hp', 'atk', 'def', 'spa', 'spd', 'spe']; readonly statNamesExceptHP: ReadonlyArray = ['atk', 'def', 'spa', 'spd', 'spe']; + pokeballs: string[] | null = null; + resourcePrefix = (() => { let prefix = ''; if (!window.document || !document.location || document.location.protocol !== 'http:') prefix = 'https:'; @@ -755,6 +757,17 @@ const Dex = new class implements ModdedDex { let sanitizedType = type.replace(/\?/g, '%3f'); return '' + type + ''; } + + getPokeballs() { + if (this.pokeballs) return this.pokeballs; + this.pokeballs = []; + if (!window.BattleItems) window.BattleItems = {}; + for (const data of Object.values(window.BattleItems) as AnyObject[]) { + if (!data.isPokeball) continue; + this.pokeballs.push(data.name); + } + return this.pokeballs; + } }; class ModdedDex { @@ -765,6 +778,7 @@ class ModdedDex { Items: {} as any as {[k: string]: Item}, Templates: {} as any as {[k: string]: Template}, }; + pokeballs: string[] | null = null; getAbility: (nameOrAbility: string | Ability | null | undefined) => Ability = Dex.getAbility; constructor(modid: ID) { this.modid = modid; @@ -869,6 +883,18 @@ class ModdedDex { this.cache.Templates[id] = template; return template; } + + getPokeballs() { + if (this.pokeballs) return this.pokeballs; + this.pokeballs = []; + if (!window.BattleItems) window.BattleItems = {}; + for (const data of Object.values(window.BattleItems) as AnyObject[]) { + if (data.gen && data.gen > this.gen) continue; + if (!data.isPokeball) continue; + this.pokeballs.push(data.name); + } + return this.pokeballs; + } } if (typeof require === 'function') {