mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
feat: start of mechanics
This commit is contained in:
1 parent
01409985a2
commit
da1af66c77
6 files changed
+37
-21
No files matched your search
@@ -1,12 +1,11 @@
|
||||
import { TankClass } from "@blitzkit/core";
|
||||
import type { CompensationComponent } from "@protos/blitz_static_compensation_component";
|
||||
import { type TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
StageParameters,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import { radToDeg } from "three/src/math/MathUtils.js";
|
||||
import type { Tank } from "../../protos/tank";
|
||||
import { applyPitchYawLimits } from "./applyPitchYawLimits";
|
||||
import { TerrainHardness, type TankState } from "./tankState";
|
||||
|
||||
@@ -19,9 +18,8 @@ type Characteristic = (helpers: {
|
||||
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
|
||||
shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null;
|
||||
state: TankState;
|
||||
tank: TankCatalogComponent;
|
||||
tank: Tank;
|
||||
parameters: StageParameters;
|
||||
compensation: CompensationComponent;
|
||||
id: string;
|
||||
}) => CharacteristicOutput;
|
||||
|
||||
@@ -349,7 +347,7 @@ export const characteristics = {
|
||||
},
|
||||
|
||||
class({ tank }) {
|
||||
return tank.tank_class;
|
||||
return tank.tank!.tank_class;
|
||||
},
|
||||
|
||||
camouflage({ attribute, characteristic, attributeSafe, state }) {
|
||||
@@ -396,26 +394,30 @@ export const characteristics = {
|
||||
},
|
||||
|
||||
nation({ tank }) {
|
||||
return tank.nation;
|
||||
return tank.tank!.nation;
|
||||
},
|
||||
|
||||
name({ tank }) {
|
||||
return tank.name!.value;
|
||||
return tank.tank!.name!.value;
|
||||
},
|
||||
|
||||
tier({ tank }) {
|
||||
return tank.tier_catalog_id;
|
||||
return tank.tank!.tier_catalog_id;
|
||||
},
|
||||
|
||||
type({ tank }) {
|
||||
return tank.tank_type;
|
||||
return tank.tank!.tank_type;
|
||||
},
|
||||
|
||||
id({ id }) {
|
||||
return id;
|
||||
},
|
||||
|
||||
compensation({ compensation }) {
|
||||
return compensation.compensation?.currency_reward?.amount ?? null;
|
||||
slug({ tank }) {
|
||||
return tank.slug;
|
||||
},
|
||||
|
||||
compensation({ tank }) {
|
||||
return tank.compensation!.compensation?.currency_reward?.amount ?? null;
|
||||
},
|
||||
} satisfies Record<string, Characteristic>;
|
||||
@@ -57,6 +57,7 @@ export const characteristicsOrder: CharacteristicsOrder = [
|
||||
},
|
||||
{ name: "compensation" },
|
||||
{ name: "id" },
|
||||
{ name: "slug" },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { CompensationComponent } from "@protos/blitz_static_compensation_component";
|
||||
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import type { Tank } from "../../protos/tank";
|
||||
import { aggregateStageParameters } from "./aggregateStageParameters";
|
||||
import {
|
||||
characteristics,
|
||||
@@ -19,13 +18,12 @@ export type ComputedCharacteristics = Record<
|
||||
|
||||
export function computeCharacteristics(
|
||||
id: string,
|
||||
tank: TankCatalogComponent,
|
||||
compensation: CompensationComponent,
|
||||
tank: Tank,
|
||||
state: TankState
|
||||
) {
|
||||
const parameters = aggregateStageParameters(
|
||||
tank.base_stats!,
|
||||
tank.upgrade_stages.slice(0, state.stage)
|
||||
tank.tank!.base_stats!,
|
||||
tank.tank!.upgrade_stages.slice(0, state.stage)
|
||||
);
|
||||
|
||||
const computed: Partial<ComputedCharacteristics> = {};
|
||||
@@ -97,7 +95,6 @@ export function computeCharacteristics(
|
||||
tank,
|
||||
parameters,
|
||||
id,
|
||||
compensation,
|
||||
});
|
||||
computed[name] = value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { APIContext } from "astro";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
|
||||
export { getStaticPaths } from "./[id].pb";
|
||||
|
||||
/**
|
||||
* Even Noah can't save these animals.
|
||||
*/
|
||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||
const tank = await api.tank(params.id);
|
||||
return Response.json(tank);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { Tank } from "../../../protos/tank";
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
const { list } = await api.tankList();
|
||||
|
||||
return list.map(({ id }) => ({ params: { id } }));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ function Content({ id }: { id: string }) {
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const compare = Tankopedia.use((state) => state.compare);
|
||||
const characteristics = useMemo(
|
||||
() =>
|
||||
computeCharacteristics(id, tank.tank!, tank.compensation!, protagonist),
|
||||
() => computeCharacteristics(id, tank, protagonist),
|
||||
[protagonist]
|
||||
);
|
||||
// const otherCharacteristics = useMemo(
|
||||
@@ -53,6 +52,12 @@ function Content({ id }: { id: string }) {
|
||||
<>
|
||||
<h1>{id}</h1>
|
||||
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "1rem" }}>
|
||||
{tank.tank?.feature_screens?.tags.map((tag) => (
|
||||
<span>{tag.value}</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div style={{ display: "flex", flexWrap: "wrap" }}>
|
||||
|
||||
Reference in new issue
Block a user