From ba6d1fcc64e3213f69ebb71b86760ce88c85daf9 Mon Sep 17 00:00:00 2001 From: Karthik99999 Date: Sat, 1 Jun 2024 15:46:12 +0530 Subject: [PATCH] Override Fling and Natural Gift data for items in past gens --- build-tools/build-indexes | 25 ++++++++++++++++++---- play.pokemonshowdown.com/src/battle-dex.ts | 15 ++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/build-tools/build-indexes b/build-tools/build-indexes index 008bc61b7e..8ef5d0fc2d 100755 --- a/build-tools/build-indexes +++ b/build-tools/build-indexes @@ -1077,6 +1077,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); const overrideSpeciesKeys = ['abilities', 'baseStats', 'cosmeticFormes', 'isNonstandard', 'requiredItems', 'types', 'unreleasedHidden']; const overrideMoveKeys = ['accuracy', 'basePower', 'category', 'desc', 'flags', 'isNonstandard', 'noSketch', 'pp', 'priority', 'shortDesc', 'target', 'type']; const overrideAbilityKeys = ['desc', 'flags', 'isNonstandard', 'rating', 'shortDesc']; + const overrideItemKeys = ['desc', 'fling', 'isNonstandard', 'naturalGift', 'shortDesc']; // // Past gen table @@ -1130,13 +1131,16 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); } } - const overrideItemDesc = {}; - BattleTeambuilderTable[gen].overrideItemDesc = overrideItemDesc; + const overrideItemData = {}; + BattleTeambuilderTable[gen].overrideItemData = overrideItemData; for (const id in genData.Items) { const curEntry = genDex.items.get(id); const nextEntry = nextGenDex.items.get(id); - if ((curEntry.shortDesc || curEntry.desc) !== (nextEntry.shortDesc || nextEntry.desc)) { - overrideItemDesc[id] = (curEntry.shortDesc || curEntry.desc); + for (const key of overrideItemKeys) { + if (JSON.stringify(curEntry[key]) !== JSON.stringify(nextEntry[key])) { + if (!overrideItemData[id]) overrideItemData[id] = {}; + overrideItemData[id][key] = curEntry[key]; + } } } @@ -1205,6 +1209,19 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); } } } + + const overrideItemData = {}; + BattleTeambuilderTable[mod].overrideItemData = overrideItemData; + for (const id in genData.Items) { + const modEntry = modDex.items.get(id); + const parentEntry = parentDex.items.get(id); + for (const key of overrideItemKeys) { + if (JSON.stringify(modEntry[key]) !== JSON.stringify(parentEntry[key])) { + if (!overrideItemData[id]) overrideItemData[id] = {}; + overrideItemData[id][key] = modEntry[key]; + } + } + } } buf += `exports.BattleTeambuilderTable = JSON.parse('${JSON.stringify(BattleTeambuilderTable).replace(/['\\]/g, "\\$&")}');\n\n`; diff --git a/play.pokemonshowdown.com/src/battle-dex.ts b/play.pokemonshowdown.com/src/battle-dex.ts index 72c8c45858..33065186f6 100644 --- a/play.pokemonshowdown.com/src/battle-dex.ts +++ b/play.pokemonshowdown.com/src/battle-dex.ts @@ -904,11 +904,16 @@ class ModdedDex { let data = {...Dex.items.get(name)}; - for (let i = this.gen; i < 9; i++) { - const table = window.BattleTeambuilderTable['gen' + i]; - if (id in table.overrideItemDesc) { - data.shortDesc = table.overrideItemDesc[id]; - break; + for (let i = Dex.gen - 1; i >= this.gen; i--) { + const table = window.BattleTeambuilderTable[`gen${i}`]; + if (id in table.overrideItemData) { + Object.assign(data, table.overrideItemData[id]); + } + } + if (this.modid !== `gen${this.gen}`) { + const table = window.BattleTeambuilderTable[this.modid]; + if (id in table.overrideItemData) { + Object.assign(data, table.overrideItemData[id]); } }