From cedd4722222966128db114c4ccdd6a7cff87523d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bastos=20Dias?= <80102738+andrebastosdias@users.noreply.github.com> Date: Thu, 8 Jan 2026 22:04:54 +0000 Subject: [PATCH] [Client] Implement Mega Stones as {key: value} pairs (#2590) * [Client] Implement Mega Stones as pairs {key: value} * Simplify conditions * Fix * Update play.pokemonshowdown.com/js/client-teambuilder.js --------- Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com> --- play.pokemonshowdown.com/js/client-teambuilder.js | 4 ++-- play.pokemonshowdown.com/src/battle-dex-data.ts | 6 ++---- play.pokemonshowdown.com/src/battle-tooltips.ts | 2 +- play.pokemonshowdown.com/src/battle.ts | 6 +++++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/play.pokemonshowdown.com/js/client-teambuilder.js b/play.pokemonshowdown.com/js/client-teambuilder.js index 8d8c4d809..5a265b5b3 100644 --- a/play.pokemonshowdown.com/js/client-teambuilder.js +++ b/play.pokemonshowdown.com/js/client-teambuilder.js @@ -1521,8 +1521,8 @@ } if (this.curTeam.gen >= 6) { var item = dex.items.get(set.item); - if (item.megaStone && species.baseSpecies === item.megaEvolves) { - species = dex.species.get(item.megaStone); + if (item.megaEvolves && item.megaEvolves[species.baseSpecies]) { + species = dex.species.get(item.megaEvolves[species.baseSpecies]); typeTable = typeTable.filter(function (type) { return species.types.includes(type); }); diff --git a/play.pokemonshowdown.com/src/battle-dex-data.ts b/play.pokemonshowdown.com/src/battle-dex-data.ts index 983da372f..df2ec834d 100644 --- a/play.pokemonshowdown.com/src/battle-dex-data.ts +++ b/play.pokemonshowdown.com/src/battle-dex-data.ts @@ -1154,8 +1154,7 @@ export class Item implements Effect { readonly desc: string; readonly shortDesc: string; - readonly megaStone: string; - readonly megaEvolves: string; + readonly megaStone: { [megaEvolves: string]: string }; readonly zMove: string | true | null; readonly zMoveType: TypeName | ''; readonly zMoveFrom: string; @@ -1181,8 +1180,7 @@ export class Item implements Effect { this.desc = data.desc || data.shortDesc || ''; this.shortDesc = data.shortDesc || this.desc; - this.megaStone = data.megaStone || ''; - this.megaEvolves = data.megaEvolves || ''; + this.megaStone = data.megaStone || null; this.zMove = data.zMove || null; this.zMoveType = data.zMoveType || ''; this.zMoveFrom = data.zMoveFrom || ''; diff --git a/play.pokemonshowdown.com/src/battle-tooltips.ts b/play.pokemonshowdown.com/src/battle-tooltips.ts index 78bcbb881..4bc1eb5ec 100644 --- a/play.pokemonshowdown.com/src/battle-tooltips.ts +++ b/play.pokemonshowdown.com/src/battle-tooltips.ts @@ -2620,7 +2620,7 @@ export class BattleStatGuesser { let abilityid = toID(set.ability); let species = this.dex.species.get(set.species || set.name!); - if (item.megaEvolves === species.name) species = this.dex.species.get(item.megaStone); + if (item.megaStone?.[species.name]) species = this.dex.species.get(item.megaStone[species.name]); if (!species.exists) return '?'; let stats = species.baseStats; diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 71c56a7c8..0f9a84531 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -2473,7 +2473,11 @@ export class Battle { let species = this.dex.species.get(newSpeciesForme); if (nextArgs) { if (nextArgs[0] === '-mega') { - species = this.dex.species.get(this.dex.items.get(nextArgs[3]).megaStone); + const item = this.dex.items.get(nextArgs[3]); + if (item.megaStone) { + const index = Object.values(item.megaStone).indexOf(species.name); + if (index >= 0) species = this.dex.species.get(Object.keys(item.megaStone)[index]); + } } else if (nextArgs[0] === '-primal' && nextArgs.length > 2) { if (nextArgs[2] === 'Red Orb') species = this.dex.species.get('Groudon-Primal'); if (nextArgs[2] === 'Blue Orb') species = this.dex.species.get('Kyogre-Primal');