Skip to content

Commit

Permalink
Override Fling and Natural Gift data for items in past gens
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik99999 committed Jun 1, 2024
1 parent 8acf7c0 commit ba6d1fc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
25 changes: 21 additions & 4 deletions build-tools/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
}
}

Expand Down Expand Up @@ -1205,6 +1209,19 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
}
}
}

const overrideItemData = {};
BattleTeambuilderTable[mod].overrideItemData = overrideItemData;
for (const id in genData.Items) {

Check failure on line 1215 in build-tools/build-indexes

View workflow job for this annotation

GitHub Actions / build (14.x)

'genData' is not defined
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`;
Expand Down
15 changes: 10 additions & 5 deletions play.pokemonshowdown.com/src/battle-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down

0 comments on commit ba6d1fc

Please sign in to comment.