Skip to content

Commit

Permalink
Merge branch 'smogon:master' into moveppups
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-Comfey authored Oct 12, 2024
2 parents 65137bf + d8eac3b commit db511a6
Show file tree
Hide file tree
Showing 57 changed files with 7,581 additions and 731 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
"BattleFormats": false, "BattleFormatsData": false, "BattleLearnsets": false, "BattleItems": false, "BattleMoveAnims": false, "BattleMovedex": false, "BattleNatures": false,
"BattleOtherAnims": false, "BattlePokedex": false,"BattlePokemonSprites": false, "BattlePokemonSpritesBW": false, "BattleSearchCountIndex": false, "BattleSearchIndex": false, "BattleArticleTitles": false,
"BattleSearchIndexOffset": false, "BattleSearchIndexType": false, "BattleStatIDs": false, "BattleStatNames": false, "BattleStatusAnims": false, "BattleStatuses": false, "BattleTeambuilderTable": false,
"ModifiableValue": false, "BattleStatGuesser": false, "BattleText": true, "BattleTextAFD": false, "BattleTextNotAFD": false,
"ModifiableValue": false, "BattleStatGuesser": false, "BattleStatOptimizer": false, "BattleText": true, "BattleTextAFD": false, "BattleTextNotAFD": false,
"BattleTextParser": false,

// Generic global variables
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules/
.DS_Store
Thumbs.db
npm-debug.log
package-lock.json
/config/
/vendor/
/caches/
Expand All @@ -11,6 +10,7 @@ package-lock.json
/play.pokemonshowdown.com/audio/
/play.pokemonshowdown.com/index.php
/play.pokemonshowdown.com/index.html
/play.pokemonshowdown.com/index-test.html
/play.pokemonshowdown.com/preactalpha.html
/play.pokemonshowdown.com/crossprotocol.html
/play.pokemonshowdown.com/data/
Expand All @@ -23,6 +23,7 @@ package-lock.json
/play.pokemonshowdown.com/js/client-main.js
/play.pokemonshowdown.com/js/client-core.js
/play.pokemonshowdown.com/js/client-connection.js
/play.pokemonshowdown.com/js/miniedit.js
/play.pokemonshowdown.com/ads.txt

/pokemonshowdown.com/.well-known/
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

83 changes: 76 additions & 7 deletions build-tools/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const LC = GENS.map(num => num + 0.7);
const STADIUM = [2.04, 1.04];
const NATDEX = [9.1, 8.1];
const OTHER = [9.9, 9.411, 9.41, 9.401, 9.4, 9.2, -9.4, -9.401, 8.6, 8.4, 8.2, 8.1, -8.4, -8.6, 7.1];
const OTHER = [9.9, 9.6, 9.411, 9.41, 9.401, 9.4, 9.2, -9.4, -9.401, 8.6, 8.4, 8.2, 8.1, -8.4, -8.6, 7.1, 5.1];

