mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 23:19:39 -05:00
Option to get wpn damage multiplier from all keys
This commit is contained in:
parent
7f9bc0b5bc
commit
dc5fc84c83
|
|
@ -1,3 +1,5 @@
|
|||
import type { DamageType } from "./types";
|
||||
|
||||
export const MAX_LDE_INTENSITY = 21;
|
||||
export const MAX_AP = 57;
|
||||
|
||||
|
|
@ -30,3 +32,18 @@ export const DAMAGE_TYPE = [
|
|||
"BOMB_NORMAL",
|
||||
"BOMB_DIRECT",
|
||||
] as const;
|
||||
|
||||
export const damageTypeToWeaponType: Record<
|
||||
DamageType,
|
||||
"MAIN" | "SUB" | "SPECIAL"
|
||||
> = {
|
||||
NORMAL_MIN: "MAIN",
|
||||
NORMAL_MAX: "MAIN",
|
||||
DIRECT: "MAIN",
|
||||
FULL_CHARGE: "MAIN",
|
||||
MAX_CHARGE: "MAIN",
|
||||
TAP_SHOT: "MAIN",
|
||||
DISTANCE: "MAIN",
|
||||
BOMB_NORMAL: "SUB",
|
||||
BOMB_DIRECT: "SUB",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,21 +7,29 @@ import type {
|
|||
} from "../in-game-lists";
|
||||
import { DAMAGE_RECEIVERS } from "./constants";
|
||||
|
||||
const objectDamageJsonKeyPriority: Record<
|
||||
DamageType,
|
||||
Array<keyof typeof objectDamages>
|
||||
/** Keys to check in the json. Lower index takes priority over higher. If key is omitted means any key with valid weapon id is okay. One json key can only map to one DamageType. */
|
||||
const objectDamageJsonKeyPriority: Partial<
|
||||
Record<DamageType, Array<keyof typeof objectDamages>>
|
||||
> = {
|
||||
NORMAL_MIN: ["Shooter"],
|
||||
NORMAL_MAX: ["Shooter"],
|
||||
DIRECT: [],
|
||||
// NORMAL_MIN: [],
|
||||
// NORMAL_MAX: [],
|
||||
DIRECT: ["Blaster_KillOneShot"],
|
||||
FULL_CHARGE: [],
|
||||
MAX_CHARGE: [],
|
||||
TAP_SHOT: [],
|
||||
DISTANCE: [],
|
||||
BOMB_NORMAL: [],
|
||||
BOMB_DIRECT: [],
|
||||
// DISTANCE: [],
|
||||
// BOMB_NORMAL: [],
|
||||
BOMB_DIRECT: ["Bomb_DirectHit"],
|
||||
};
|
||||
|
||||
const commonObjectDamageJsonKeys = () =>
|
||||
Object.keys(objectDamages).filter(
|
||||
(key) =>
|
||||
!Object.values(objectDamageJsonKeyPriority)
|
||||
.flat()
|
||||
.includes(key as any)
|
||||
) as Array<keyof typeof objectDamages>;
|
||||
|
||||
export function damageTypeToMultipliers({
|
||||
type,
|
||||
weapon,
|
||||
|
|
@ -41,7 +49,10 @@ export function damageTypeToMultipliers({
|
|||
id: SpecialWeaponId;
|
||||
};
|
||||
}) {
|
||||
for (const key of objectDamageJsonKeyPriority[type]) {
|
||||
const keysToCheck =
|
||||
objectDamageJsonKeyPriority[type] ?? commonObjectDamageJsonKeys();
|
||||
|
||||
for (const key of keysToCheck) {
|
||||
const objectDamagesObj = objectDamages[key];
|
||||
|
||||
let ok = false;
|
||||
|
|
@ -58,7 +69,10 @@ export function damageTypeToMultipliers({
|
|||
);
|
||||
}
|
||||
|
||||
if (ok) return objectDamagesObj.rates;
|
||||
if (ok) {
|
||||
console.log(`for ${type} used ${key ?? "FALLBACK"}`);
|
||||
return objectDamagesObj.rates;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { useSearchParams } from "@remix-run/react";
|
||||
import { type MainWeaponId } from "../in-game-lists";
|
||||
import { damageTypeToWeaponType } from "./constants";
|
||||
import { damageTypeToMultipliers, fallbackRates } from "./damageMultipliers";
|
||||
import { buildStats } from "./stats";
|
||||
import { validatedWeaponIdFromSearchParams } from "./utils";
|
||||
|
|
@ -28,12 +29,20 @@ export function useObjectDamage() {
|
|||
|
||||
const multipliers = Object.fromEntries(
|
||||
analyzed.stats.damages.map((damage) => {
|
||||
const weaponType = damageTypeToWeaponType[damage.type];
|
||||
const weaponId: any =
|
||||
weaponType === "MAIN"
|
||||
? mainWeaponId
|
||||
: weaponType === "SUB"
|
||||
? analyzed.weapon.subWeaponSplId
|
||||
: analyzed.weapon.specialWeaponSplId;
|
||||
|
||||
return [
|
||||
damage.type,
|
||||
fallbackRates(
|
||||
damageTypeToMultipliers({
|
||||
type: damage.type,
|
||||
weapon: { type: "MAIN", id: mainWeaponId },
|
||||
weapon: { type: weaponType, id: weaponId },
|
||||
})
|
||||
),
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user