mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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",
|
"astrojs",
|
||||||
"astrolib",
|
"astrolib",
|
||||||
"atgm",
|
"atgm",
|
||||||
"Autoloader",
|
|
||||||
"Autoreloader",
|
|
||||||
"AYUV",
|
"AYUV",
|
||||||
"battleresults",
|
"battleresults",
|
||||||
"bbox",
|
"bbox",
|
||||||
|
|||||||
@@ -10,12 +10,75 @@ export enum CharacteristicsGroup {
|
|||||||
type CharacteristicsOrder = {
|
type CharacteristicsOrder = {
|
||||||
group: CharacteristicsGroup;
|
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: {
|
attributes: {
|
||||||
name: TankAttributeChange_AttributeName;
|
name: TankAttributeChange_AttributeName;
|
||||||
}[];
|
}[];
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
export const characteristicsOrder: CharacteristicsOrder = [
|
export const _characteristicsOrder: _CharacteristicsOrder = [
|
||||||
{
|
{
|
||||||
group: CharacteristicsGroup.Firepower,
|
group: CharacteristicsGroup.Firepower,
|
||||||
|
|
||||||
@@ -257,7 +320,7 @@ if (import.meta.env.DEV) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isImplemented = characteristicsOrder.some((group) =>
|
const isImplemented = _characteristicsOrder.some((group) =>
|
||||||
group.attributes.some((attribute) => attribute.name === name)
|
group.attributes.some((attribute) => attribute.name === name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,13 @@ import {
|
|||||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
|
|
||||||
|
export type AggregateAttributes = Partial<
|
||||||
|
Record<TankAttributeChange_AttributeName, number>
|
||||||
|
>;
|
||||||
|
|
||||||
function patch(
|
function patch(
|
||||||
changes: TankAttributeChange[],
|
changes: TankAttributeChange[],
|
||||||
attributes: Partial<Record<TankAttributeChange_AttributeName, number>>
|
attributes: AggregateAttributes
|
||||||
) {
|
) {
|
||||||
for (const { attribute_name, value, modifier } of changes) {
|
for (const { attribute_name, value, modifier } of changes) {
|
||||||
switch (modifier) {
|
switch (modifier) {
|
||||||
@@ -41,8 +45,7 @@ export function aggregateAttributes(
|
|||||||
stages: TankAttributeChange[][],
|
stages: TankAttributeChange[][],
|
||||||
stage: number
|
stage: number
|
||||||
) {
|
) {
|
||||||
const attributes: Partial<Record<TankAttributeChange_AttributeName, number>> =
|
const attributes: AggregateAttributes = {};
|
||||||
{};
|
|
||||||
|
|
||||||
patch(base, attributes);
|
patch(base, attributes);
|
||||||
times(stage, (index) => patch(stages[index], 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() {
|
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 { Suspense, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
CharacteristicsGroup,
|
CharacteristicsGroup,
|
||||||
characteristicsOrder,
|
_characteristicsOrder,
|
||||||
} from "../../../constants/characteristicsOrder";
|
} from "../../../constants/characteristicsOrder";
|
||||||
import { api } from "../../../core/api/dynamic";
|
import { api } from "../../../core/api/dynamic";
|
||||||
import { aggregateAttributes } from "../../../core/blitz/aggregateAttributes";
|
import { aggregateAttributes } from "../../../core/blitz/aggregateAttributes";
|
||||||
@@ -53,7 +53,7 @@ function Content({ id }: { id: string }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{characteristicsOrder.map((group) => (
|
{_characteristicsOrder.map((group) => (
|
||||||
<>
|
<>
|
||||||
<h2>{CharacteristicsGroup[group.group]}</h2>
|
<h2>{CharacteristicsGroup[group.group]}</h2>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user