mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +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 tank = useProtagonist();
|
||||||
const equipment = useEquipment(tank.tank!);
|
const equipment = useEquipment(tank.tank!);
|
||||||
|
|
||||||
|
console.log(equipment);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.section}>
|
<div className={styles.section}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { api } from "../../../../api/dynamic";
|
|||||||
import { TankopediaLoadout } from "../../../../components/TankopediaLoadout";
|
import { TankopediaLoadout } from "../../../../components/TankopediaLoadout";
|
||||||
import { useAwait } from "../../../../hooks/useAwait";
|
import { useAwait } from "../../../../hooks/useAwait";
|
||||||
import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer";
|
import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer";
|
||||||
import { useGameStrings } from "../../../../hooks/useGameStrings";
|
import { useEquipment } from "../../../../hooks/useEquipment";
|
||||||
import { LocaleProvider } from "../../../../hooks/useLocale";
|
import { LocaleProvider } from "../../../../hooks/useLocale";
|
||||||
import { Tankopedia } from "../../../../stores/tankopedia";
|
import { Tankopedia } from "../../../../stores/tankopedia";
|
||||||
import { characteristicsOrder } from "../../../../tankopedia/characteristicsOrder";
|
import { characteristicsOrder } from "../../../../tankopedia/characteristicsOrder";
|
||||||
@@ -27,7 +27,6 @@ export function Page({ id, locale }: PageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Content() {
|
function Content() {
|
||||||
const tankEntityGameStrings = useGameStrings("TankEntity");
|
|
||||||
const renderCharacteristic = useCharacteristicRenderer();
|
const renderCharacteristic = useCharacteristicRenderer();
|
||||||
|
|
||||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||||
@@ -35,9 +34,15 @@ function Content() {
|
|||||||
() => api.tank(protagonist.id),
|
() => api.tank(protagonist.id),
|
||||||
`tank-${protagonist.id}`,
|
`tank-${protagonist.id}`,
|
||||||
);
|
);
|
||||||
|
const protagonistEquipment = useEquipment(protagonistTank.tank!);
|
||||||
|
|
||||||
const { characteristics } = useMemo(
|
const { characteristics } = useMemo(
|
||||||
() => computeCharacteristics(protagonistTank, protagonist),
|
() =>
|
||||||
|
computeCharacteristics(
|
||||||
|
protagonistTank,
|
||||||
|
protagonistEquipment,
|
||||||
|
protagonist,
|
||||||
|
),
|
||||||
[protagonist],
|
[protagonist],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import {
|
|||||||
TankAttributeChange_Modifier,
|
TankAttributeChange_Modifier,
|
||||||
VisualChanges,
|
VisualChanges,
|
||||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||||
import {
|
import { isAlternativeLine, originalLineName } from "../config/modules";
|
||||||
isAlternativeLine,
|
|
||||||
originalLineName,
|
|
||||||
} from "../config/modules";
|
|
||||||
|
|
||||||
function patch(stage0: StageParameters, stage1: StageParameters) {
|
function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||||
if (stage1.number !== ++stage0.number) {
|
if (stage1.number !== ++stage0.number) {
|
||||||
@@ -244,6 +241,7 @@ export function aggregateParameters(
|
|||||||
tank: TankCatalogComponent,
|
tank: TankCatalogComponent,
|
||||||
upgrades: Record<string, number>,
|
upgrades: Record<string, number>,
|
||||||
alternates: Record<string, boolean>,
|
alternates: Record<string, boolean>,
|
||||||
|
equipmentParameters: StageParameters[],
|
||||||
) {
|
) {
|
||||||
const stage0 = StageParameters.create({});
|
const stage0 = StageParameters.create({});
|
||||||
|
|
||||||
@@ -273,5 +271,10 @@ export function aggregateParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const equipmentParameter of equipmentParameters) {
|
||||||
|
stage0.number = -1;
|
||||||
|
patch(stage0, equipmentParameter);
|
||||||
|
}
|
||||||
|
|
||||||
return stage0;
|
return stage0;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import type { StageParameters } from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||||
import {
|
import {
|
||||||
ShellUpgradeSingleChange_AttributeName,
|
ShellUpgradeSingleChange_AttributeName,
|
||||||
TankAttributeChange_AttributeName,
|
TankAttributeChange_AttributeName,
|
||||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||||
import type { Tank } from "@protos/tank";
|
import type { Tank } from "@protos/tank";
|
||||||
|
import { useEquipment } from "../hooks/useEquipment";
|
||||||
import { aggregateParameters } from "./aggregateParameters";
|
import { aggregateParameters } from "./aggregateParameters";
|
||||||
import {
|
import {
|
||||||
characteristics,
|
characteristics,
|
||||||
@@ -16,11 +18,27 @@ export type ComputedCharacteristics = Record<
|
|||||||
CharacteristicOutput
|
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(
|
const parameters = aggregateParameters(
|
||||||
tank.tank!,
|
tank.tank!,
|
||||||
state.upgrades,
|
state.upgrades,
|
||||||
state.alternates,
|
state.alternates,
|
||||||
|
equipmentParameters,
|
||||||
);
|
);
|
||||||
|
|
||||||
const computed: Partial<ComputedCharacteristics> = {};
|
const computed: Partial<ComputedCharacteristics> = {};
|
||||||
|
|||||||
Reference in new issue
Block a user