Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mine #2552

Merged
merged 8 commits into from
Dec 17, 2024
Merged

mine #2552

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/src/dojo/modelManager/ResourceManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getEntityIdFromKeys, gramToKg, multiplyByPrecision } from "@/ui/utils/utils";
import { BuildingType, CapacityConfigCategory, ResourcesIds, type ID } from "@bibliothecadao/eternum";
import { BuildingType, CapacityConfigCategory, ResourcesIds, StructureType, type ID } from "@bibliothecadao/eternum";
import { getComponentValue } from "@dojoengine/recs";
import { configManager, type SetupResult } from "../setup";

Expand Down Expand Up @@ -91,6 +91,12 @@ export class ResourceManager {
}

public getStoreCapacity(): number {
const structure = getComponentValue(
this.setup.components.Structure,
getEntityIdFromKeys([BigInt(this.entityId || 0)]),
);
if (structure?.category === StructureType[StructureType.FragmentMine]) return Infinity;

const storehouseCapacityKg = gramToKg(configManager.getCapacityConfig(CapacityConfigCategory.Storehouse));
const quantity =
getComponentValue(
Expand Down
3 changes: 2 additions & 1 deletion client/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@ export async function setup({ ...config }: DojoConfig) {
models: [
"s0_eternum-GameEnded",
"s0_eternum-HyperstructureFinished",
"s0_eternum-BattleStartData",
"s0_eternum-BattleClaimData",
"s0_eternum-BattleJoinData",
"s0_eternum-BattleLeaveData",
"s0_eternum-BattlePillageData",
"s0_eternum-BattleStartData",
"s0_eternum-AcceptOrder",
"s0_eternum-SwapEvent",
"s0_eternum-LiquidityEvent",
Expand Down
7 changes: 6 additions & 1 deletion client/src/ui/components/resources/EntityResourceTable.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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";
import { getComponentValue } from "@dojoengine/recs";

export const EntityResourceTable = ({ entityId }: { entityId: ID | undefined }) => {
const dojo = useDojo();
Expand All @@ -18,7 +20,10 @@ export const EntityResourceTable = ({ entityId }: { entityId: ID | undefined })
getEntityIdFromKeys([BigInt(entityId || 0), BigInt(BuildingType.Storehouse)]),
)?.value || 0;

const structure = getComponentValue(dojo.setup.components.Structure, getEntityIdFromKeys([BigInt(entityId || 0)]));

const maxStorehouseCapacityKg = useMemo(() => {
if (structure?.category !== StructureType[StructureType.Realm]) return Infinity;
const storehouseCapacityKg = gramToKg(configManager.getCapacityConfig(CapacityConfigCategory.Storehouse));
return multiplyByPrecision(quantity * storehouseCapacityKg + storehouseCapacityKg);
}, [quantity, entityId]);
Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/modules/navigation/LeftNavigationModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const LeftNavigationModule = memo(() => {
name: MenuEnum.construction,
button: (
<CircleButton
disabled={!structureIsMine || !isRealm}
// disabled={!structureIsMine || !isRealm}
className="construction-selector"
image={BuildingThumbs.construction}
tooltipLocation="top"
Expand Down
10 changes: 8 additions & 2 deletions client/src/ui/modules/navigation/TopLeftNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const TopLeftNavigation = memo(() => {
return { timeLeftBeforeNextTick: timeLeft, progress: progressValue };
}, [nextBlockTimestamp]);

console.log(entityInfo.structureCategory);
return (
<div className="pointer-events-auto w-screen flex justify-between md:pl-2">
<motion.div
Expand Down Expand Up @@ -253,11 +254,16 @@ export const TopLeftNavigation = memo(() => {
className="storehouse-selector px-3 flex gap-2 justify-start items-center text-xxs md:text-sm"
>
<ResourceIcon withTooltip={false} resource="Silo" size="sm" />
{IS_MOBILE ? (
<div className="self-center">{storehouses.quantity.toLocaleString()}</div>
{entityInfo.structureCategory !== "Realm" ? (
<div className="self-center"></div>
) : (
<div className="self-center">{storehouses.capacityKg.toLocaleString()} kg</div>
)}
{/* {IS_MOBILE ? (
<div className="self-center">{storehouses.quantity.toLocaleString()}</div>
) : (
<div className="self-center">{storehouses.capacityKg.toLocaleString()} kg</div>
)} */}
</div>
)}

Expand Down
Loading