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 Apr 2, 2024
2 parents 5407548 + 8411650 commit 90d3a09
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions play.pokemonshowdown.com/js/client-ladder.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
}, function (data) {
if (self.curFormat !== format) return;
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p><p><button class="button" name="refresh"><i class="fa fa-refresh"></i> Refresh</button>';
buf += '&nbsp;<button class="button" name="send" value="/join view-seasonladder-' + format + '"><i class="fa fa-trophy"></i> Season rankings</button>';
buf += '<form class="search"><input type="text" name="searchval" class="textbox searchinput" value="' + BattleLog.escapeHTML(self.curSearchVal || '') + '" placeholder="username prefix" /><button type="submit"> Search</button></form></p>';
buf += '<h3>' + BattleLog.escapeFormat(format) + ' Top ' + BattleLog.escapeHTML(self.curSearchVal ? "- '" + self.curSearchVal + "'" : '500') + '</h3>';
buf += data + '</div>';
Expand Down
2 changes: 2 additions & 0 deletions play.pokemonshowdown.com/js/client-mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@
this.open = Storage.prefs('openformats') || {
"S/V Singles": true, "S/V Doubles": true, "Unofficial Metagames": true, "National Dex": true, "OM of the Month": true,
"Other Metagames": true, "Randomized Format Spotlight": true, "RoA Spotlight": true,
// For AFD
"Random Meta of the Decade": true,
};
}
if (!this.starred) this.starred = Storage.prefs('starredformats') || {};
Expand Down
29 changes: 28 additions & 1 deletion play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,34 @@ export class BattleScene implements BattleSceneStub {
pokemonhtml = '<div class="teamicons">' + pokemonhtml + '</div>';
const ratinghtml = side.rating ? ` title="Rating: ${BattleLog.escapeHTML(side.rating)}"` : ``;
const faded = side.name ? `` : ` style="opacity: 0.4"`;
return `<div class="trainer trainer-${posStr}"${faded}><strong>${BattleLog.escapeHTML(side.name)}</strong><div class="trainersprite"${ratinghtml} style="background-image:url(${Dex.resolveAvatar(side.avatar)})"></div>${pokemonhtml}</div>`;
let badgehtml = '';
if (side.badges.length) {
badgehtml = '<span class="badges">';
// hard limiting it to only ever 3 allowed at a time
// that's what the server limit is anyway but there should be a client limit too
// just in case
for (const badgeData of side.badges.slice(0, 3)) {
// ${badge.type}|${badge.format}|${BADGE_THRESHOLDS[badge.type]}-${badge.season}
const [type, format, details] = badgeData.split('|');
// todo, maybe make this more easily configured if we ever add badges for other stuff?
// but idk that we're planning that for now so
const [threshold] = details.split('-');
const hover = `User is Top ${threshold} on the ${format} Ladder`;
// ou and randbats get diff badges from everyone else, find it
// (regex futureproofs for double digit gens)
let formatType = format.split(/gen\d+/)[1] || 'none';
if (!['ou', 'randombattle'].includes(formatType)) {
formatType = 'rotating';
}
badgehtml += `<img src="${Dex.resourcePrefix}/sprites/misc/${formatType}_${type}.png" style="padding: 0px 1px 0px 1px" width="16px" height="16px" title="${hover}" />`;
}
badgehtml += '</span>';
}
return (
`<div class="trainer trainer-${posStr}"${faded}><strong>${BattleLog.escapeHTML(side.name)}</strong>` +
`<div class="trainersprite"${ratinghtml} style="background-image:url(${Dex.resolveAvatar(side.avatar)})">` +
`</div>${badgehtml}${pokemonhtml}</div>`
);
}
updateSidebar(side: Side) {
if (this.battle.gameType === 'freeforall') {
Expand Down
3 changes: 2 additions & 1 deletion play.pokemonshowdown.com/src/battle-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ const Dex = new class implements ModdedDex {
if (options.shiny && mechanicsGen > 1) dir += '-shiny';

// April Fool's 2014
if (window.Config?.server?.afd || Dex.prefs('afd') || options.afd) {
if (Dex.prefs('afd') !== false && (window.Config?.server?.afd || Dex.prefs('afd') || options.afd)) {
// Explicit false check above means AFD will be off if the user disables it - no matter what
dir = 'afd' + dir;
spriteData.url += dir + '/' + name + '.png';
// Duplicate code but needed to make AFD tinymax work
Expand Down
10 changes: 10 additions & 0 deletions play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ export class Side {
foe: Side = null!;
ally: Side | null = null;
avatar: string = 'unknown';
badges: string[] = [];
rating: string = '';
totalPokemon = 6;
x = 0;
Expand Down Expand Up @@ -3560,6 +3561,15 @@ export class Battle {
this.scene.updateSidebar(side);
break;
}
case 'badge': {
let side = this.getSide(args[1]);
// handle all the rendering further down
const badge = args.slice(2).join('|');
// (don't allow duping)
if (!side.badges.includes(badge)) side.badges.push(badge);
this.scene.updateSidebar(side);
break;
}
case 'teamsize': {
let side = this.getSide(args[1]);
side.totalPokemon = parseInt(args[2], 10);
Expand Down

0 comments on commit 90d3a09

Please sign in to comment.