Skip to content

Commit

Permalink
Merge pull request #2548 from BibliothecaDAO/fix/mine-max-balance
Browse files Browse the repository at this point in the history
fix mine balance max cap
  • Loading branch information
ponderingdemocritus authored Dec 17, 2024
2 parents 93bfe50 + 9d2794d commit 7e4dbf8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/src/ui/components/resources/EntityResourceTable.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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]);
Expand Down

0 comments on commit 7e4dbf8

Please sign in to comment.