diff --git a/client/src/ui/components/construction/SelectPreviewBuilding.tsx b/client/src/ui/components/construction/SelectPreviewBuilding.tsx index 213478d6f..5b8890758 100644 --- a/client/src/ui/components/construction/SelectPreviewBuilding.tsx +++ b/client/src/ui/components/construction/SelectPreviewBuilding.tsx @@ -18,6 +18,7 @@ import { Tabs } from "@/ui/elements/tab"; import { unpackResources } from "@/ui/utils/packedData"; import { hasEnoughPopulationForBuilding } from "@/ui/utils/realms"; import { + adjustWonderLordsCost, divideByPrecision, getEntityIdFromKeys, gramToKg, @@ -400,7 +401,7 @@ export const ResourceInfo = ({ const realm = getComponentValue(dojo.setup.components.Realm, getEntityIdFromKeys([BigInt(entityId || 0)])); if (resourceId == ResourcesIds.Donkey && realm?.has_wonder) { - cost = cost.map((cost) => (cost.resource === ResourcesIds.Lords ? { ...cost, amount: cost.amount * 0.1 } : cost)); + cost = adjustWonderLordsCost(cost); } const buildingCost = getResourceBuildingCosts(entityId ?? 0, dojo, resourceId) ?? []; @@ -536,10 +537,9 @@ export const BuildingInfo = ({ let ongoingCost = resourceProduced !== undefined ? configManager.resourceInputs[resourceProduced] || [] : []; const realm = getComponentValue(dojo.setup.components.Realm, getEntityIdFromKeys([BigInt(entityId || 0)])); + if (buildingId == BuildingType.Market && realm?.has_wonder && ongoingCost.length > 0) { - ongoingCost = ongoingCost.map((cost) => - cost.resource === ResourcesIds.Lords ? { ...cost, amount: cost.amount * 0.1 } : cost, - ); + ongoingCost = adjustWonderLordsCost(ongoingCost); } const perTick = diff --git a/client/src/ui/utils/utils.tsx b/client/src/ui/utils/utils.tsx index bd92c0e80..543eb6360 100644 --- a/client/src/ui/utils/utils.tsx +++ b/client/src/ui/utils/utils.tsx @@ -9,6 +9,7 @@ import { type ID, type Position, type Resource, + ResourceCost, ResourcesIds, TickIds, } from "@bibliothecadao/eternum"; @@ -494,3 +495,7 @@ export const getRandomBackgroundImage = () => { const paddedNumber = imageNumber.toString().padStart(2, "0"); return paddedNumber; }; + +export const adjustWonderLordsCost = (cost: ResourceCost[]): ResourceCost[] => { + return cost.map((item) => (item.resource === ResourcesIds.Lords ? { ...item, amount: item.amount * 0.1 } : item)); +};