mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
equipment stage parameters
This commit is contained in:
1 parent
c100a1e655
commit
4e9c3df5eb
4 files changed
+36
-8
No files matched your search
@@ -41,6 +41,8 @@ function Equipment() {
|
||||
const tank = useProtagonist();
|
||||
const equipment = useEquipment(tank.tank!);
|
||||
|
||||
console.log(equipment);
|
||||
|
||||
return (
|
||||
<div className={styles.section}>
|
||||
<div className={styles.header}>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { api } from "../../../../api/dynamic";
|
||||
import { TankopediaLoadout } from "../../../../components/TankopediaLoadout";
|
||||
import { useAwait } from "../../../../hooks/useAwait";
|
||||
import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer";
|
||||
import { useGameStrings } from "../../../../hooks/useGameStrings";
|
||||
import { useEquipment } from "../../../../hooks/useEquipment";
|
||||
import { LocaleProvider } from "../../../../hooks/useLocale";
|
||||
import { Tankopedia } from "../../../../stores/tankopedia";
|
||||
import { characteristicsOrder } from "../../../../tankopedia/characteristicsOrder";
|
||||
@@ -27,7 +27,6 @@ export function Page({ id, locale }: PageProps) {
|
||||
}
|
||||
|
||||
function Content() {
|
||||
const tankEntityGameStrings = useGameStrings("TankEntity");
|
||||
const renderCharacteristic = useCharacteristicRenderer();
|
||||
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
@@ -35,9 +34,15 @@ function Content() {
|
||||
() => api.tank(protagonist.id),
|
||||
`tank-${protagonist.id}`,
|
||||
);
|
||||
const protagonistEquipment = useEquipment(protagonistTank.tank!);
|
||||
|
||||
const { characteristics } = useMemo(
|
||||
() => computeCharacteristics(protagonistTank, protagonist),
|
||||
() =>
|
||||
computeCharacteristics(
|
||||
protagonistTank,
|
||||
protagonistEquipment,
|
||||
protagonist,
|
||||
),
|
||||
[protagonist],
|
||||
);
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ import {
|
||||
TankAttributeChange_Modifier,
|
||||
VisualChanges,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import {
|
||||
isAlternativeLine,
|
||||
originalLineName,
|
||||
} from "../config/modules";
|
||||
import { isAlternativeLine, originalLineName } from "../config/modules";
|
||||
|
||||
function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||
if (stage1.number !== ++stage0.number) {
|
||||
@@ -244,6 +241,7 @@ export function aggregateParameters(
|
||||
tank: TankCatalogComponent,
|
||||
upgrades: Record<string, number>,
|
||||
alternates: Record<string, boolean>,
|
||||
equipmentParameters: StageParameters[],
|
||||
) {
|
||||
const stage0 = StageParameters.create({});
|
||||
|
||||
@@ -273,5 +271,10 @@ export function aggregateParameters(
|
||||
}
|
||||
}
|
||||
|
||||
for (const equipmentParameter of equipmentParameters) {
|
||||
stage0.number = -1;
|
||||
patch(stage0, equipmentParameter);
|
||||
}
|
||||
|
||||
return stage0;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { StageParameters } from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import {
|
||||
ShellUpgradeSingleChange_AttributeName,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import type { Tank } from "@protos/tank";
|
||||
import { useEquipment } from "../hooks/useEquipment";
|
||||
import { aggregateParameters } from "./aggregateParameters";
|
||||
import {
|
||||
characteristics,
|
||||
@@ -16,11 +18,27 @@ export type ComputedCharacteristics = Record<
|
||||
CharacteristicOutput
|
||||
>;
|
||||
|
||||
export function computeCharacteristics(tank: Tank, state: TankState) {
|
||||
export function computeCharacteristics(
|
||||
tank: Tank,
|
||||
equipment: ReturnType<typeof useEquipment>,
|
||||
state: TankState,
|
||||
) {
|
||||
const equipmentParameters: StageParameters[] = [];
|
||||
|
||||
for (const key in state.equipment) {
|
||||
const index = Number(key);
|
||||
const choice = state.equipment[index];
|
||||
const name = equipment.preset.slots[index].options_catalog_i_ds[choice];
|
||||
const data = equipment.equipments[name];
|
||||
|
||||
equipmentParameters.push(data.upgrade_level!);
|
||||
}
|
||||
|
||||
const parameters = aggregateParameters(
|
||||
tank.tank!,
|
||||
state.upgrades,
|
||||
state.alternates,
|
||||
equipmentParameters,
|
||||
);
|
||||
|
||||
const computed: Partial<ComputedCharacteristics> = {};
|
||||
|
||||
Reference in new issue
Block a user