diff --git a/play.pokemonshowdown.com/js/client-ladder.js b/play.pokemonshowdown.com/js/client-ladder.js index 89547a6b7d..c08ef1294b 100644 --- a/play.pokemonshowdown.com/js/client-ladder.js +++ b/play.pokemonshowdown.com/js/client-ladder.js @@ -161,6 +161,7 @@ }, function (data) { if (self.curFormat !== format) return; var buf = '

'; + buf += ' '; buf += '

'; buf += '

' + BattleLog.escapeFormat(format) + ' Top ' + BattleLog.escapeHTML(self.curSearchVal ? "- '" + self.curSearchVal + "'" : '500') + '

'; buf += data + '
'; diff --git a/play.pokemonshowdown.com/src/battle-animations.ts b/play.pokemonshowdown.com/src/battle-animations.ts index d07e134fe4..31087b3da5 100644 --- a/play.pokemonshowdown.com/src/battle-animations.ts +++ b/play.pokemonshowdown.com/src/battle-animations.ts @@ -690,7 +690,34 @@ export class BattleScene implements BattleSceneStub { pokemonhtml = '
' + pokemonhtml + '
'; const ratinghtml = side.rating ? ` title="Rating: ${BattleLog.escapeHTML(side.rating)}"` : ``; const faded = side.name ? `` : ` style="opacity: 0.4"`; - return `
${BattleLog.escapeHTML(side.name)}
${pokemonhtml}
`; + let badgehtml = ''; + if (side.badges.length) { + badgehtml = ''; + // 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 += ``; + } + badgehtml += ''; + } + return ( + `
${BattleLog.escapeHTML(side.name)}` + + `
` + + `
${badgehtml}${pokemonhtml}
` + ); } updateSidebar(side: Side) { if (this.battle.gameType === 'freeforall') { diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 04ca1b915a..d5c67d86ae 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -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; @@ -3535,6 +3536,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);