feat: autoreloader dom

This commit is contained in:
TrèsAbhi committed 2025-12-24 19:33:01 -06:00
1 parent d2a6379131
commit a364b79a9b
4 files changed
+47 -14

No files matched your search

Whitespace-only changes.
@@ -147,12 +147,6 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
stage0.pump_reload_times = [...stage1.pump_reload_times]; 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) { if (stage1.pitch_limits_up.length > 0 && stage0.pitch_limits_up.length > 0) {
throw new Error("Pitch limits not implemented"); throw new Error("Pitch limits not implemented");
} }
@@ -8,7 +8,7 @@ import { radToDeg } from "three/src/math/MathUtils.js";
import { applyPitchYawLimits } from "./applyPitchYawLimits"; import { applyPitchYawLimits } from "./applyPitchYawLimits";
import type { TankState } from "./tankState"; import type { TankState } from "./tankState";
export type CharacteristicOutput = number | null; export type CharacteristicOutput = number | number[] | null;
type Characteristic = (helpers: { type Characteristic = (helpers: {
characteristic: (name: CharacteristicName) => CharacteristicOutput; 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 }) { intra_clip({ characteristic, attribute }) {
const gunType = characteristic("gun_type")!; const gunType = characteristic("gun_type")!;
@@ -96,30 +104,58 @@ export const characteristics = {
return 60 / clipRate; 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 }) { dpm({ characteristic }) {
let dps: number; let dps: number;
const gunType = characteristic("gun_type")!; const gunType = characteristic("gun_type")!;
const damage = characteristic("damage")!; const damage = characteristic("damage") as number;
switch (gunType) { switch (gunType) {
case GunType.Regular: { case GunType.Regular: {
const reload = characteristic("reload")!; const reload = characteristic("reload") as number;
dps = damage / reload; dps = damage / reload;
break; break;
} }
case GunType.AutoLoader: { case GunType.AutoLoader: {
const reload = characteristic("reload")!; const reload = characteristic("reload") as number;
const intraClip = characteristic("intra_clip")!; const intraClip = characteristic("intra_clip") as number;
const clipSize = characteristic("clip_size")!; const clipSize = characteristic("clip_size") as number;
dps = (damage * clipSize) / (reload + (clipSize - 1) * intraClip); dps = (damage * clipSize) / (reload + (clipSize - 1) * intraClip);
break; break;
} }
case GunType.AutoReloader: { 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: default:
@@ -2,13 +2,15 @@
import "@fontsource-variable/inter"; import "@fontsource-variable/inter";
import BaseMeta from "../components/BaseMeta.astro"; import BaseMeta from "../components/BaseMeta.astro";
import BaseStyles from "../components/BaseStyles.astro"; import BaseStyles from "../components/BaseStyles.astro";
import Navbar from "../components/Navbar.astro";
import type { Color } from "../pages/styles/colors/[accent].css"; import type { Color } from "../pages/styles/colors/[accent].css";
interface Props { interface Props {
accent: Color; accent: Color;
noNavbar?: boolean;
} }
const { accent } = Astro.props; const { accent, noNavbar } = Astro.props;
--- ---
<html> <html>
@@ -18,6 +20,7 @@ const { accent } = Astro.props;
</head> </head>
<body class="dark"> <body class="dark">
{!noNavbar && <Navbar />}
<slot /> <slot />
</body> </body>
</html> </html>