Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion protocol/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,17 @@ export namespace Protocol {
* Indicates that the game has started.
*/
'|start|': readonly ['start'];
/**
* `|badge|PLAYER|TYPE|FORMAT|THRESHOLD-SEASON`
*
* Indicates that a player has a ladder season badge.
*
* - `PLAYER` is `p1`, `p2`, `p3`, or `p4`
* - `TYPE` is `gold`, `silver`, or `bronze`
* - `FORMAT` is the format ID (e.g. `gen9ou`)
* - `THRESHOLD-SEASON` is the badge threshold and season (e.g. `100-7`)
*/
'|badge|': readonly ['badge', Player, 'gold' | 'silver' | 'bronze', ID, string];
}

export type BattleInitArgName = keyof BattleInitArgs;
Expand Down Expand Up @@ -1897,7 +1908,8 @@ export const Protocol = new class {
'|tournament|end|': 1, '|tournament|scouting|': 1, '|tournament|autostart|': 1,
'|tournament|autodq|': 1, '|player|': 1, '|teamsize|': 1, '|gametype|': 1, '|gen|': 1,
'|tier|': 1, '|rated|': 1, '|seed|': 1, '|rule|': 1, '|teampreview|': 1, '|custom|': 1,
'|clearpoke|': 1, '|poke|': 1, '|start|': 1, '|done|': 1, '|request|': 1, '|inactive|': 1,
'|clearpoke|': 1, '|poke|': 1, '|start|': 1, '|badge|': 1, '|done|': 1, '|request|': 1,
'|inactive|': 1,
'|inactiveoff|': 1, '|upkeep|': 1, '|turn|': 1, '|win|': 1, '|tie|': 1, '|move|': 1,
'|switch|': 1, '|drag|': 1, '|detailschange|': 1, '|replace|': 1, '|swap|': 1, '|cant|': 1,
'|faint|': 1, '|-formechange|': 1, '|-fail|': 1, '|-block|': 1, '|-notarget|': 1, '|-miss|': 1,
Expand Down
8 changes: 8 additions & 0 deletions protocol/src/verifier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,14 @@ class Handler implements Required<Protocol.Handler<boolean>> {
return args.length === 1;
}

'|badge|'(args: Args['|badge|']) {
return args.length === 5 &&
verifyPlayer(args[1]) &&
['gold', 'silver', 'bronze'].includes(args[2]) &&
verifyID(args[3]) &&
!!args[4];
}

'|done|'(args: Args['|done|']) {
return args.length === 1;
}
Expand Down