fix: find att0 correctly

This commit is contained in:
TrèsAbhi committed 2025-12-18 13:16:20 -06:00
1 parent 6ba6e10108
commit 0e0f4fbe9f
2 files changed
+17 -14

No files matched your search

@@ -28,23 +28,26 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
case TankAttributeChange_Modifier.MODIFIER_MULTIPLY:
case TankAttributeChange_Modifier.MODIFIER_ADD:
if (!(attribute1.attribute_name in stage0)) {
const attribute0 = stage0.attributes.find(
(attribute0) =>
attribute0.attribute_name === attribute1.attribute_name
);
if (!attribute0) {
throw new Error(
`Missing attribute ${
TankAttributeChange_AttributeName[attribute1.attribute_name]
} to modify`
} (${attribute1.attribute_name}) to modify`
);
}
const oldValue = stage0.attributes[attribute1.attribute_name]!.value;
case TankAttributeChange_Modifier.MODIFIER_MULTIPLY: {
value1 = oldValue! * attribute1.value;
value1 = attribute0!.value! * attribute1.value;
break;
}
case TankAttributeChange_Modifier.MODIFIER_ADD: {
value1 = oldValue! + attribute1.value;
value1 = attribute0!.value! + attribute1.value;
break;
}
@@ -17,33 +17,33 @@ function Content({ id }: { id: string }) {
const tank = useAwait(() => api.tank(id), `tank-${id}`);
const stage = Tankopedia.use((state) => state.stage);
const aggregatedStages = useMemo(
const parameters = useMemo(
() => aggregateStages(tank.base_stats!, tank.upgrade_stages, stage),
[stage]
);
return (
<>
<pre children={JSON.stringify(tank, null, 2)} />
<h1>{tank.name?.value}</h1>
<h2>Characteristics</h2>
<div style={{ display: "flex" }}>
{times(tank.upgrade_stages.length, (index) => (
<button
key={index}
onClick={() => {
Tankopedia.mutate((draft) => {
draft.stage = index;
});
}}
>
Stage {index + 1} {index === stage && "(selected)"}
Stage {index} {index === stage && "(selected)"}
</button>
))}
</div>
<pre children={JSON.stringify(parameters, null, 2)} />
<h1>{tank.name?.value}</h1>
<h2>Characteristics</h2>
{/* {_characteristicsOrder.map((group) => (
<>
<h2>{CharacteristicsGroup[group.group]}</h2>