// process.stdout.write("\n ");
for (const genIdent of [...GENS, ...DOUBLES, ...VGC, ...NFE, ...STADIUM, ...OTHER, ...NATDEX, ...LC]) {
Expand All @@ -339,7 +339,9 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const isDoubles = (genIdent < 0);
const isVGC = ('' + genIdent).endsWith('.5');
const isGen9BH = genIdent === 9.9;
const isSSB = genIdent === 9.6;
const genNum = Math.floor(isDoubles ? -genIdent : genIdent);
const isBW1 = genIdent === 5.1;
const gen = (() => {
let genStr = 'gen' + genNum;
if (isSSDLC1) genStr += 'dlc1';
Expand All @@ -348,6 +350,8 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (isPreDLC) genStr += 'predlc';
if (isSVDLC1) genStr += 'dlc1';
if (isStadium) genStr += 'stadium' + (genNum > 1 ? genNum : '');
if (isSSB) genStr += 'ssb';
if (isBW1) genStr += 'bw1';
return genStr;
})();
// process.stdout.write("" + gen + (isDoubles ? " doubles" : "") + "... ");
Expand All @@ -357,8 +361,10 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const overrideTier = {};
const ubersUUBans = {};
const ndDoublesBans = {};
const thirtyfivePokes = {};
const monotypeBans = {};
const nonstandardMoves = [];
const gen5zuBans = {};
for (const id of pokemon) {
const species = Dex.mod(gen).species.get(id);
const baseSpecies = Dex.mod(gen).species.get(species.baseSpecies);
Expand Down Expand Up @@ -473,8 +479,18 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (ndDoubles.exists && Dex.formats.getRuleTable(ndDoubles).isBannedSpecies(species)) {
ndDoublesBans[species.id] = 1;
}
const nd35Pokes = Dex.formats.get(gen + 'nationaldex35pokes');
if (nd35Pokes.exists && !Dex.formats.getRuleTable(nd35Pokes).isBannedSpecies(species)) {
thirtyfivePokes[species.id] = 1;
}
}
if (genNum >= 5) {
if (genNum === 5) {
const gen5zu = Dex.formats.get(gen + 'zu');
if (gen5zu.exists && Dex.formats.getRuleTable(gen5zu).isBannedSpecies(species)) {
gen5zuBans[species.id] = 1;
}
}
const mono = Dex.formats.get(gen + (isNatDex ? 'nationaldex' : '') + 'monotype');
if (mono.exists && Dex.formats.getRuleTable(mono).isBannedSpecies(species)) {
monotypeBans[species.id] = 1;
Expand All @@ -500,6 +516,9 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
BattleTeambuilderTable['gen' + genNum + 'natdex'].ndDoublesBans = ndDoublesBans;
BattleTeambuilderTable['gen' + genNum + 'natdex'].monotypeBans = monotypeBans;
BattleTeambuilderTable['gen' + genNum + 'natdex'].formatSlices = formatSlices;
if (isNatDex && genNum === 9) {
BattleTeambuilderTable['gen' + genNum + 'natdex'].thirtyfivePokes = thirtyfivePokes;
}
} else if (isMetBattle) {
BattleTeambuilderTable[gen + 'metronome'] = {};
BattleTeambuilderTable[gen + 'metronome'].tiers = tiers;
Expand Down Expand Up @@ -543,15 +562,31 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
BattleTeambuilderTable['bh'].tiers = tiers;
BattleTeambuilderTable['bh'].overrideTier = overrideTier;
BattleTeambuilderTable['bh'].formatSlices = formatSlices;
} else if (isSSB) {
BattleTeambuilderTable['gen9ssb'] = {};
BattleTeambuilderTable['gen9ssb'].tiers = tiers;
BattleTeambuilderTable['gen9ssb'].overrideTier = overrideTier;
BattleTeambuilderTable['gen9ssb'].formatSlices = formatSlices;
} else if (gen === 'gen9') {
BattleTeambuilderTable.tiers = tiers;
BattleTeambuilderTable.items = items;
BattleTeambuilderTable.overrideTier = overrideTier;
BattleTeambuilderTable.ubersUUBans = ubersUUBans;
BattleTeambuilderTable.monotypeBans = monotypeBans;
BattleTeambuilderTable.formatSlices = formatSlices;
} else if (isBW1) {
BattleTeambuilderTable[gen] = {};
BattleTeambuilderTable[gen].overrideTier = overrideTier;
BattleTeambuilderTable[gen].tiers = tiers;
BattleTeambuilderTable[gen].items = items;
BattleTeambuilderTable[gen].formatSlices = formatSlices;
BattleTeambuilderTable[gen].nonstandardMoves = nonstandardMoves;
BattleTeambuilderTable[gen].learnsets = {};
} else {
BattleTeambuilderTable[gen] = {};
if (genNum === 5) {
BattleTeambuilderTable[gen].gen5zuBans = gen5zuBans;
}
BattleTeambuilderTable[gen].overrideTier = overrideTier;
BattleTeambuilderTable[gen].tiers = tiers;
BattleTeambuilderTable[gen].items = items;
Expand Down Expand Up @@ -759,6 +794,12 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
case 'chippedpot':
case 'crackedpot':
case 'galaricawreath':
case 'auspiciousarmor':
case 'maliciousarmor':
case 'masterpieceteacup':
case 'metalalloy':
case 'unremarkableteacup':
case 'bignugget':
badItems.push(id);
break;
// outclassed items
Expand Down Expand Up @@ -885,6 +926,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (gens.indexOf(9) >= 0 && learnset[moveid].some(x => x[0] === '9' && x !== '9V')) {
learnsets[id][moveid] += 'a';
}
if (gens.indexOf(9) >= 0 && learnset[moveid].some(x => x === '9E')) learnsets[id][moveid] += 'e';
}
}
const G2Learnsets = Dex.mod('gen2').data.Learnsets;
Expand All @@ -901,6 +943,16 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (minGen === 1) learnsets[id][moveid] = '12' + learnsets[id][moveid];
}
}
const G5BW1Learnsets = Dex.mod('gen5bw1').data.Learnsets;
for (const id in G5BW1Learnsets) {
const species = Dex.mod('gen5bw1').species.get(id);
if (species.isNonstandard && !['Unobtainable', 'CAP'].includes(species.isNonstandard)) continue;
const learnset = G5BW1Learnsets[id].learnset;
BattleTeambuilderTable['gen5bw1'].learnsets[id] = {};
for (const moveid in learnset) {
BattleTeambuilderTable['gen5bw1'].learnsets[id][moveid] = '5';
}
}
const LGLearnsets = Dex.mod('gen7letsgo').data.Learnsets;
for (const id in LGLearnsets) {
const species = Dex.mod('gen7letsgo').species.get(id);
Expand Down Expand Up @@ -1062,8 +1114,9 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");

// Client relevant data that should be overriden by past gens and mods
const overrideSpeciesKeys = ['abilities', 'baseStats', 'cosmeticFormes', 'isNonstandard', 'requiredItems', 'types', 'unreleasedHidden'];
const overrideMoveKeys = ['accuracy', 'basePower', 'category', 'desc', 'flags', 'isNonstandard', 'noSketch', 'pp', 'priority', 'shortDesc', 'target', 'type'];
const overrideMoveKeys = ['accuracy', 'basePower', 'category', 'desc', 'flags', 'isNonstandard', '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 @@ -1117,13 +1170,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 All @@ -1148,7 +1204,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
// Mods
//

for (const mod of ['gen7letsgo', 'gen8bdsp']) {
for (const mod of ['gen5bw1', 'gen7letsgo', 'gen8bdsp', 'gen9ssb']) {
const modDex = Dex.mod(mod);
const modData = modDex.data;
const parentDex = Dex.forGen(modDex.gen);
Expand Down Expand Up @@ -1192,6 +1248,19 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
}
}
}

const overrideItemData = {};
BattleTeambuilderTable[mod].overrideItemData = overrideItemData;
for (const id in modData.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`;
Expand Down
9 changes: 9 additions & 0 deletions build-tools/swap-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
cd ..
cp config/config.js config/config.js.old
cp config/head-custom.html config/head-custom.html.old
mv -f config/config-test.js config/config.js
mv -f config/head-custom-test.html config/head-custom.html
mv -i config/config.js.old config/config-test.js
mv -i config/head-custom.html.old config/head-custom-test.html
7 changes: 7 additions & 0 deletions build-tools/update
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,18 @@ try {
indexContents = indexContents.replace(/<!-- newsid -->/g, newsid);
indexContents = indexContents.replace(/<!-- news -->/g, news);

let indexContents2 = '';
try {
let indexContentsOld = indexContents;
indexContents = indexContents.replace(/<!-- head custom -->/g, '' + fs.readFileSync('config/head-custom.html'));
indexContents2 = indexContentsOld.replace(/<!-- head custom -->/g, '' + fs.readFileSync('config/head-custom-test.html'));
indexContents2 = indexContents2.replace(/src="\/\/play.pokemonshowdown.com\/config\/config.js\?[a-z0-9]*"/, 'src="//play.pokemonshowdown.com/config/config-test.js?3"');
} catch (e) {}

fs.writeFileSync('play.pokemonshowdown.com/index.html', indexContents);
if (indexContents2) {
fs.writeFileSync('play.pokemonshowdown.com/index-test.html', indexContents2);
}
fs.writeFileSync('play.pokemonshowdown.com/preactalpha.html', preactIndexContents);
fs.writeFileSync('play.pokemonshowdown.com/crossprotocol.html', crossprotocolContents);
fs.writeFileSync('play.pokemonshowdown.com/js/replay-embed.js', replayEmbedContents);
Expand Down
26 changes: 24 additions & 2 deletions lib/ntbb-ladder.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,32 @@ function getTop($prefix = null) {
"SELECT * FROM (SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $overfetch) AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, "$prefix%"]
);
$res = $ladderdb->query(
"WITH `max_elo` AS (
SELECT MAX(elo) AS `max_elo` FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
`rpr_filtered` AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM
(SELECT * FROM `rpr_filtered` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT {$overfetch})
AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, $this->formatid, $this->formatid, "$prefix%"]
);
} else {
$res = $ladderdb->query(
"SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid]
"WITH max_elo AS (
SELECT MAX(elo) AS max_elo FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
rpr_filtered AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM `rpr_filtered` ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid, $this->formatid]
);
}

Expand Down
Loading

0 comments on commit db511a6

Please sign in to comment.