From 9d2794d0f42fdf20dbad474f41bcf0fcbfad5408 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 17 Dec 2024 08:27:22 +0100 Subject: [PATCH] fix mine balance max cap --- client/src/ui/components/resources/EntityResourceTable.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/ui/components/resources/EntityResourceTable.tsx b/client/src/ui/components/resources/EntityResourceTable.tsx index 37a04668b..bba2e08fc 100644 --- a/client/src/ui/components/resources/EntityResourceTable.tsx +++ b/client/src/ui/components/resources/EntityResourceTable.tsx @@ -1,8 +1,9 @@ import { configManager } from "@/dojo/setup"; import { useDojo } from "@/hooks/context/DojoContext"; +import { useStructures } from "@/hooks/helpers/useStructures"; import useNextBlockTimestamp from "@/hooks/useNextBlockTimestamp"; import { getEntityIdFromKeys, gramToKg, multiplyByPrecision } from "@/ui/utils/utils"; -import { BuildingType, CapacityConfigCategory, ID, RESOURCE_TIERS } from "@bibliothecadao/eternum"; +import { BuildingType, CapacityConfigCategory, ID, RESOURCE_TIERS, StructureType } from "@bibliothecadao/eternum"; import { useComponentValue } from "@dojoengine/react"; import { useMemo } from "react"; import { ResourceChip } from "./ResourceChip"; @@ -18,7 +19,11 @@ export const EntityResourceTable = ({ entityId }: { entityId: ID | undefined }) getEntityIdFromKeys([BigInt(entityId || 0), BigInt(BuildingType.Storehouse)]), )?.value || 0; + const { getStructureByEntityId } = useStructures(); + const structure = getStructureByEntityId(entityId || 0); + const maxStorehouseCapacityKg = useMemo(() => { + if (structure?.category === StructureType[StructureType.FragmentMine]) return Infinity; const storehouseCapacityKg = gramToKg(configManager.getCapacityConfig(CapacityConfigCategory.Storehouse)); return multiplyByPrecision(quantity * storehouseCapacityKg + storehouseCapacityKg); }, [quantity, entityId]);