From a10d97d91d352592d965ee8ff9dcaea879e78911 Mon Sep 17 00:00:00 2001 From: kitt Date: Sat, 8 Jul 2023 14:13:13 -0400 Subject: [PATCH] send challenge data --- src/exporters/splashcat-types.ts | 30 ++++++++++++++++++++++-------- src/exporters/splashcat.ts | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/exporters/splashcat-types.ts b/src/exporters/splashcat-types.ts index 7831140..9e1dcbe 100644 --- a/src/exporters/splashcat-types.ts +++ b/src/exporters/splashcat-types.ts @@ -1,6 +1,6 @@ /** * A battle to be uploaded to Splashcat. Any SplatNet 3 strings should use en-US locale. - * Splashcat will translate strings into the user's langauge. + * Splashcat will translate strings into the user's language. */ export interface SplashcatBattle { anarchy?: Anarchy; @@ -9,6 +9,7 @@ export interface SplashcatBattle { * and manage the award's rank. */ awards: string[]; + challenge?: Challenge; duration: number; judgement: SplashcatBattleJudgement; knockout?: Knockout; @@ -29,11 +30,21 @@ export interface SplashcatBattle { export interface Anarchy { mode?: AnarchyMode; pointChange?: number; + power?: number; [property: string]: any; } export type AnarchyMode = "SERIES" | "OPEN"; +export interface Challenge { + /** + * base64 decoded and split by `-` to get the last section + */ + id?: string; + power?: number; + [property: string]: any; +} + export type SplashcatBattleJudgement = "WIN" | "LOSE" | "DRAW" | "EXEMPTED_LOSE" | "DEEMED_LOSE"; export type Knockout = "NEITHER" | "WIN" | "LOSE"; @@ -56,7 +67,7 @@ export interface Team { festUniformBonusRate?: number; festUniformName?: string; isMyTeam: boolean; - judgement: TeamJudgement; + judgement?: TeamJudgement; noroshi?: number; order: number; paintRatio?: number; @@ -81,12 +92,15 @@ export interface Player { /** * Array of badge IDs. Use JSON `null` for empty slots. */ - badges: Array; - clothingGear: Gear; - deaths?: number; - disconnected: boolean; - headGear: Gear; - isMe: boolean; + badges: Array; + clothingGear: Gear; + deaths?: number; + disconnected: boolean; + headGear: Gear; + isMe: boolean; + /** + * Should report the same way that SplatNet 3 does (kills + assists) + */ kills?: number; name: string; nameId: string; diff --git a/src/exporters/splashcat.ts b/src/exporters/splashcat.ts index 792b84d..06a4d4d 100644 --- a/src/exporters/splashcat.ts +++ b/src/exporters/splashcat.ts @@ -236,6 +236,10 @@ export class SplashcatExporter implements GameExporter { xBattle: vsDetail.vsMode.mode === "X_MATCH" ? { xPower: vsDetail.xMatch?.lastXPower ?? undefined, } : undefined, + challenge: vsDetail.vsMode.mode === "LEAGUE" ? { + id: new TextDecoder().decode(base64.decode(vsDetail.leagueMatch?.leagueMatchEvent?.id!)).split("-")[1], + power: vsDetail.leagueMatch?.myLeaguePower ?? undefined, + } : undefined, teams: [], awards: vsDetail.awards.map((i) => i.name), };