diff --git a/constant.ts b/constant.ts index ed5b147..40a492e 100644 --- a/constant.ts +++ b/constant.ts @@ -1,7 +1,7 @@ import type { StatInkPostBody, VsHistoryDetail } from "./types.ts"; export const AGENT_NAME = "s3si.ts"; -export const S3SI_VERSION = "0.1.0"; +export const S3SI_VERSION = "0.1.1"; export const NSOAPP_VERSION = "2.3.1"; export const WEB_VIEW_VERSION = "1.0.0-216d0219"; diff --git a/exporter/stat.ink.ts b/exporter/stat.ink.ts index 04bb7cc..65f4338 100644 --- a/exporter/stat.ink.ts +++ b/exporter/stat.ink.ts @@ -224,8 +224,8 @@ export class StatInkExporter implements BattleExporter { result.fest_power = festMatch.myFestPower ?? undefined; } if (rule === "TURF_WAR") { - result.our_team_percent = (myTeam.result.paintRatio ?? 0) * 100; - result.their_team_percent = (otherTeams?.[0].result.paintRatio ?? 0) * + result.our_team_percent = (myTeam?.result?.paintRatio ?? 0) * 100; + result.their_team_percent = (otherTeams?.[0]?.result?.paintRatio ?? 0) * 100; result.our_team_inked = myTeam.players.reduce( (acc, i) => acc + i.paint, @@ -236,13 +236,12 @@ export class StatInkExporter implements BattleExporter { 0, ); } - if (bankaraMatch) { - result.our_team_count = myTeam.result.score ?? undefined; - result.their_team_count = otherTeams?.[0].result.score ?? undefined; - - result.knockout = (!knockout || knockout === "NEITHER") ? "no" : "yes"; - result.rank_exp_change = bankaraMatch.earnedUdemaePoint; + if (knockout) { + result.knockout = knockout === "NEITHER" ? "no" : "yes"; } + result.our_team_count = myTeam?.result?.score ?? undefined; + result.their_team_count = otherTeams?.[0]?.result?.score ?? undefined; + result.rank_exp_change = bankaraMatch?.earnedUdemaePoint; if (listNode) { [result.rank_before, result.rank_before_s_plus] = parseUdemae( listNode.udemae, @@ -261,7 +260,8 @@ export class StatInkExporter implements BattleExporter { if (lastInChallenge) { result.challenge_win = bankaraMatchChallenge.winCount; result.challenge_lose = bankaraMatchChallenge.loseCount; - result.rank_exp_change = bankaraMatchChallenge.earnedUdemaePoint; + result.rank_exp_change = bankaraMatchChallenge.earnedUdemaePoint ?? + undefined; } } diff --git a/types.ts b/types.ts index 2cf2374..b0af56a 100644 --- a/types.ts +++ b/types.ts @@ -35,9 +35,9 @@ export type BankaraMatchChallenge = { maxLoseCount: number; state: "FAILED" | "SUCCEEDED" | "INPROGRESS"; isPromo: boolean; - isUdemaeUp: boolean; + isUdemaeUp: boolean | null; udemaeAfter: string | null; - earnedUdemaePoint: number; + earnedUdemaePoint: number | null; }; export type BattleListNode = { // battle id added after fetch @@ -76,7 +76,7 @@ export type VsPlayer = { }; export type VsTeam = { players: VsPlayer[]; - result: { + result: null | { paintRatio: null | number; score: null | number; };