refactor: better convert (v0.1.1)

main
spacemeowx2 2022-10-21 16:14:44 +08:00
parent ce95475201
commit a4f69f4ad5
3 changed files with 13 additions and 13 deletions

View File

@ -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";

View File

@ -224,8 +224,8 @@ export class StatInkExporter implements BattleExporter<VsBattle> {
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<VsBattle> {
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<VsBattle> {
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;
}
}

View File

@ -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;
};