fix: auto promotion not working as expecting

main
spacemeowx2 2022-11-28 16:09:14 +08:00 committed by imspace
parent 707d7204dc
commit af95defd9a
3 changed files with 26 additions and 1 deletions

View File

@ -132,11 +132,25 @@ Deno.test("RankTracker autotrack after promotion", async () => {
}, },
}]); }]);
const gameId1 = await gameId(genId(1));
assertEquals(finalState, { assertEquals(finalState, {
gameId: await gameId(genId(1)), gameId: gameId1,
rank: "A-", rank: "A-",
rankPoint: 200, rankPoint: 200,
}); });
assertEquals(await tracker.getRankStateById(genId(1)), {
before: {
gameId: await gameId(genId(0)),
rank: "B+",
rankPoint: -1,
},
after: {
gameId: gameId1,
rank: "A-",
rankPoint: 200,
},
});
}); });
Deno.test("RankTracker tracks promotion, ignoring INPROGRESS", async () => { Deno.test("RankTracker tracks promotion, ignoring INPROGRESS", async () => {

View File

@ -331,6 +331,7 @@ export class RankTracker {
return; return;
} }
this.state = curState;
const deltaList = generateDeltaList(curState, flatten); const deltaList = generateDeltaList(curState, flatten);
if (!deltaList) { if (!deltaList) {

View File

@ -492,6 +492,16 @@ export class StatInkExporter implements GameExporter {
result.rank_exp_change === undefined result.rank_exp_change === undefined
) { ) {
result.rank_exp_change = result.rank_after_exp - result.rank_before_exp; result.rank_exp_change = result.rank_after_exp - result.rank_before_exp;
} else if (
bankaraMatchChallenge?.isUdemaeUp &&
bankaraMatchChallenge.earnedUdemaePoint
) {
// If the before state is generated by auto promotion, the rank_before_exp is wrong.
// And `earnedUdemaePoint` from splatnet3 is -xxx.
// So we calcuate `rank_before_exp` and remove `rank_exp_change` here
result.rank_before_exp = result.rank_after_exp -
bankaraMatchChallenge.earnedUdemaePoint;
result.rank_exp_change = undefined;
} }
if (!result.rank_after) { if (!result.rank_after) {