fix: random weapon (#29)
* fix: allow weapon to be random * feat: save pathname of image in file exporter * fix: allow random weapon * build: update chagnelogmain
parent
0e4f080054
commit
54d53fc488
|
|
@ -1,3 +1,9 @@
|
||||||
|
## 0.1.28
|
||||||
|
|
||||||
|
fix: allow random weapon
|
||||||
|
|
||||||
|
feat: save pathname of image in file exporter
|
||||||
|
|
||||||
## 0.1.27
|
## 0.1.27
|
||||||
|
|
||||||
fix: export error when disconnected
|
fix: export error when disconnected
|
||||||
|
|
|
||||||
|
|
@ -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.27";
|
export const S3SI_VERSION = "0.1.28";
|
||||||
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,7 +1,7 @@
|
||||||
import { CoopInfo, GameExporter, VsInfo } from "../types.ts";
|
import { CoopInfo, GameExporter, VsInfo } from "../types.ts";
|
||||||
import { path } from "../../deps.ts";
|
import { path } from "../../deps.ts";
|
||||||
import { NSOAPP_VERSION, S3SI_VERSION } from "../constant.ts";
|
import { NSOAPP_VERSION, S3SI_VERSION } from "../constant.ts";
|
||||||
import { parseHistoryDetailId } from "../utils.ts";
|
import { parseHistoryDetailId, urlSimplify } from "../utils.ts";
|
||||||
|
|
||||||
export type FileExporterType = {
|
export type FileExporterType = {
|
||||||
type: "VS" | "COOP";
|
type: "VS" | "COOP";
|
||||||
|
|
@ -15,9 +15,11 @@ export type FileExporterType = {
|
||||||
* Don't save url in exported file
|
* Don't save url in exported file
|
||||||
*/
|
*/
|
||||||
function replacer(key: string, value: unknown): unknown {
|
function replacer(key: string, value: unknown): unknown {
|
||||||
return ["url", "maskImageUrl", "overlayImageUrl"].includes(key)
|
if (!["url", "maskImageUrl", "overlayImageUrl"].includes(key)) {
|
||||||
? undefined
|
return value;
|
||||||
: value;
|
}
|
||||||
|
|
||||||
|
return typeof value === "string" ? urlSimplify(value) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import {
|
||||||
CoopInfo,
|
CoopInfo,
|
||||||
Game,
|
Game,
|
||||||
GameExporter,
|
GameExporter,
|
||||||
|
Image,
|
||||||
PlayerGear,
|
PlayerGear,
|
||||||
StatInkAbility,
|
StatInkAbility,
|
||||||
StatInkCoopPlayer,
|
StatInkCoopPlayer,
|
||||||
|
|
@ -456,13 +457,23 @@ export class StatInkExporter implements GameExporter {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
async mapCoopWeapon({ name }: { name: string }): Promise<string> {
|
isRandomWeapon(image: Image | null): boolean {
|
||||||
|
return (image?.url.includes(
|
||||||
|
"473fffb2442075078d8bb7125744905abdeae651b6a5b7453ae295582e45f7d1",
|
||||||
|
)) ?? false;
|
||||||
|
}
|
||||||
|
async mapCoopWeapon(
|
||||||
|
{ name, image }: { name: string; image: Image | null },
|
||||||
|
): Promise<string | null> {
|
||||||
const weaponMap = await this.api.getWeapon();
|
const weaponMap = await this.api.getWeapon();
|
||||||
const weapon =
|
const weapon =
|
||||||
weaponMap.find((i) => Object.values(i.name).includes(name))?.key ??
|
weaponMap.find((i) => Object.values(i.name).includes(name))?.key ??
|
||||||
KEY_DICT.get(name);
|
KEY_DICT.get(name);
|
||||||
|
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
|
if (this.isRandomWeapon(image)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
throw new Error(`Weapon not found: ${name}`);
|
throw new Error(`Weapon not found: ${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ export type CoopHistoryPlayerResult = {
|
||||||
};
|
};
|
||||||
isMyself: boolean;
|
isMyself: boolean;
|
||||||
};
|
};
|
||||||
weapons: { name: string }[];
|
weapons: { name: string; image: Image | null }[];
|
||||||
specialWeapon: null | {
|
specialWeapon: null | {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -447,7 +447,7 @@ export type StatInkCoopPlayer = {
|
||||||
splashtag_title: string | null;
|
splashtag_title: string | null;
|
||||||
uniform?: "orange" | "green" | "yellow" | "pink" | "blue" | "black" | "white";
|
uniform?: "orange" | "green" | "yellow" | "pink" | "blue" | "black" | "white";
|
||||||
special?: string;
|
special?: string;
|
||||||
weapons: string[];
|
weapons: (string | null)[];
|
||||||
golden_eggs: number;
|
golden_eggs: number;
|
||||||
golden_assist: number;
|
golden_assist: number;
|
||||||
power_eggs: number;
|
power_eggs: number;
|
||||||
|
|
|
||||||
13
src/utils.ts
13
src/utils.ts
|
|
@ -163,3 +163,16 @@ export function b64Number(id: string): number {
|
||||||
export function nonNullable<T>(v: T | null | undefined): v is T {
|
export function nonNullable<T>(v: T | null | undefined): v is T {
|
||||||
return v !== null && v !== undefined;
|
return v !== null && v !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only preserve the pathname of the URL
|
||||||
|
* @param url A url
|
||||||
|
*/
|
||||||
|
export function urlSimplify(url: string): { pathname: string } | string {
|
||||||
|
try {
|
||||||
|
const { pathname } = new URL(url);
|
||||||
|
return { pathname };
|
||||||
|
} catch (_e) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue