mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: autoreloader dom
This commit is contained in:
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];
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
---
|
||||
|
||||
<html>
|
||||
@@ -18,6 +20,7 @@ const { accent } = Astro.props;
|
||||
</head>
|
||||
|
||||
<body class="dark">
|
||||
{!noNavbar && <Navbar />}
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user