Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaD173 committed Jul 23, 2024
2 parents 05d5cce + 2cfbc35 commit b17e8b3
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ npm-debug.log
/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 Down
37 changes: 34 additions & 3 deletions build-tools/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const STADIUM = [2.04, 1.04];
const NATDEX = [9.1, 8.1];
const ADDED = [-4.81, -9.81, 9.21, -9.82];
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];
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, ...ADDED, ...NATDEX, ...LC]) {
Expand All @@ -346,6 +346,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
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 @@ -359,6 +360,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (isSpring) genStr = 'gen9vgcspringmayhem';
if (isMet) genStr = 'gen9metronome';
if (isSSB) genStr += 'ssb';
if (isBW1) genStr += 'bw1';
return genStr;
})();
// process.stdout.write("" + gen + (isDoubles ? " doubles" : "") + "... ");
Expand All @@ -370,6 +372,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const ndDoublesBans = {};
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 @@ -492,6 +495,12 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
}
}
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 Down Expand Up @@ -580,8 +589,19 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
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 @@ -924,6 +944,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 @@ -940,6 +961,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 @@ -1127,7 +1158,7 @@ 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', 'secondaries', 'multihit', 'heal'];
const overrideMoveKeys = ['accuracy', 'basePower', 'category', 'desc', 'flags', 'isNonstandard', 'pp', 'priority', 'shortDesc', 'target', 'type', 'secondaries', 'multihit', 'heal'];
const overrideAbilityKeys = ['desc', 'flags', 'isNonstandard', 'rating', 'shortDesc'];
const overrideItemKeys = ['desc', 'fling', 'isNonstandard', 'naturalGift', 'shortDesc'];

Expand Down Expand Up @@ -1217,7 +1248,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
// Mods
//

for (const mod of ['gen7letsgo', 'gen8bdsp', 'gen9ssb', 'gen4vgcplat', 'gen9vgcgay', 'gen9vgcspringmayhem']) {
for (const mod of ['gen5bw1', 'gen7letsgo', 'gen8bdsp', 'gen9ssb', 'gen4vgcplat', 'gen9vgcgay', 'gen9vgcspringmayhem']) {
const modDex = Dex.mod(mod);
const modData = modDex.data;
const parentDex = Dex.forGen(modDex.gen);
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 @@ -202,11 +202,18 @@ let news = '[failed to retrieve news]';
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
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RewriteRule ^adminrequests?\/?$ https://www.smogon.com/forums/threads/names-pass
RewriteCond %{HTTP_HOST} ^play\.pokemonshowdown\.com$ [NC]
RewriteRule ^forgotpassword\/?$ https://www.smogon.com/forums/threads/names-passwords-rooms-and-servers-contacting-upper-staff.3538721/post-6227626/ [R=302,L]
RewriteCond %{HTTP_HOST} ^play\.pokemonshowdown\.com$ [NC]
RewriteRule ^bugs?(reports?)?\/?$ https://www.smogon.com/forums/ps-bug-report-form/ [R=302,L]
RewriteRule ^bugs?(reports?)?\/?$ https://www.smogon.com/forums/forums/876/ [R=302,L]
RewriteCond %{HTTP_HOST} ^play\.pokemonshowdown\.com$ [NC]
RewriteRule ^rules?\/?$ https://pokemonshowdown.com/rules [R=302,L]
RewriteCond %{HTTP_HOST} ^play\.pokemonshowdown\.com$ [NC]
Expand Down
1 change: 1 addition & 0 deletions play.pokemonshowdown.com/config/coil.json
1 change: 1 addition & 0 deletions play.pokemonshowdown.com/config/config-test.js
1 change: 1 addition & 0 deletions play.pokemonshowdown.com/js/client-battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,7 @@

var target = e.getAttribute('data-target');
var choosableTargets = {normal: 1, any: 1, adjacentAlly: 1, adjacentAllyOrSelf: 1, adjacentFoe: 1};
if (this.battle.gameType === 'freeforall') delete choosableTargets['adjacentAllyOrSelf'];

this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isMegaX ? ' megax' : isMegaY ? ' megay' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '') + (isDynamax ? ' dynamax' : '') + (isTerastal ? ' terastallize' : ''));
if (nearActive.length > 1 && target in choosableTargets) {
Expand Down
8 changes: 7 additions & 1 deletion play.pokemonshowdown.com/js/client-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@
buffer += '</table></div>';
return self.add('|raw|' + buffer);
}
buffer += '<tr><th>Format</th><th><abbr title="Elo rating">Elo</abbr></th><th><abbr title="user\'s percentage chance of winning a random battle (aka GLIXARE)">GXE</abbr></th><th><abbr title="Glicko-1 rating: rating±deviation">Glicko-1</abbr></th><th>W</th><th>L</th><th>Total</th></tr>';
buffer += '<tr><th>Format</th><th><abbr title="Elo rating">Elo</abbr></th><th><abbr title="user\'s percentage chance of winning a random battle (aka GLIXARE)">GXE</abbr></th><th><abbr title="Glicko-1 rating: rating±deviation">Glicko-1</abbr></th><th>COIL</th><th>W</th><th>L</th><th>Total</th></tr>';

