fix: detect random special
parent
e49706c58e
commit
407182bc3b
|
|
@ -568,17 +568,18 @@ export class StatInkExporter implements GameExporter {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
isRandomWeapon(image: Image | null): boolean {
|
isRandom(image: Image | null): boolean {
|
||||||
const RANDOM_WEAPON_FILENAME =
|
// question mark
|
||||||
|
const RANDOM_FILENAME =
|
||||||
"473fffb2442075078d8bb7125744905abdeae651b6a5b7453ae295582e45f7d1";
|
"473fffb2442075078d8bb7125744905abdeae651b6a5b7453ae295582e45f7d1";
|
||||||
// file exporter will replace url to { pathname: string } | string
|
// file exporter will replace url to { pathname: string } | string
|
||||||
const url = image?.url as ReturnType<typeof urlSimplify> | undefined | null;
|
const url = image?.url as ReturnType<typeof urlSimplify> | undefined | null;
|
||||||
if (typeof url === "string") {
|
if (typeof url === "string") {
|
||||||
return url.includes(RANDOM_WEAPON_FILENAME);
|
return url.includes(RANDOM_FILENAME);
|
||||||
} else if (url === undefined || url === null) {
|
} else if (url === undefined || url === null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return url.pathname.includes(RANDOM_WEAPON_FILENAME);
|
return url.pathname.includes(RANDOM_FILENAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async mapCoopWeapon(
|
async mapCoopWeapon(
|
||||||
|
|
@ -588,7 +589,7 @@ export class StatInkExporter implements GameExporter {
|
||||||
const weapon = weaponMap.get(name);
|
const weapon = weaponMap.get(name);
|
||||||
|
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
if (this.isRandomWeapon(image)) {
|
if (this.isRandom(image)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new Error(`Weapon not found: ${name}`);
|
throw new Error(`Weapon not found: ${name}`);
|
||||||
|
|
@ -599,13 +600,16 @@ export class StatInkExporter implements GameExporter {
|
||||||
mapSpecial({ name, image }: {
|
mapSpecial({ name, image }: {
|
||||||
image: Image;
|
image: Image;
|
||||||
name: string;
|
name: string;
|
||||||
}): Promise<string> {
|
}): Promise<string | undefined> {
|
||||||
const { url } = image;
|
const { url } = image;
|
||||||
const imageName = typeof url === "object" ? url.pathname : url ?? "";
|
const imageName = typeof url === "object" ? url.pathname : url ?? "";
|
||||||
const hash = /\/(\w+)_0\.\w+/.exec(imageName)?.[1] ?? "";
|
const hash = /\/(\w+)_0\.\w+/.exec(imageName)?.[1] ?? "";
|
||||||
const special = SPLATNET3_STATINK_MAP.COOP_SPECIAL_MAP[hash];
|
const special = SPLATNET3_STATINK_MAP.COOP_SPECIAL_MAP[hash];
|
||||||
|
|
||||||
if (!special) {
|
if (!special) {
|
||||||
|
if (this.isRandom(image)) {
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
throw new Error(`Special not found: ${name} (${imageName})`);
|
throw new Error(`Special not found: ${name} (${imageName})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -622,6 +626,14 @@ export class StatInkExporter implements GameExporter {
|
||||||
rescueCount,
|
rescueCount,
|
||||||
rescuedCount,
|
rescuedCount,
|
||||||
}: CoopHistoryPlayerResult): Promise<StatInkCoopPlayer> {
|
}: CoopHistoryPlayerResult): Promise<StatInkCoopPlayer> {
|
||||||
|
const disconnected = [
|
||||||
|
goldenDeliverCount,
|
||||||
|
deliverCount,
|
||||||
|
rescueCount,
|
||||||
|
rescuedCount,
|
||||||
|
defeatEnemyCount,
|
||||||
|
].every((v) => v === 0) || !specialWeapon;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
me: isMyself ? "yes" : "no",
|
me: isMyself ? "yes" : "no",
|
||||||
name: player.name,
|
name: player.name,
|
||||||
|
|
@ -637,7 +649,7 @@ export class StatInkExporter implements GameExporter {
|
||||||
rescue: rescueCount,
|
rescue: rescueCount,
|
||||||
rescued: rescuedCount,
|
rescued: rescuedCount,
|
||||||
defeat_boss: defeatEnemyCount,
|
defeat_boss: defeatEnemyCount,
|
||||||
disconnected: specialWeapon ? "no" : "yes",
|
disconnected: disconnected ? "yes" : "no",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
mapKing(id?: string) {
|
mapKing(id?: string) {
|
||||||
|
|
@ -656,10 +668,12 @@ export class StatInkExporter implements GameExporter {
|
||||||
: undefined;
|
: undefined;
|
||||||
const special_uses = (await Promise.all(
|
const special_uses = (await Promise.all(
|
||||||
wave.specialWeapons.map((w) => this.mapSpecial(w)),
|
wave.specialWeapons.map((w) => this.mapSpecial(w)),
|
||||||
)).reduce((p, key) => ({
|
))
|
||||||
...p,
|
.flatMap((key) => key ? [key] : [])
|
||||||
[key]: (p[key] ?? 0) + 1,
|
.reduce((p, key) => ({
|
||||||
}), {} as Record<string, number | undefined>) as Record<string, number>;
|
...p,
|
||||||
|
[key]: (p[key] ?? 0) + 1,
|
||||||
|
}), {} as Record<string, number | undefined>) as Record<string, number>;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tide: SPLATNET3_STATINK_MAP.WATER_LEVEL_MAP[wave.waterLevel],
|
tide: SPLATNET3_STATINK_MAP.WATER_LEVEL_MAP[wave.waterLevel],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue