mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-04 11:22:40 -05:00
Create analyzer json get overwrites
This commit is contained in:
parent
cbb62bd3f9
commit
2ba93c41c8
|
|
@ -4,6 +4,8 @@ export interface MainWeaponParams {
|
|||
subWeaponId: number;
|
||||
specialWeaponId: number;
|
||||
internalName: string;
|
||||
/** Replacing default values of the ability json for this specific weapon */
|
||||
overwrites?: Record<string, Partial<Record<"High" | "Mid" | "Low", number>>>;
|
||||
SpecialPoint: number;
|
||||
/** How much ink one shot consumes? InkConsume = 0.5 means 2 shots per full tank */
|
||||
InkConsume?: number;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import path from "node:path";
|
|||
import invariant from "tiny-invariant";
|
||||
import type { MainWeaponParams, SubWeaponParams } from "~/modules/analyzer";
|
||||
import type { ParamsJson } from "~/modules/analyzer/types";
|
||||
import { z } from "zod";
|
||||
|
||||
const CURRENT_SEASON = 0;
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ function parametersToMainWeaponResult(
|
|||
SpecialPoint: weapon.SpecialPoint,
|
||||
subWeaponId: resolveSubWeaponId(weapon),
|
||||
specialWeaponId: resolveSpecialWeaponId(weapon),
|
||||
overwrites: resolveOverwrites(params),
|
||||
internalName: weapon.__RowId.replace("_00", ""),
|
||||
InkConsume: params["WeaponParam"]?.["InkConsume"],
|
||||
InkConsumeFullCharge: params["WeaponParam"]?.["InkConsumeFullCharge"],
|
||||
|
|
@ -155,6 +157,40 @@ function resolveSpecialWeaponId(weapon: MainWeapon) {
|
|||
return specialWeaponObj.Id;
|
||||
}
|
||||
|
||||
const overwriteSchema = z.object({
|
||||
High: z.number().optional(),
|
||||
Mid: z.number().optional(),
|
||||
Low: z.number().optional(),
|
||||
});
|
||||
|
||||
function resolveOverwrites(params: any) {
|
||||
const result: MainWeaponParams["overwrites"] = {};
|
||||
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
const parsed = overwriteSchema.safeParse(value);
|
||||
|
||||
// each object has a $type property which we ignore
|
||||
if (
|
||||
key.includes("PlayerGearSkillParam") &&
|
||||
parsed.success &&
|
||||
Object.keys(parsed).length > 1
|
||||
) {
|
||||
const abilityKey = key.split("_").at(-1);
|
||||
invariant(abilityKey, `Could not find ability key for '${key}'`);
|
||||
|
||||
result[abilityKey] = {
|
||||
High: parsed.data.High,
|
||||
Mid: parsed.data.Mid,
|
||||
Low: parsed.data.Low,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(result).length === 0) return;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function mainWeaponShouldBeSkipped(weapon: MainWeapon) {
|
||||
if (!weaponIds.includes(weapon.Id as any)) return true;
|
||||
if (weapon.Season > CURRENT_SEASON) return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user