imspace 2022-11-07 12:37:24 +08:00 committed by GitHub
parent 62b53893de
commit 443c6c7936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 26 deletions

View File

@ -1,3 +1,9 @@
## 0.1.18
feat: remove gear map workaround
https://github.com/fetus-hina/stat.ink/issues/1127
## 0.1.17
feat: add gears to stat.ink

View File

@ -6,7 +6,7 @@ import {
State,
StateBackend,
} from "./state.ts";
import { getBattleList, getGearPower, isTokenExpired } from "./splatnet3.ts";
import { getBattleList, isTokenExpired } from "./splatnet3.ts";
import { BattleListType, Game, GameExporter } from "./types.ts";
import { Cache, FileCache } from "./cache.ts";
import { StatInkExporter } from "./exporters/stat.ink.ts";
@ -65,7 +65,6 @@ export class App {
await this.fetchToken();
},
};
gearMap: Record<string, number> | null = null;
constructor(public opts: Opts) {
this.stateBackend = opts.stateBackend ??
@ -89,16 +88,6 @@ export class App {
await this.writeState(DEFAULT_STATE);
}
}
async getGearMap() {
if (this.gearMap) {
return this.gearMap;
}
const { gearPowers } = await getGearPower(this.state);
this.gearMap = Object.fromEntries(
gearPowers.nodes.map((i, id) => [i.name, id]),
);
return this.gearMap;
}
getSkipMode(): ("vs" | "coop")[] {
const mode = this.opts.skipMode;
if (mode === "vs") {
@ -129,9 +118,6 @@ export class App {
new StatInkExporter({
statInkApiKey: this.state.statInkApiKey!,
uploadMode: this.opts.monitor ? "Monitoring" : "Manual",
nameDict: {
gearPower: await this.getGearMap(),
},
}),
);
}

View File

@ -1,7 +1,7 @@
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
export const AGENT_NAME = "s3si.ts";
export const S3SI_VERSION = "0.1.17";
export const S3SI_VERSION = "0.1.18";
export const NSOAPP_VERSION = "2.3.1";
export const WEB_VIEW_VERSION = "1.0.0-5644e7a2";
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";

View File

@ -66,13 +66,11 @@ export class StatInkExporter implements GameExporter {
name = "stat.ink";
private statInkApiKey: string;
private uploadMode: string;
private nameDict: NameDict;
constructor(
{ statInkApiKey, uploadMode, nameDict }: {
{ statInkApiKey, uploadMode }: {
statInkApiKey: string;
uploadMode: string;
nameDict: NameDict;
},
) {
if (statInkApiKey.length !== 43) {
@ -80,7 +78,6 @@ export class StatInkExporter implements GameExporter {
}
this.statInkApiKey = statInkApiKey;
this.uploadMode = uploadMode;
this.nameDict = nameDict;
}
requestHeaders() {
return {
@ -192,13 +189,12 @@ export class StatInkExporter implements GameExporter {
async mapGears(
{ headGear, clothingGear, shoesGear }: VsPlayer,
): Promise<StatInkGears> {
const amap = await getAbility();
const amap = (await getAbility()).map((i) => ({
...i,
names: Object.values(i.name),
}));
const mapAbility = ({ name }: { name: string }): string | null => {
const abilityIdx = this.nameDict.gearPower[name];
if (abilityIdx === undefined) {
return null;
}
const result = amap[abilityIdx];
const result = amap.find((a) => a.names.includes(name));
if (!result) {
return null;
}