var hiddenFormats = [];
for (var i = 0; i < data.length; i++) {
Expand Down Expand Up @@ -969,6 +969,12 @@
buffer += '<td><em>' + Math.round(row.rpr) + '<small> &#177; ' + Math.round(row.rprd) + '</small></em></td>';
}
var N = parseInt(row.w, 10) + parseInt(row.l, 10) + parseInt(row.t, 10);
var COIL_B = LadderRoom.COIL_B[formatId];
if (COIL_B) {
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -COIL_B / N), 0) + '</td>';
} else {
buffer += '<td>--</td>';
}
buffer += '<td>' + row.w + '</td><td>' + row.l + '</td><td>' + N + '</td></tr>';
}
if (hiddenFormats.length) {
Expand Down
5 changes: 4 additions & 1 deletion play.pokemonshowdown.com/js/client-ladder.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@
showHelp: function () {
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p>';
buf += '<h3>How the ladder works</h3>';
buf += '<p>Our ladder displays three ratings: Elo, GXE, and Glicko-1.</p>';
buf += '<p>Our ladder displays four ratings: Elo, GXE, Glicko-1, and COIL.</p>';
buf += '<p><strong>Elo</strong> is the main ladder rating. It\'s a pretty normal ladder rating: goes up when you win and down when you lose.</p>';
buf += '<p><strong>GXE</strong> (Glicko X-Act Estimate) is an estimate of your win chance against an average ladder player.</p>';
buf += '<p><strong>Glicko-1</strong> is a different rating system. It has rating and deviation values.</p>';
buf += '<p><strong>COIL</strong> (Converging Order Invariant Ladder) is mainly used for suspect tests. It goes up as you play games, but not too many games.</p>';
buf += '<p>Note that win/loss should not be used to estimate skill, since who you play against is much more important than how many times you win or lose. Our other stats like Elo and GXE are much better for estimating skill.</p>';
buf += '</div>';
this.$el.html(buf);
Expand All @@ -194,6 +195,8 @@
this.$('button[name=refresh]').addClass('disabled').prop('disabled', true);
this.update();
}
}, {
COIL_B: {},
});

}).call(this, jQuery);
3 changes: 3 additions & 0 deletions play.pokemonshowdown.com/js/client-mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,9 @@
case 'error':
return '<div class="chat message-error">' + BattleLog.escapeHTML(target) + '</div>';
case 'html':
if (!name) {
return {message: '<div class="chat' + hlClass + '">' + timestamp + '<em>' + BattleLog.sanitizeHTML(target) + '</em></div>', noNotify: isNotPM};
}
return {message: '<div class="chat chatmessage-' + toID(name) + hlClass + mineClass + '">' + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <em>' + BattleLog.sanitizeHTML(target) + '</em></div>', noNotify: isNotPM};
case 'uhtml':
case 'uhtmlchange':
Expand Down
3 changes: 2 additions & 1 deletion play.pokemonshowdown.com/js/client-teambuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@
if (!selection || selection === 'random') continue;
var obj = app.rooms[room].id === "" ? app.rooms[room] : app.rooms[room].tournamentBox;
obj.curTeamIndex++;
obj.updateTeams();
}
this.edit(0);
},
Expand Down Expand Up @@ -3451,7 +3452,7 @@
} else if (move.category === 'Physical' && !move.damage && !move.ohko &&
!['foulplay', 'endeavor', 'counter', 'bodypress', 'seismictoss', 'bide', 'metalburst', 'superfang'].includes(move.id) && !(this.curTeam.gen < 8 && move.id === 'rapidspin')) {
minAtk = false;
} else if (['metronome', 'assist', 'copycat', 'mefirst', 'photongeyser', 'shellsidearm'].includes(move.id) || (this.curTeam.gen === 5 && move.id === 'naturepower')) {
} else if (['metronome', 'assist', 'copycat', 'mefirst', 'photongeyser', 'shellsidearm', 'terablast'].includes(move.id) || (this.curTeam.gen === 5 && move.id === 'naturepower')) {
minAtk = false;
}
if (minSpe === false && moveName === 'Gyro Ball') {
Expand Down
10 changes: 8 additions & 2 deletions play.pokemonshowdown.com/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function toId() {
this.supports = {};

// down
// if (document.location.hostname === 'play.pokemonshowdown.com') this.down = true;
// if (document.location.hostname === 'play.pokemonshowdown.com' || document.location.hostname === 'smogtours.psim.us') this.down = true;
// this.down = true;

this.addRoom('');
Expand Down Expand Up @@ -459,7 +459,8 @@ function toId() {
var settings = Dex.prefs('serversettings') || {};
if (Object.keys(settings).length) app.user.set('settings', settings);
// HTML5 history throws exceptions when running on file://
Backbone.history.start({pushState: !Config.testclient});
var useHistory = !Config.testclient && (location.pathname.slice(-5) !== '.html');
Backbone.history.start({pushState: useHistory});
app.ignore = app.loadIgnore();
});
}
Expand Down Expand Up @@ -697,6 +698,11 @@ function toId() {
Object.assign(Config.customcolors, data);
});

