fix: RankTracker shouldn't return -1 rankPoint (#58)
* fix: RankTracker returns wrong rankPoint * fix: remove rank exp change calc * test: fix RankTracker test * build: bump versionmain
parent
d2e0885fb2
commit
4c8fa4102e
|
|
@ -1,3 +1,7 @@
|
|||
## 0.2.7
|
||||
|
||||
fix: RankTracker shouldn't return -1 rankPoint
|
||||
|
||||
## 0.2.6
|
||||
|
||||
feat: add tri-color support
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ Deno.test("RankTracker autotrack after promotion", async () => {
|
|||
isPromo: true,
|
||||
isUdemaeUp: true,
|
||||
udemaeAfter: "A-",
|
||||
earnedUdemaePoint: null,
|
||||
earnedUdemaePoint: -233,
|
||||
},
|
||||
historyDetails: {
|
||||
nodes: [{
|
||||
|
|
@ -146,7 +146,7 @@ Deno.test("RankTracker autotrack after promotion", async () => {
|
|||
before: {
|
||||
gameId: await gameId(genId(0)),
|
||||
rank: "B+",
|
||||
rankPoint: -1,
|
||||
rankPoint: 433,
|
||||
timestamp: 1640995200,
|
||||
},
|
||||
after: {
|
||||
|
|
@ -176,10 +176,17 @@ Deno.test("RankTracker issue #36", async () => {
|
|||
isPromo: true,
|
||||
isUdemaeUp: true,
|
||||
udemaeAfter: "S+20",
|
||||
earnedUdemaePoint: null,
|
||||
earnedUdemaePoint: -3450,
|
||||
},
|
||||
historyDetails: {
|
||||
nodes: [{
|
||||
id: genId(2),
|
||||
udemae: "S+19",
|
||||
judgement: "WIN",
|
||||
bankaraMatch: {
|
||||
earnedUdemaePoint: null,
|
||||
},
|
||||
}, {
|
||||
id: genId(1),
|
||||
udemae: "S+19",
|
||||
judgement: "WIN",
|
||||
|
|
@ -197,28 +204,42 @@ Deno.test("RankTracker issue #36", async () => {
|
|||
},
|
||||
}]);
|
||||
|
||||
const gameId1 = await gameId(genId(1));
|
||||
const gameId2 = await gameId(genId(2));
|
||||
assertEquals(finalState, {
|
||||
gameId: gameId1,
|
||||
gameId: gameId2,
|
||||
rank: "S+20",
|
||||
rankPoint: 300,
|
||||
timestamp: 1640995201,
|
||||
timestamp: 1640995202,
|
||||
});
|
||||
|
||||
assertEquals(await tracker.getRankStateById(genId(0)), undefined);
|
||||
|
||||
assertEquals(await tracker.getRankStateById(genId(1)), {
|
||||
before: {
|
||||
gameId: await gameId(genId(0)),
|
||||
rank: "S+19",
|
||||
rankPoint: -1,
|
||||
rankPoint: 3750,
|
||||
timestamp: 1640995200,
|
||||
},
|
||||
after: {
|
||||
gameId: gameId1,
|
||||
gameId: await gameId(genId(1)),
|
||||
rank: "S+19",
|
||||
rankPoint: 3750,
|
||||
timestamp: 1640995201,
|
||||
},
|
||||
});
|
||||
|
||||
assertEquals(await tracker.getRankStateById(genId(2)), {
|
||||
before: {
|
||||
gameId: await gameId(genId(1)),
|
||||
rank: "S+19",
|
||||
rankPoint: 3750,
|
||||
timestamp: 1640995201,
|
||||
},
|
||||
after: {
|
||||
gameId: gameId2,
|
||||
rank: "S+20",
|
||||
rankPoint: 300,
|
||||
timestamp: 1640995201,
|
||||
timestamp: 1640995202,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
HistoryGroups,
|
||||
RankParam,
|
||||
} from "./types.ts";
|
||||
import { gameId, parseHistoryDetailId } from "./utils.ts";
|
||||
import { gameId, nonNullable, parseHistoryDetailId } from "./utils.ts";
|
||||
|
||||
const splusParams = () => {
|
||||
const out: RankParam[] = [];
|
||||
|
|
@ -234,19 +234,29 @@ function generateDeltaList(
|
|||
|
||||
function getRankState(i: FlattenItem): RankState {
|
||||
const rank = i.detail.udemae;
|
||||
if (!rank) {
|
||||
throw new Error("rank must be defined");
|
||||
const nextRank = i.bankaraMatchChallenge?.udemaeAfter;
|
||||
const earnedUdemaePoint = i.bankaraMatchChallenge?.earnedUdemaePoint;
|
||||
if (!nonNullable(earnedUdemaePoint)) {
|
||||
throw new TypeError("earnedUdemaePoint must be defined");
|
||||
}
|
||||
if (!rank || !nextRank) {
|
||||
throw new Error("rank and nextRank must be defined");
|
||||
}
|
||||
const param = RANK_PARAMS.find((i) => i.rank === rank);
|
||||
const nextParam = RANK_PARAMS.find((i) => i.rank === nextRank);
|
||||
|
||||
if (!param) {
|
||||
throw new Error(`Rank not found: ${rank}`);
|
||||
if (!param || !nextParam) {
|
||||
throw new Error(`Rank or nextRank not found: ${rank} ${nextRank}`);
|
||||
}
|
||||
|
||||
const oldRankPoint = nextParam.pointRange[0] -
|
||||
earnedUdemaePoint;
|
||||
|
||||
return {
|
||||
gameId: i.gameId,
|
||||
timestamp: Math.floor(i.time.getTime() / 1000),
|
||||
rank,
|
||||
rankPoint: -1,
|
||||
rankPoint: oldRankPoint,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
||||
|
||||
export const AGENT_NAME = "s3si.ts";
|
||||
export const S3SI_VERSION = "0.2.6";
|
||||
export const S3SI_VERSION = "0.2.7";
|
||||
export const NSOAPP_VERSION = "2.4.0";
|
||||
export const WEB_VIEW_VERSION = "2.0.0-bd36a652";
|
||||
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
||||
|
|
|
|||
|
|
@ -586,16 +586,6 @@ export class StatInkExporter implements GameExporter {
|
|||
result.rank_exp_change === undefined
|
||||
) {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue