diff --git a/CHANGELOG b/CHANGELOG index 6584b34..3ab2236 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/src/app.ts b/src/app.ts index 1c4cfe3..513cc11 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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 | 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(), - }, }), ); } diff --git a/src/constant.ts b/src/constant.ts index 83ef628..d550123 100644 --- a/src/constant.ts +++ b/src/constant.ts @@ -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"; diff --git a/src/exporters/stat.ink.ts b/src/exporters/stat.ink.ts index 767b8f7..c1e2de9 100644 --- a/src/exporters/stat.ink.ts +++ b/src/exporters/stat.ink.ts @@ -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 { - 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; }