fix: missing title_before (#28)
parent
47a3425627
commit
a4d4f23263
|
|
@ -1,3 +1,8 @@
|
||||||
|
## 0.1.26
|
||||||
|
|
||||||
|
fix: missing title_before
|
||||||
|
([#28](https://github.com/spacemeowx2/s3si.ts/issues/28))
|
||||||
|
|
||||||
## 0.1.25
|
## 0.1.25
|
||||||
|
|
||||||
fix: missing king_smell
|
fix: missing king_smell
|
||||||
|
|
|
||||||
|
|
@ -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.25";
|
export const S3SI_VERSION = "0.1.26";
|
||||||
export const NSOAPP_VERSION = "2.3.1";
|
export const NSOAPP_VERSION = "2.3.1";
|
||||||
export const WEB_VIEW_VERSION = "1.0.0-433ec0e8";
|
export const WEB_VIEW_VERSION = "1.0.0-433ec0e8";
|
||||||
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,17 @@ import {
|
||||||
} from "../types.ts";
|
} from "../types.ts";
|
||||||
import { msgpack, Mutex } from "../../deps.ts";
|
import { msgpack, Mutex } from "../../deps.ts";
|
||||||
import { APIError } from "../APIError.ts";
|
import { APIError } from "../APIError.ts";
|
||||||
import { b64Number, gameId, s3siGameId } from "../utils.ts";
|
import { b64Number, gameId, nonNullable, s3siGameId } from "../utils.ts";
|
||||||
import { Env } from "../env.ts";
|
import { Env } from "../env.ts";
|
||||||
import { KEY_DICT } from "../dict/stat.ink.ts";
|
import { KEY_DICT } from "../dict/stat.ink.ts";
|
||||||
|
|
||||||
|
const COOP_POINT_MAP: Record<number, number | undefined> = {
|
||||||
|
0: -20,
|
||||||
|
1: -10,
|
||||||
|
2: 0,
|
||||||
|
3: 20,
|
||||||
|
};
|
||||||
|
|
||||||
class StatInkAPI {
|
class StatInkAPI {
|
||||||
FETCH_LOCK = new Mutex();
|
FETCH_LOCK = new Mutex();
|
||||||
cache: Record<string, unknown> = {};
|
cache: Record<string, unknown> = {};
|
||||||
|
|
@ -553,10 +560,32 @@ export class StatInkExporter implements GameExporter {
|
||||||
defeated_by_me: i.defeatCount,
|
defeated_by_me: i.defeatCount,
|
||||||
}]),
|
}]),
|
||||||
);
|
);
|
||||||
|
const title_after = detail.afterGrade
|
||||||
|
? b64Number(detail.afterGrade.id).toString()
|
||||||
|
: undefined;
|
||||||
|
const title_exp_after = detail.afterGradePoint;
|
||||||
const clear_waves =
|
const clear_waves =
|
||||||
detail.waveResults.filter((i) => i.waveNumber < 4).length -
|
detail.waveResults.filter((i) => i.waveNumber < 4).length -
|
||||||
1 + (resultWave === 0 ? 1 : 0);
|
1 + (resultWave === 0 ? 1 : 0);
|
||||||
|
|
||||||
|
let title_before = undefined;
|
||||||
|
let title_exp_before = undefined;
|
||||||
|
const expDiff = COOP_POINT_MAP[clear_waves];
|
||||||
|
|
||||||
|
if (nonNullable(title_exp_after) && nonNullable(expDiff)) {
|
||||||
|
if (title_exp_after === 40 && expDiff === 20) {
|
||||||
|
// 20 -> 40 or ?(rank up) -> 40
|
||||||
|
} else if (title_exp_after === 40 && expDiff < 0 && title_after !== "8") {
|
||||||
|
// 60,50 -> 40 or ?(rank down) to 40
|
||||||
|
} else if (title_exp_after === 999 && expDiff !== 0) {
|
||||||
|
// 980,990 -> 999
|
||||||
|
title_before = title_after;
|
||||||
|
} else {
|
||||||
|
title_before = title_after;
|
||||||
|
title_exp_before = title_exp_after - expDiff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result: StatInkCoopPostBody = {
|
const result: StatInkCoopPostBody = {
|
||||||
uuid: await gameId(detail.id),
|
uuid: await gameId(detail.id),
|
||||||
private: groupInfo?.mode === "PRIVATE_CUSTOM" ? "yes" : "no",
|
private: groupInfo?.mode === "PRIVATE_CUSTOM" ? "yes" : "no",
|
||||||
|
|
@ -568,10 +597,10 @@ export class StatInkExporter implements GameExporter {
|
||||||
king_smell: smellMeter,
|
king_smell: smellMeter,
|
||||||
king_salmonid: this.mapKing(detail.bossResult?.boss.id),
|
king_salmonid: this.mapKing(detail.bossResult?.boss.id),
|
||||||
clear_extra: bossResult?.hasDefeatBoss ? "yes" : "no",
|
clear_extra: bossResult?.hasDefeatBoss ? "yes" : "no",
|
||||||
title_after: detail.afterGrade
|
title_before,
|
||||||
? b64Number(detail.afterGrade.id).toString()
|
title_exp_before,
|
||||||
: undefined,
|
title_after,
|
||||||
title_exp_after: detail.afterGradePoint,
|
title_exp_after,
|
||||||
golden_eggs,
|
golden_eggs,
|
||||||
power_eggs,
|
power_eggs,
|
||||||
gold_scale: scale?.gold,
|
gold_scale: scale?.gold,
|
||||||
|
|
|
||||||
|
|
@ -159,3 +159,7 @@ export function b64Number(id: string): number {
|
||||||
const [_, num] = text.split("-");
|
const [_, num] = text.split("-");
|
||||||
return parseInt(num);
|
return parseInt(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function nonNullable<T>(v: T | null | undefined): v is T {
|
||||||
|
return v !== null && v !== undefined;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue