diff --git a/src/RankTracker.test.ts b/src/RankTracker.test.ts index 406302b..36b32e7 100644 --- a/src/RankTracker.test.ts +++ b/src/RankTracker.test.ts @@ -46,8 +46,6 @@ function genOpenWins( bankaraMatch: { earnedUdemaePoint: 8, }, - nextHistoryDetail: null, - previousHistoryDetail: null, }); id += 1; } @@ -55,6 +53,115 @@ function genOpenWins( return result; } +Deno.test("RankTracker tracks promotion, ignoring INPROGRESS", async () => { + const INIT_STATE = { + gameId: await gameId(genId(0)), + rank: "B+", + rankPoint: 850, + }; + + const tracker = new TestRankTracker(INIT_STATE); + assertEquals(tracker.testGet(), { + state: INIT_STATE, + deltaMap: new Map(), + }); + + const finalState = await tracker.updateState([{ + bankaraMatchChallenge: { + winCount: 2, + loseCount: 0, + maxWinCount: 3, + maxLoseCount: 3, + state: "INPROGRESS", + isPromo: true, + isUdemaeUp: true, + udemaeAfter: "A-", + earnedUdemaePoint: null, + }, + historyDetails: { + nodes: [{ + id: await genId(1), + udemae: "B+", + judgement: "WIN", + bankaraMatch: { + earnedUdemaePoint: null, + }, + }, { + id: await genId(0), + udemae: "B+", + judgement: "WIN", + bankaraMatch: { + earnedUdemaePoint: null, + }, + }], + }, + }]); + + assertEquals(finalState, { + gameId: await gameId(genId(1)), + rank: "B+", + rankPoint: 850, + }); +}); + +Deno.test("RankTracker tracks promotion", async () => { + const INIT_STATE = { + gameId: await gameId(genId(0)), + rank: "B+", + rankPoint: 850, + }; + + const tracker = new TestRankTracker(INIT_STATE); + assertEquals(tracker.testGet(), { + state: INIT_STATE, + deltaMap: new Map(), + }); + + const finalState = await tracker.updateState([{ + bankaraMatchChallenge: { + winCount: 3, + loseCount: 0, + maxWinCount: 3, + maxLoseCount: 3, + state: "SUCCEEDED", + isPromo: true, + isUdemaeUp: true, + udemaeAfter: "A-", + earnedUdemaePoint: null, + }, + historyDetails: { + nodes: [{ + id: await genId(2), + udemae: "B+", + judgement: "WIN", + bankaraMatch: { + earnedUdemaePoint: null, + }, + }, { + id: await genId(1), + udemae: "B+", + judgement: "WIN", + bankaraMatch: { + earnedUdemaePoint: null, + }, + }, { + id: await genId(0), + udemae: "B+", + judgement: "WIN", + bankaraMatch: { + earnedUdemaePoint: null, + }, + }], + }, + }]); + + assertEquals(finalState, { + gameId: await gameId(genId(2)), + rank: "A-", + rankPoint: 200, + }); +}); + Deno.test("RankTracker tracks challenge charge", async () => { const tracker = new TestRankTracker(INIT_STATE); assertEquals(tracker.testGet(), { @@ -83,8 +190,6 @@ Deno.test("RankTracker tracks challenge charge", async () => { bankaraMatch: { earnedUdemaePoint: null, }, - nextHistoryDetail: null, - previousHistoryDetail: null, }, ], }, diff --git a/src/types.ts b/src/types.ts index ef168e6..236cddf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -45,12 +45,6 @@ export type BattleListNode = { id: string; udemae: string; judgement: "LOSE" | "WIN" | "DEEMED_LOSE" | "EXEMPTED_LOSE" | "DRAW"; - nextHistoryDetail: null | { - id: string; - }; - previousHistoryDetail: null | { - id: string; - }; bankaraMatch: null | { earnedUdemaePoint: null | number; };