feat: use /api/v3/salmon/weapon (#31)
* feat: use /api/v3/salmon/weapon https://github.com/fetus-hina/stat.ink/issues/1128#issuecomment-1328007235 * feat: remove hardcoded dict * build: bump versionmain
parent
d6980c8208
commit
d13d75d40a
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 0.1.30
|
||||||
|
|
||||||
|
feat: use /api/v3/salmon/weapon
|
||||||
|
|
||||||
## 0.1.29
|
## 0.1.29
|
||||||
|
|
||||||
feat: add fail_reason for salmon run
|
feat: add fail_reason for salmon run
|
||||||
|
|
|
||||||
|
|
@ -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.29";
|
export const S3SI_VERSION = "0.1.30";
|
||||||
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";
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
const SOURCE = `
|
|
||||||
kuma_slosher 23900, grizzco_slosher 熊先生印章泼桶 Bär-Schwapper Grizzco Slosher Grizzco Slosher Derramatic Don Oso Derramatic Don Oso Seau M. Ours SA Seau M. Ours Cie Secchiostro Ursus Beer & Co-morser Ведроган «Потапыч Inc.» クマサン印のスロッシャー 熊先生商會潑桶 Grizzco Slosher
|
|
||||||
kuma_blaster 20900, grizzco_blaster 熊先生印章爆破枪 Bär-Blaster Grizzco Blaster Grizzco Blaster Devastador Don Oso Lanzamotas Don Oso Blaster M. Ours SA Blasteur M. Ours Cie Blaster Ursus Beer & Co-blaster Бластер «Потапыч Inc.» クマサン印のブラスター 熊先生商會爆破槍 Mr. 베어표 블래스터
|
|
||||||
kuma_stringer 27900, grizzco_stringer 熊先生印章猎鱼弓 Bär-Stringer Grizzco Stringer Grizzco Stringer Arcromatizador Don Oso Arcromatizador Don Oso Transperceur M. Ours SA Transperceur M. Ours Cie Calamarco Ursus Beer & Co-spanner Тетиватор «Потапыч Inc.» クマサン印のストリンガー 熊先生商會獵魚弓 Mr. 베어표 스트링거
|
|
||||||
kuma_charger 22900, grizzco_charger 熊先生印章蓄力狙击枪 Bär-Konzentrator Grizzco Charger Grizzco Charger Cargatintas Don Oso Cargatintas Don Oso Fusil M. Ours SA Fusil M. Ours Cie Splatter Ursus Beer & Co-lader Сплатган «Потапыч Inc.» クマサン印のチャージャー 熊先生商會蓄力狙擊槍 Grizzco Charger
|
|
||||||
kuma_shelter 26900, grizzco_brella 熊先生印章防空伞 Bär-Pluviator Grizzco Brella Grizzco Brella Paratintas Don Oso Paratintas Don Oso Para-encre M. Ours SA Para-encre M. Ours Cie Sparasole Ursus Beer & Co-plenzer Зонтган «Потапыч Inc.» クマサン印のシェルター 熊先生商會防空傘 Mr. 베어표 셸터
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const KEY_DICT = new Map<string, string>();
|
|
||||||
for (const line of SOURCE.split(/\n/)) {
|
|
||||||
const [key, ...names] = line.split(/\t/);
|
|
||||||
for (let name of names) {
|
|
||||||
name = name.trim();
|
|
||||||
if (KEY_DICT.has(name) && KEY_DICT.get(name) !== key) {
|
|
||||||
console.log(`Conflict: ${name} => ${KEY_DICT.get(name)} and ${key}`);
|
|
||||||
}
|
|
||||||
KEY_DICT.set(name, key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -37,7 +37,6 @@ import {
|
||||||
urlSimplify,
|
urlSimplify,
|
||||||
} from "../utils.ts";
|
} from "../utils.ts";
|
||||||
import { Env } from "../env.ts";
|
import { Env } from "../env.ts";
|
||||||
import { KEY_DICT } from "../dict/stat.ink.ts";
|
|
||||||
|
|
||||||
const COOP_POINT_MAP: Record<number, number | undefined> = {
|
const COOP_POINT_MAP: Record<number, number | undefined> = {
|
||||||
0: -20,
|
0: -20,
|
||||||
|
|
@ -47,6 +46,7 @@ const COOP_POINT_MAP: Record<number, number | undefined> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatInkAPI {
|
class StatInkAPI {
|
||||||
|
statInk = "https://stat.ink";
|
||||||
FETCH_LOCK = new Mutex();
|
FETCH_LOCK = new Mutex();
|
||||||
cache: Record<string, unknown> = {};
|
cache: Record<string, unknown> = {};
|
||||||
|
|
||||||
|
|
@ -67,8 +67,8 @@ class StatInkAPI {
|
||||||
const fetch = this.env.newFetcher();
|
const fetch = this.env.newFetcher();
|
||||||
return await (await fetch.get({
|
return await (await fetch.get({
|
||||||
url: type === "VsInfo"
|
url: type === "VsInfo"
|
||||||
? "https://stat.ink/api/v3/s3s/uuid-list"
|
? `${this.statInk}/api/v3/s3s/uuid-list`
|
||||||
: "https://stat.ink/api/v3/salmon/uuid-list",
|
: `${this.statInk}/api/v3/salmon/uuid-list`,
|
||||||
headers: this.requestHeaders(),
|
headers: this.requestHeaders(),
|
||||||
})).json();
|
})).json();
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ class StatInkAPI {
|
||||||
async postBattle(body: StatInkPostBody) {
|
async postBattle(body: StatInkPostBody) {
|
||||||
const fetch = this.env.newFetcher();
|
const fetch = this.env.newFetcher();
|
||||||
const resp = await fetch.post({
|
const resp = await fetch.post({
|
||||||
url: "https://stat.ink/api/v3/battle",
|
url: `${this.statInk}/api/v3/battle`,
|
||||||
headers: {
|
headers: {
|
||||||
...this.requestHeaders(),
|
...this.requestHeaders(),
|
||||||
"Content-Type": "application/x-msgpack",
|
"Content-Type": "application/x-msgpack",
|
||||||
|
|
@ -108,7 +108,7 @@ class StatInkAPI {
|
||||||
async postCoop(body: StatInkCoopPostBody) {
|
async postCoop(body: StatInkCoopPostBody) {
|
||||||
const fetch = this.env.newFetcher();
|
const fetch = this.env.newFetcher();
|
||||||
const resp = await fetch.post({
|
const resp = await fetch.post({
|
||||||
url: "https://stat.ink/api/v3/salmon",
|
url: `${this.statInk}/api/v3/salmon`,
|
||||||
headers: {
|
headers: {
|
||||||
...this.requestHeaders(),
|
...this.requestHeaders(),
|
||||||
"Content-Type": "application/x-msgpack",
|
"Content-Type": "application/x-msgpack",
|
||||||
|
|
@ -156,12 +156,16 @@ class StatInkAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSalmonWeapon = () =>
|
||||||
|
this._getCached<StatInkWeapon>(
|
||||||
|
`${this.statInk}/api/v3/salmon/weapon?full=1`,
|
||||||
|
);
|
||||||
getWeapon = () =>
|
getWeapon = () =>
|
||||||
this._getCached<StatInkWeapon>("https://stat.ink/api/v3/weapon?full=1");
|
this._getCached<StatInkWeapon>(`${this.statInk}/api/v3/weapon?full=1`);
|
||||||
getAbility = () =>
|
getAbility = () =>
|
||||||
this._getCached<StatInkAbility>("https://stat.ink/api/v3/ability?full=1");
|
this._getCached<StatInkAbility>(`${this.statInk}/api/v3/ability?full=1`);
|
||||||
getStage = () =>
|
getStage = () =>
|
||||||
this._getCached<StatInkStage>("https://stat.ink/api/v3/stage");
|
this._getCached<StatInkStage>(`${this.statInk}/api/v3/stage`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NameDict = {
|
export type NameDict = {
|
||||||
|
|
@ -479,10 +483,9 @@ export class StatInkExporter implements GameExporter {
|
||||||
async mapCoopWeapon(
|
async mapCoopWeapon(
|
||||||
{ name, image }: { name: string; image: Image | null },
|
{ name, image }: { name: string; image: Image | null },
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const weaponMap = await this.api.getWeapon();
|
const weaponMap = await this.api.getSalmonWeapon();
|
||||||
const weapon =
|
const weapon = weaponMap.find((i) => Object.values(i.name).includes(name))
|
||||||
weaponMap.find((i) => Object.values(i.name).includes(name))?.key ??
|
?.key;
|
||||||
KEY_DICT.get(name);
|
|
||||||
|
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
if (this.isRandomWeapon(image)) {
|
if (this.isRandomWeapon(image)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue