-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix mine balance max cap #2548
fix mine balance max cap #2548
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Caution Review failedThe pull request is closed. WalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant Component as EntityResourceTable
participant Hook as useStructures
participant Type as StructureType
Component->>Hook: getStructureByEntityId(entityId)
Hook-->>Component: Return structure details
Component->>Type: Check structure category
alt Is FragmentMine
Component->>Component: Set maxStorehouseCapacityKg to Infinity
else Other structure types
Component->>Component: Calculate standard capacity
end
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good overall and implement the Fragment Mine special case correctly. The code is well integrated with existing patterns and hooks. Just a couple of minor suggestions around documentation and dependency tracking.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
@@ -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(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining why Fragment Mines have infinite storage capacity for future maintainers. This special case might not be immediately obvious to someone new to the codebase.
const maxStorehouseCapacityKg = useMemo(() => { | |
const maxStorehouseCapacityKg = useMemo(() => { | |
// Fragment Mines have unlimited storage capacity since they are the primary resource generation structures |
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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useMemo dependency array should include structure
since it's used in the calculation. Without it, changes to structure won't trigger a recalculation.
}, [quantity, entityId]); | |
}, [quantity, entityId, structure]); |
Failed to generate code suggestions for PR |
Summary by CodeRabbit
New Features
EntityResourceTable
component to retrieve and utilize structure information based onentityId
.Bug Fixes