fix: wrong win/lose count in challenge (0.1.4)
parent
f1799f25f4
commit
c2d20eeaaf
19
src/app.ts
19
src/app.ts
|
|
@ -9,6 +9,7 @@ import {
|
||||||
} from "./splatnet3.ts";
|
} from "./splatnet3.ts";
|
||||||
import {
|
import {
|
||||||
BattleExporter,
|
BattleExporter,
|
||||||
|
ChallengeProgress,
|
||||||
HistoryGroups,
|
HistoryGroups,
|
||||||
VsBattle,
|
VsBattle,
|
||||||
VsHistoryDetail,
|
VsHistoryDetail,
|
||||||
|
|
@ -84,6 +85,7 @@ class BattleFetcher {
|
||||||
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return {
|
return {
|
||||||
|
challengeProgress: null,
|
||||||
bankaraMatchChallenge: null,
|
bankaraMatchChallenge: null,
|
||||||
listNode: null,
|
listNode: null,
|
||||||
};
|
};
|
||||||
|
|
@ -92,10 +94,27 @@ class BattleFetcher {
|
||||||
const { bankaraMatchChallenge } = group;
|
const { bankaraMatchChallenge } = group;
|
||||||
const listNode = group.historyDetails.nodes.find((i) => i._bid === bid) ??
|
const listNode = group.historyDetails.nodes.find((i) => i._bid === bid) ??
|
||||||
null;
|
null;
|
||||||
|
const index = group.historyDetails.nodes.indexOf(listNode!);
|
||||||
|
|
||||||
|
let challengeProgress: null | ChallengeProgress = null;
|
||||||
|
if (bankaraMatchChallenge) {
|
||||||
|
const pastBattles = group.historyDetails.nodes.slice(0, index);
|
||||||
|
const { winCount, loseCount } = bankaraMatchChallenge;
|
||||||
|
challengeProgress = {
|
||||||
|
index,
|
||||||
|
winCount: winCount -
|
||||||
|
pastBattles.filter((i) => i.judgement == "WIN").length,
|
||||||
|
loseCount: loseCount -
|
||||||
|
pastBattles.filter((i) =>
|
||||||
|
["LOSE", "DEEMED_LOSE"].includes(i.judgement)
|
||||||
|
).length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bankaraMatchChallenge,
|
bankaraMatchChallenge,
|
||||||
listNode,
|
listNode,
|
||||||
|
challengeProgress,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async getBattleDetail(id: string): Promise<VsHistoryDetail> {
|
async getBattleDetail(id: string): Promise<VsHistoryDetail> {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
||||||
|
|
||||||
export const AGENT_NAME = "s3si.ts";
|
export const AGENT_NAME = "s3si.ts";
|
||||||
export const S3SI_VERSION = "0.1.3";
|
export const S3SI_VERSION = "0.1.4";
|
||||||
export const NSOAPP_VERSION = "2.3.1";
|
export const NSOAPP_VERSION = "2.3.1";
|
||||||
export const WEB_VIEW_VERSION = "1.0.0-216d0219";
|
export const WEB_VIEW_VERSION = "1.0.0-216d0219";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,8 @@ export class StatInkExporter implements BattleExporter<VsBattle> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
async mapBattle(
|
async mapBattle(
|
||||||
{ bankaraMatchChallenge, listNode, detail: vsDetail }: VsBattle,
|
{ challengeProgress, bankaraMatchChallenge, listNode, detail: vsDetail }:
|
||||||
|
VsBattle,
|
||||||
): Promise<StatInkPostBody> {
|
): Promise<StatInkPostBody> {
|
||||||
const {
|
const {
|
||||||
knockout,
|
knockout,
|
||||||
|
|
@ -256,11 +257,13 @@ export class StatInkExporter implements BattleExporter<VsBattle> {
|
||||||
result.rank_after = result.rank_before;
|
result.rank_after = result.rank_before;
|
||||||
result.rank_after_s_plus = result.rank_before_s_plus;
|
result.rank_after_s_plus = result.rank_before_s_plus;
|
||||||
}
|
}
|
||||||
result.challenge_win = bankaraMatchChallenge.winCount;
|
|
||||||
result.challenge_lose = bankaraMatchChallenge.loseCount;
|
|
||||||
result.rank_exp_change = bankaraMatchChallenge.earnedUdemaePoint ??
|
result.rank_exp_change = bankaraMatchChallenge.earnedUdemaePoint ??
|
||||||
undefined;
|
undefined;
|
||||||
}
|
}
|
||||||
|
if (challengeProgress) {
|
||||||
|
result.challenge_win = challengeProgress.winCount;
|
||||||
|
result.challenge_lose = challengeProgress.loseCount;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ export type BattleListNode = {
|
||||||
_bid: string;
|
_bid: string;
|
||||||
id: string;
|
id: string;
|
||||||
udemae: string;
|
udemae: string;
|
||||||
|
judgement: "LOSE" | "WIN" | "DEEMED_LOSE" | "EXEMPTED_LOSE";
|
||||||
};
|
};
|
||||||
export type HistoryGroups = {
|
export type HistoryGroups = {
|
||||||
nodes: {
|
nodes: {
|
||||||
|
|
@ -89,10 +90,16 @@ export type VsRule =
|
||||||
| "CLAM"
|
| "CLAM"
|
||||||
| "TRI_COLOR";
|
| "TRI_COLOR";
|
||||||
|
|
||||||
|
export type ChallengeProgress = {
|
||||||
|
index: number;
|
||||||
|
winCount: number;
|
||||||
|
loseCount: number;
|
||||||
|
};
|
||||||
// With challenge info
|
// With challenge info
|
||||||
export type VsBattle = {
|
export type VsBattle = {
|
||||||
listNode: null | BattleListNode;
|
listNode: null | BattleListNode;
|
||||||
bankaraMatchChallenge: null | BankaraMatchChallenge;
|
bankaraMatchChallenge: null | BankaraMatchChallenge;
|
||||||
|
challengeProgress: null | ChallengeProgress;
|
||||||
detail: VsHistoryDetail;
|
detail: VsHistoryDetail;
|
||||||
};
|
};
|
||||||
export type VsHistoryDetail = {
|
export type VsHistoryDetail = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue