Skip to content

Commit

Permalink
dry
Browse files Browse the repository at this point in the history
  • Loading branch information
bob0005 committed Dec 10, 2024
1 parent 1ee218d commit 43654f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) ?? [];
Expand Down Expand Up @@ -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 =
Expand Down
5 changes: 5 additions & 0 deletions client/src/ui/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type ID,
type Position,
type Resource,
ResourceCost,
ResourcesIds,
TickIds,
} from "@bibliothecadao/eternum";
Expand Down Expand Up @@ -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));
};

0 comments on commit 43654f7

Please sign in to comment.