`;
+ 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);