From a364b79a9bb40de403ec477cf0431a172e3fcb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 24 Dec 2025 19:33:01 -0600 Subject: [PATCH] feat: autoreloader dom --- .../website-ue/src/components/Navbar.astro | 0 .../tankopedia/aggregateStageParameters.ts | 6 --- .../src/core/tankopedia/characteristics.ts | 50 ++++++++++++++++--- .../website-ue/src/layouts/BaseLayout.astro | 5 +- 4 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 packages/website-ue/src/components/Navbar.astro diff --git a/packages/website-ue/src/components/Navbar.astro b/packages/website-ue/src/components/Navbar.astro new file mode 100644 index 000000000..e69de29bb diff --git a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts index a0f9df7b2..45ff21489 100644 --- a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts +++ b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts @@ -147,12 +147,6 @@ function patch(stage0: StageParameters, stage1: StageParameters) { stage0.pump_reload_times = [...stage1.pump_reload_times]; } - if (stage1.pump_reload_times.length < stage0.pump_reload_times.length) { - throw new Error( - `Pump reload times go down???? (${stage0.pump_reload_times.length} -> ${stage1.pump_reload_times.length})` - ); - } - if (stage1.pitch_limits_up.length > 0 && stage0.pitch_limits_up.length > 0) { throw new Error("Pitch limits not implemented"); } diff --git a/packages/website-ue/src/core/tankopedia/characteristics.ts b/packages/website-ue/src/core/tankopedia/characteristics.ts index c3795b0fd..45aebe78e 100644 --- a/packages/website-ue/src/core/tankopedia/characteristics.ts +++ b/packages/website-ue/src/core/tankopedia/characteristics.ts @@ -8,7 +8,7 @@ import { radToDeg } from "three/src/math/MathUtils.js"; import { applyPitchYawLimits } from "./applyPitchYawLimits"; import type { TankState } from "./tankState"; -export type CharacteristicOutput = number | null; +export type CharacteristicOutput = number | number[] | null; type Characteristic = (helpers: { characteristic: (name: CharacteristicName) => CharacteristicOutput; @@ -84,6 +84,14 @@ export const characteristics = { ); }, + reloads({ characteristic, attribute, parameters }) { + const gunType = characteristic("gun_type")!; + + if (gunType !== GunType.AutoReloader) return null; + + return parameters.pump_reload_times; + }, + intra_clip({ characteristic, attribute }) { const gunType = characteristic("gun_type")!; @@ -96,30 +104,58 @@ export const characteristics = { return 60 / clipRate; }, + optimal_shell({ characteristic }) { + const gunType = characteristic("gun_type")!; + + if (gunType !== GunType.AutoReloader) return null; + + const intraClip = characteristic("intra_clip") as number; + const reloads = characteristic("reloads") as number[]; + let optimal: number | undefined = undefined; + + for (let index = 0; index < reloads.length; index++) { + const reload = reloads[index] + (index > 0 ? intraClip : 0); + if (optimal === undefined || reload < reloads[optimal]) optimal = index; + } + + if (optimal === undefined) { + throw new Error("Unable to find optimal shell"); + } + + return optimal; + }, + dpm({ characteristic }) { let dps: number; const gunType = characteristic("gun_type")!; - const damage = characteristic("damage")!; + const damage = characteristic("damage") as number; switch (gunType) { case GunType.Regular: { - const reload = characteristic("reload")!; + const reload = characteristic("reload") as number; dps = damage / reload; break; } case GunType.AutoLoader: { - const reload = characteristic("reload")!; - const intraClip = characteristic("intra_clip")!; - const clipSize = characteristic("clip_size")!; + const reload = characteristic("reload") as number; + const intraClip = characteristic("intra_clip") as number; + const clipSize = characteristic("clip_size") as number; dps = (damage * clipSize) / (reload + (clipSize - 1) * intraClip); break; } case GunType.AutoReloader: { - return -Infinity; + const reloads = characteristic("reloads") as number[]; + const optimalShell = characteristic("optimal_shell") as number; + const intraClip = characteristic("intra_clip") as number; + const reload = + reloads[optimalShell] + (optimalShell > 0 ? intraClip : 0); + + dps = damage / reload; + break; } default: diff --git a/packages/website-ue/src/layouts/BaseLayout.astro b/packages/website-ue/src/layouts/BaseLayout.astro index 63e940a80..1f0a640ff 100644 --- a/packages/website-ue/src/layouts/BaseLayout.astro +++ b/packages/website-ue/src/layouts/BaseLayout.astro @@ -2,13 +2,15 @@ import "@fontsource-variable/inter"; import BaseMeta from "../components/BaseMeta.astro"; import BaseStyles from "../components/BaseStyles.astro"; +import Navbar from "../components/Navbar.astro"; import type { Color } from "../pages/styles/colors/[accent].css"; interface Props { accent: Color; + noNavbar?: boolean; } -const { accent } = Astro.props; +const { accent, noNavbar } = Astro.props; --- @@ -18,6 +20,7 @@ const { accent } = Astro.props; + {!noNavbar && }