mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: start of derived statistics
This commit is contained in:
1 parent
122d65840e
commit
5541eca23d
5 files changed
+75
-11
No files matched your search
Vendored
-2
@@ -17,8 +17,6 @@
|
||||
"astrojs",
|
||||
"astrolib",
|
||||
"atgm",
|
||||
"Autoloader",
|
||||
"Autoreloader",
|
||||
"AYUV",
|
||||
"battleresults",
|
||||
"bbox",
|
||||
|
||||
@@ -10,12 +10,75 @@ export enum CharacteristicsGroup {
|
||||
type CharacteristicsOrder = {
|
||||
group: CharacteristicsGroup;
|
||||
|
||||
characteristics: {
|
||||
name: string;
|
||||
value(
|
||||
get: (name: TankAttributeChange_AttributeName) => number
|
||||
): number | string | null;
|
||||
}[];
|
||||
}[];
|
||||
|
||||
export const characteristicsOrder: CharacteristicsOrder = [
|
||||
{
|
||||
group: CharacteristicsGroup.Firepower,
|
||||
|
||||
characteristics: [
|
||||
{
|
||||
name: "gun_type",
|
||||
|
||||
value(get) {
|
||||
const isPump = get(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_IS_PUMP
|
||||
);
|
||||
|
||||
if (isPump === 1) return "auto_reloader";
|
||||
|
||||
const clipSize = get(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
);
|
||||
|
||||
if (clipSize === 1) return "regular";
|
||||
|
||||
return "auto_loader";
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "dpm",
|
||||
|
||||
value(get) {
|
||||
return -1;
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "clipping_potential",
|
||||
|
||||
value(get) {
|
||||
const clipSize = get(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
);
|
||||
|
||||
if (clipSize === 1) return null;
|
||||
|
||||
// const damage
|
||||
|
||||
return -1;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
type _CharacteristicsOrder = {
|
||||
group: CharacteristicsGroup;
|
||||
|
||||
attributes: {
|
||||
name: TankAttributeChange_AttributeName;
|
||||
}[];
|
||||
}[];
|
||||
|
||||
export const characteristicsOrder: CharacteristicsOrder = [
|
||||
export const _characteristicsOrder: _CharacteristicsOrder = [
|
||||
{
|
||||
group: CharacteristicsGroup.Firepower,
|
||||
|
||||
@@ -257,7 +320,7 @@ if (import.meta.env.DEV) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const isImplemented = characteristicsOrder.some((group) =>
|
||||
const isImplemented = _characteristicsOrder.some((group) =>
|
||||
group.attributes.some((attribute) => attribute.name === name)
|
||||
);
|
||||
|
||||
|
||||
@@ -5,9 +5,13 @@ import {
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import { times } from "lodash-es";
|
||||
|
||||
export type AggregateAttributes = Partial<
|
||||
Record<TankAttributeChange_AttributeName, number>
|
||||
>;
|
||||
|
||||
function patch(
|
||||
changes: TankAttributeChange[],
|
||||
attributes: Partial<Record<TankAttributeChange_AttributeName, number>>
|
||||
attributes: AggregateAttributes
|
||||
) {
|
||||
for (const { attribute_name, value, modifier } of changes) {
|
||||
switch (modifier) {
|
||||
@@ -41,8 +45,7 @@ export function aggregateAttributes(
|
||||
stages: TankAttributeChange[][],
|
||||
stage: number
|
||||
) {
|
||||
const attributes: Partial<Record<TankAttributeChange_AttributeName, number>> =
|
||||
{};
|
||||
const attributes: AggregateAttributes = {};
|
||||
|
||||
patch(base, attributes);
|
||||
times(stage, (index) => patch(stages[index], attributes));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { characteristicsOrder } from "../../../../constants/characteristicsOrder";
|
||||
import { _characteristicsOrder } from "../../../../constants/characteristicsOrder";
|
||||
|
||||
export function GET() {
|
||||
return Response.json(characteristicsOrder);
|
||||
return Response.json(_characteristicsOrder);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { times } from "lodash-es";
|
||||
import { Suspense, useMemo } from "react";
|
||||
import {
|
||||
CharacteristicsGroup,
|
||||
characteristicsOrder,
|
||||
_characteristicsOrder,
|
||||
} from "../../../constants/characteristicsOrder";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { aggregateAttributes } from "../../../core/blitz/aggregateAttributes";
|
||||
@@ -53,7 +53,7 @@ function Content({ id }: { id: string }) {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{characteristicsOrder.map((group) => (
|
||||
{_characteristicsOrder.map((group) => (
|
||||
<>
|
||||
<h2>{CharacteristicsGroup[group.group]}</h2>
|
||||
|
||||
|
||||
Reference in new issue
Block a user