// get coil values too
$.get('/config/coil.json', {}, function (data) {
Object.assign(LadderRoom.COIL_B, data);
});

this.initializeConnection();
},
/**
Expand Down
14 changes: 14 additions & 0 deletions play.pokemonshowdown.com/ladder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<table>
<tr>
<th></th><th>Name</th><th><abbr title="Elo rating">Elo</abbr></th><th><abbr title="user's percentage chance of winning a random battle (aka GLIXARE)">GXE</abbr></th><th><abbr title="Glicko-1 rating system: rating&#177;deviation (provisional if deviation>100)">Glicko-1</abbr></th>
<th>COIL</th>
</tr>
<?php

Expand All @@ -36,6 +37,12 @@
</tr>
<?php
}

$coil_vals = array();
try {
$coil_vals = json_decode(file_get_contents('../config/coil.json'), true);
} catch (Exception $e) {}

foreach ($toplist as $row)
{
$i++;
Expand All @@ -44,6 +51,13 @@
<tr<?php /* if (floatval($row['rprd']) > 100) echo ' style="color:#999"'; */ ?>>
<td><?php echo $i; ?></td><td><?php echo htmlspecialchars($row['username']); ?></td><td><strong><?php echo round($row['elo']); ?></strong></td><td><?php echo ($row['rprd'] < 100 ? number_format($row['gxe'],1) . '<small>%</small>' : '&ndash;'); ?></td>
<td><?php echo '<em>'.round($row['rpr']).'<small> &#177; '.round($row['rprd']).'</small></em>'; /* if (floatval($row['rprd']) > 100) echo ' <small>(provisional)</small>'; */ ?></td>
<td>
<?php
if (isset($coil_vals[$row['formatid']])) {
$N=$row['w']+$row['l']+$row['t'];
echo number_format($N ? 40*$row['gxe']*pow(2.0,-$coil_vals[$row['formatid']]/$N) : 0,1,'.','');
} else echo '--';
?></td>
</tr>
<?php
}
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ export class BattleScene implements BattleSceneStub {

typeAnim(pokemon: Pokemon, types: string) {
const result = BattleLog.escapeHTML(types).split('/').map(type =>
'<img src="' + Dex.resourcePrefix + 'sprites/types/' + type + '.png" alt="' + type + '" class="pixelated" />'
'<img src="' + Dex.resourcePrefix + 'sprites/types/' + encodeURIComponent(type) + '.png" alt="' + type + '" class="pixelated" />'
).join(' ');
this.resultAnim(pokemon, result, 'neutral');
}
Expand Down
9 changes: 5 additions & 4 deletions play.pokemonshowdown.com/src/battle-dex-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,8 @@ interface MoveFlags {
mirror?: 1 | 0;
/** Prevented from being executed or selected in a Sky Battle. */
nonsky?: 1 | 0;
/** Cannot be copied by Sketch */
nosketch?: 1 | 0;
/** Has no effect on Grass-type Pokemon, Pokemon with the Overcoat Ability, and Pokemon holding Safety Goggles. */
powder?: 1 | 0;
/** Blocked by Detect, Protect, Spiky Shield, and if not a Status move, King's Shield. */
Expand Down Expand Up @@ -1246,7 +1248,6 @@ class Move implements Effect {
readonly noPPBoosts: boolean;
readonly status: string;
readonly secondaries: ReadonlyArray<any> | null;
readonly noSketch: boolean;
readonly num: number;

constructor(id: ID, name: string, data: any) {
Expand Down Expand Up @@ -1283,7 +1284,6 @@ class Move implements Effect {
this.noPPBoosts = data.noPPBoosts || false;
this.status = data.status || '';
this.secondaries = data.secondaries || (data.secondary ? [data.secondary] : null);
this.noSketch = !!data.noSketch;

this.isMax = data.isMax || false;
this.maxMove = data.maxMove || {basePower: 0};
Expand Down Expand Up @@ -1555,11 +1555,12 @@ class Species implements Effect {
this.canGigantamax = !!data.canGigantamax;
this.cannotDynamax = !!data.cannotDynamax;
this.forceTeraType = data.forceTeraType || '';
this.battleOnly = data.battleOnly || undefined;
this.battleOnly = data.battleOnly || (this.isMega ? this.baseSpecies : undefined);
this.isNonstandard = data.isNonstandard || null;
this.unreleasedHidden = data.unreleasedHidden || false;
this.changesFrom = data.changesFrom || undefined;
this.usage = usage;
this.changesFrom = data.changesFrom ||
(this.battleOnly !== this.baseSpecies ? this.battleOnly : this.baseSpecies);
if (!this.gen) {
if (this.num >= 906 || this.formeid.startsWith('-paldea')) {
this.gen = 9;
Expand Down
Loading

0 comments on commit b17e8b3

Please sign in to comment.