-
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
Eternum docs #2221
Eternum docs #2221
Conversation
next into main
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughThe pull request includes the deletion of the Changes
Possibly related PRs
Suggested reviewers
Poem
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 (
|
You are out of MentatBot reviews. Your usage will refresh December 9 at 08:00 AM. |
Failed to generate code suggestions for PR |
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.
Actionable comments posted: 12
🧹 Outside diff range and nitpick comments (24)
eternum-docs/vocs.config.ts (1)
29-33
: Clean up and reorder navigation itemsTwo suggestions for improvement:
- Remove the commented-out Welcome page instead of keeping it as a comment
- Consider moving the "Disclaimer - MUST READ" higher in the navigation, possibly right after Introduction, given its importance
text: "Overview", items: [ - // { text: "Welcome", link: "/overview/welcome" }, { text: "Introduction", link: "/overview/introduction" }, + { text: "Disclaimer - MUST READ", link: "/overview/disclaimer" }, { text: "Entry", link: "/overview/entry" }, { text: "Quick Links", link: "/overview/links" }, - { text: "Disclaimer - MUST READ", link: "/overview/disclaimer" }, ],eternum-docs/src/components/ResourceIcon.tsx (1)
3-7
: Consider adding resource ID type safetyThe
id
parameter could benefit from a more specific type thannumber | undefined
to ensure only valid resource IDs are passed.+type ResourceId = number; // Consider making this a union of valid IDs type Props = { name: string; - id: number | undefined; + id: ResourceId | undefined; size?: number; };eternum-docs/docs/pages/overview/links.mdx (1)
12-13
: Maintain consistent punctuation in link descriptionsFor consistency with other entries, ensure all descriptions end with periods.
- - [Data & Analytics](https://empire.realms.world/) - Mint your season pass - - [Marketplace](https://market.realms.world/) - Buy your own Realm NFT or season pass + - [Data & Analytics](https://empire.realms.world/) - Mint your season pass. + - [Marketplace](https://market.realms.world/) - Buy your own Realm NFT or season pass.🧰 Tools
🪛 LanguageTool
[uncategorized] ~12-~12: A punctuation mark might be missing here.
Context: ...e.realms.world/) - Mint your season pass - [Marketplace](https://market.realms.world...(AI_EN_LECTOR_MISSING_PUNCTUATION)
eternum-docs/tsconfig.json (1)
25-25
: Remove redundant include pathThe path
"src/components"
is redundant in theinclude
array since"src"
already includes all subdirectories undersrc
. TypeScript will automatically include all.ts
,.tsx
,.d.ts
files insrc
and its subdirectories.- "include": ["src", "src/components"], + "include": ["src"],eternum-docs/src/utils/formatting.tsx (1)
7-15
: Add input validation for decimal placesThe
formatNumber
function should validate thedecimals
parameter to prevent negative values or excessive precision.export const formatNumber = (num: number, decimals: number): string => { + if (decimals < 0) throw new Error('Decimals cannot be negative'); + if (decimals > 20) throw new Error('Maximum 20 decimal places supported'); let str = num.toFixed(decimals); if (str.includes(".")) { str = str.replace(/\.?0+$/, ""); } return str; };eternum-docs/src/components/RealmUpgradeCosts.tsx (1)
14-29
: Add semantic HTML structureThe component should use semantic HTML elements for better accessibility.
return ( - <div className="my-4 p-3"> - <div className="font-bold mb-2">Upgrade costs:</div> - <div className="grid grid-cols-2 sm:grid-cols-3 gap-2"> + <section className="my-4 p-3" aria-labelledby="upgrade-costs-title"> + <h2 id="upgrade-costs-title" className="font-bold mb-2">Upgrade costs:</h2> + <ul className="grid grid-cols-2 sm:grid-cols-3 gap-2" role="list"> {costs.map((cost) => { // ... existing mapping code ... })} - </div> - </div> + </ul> + </section> );eternum-docs/src/components/QuestRewards.tsx (1)
22-22
: Consider making the 'K' suffix configurableThe hardcoded 'K' suffix might not be suitable for all amounts. Consider making it dynamic based on the value range.
- <span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> + <span className="font-medium"> + {formatNumberWithSpaces(cost.amount)} + {cost.amount >= 1000 ? 'K' : ''} + </span>eternum-docs/docs/pages/mechanics/resources/production.mdx (1)
6-7
: Consider enhancing the resource insufficiency explanationThe explanation about production halting could be more specific about the threshold at which production stops and how players can monitor this.
-Each resource incurs a production cost. To sustain production, you must balance these costs. If resources are -insufficient, production will halt until they are replenished. +Each resource incurs a production cost. To sustain production, you must maintain sufficient input resources. Production +automatically halts when any required input resource falls below the required amount, and resumes once all resources +are replenished above the minimum threshold.eternum-docs/docs/pages/overview/entry.mdx (2)
22-23
: Clarify marketplace listing processThe marketplace section could be more detailed about how the listing process works.
-Should a Realm Holder decide not to play with his season ticket, he/she can sell it on the -[Realms MarketPlace](https://market.realms.world/) +Should a Realm Holder decide not to participate in a season, they can list their season ticket for sale on the +[Realms MarketPlace](https://market.realms.world/). The listing process requires connecting your wallet and setting +a sale price in $LORDS tokens.
42-45
: Expand on the Takeover System mechanicsThe Takeover System section could benefit from more details about the mechanics and implications.
-> Realms can be conquered within a Season, leading to a temporary loss of control for the original owner. Gameplay -> rights are restored at the start of the next Season, ensuring a dynamic and competitive environment. +> Realms can be conquered within a Season through specific combat mechanics: +> - Conquering requires meeting certain military strength thresholds +> - Original owners temporarily lose control of resource production and building management +> - All conquest effects are reset at the start of each new Season +> - Original owners retain their NFT ownership throughout the process +> This system creates a dynamic and competitive environment while preserving long-term ownership rights.eternum-docs/docs/pages/mechanics/resources/storage.mdx (1)
13-20
: Consider adding units of measurement consistently.While the weights are correctly displayed using dynamic values, consider standardizing the unit display format. For example:
-- Basic resources (Wood, Stone, Coal,...): - {divideByPrecision(EternumGlobalConfig.resources.resourceWeightsGrams[ResourcesIds.Wood])}kg per unit +- Basic resources (Wood, Stone, Coal,...): {divideByPrecision(EternumGlobalConfig.resources.resourceWeightsGrams[ResourcesIds.Wood])} kg/uniteternum-docs/docs/pages/mechanics/realm/realm.mdx (1)
65-68
: Consider adding more context to immunity duration.The immunity duration calculation might be confusing for readers. Consider presenting it in a more reader-friendly format.
-- {(EternumGlobalConfig.tick.armiesTickIntervalInSeconds / 3600 * EternumGlobalConfig.battle.graceTickCount)}-hour immunity from attacks and from attacking others +- {formatNumberWithSpaces(EternumGlobalConfig.tick.armiesTickIntervalInSeconds / 3600 * EternumGlobalConfig.battle.graceTickCount)} hours of immunity from both incoming and outgoing attackseternum-docs/docs/pages/mechanics/hyperstructures.mdx (1)
47-50
: Enhance readability of points system description.Consider using a more structured format for the points system information.
-- {EternumGlobalConfig.hyperstructures.hyperstructurePointsPerCycle} points are generated each Eternum cycle -- Distribution follows a share-based system -- The structure owner controls share allocation -- Share modifications have a 48-hour cooldown period +- Points Generation: + - {formatNumberWithSpaces(EternumGlobalConfig.hyperstructures.hyperstructurePointsPerCycle)} points per Eternum cycle +- Share System: + - Points distributed based on share allocation + - Structure owner controls share distribution + - 48-hour cooldown period for share modificationseternum-docs/docs/pages/mechanics/military/combat.mdx (4)
15-17
: Consider adding examples for combat advantage calculations.The damage modifiers are clearly stated, but adding practical examples would help players better understand the impact of these advantages in actual combat scenarios.
29-30
: Format the troop loss percentage for better readability.Consider formatting the configuration value for better readability. For example:
-Retreating forces pay a steep price: deserting armies lose {EternumGlobalConfig.battle.TROOP_BATTLE_LEAVE_SLASH_NUM}% of +Retreating forces pay a steep price: deserting armies lose **{EternumGlobalConfig.battle.TROOP_BATTLE_LEAVE_SLASH_NUM}%** of
36-49
: Consider adding a visual timeline for siege mechanics.The siege mechanics are well documented, but a visual representation (timeline) could help players better understand the sequence of events and available actions during different phases.
54-61
: Add specific examples of resource pillaging calculations.The resource pillaging section would benefit from concrete examples showing:
- How stamina affects maximum resource theft
- Typical troop loss scenarios
eternum-docs/src/components/BuildingCosts.tsx (2)
19-37
: Extract repeated resource cost mapping logic.The resource cost mapping logic is duplicated. Consider extracting it into a reusable component or function.
const ResourceCostDisplay = ({ costs }: { costs: typeof resourceCostsWheat }) => ( <> {costs.map((cost) => { const resource = findResourceById(cost.resource); return ( <div key={cost.resource} className="flex items-center gap-1 px-2 py-1.5 rounded-md"> <ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> <span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> </div> ); })} </> );Then use it like:
<ResourceCostDisplay costs={woodBuildingCosts} /> <span className="">or</span> <ResourceCostDisplay costs={stoneBuildingCosts} />
43-43
: Add error boundary for missing costs.Consider adding error boundaries or proper error messaging when costs are not available.
-if (costs.length === 0) return null; +if (!costs?.length) { + console.warn(`No costs found for building type: ${buildingType}`); + return null; +}eternum-docs/docs/pages/seasons/rewards.mdx (2)
27-27
: Consider improving grammar in the distribution section.Add "the" before "season end" for better readability:
-Rewards are distributed after season end: +Rewards are distributed after the season end:🧰 Tools
🪛 LanguageTool
[uncategorized] ~27-~27: You might be missing the article “the” here.
Context: ...ribution Rewards are distributed after season end: - Individual rewards are airdropp...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~27-~27: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...n Rewards are distributed after season end: - Individual rewards are airdropped d...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
71-81
: Consider using a table for guild rewards structure.The current list format for guild rewards could be improved using a table for better readability and comparison.
Consider using markdown table format:
-1st Place: 30% -2nd Place: 20% -3rd Place: 13% +| Place | Reward | +|-------|--------| +| 1st | 30% | +| 2nd | 20% | +| 3rd | 13% |eternum-docs/docs/pages/mechanics/realm/buildings.mdx (1)
129-136
: Consider adding a cost calculation example.The cost scaling section could benefit from a concrete example showing the actual resource costs for subsequent buildings.
Consider adding:
Example for a Farm: - First Farm: 100 wood, 50 stone - Second Farm: 200 wood, 100 stone - Third Farm: 400 wood, 200 stoneeternum-docs/src/utils/constants.tsx (2)
8-11
: Maintain consistent description formatting across resourcesSeveral resources have inconsistent description formatting:
- Basic resources (Stone, Coal, etc.) have detailed, lore-rich descriptions
- Game units (Knight, Crossbowman, etc.) have minimal "Wheat." descriptions
- Some descriptions end with periods, others don't
Consider updating these descriptions to maintain a consistent style and level of detail across all resources.
Also applies to: 224-227, 234-237, 243-246, 252-255, 261-264, 270-273, 279-282
11-11
: Document ticker symbol abbreviation conventionsEach resource has a ticker symbol (e.g., "$STONE", "$CLDIRN", "$HRTWD") but the rules for abbreviation are not documented. This could make it difficult for other developers to maintain consistency when adding new resources.
Consider adding documentation about:
- The use of "$" prefix
- Maximum ticker length
- Abbreviation rules
Also applies to: 21-21, 30-30, 40-40, 50-50, 60-60, 69-69, 78-78, 88-88, 98-98, 108-108, 118-118, 128-128, 138-138, 148-148, 158-158, 168-168, 178-178, 188-188, 198-198, 208-208, 218-218, 227-227, 236-236, 245-245, 254-254, 263-263, 272-272, 281-281, 290-290
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
eternum-docs/docs/public/resources/253.png
is excluded by!**/*.png
📒 Files selected for processing (24)
eternum-docs/components/ResourceIcon.tsx
(0 hunks)eternum-docs/docs/pages/mechanics/achievements.mdx
(1 hunks)eternum-docs/docs/pages/mechanics/hyperstructures.mdx
(2 hunks)eternum-docs/docs/pages/mechanics/military/combat.mdx
(3 hunks)eternum-docs/docs/pages/mechanics/realm/buildings.mdx
(8 hunks)eternum-docs/docs/pages/mechanics/realm/realm.mdx
(2 hunks)eternum-docs/docs/pages/mechanics/realm/wonders.mdx
(1 hunks)eternum-docs/docs/pages/mechanics/resources/production.mdx
(2 hunks)eternum-docs/docs/pages/mechanics/resources/resources.mdx
(6 hunks)eternum-docs/docs/pages/mechanics/resources/storage.mdx
(2 hunks)eternum-docs/docs/pages/overview/disclaimer.mdx
(1 hunks)eternum-docs/docs/pages/overview/entry.mdx
(1 hunks)eternum-docs/docs/pages/overview/links.mdx
(1 hunks)eternum-docs/docs/pages/seasons/overview.mdx
(0 hunks)eternum-docs/docs/pages/seasons/rewards.mdx
(1 hunks)eternum-docs/src/components/BuildingCosts.tsx
(1 hunks)eternum-docs/src/components/QuestRewards.tsx
(1 hunks)eternum-docs/src/components/RealmUpgradeCosts.tsx
(1 hunks)eternum-docs/src/components/ResourceIcon.tsx
(1 hunks)eternum-docs/src/components/ResourceTable.tsx
(1 hunks)eternum-docs/src/utils/constants.tsx
(1 hunks)eternum-docs/src/utils/formatting.tsx
(1 hunks)eternum-docs/tsconfig.json
(1 hunks)eternum-docs/vocs.config.ts
(2 hunks)
💤 Files with no reviewable changes (2)
- eternum-docs/components/ResourceIcon.tsx
- eternum-docs/docs/pages/seasons/overview.mdx
✅ Files skipped from review due to trivial changes (2)
- eternum-docs/docs/pages/mechanics/achievements.mdx
- eternum-docs/docs/pages/overview/disclaimer.mdx
🧰 Additional context used
🪛 LanguageTool
eternum-docs/docs/pages/overview/links.mdx
[uncategorized] ~12-~12: A punctuation mark might be missing here.
Context: ...e.realms.world/) - Mint your season pass - [Marketplace](https://market.realms.world...
(AI_EN_LECTOR_MISSING_PUNCTUATION)
eternum-docs/docs/pages/seasons/rewards.mdx
[uncategorized] ~27-~27: You might be missing the article “the” here.
Context: ...ribution Rewards are distributed after season end: - Individual rewards are airdropp...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~27-~27: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...n Rewards are distributed after season end: - Individual rewards are airdropped d...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
[uncategorized] ~45-~45: A period might be missing here.
Context: ...kens within the game become permanently inaccessible ### Season Rewards #### Individual Le...
(AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)
[uncategorized] ~58-~58: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...ercentage of total VP earned: - If you earned 5% of all VP during the season, you rec...
(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)
[grammar] ~58-~58: With the quantifier ‘all’, the plural form may be more appropriate here.
Context: ...l VP earned: - If you earned 5% of all VP during the season, you receive 5% of th...
(OF_ALL_PLURAL)
eternum-docs/docs/pages/mechanics/realm/realm.mdx
[uncategorized] ~56-~56: Possible missing comma found.
Context: ...ropes as a newly appointed Lord of your Realm Going through these will > help you lea...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Biome (1.9.4)
eternum-docs/src/components/ResourceTable.tsx
[error] 54-54: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
eternum-docs/src/components/QuestRewards.tsx
[error] 14-14: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
🔇 Additional comments (13)
eternum-docs/vocs.config.ts (2)
74-81
: Verify the existence of new Season pages
The new Seasons section structure looks good and provides a clear separation of concerns.
Let's verify that the referenced documentation pages exist:
✅ Verification successful
Navigation structure matches existing documentation pages
The new Seasons section in the navigation correctly references the existing documentation pages:
/seasons/overview
→eternum-docs/docs/pages/seasons/overview.mdx
/seasons/rewards
→eternum-docs/docs/pages/seasons/rewards.mdx
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if the new season documentation pages exist
# Expected: Both files should exist in the docs directory
fd -t f "overview.mdx|rewards.mdx" -p "seasons/"
Length of output: 144
Script:
#!/bin/bash
# Let's first find the docs directory structure
fd -t d "docs"
# Then search for the season-related files in the entire repository
fd -t f "overview.mdx|rewards.mdx"
Length of output: 173
Line range hint 12-19
: Verify color contrast for accessibility
The custom theme colors, particularly textAccent: "#f6c297"
against background: "#14100d"
, should be verified for sufficient contrast ratio to ensure accessibility compliance.
eternum-docs/docs/pages/mechanics/realm/wonders.mdx (1)
13-13
: LGTM! Clear and informative addition
The new bullet point clearly explains the donkey production benefit of Wonders, providing specific numerical details (10% cost) while maintaining consistent documentation style.
eternum-docs/docs/pages/overview/links.mdx (1)
12-13
: Verify link accessibility
Let's verify that the new links are accessible and working correctly.
✅ Verification successful
Links are accessible and working correctly
Both URLs return HTTP 200 status codes, indicating they are accessible and functioning properly:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if the new URLs are accessible
curl -sL -w "%{http_code}\n" "https://empire.realms.world/" -o /dev/null
curl -sL -w "%{http_code}\n" "https://market.realms.world/" -o /dev/null
Length of output: 153
🧰 Tools
🪛 LanguageTool
[uncategorized] ~12-~12: A punctuation mark might be missing here.
Context: ...e.realms.world/) - Mint your season pass - [Marketplace](https://market.realms.world...
(AI_EN_LECTOR_MISSING_PUNCTUATION)
eternum-docs/src/utils/formatting.tsx (1)
25-27
: Consider handling potential precision loss
The divideByPrecision
function might lose precision with large numbers due to floating-point arithmetic. Consider using a decimal library for critical financial calculations.
eternum-docs/docs/pages/mechanics/resources/storage.mdx (1)
1-2
: LGTM! Good use of dynamic configuration values.
The imports are well-organized, and the use of utility functions for formatting ensures consistent number presentation throughout the documentation.
eternum-docs/docs/pages/seasons/rewards.mdx (1)
34-34
: Verify the Hyperstructure points constant.
The code uses a dynamic value from HYPERSTRUCTURE_POINTS_FOR_WIN
. Let's verify this constant is properly defined and imported.
✅ Verification successful
Let me verify if this constant is properly imported in the file.
Constant is properly defined and imported
The HYPERSTRUCTURE_POINTS_FOR_WIN
constant is correctly defined in sdk/packages/eternum/src/constants/global.ts
with a value of 6,320,000 and is properly imported from "@bibliothecadao/eternum" in the rewards.mdx file.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for HYPERSTRUCTURE_POINTS_FOR_WIN constant definition
ast-grep --pattern 'export const HYPERSTRUCTURE_POINTS_FOR_WIN = $_'
Length of output: 595
Script:
#!/bin/bash
# Search for imports of HYPERSTRUCTURE_POINTS_FOR_WIN in the rewards.mdx file
rg "HYPERSTRUCTURE_POINTS_FOR_WIN" "eternum-docs/docs/pages/seasons/rewards.mdx" -B2 -A2
Length of output: 543
eternum-docs/docs/pages/mechanics/resources/resources.mdx (1)
16-17
: Verify resource ID mappings.
The changes convert string IDs to numeric IDs. Let's verify these IDs match the game's configuration.
Also applies to: 33-37, 43-46, 52-55, 61-66, 72-74, 82-84, 96-96, 110-110, 122-122
✅ Verification successful
The previous pattern didn't find matches, so let's try a broader search to:
- Find files that might contain resource definitions
- Look for specific numeric IDs being used in the codebase
Based on the search results, I found the resource ID mappings in two key files:
eternum-docs/src/utils/constants.tsx
andsdk/packages/eternum/src/constants/resources.ts
Both files consistently define:
- Wheat as ID 254
- Fish as ID 255
Let's verify the other IDs mentioned in the comment by searching for their definitions:
Resource ID mappings verified successfully
The numeric IDs in the code match the game's configuration files exactly. Both eternum-docs/src/utils/constants.tsx
and sdk/packages/eternum/src/constants/resources.ts
define consistent resource mappings, including:
- Wheat: ID 254
- Fish: ID 255
- Donkey: ID 249
- Knight: ID 250
- Crossbowman: ID 251
- Paladin: ID 252
- Lords: ID 253
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for resource ID definitions in the game configuration
ast-grep --pattern 'export enum ResourceType {
$$$
}'
Length of output: 57
Script:
#!/bin/bash
# Search for resource-related enums, constants, or type definitions
rg -g '*.{ts,tsx,js,jsx}' -l "(?i)resource.*?(type|id|enum|const|mapping)"
# Then search for specific numeric values
rg -g '*.{ts,tsx,js,jsx}' "(254|255)" -C 2
Length of output: 111368
Script:
#!/bin/bash
# Search for resource definitions in the constants files
rg -A 2 "trait:|value:" sdk/packages/eternum/src/constants/resources.ts eternum-docs/src/utils/constants.tsx
Length of output: 14931
eternum-docs/docs/pages/mechanics/realm/buildings.mdx (2)
15-15
: Verify BuildingCosts component usage consistency.
The BuildingCosts component is used consistently across all building types. Let's verify the component implementation.
Also applies to: 24-24, 38-38, 52-52, 62-62, 79-79, 93-93, 101-101, 109-109
✅ Verification successful
BuildingCosts component is implemented and used correctly
The verification shows that:
- The BuildingCosts component is properly implemented in
eternum-docs/src/components/BuildingCosts.tsx
- It's consistently used across all building types in
buildings.mdx
- The component correctly handles different building types by accessing the appropriate cost configurations from
EternumGlobalConfig
- The implementation aligns with the SDK's building costs configuration system
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check BuildingCosts component implementation
fd --type f "BuildingCosts.tsx" src/components/
Length of output: 150
Script:
#!/bin/bash
# Search for BuildingCosts component file across the repository
fd BuildingCosts
# Search for BuildingCosts component usage
rg "BuildingCosts" -A 2
Length of output: 11250
1-2
: Verify imports from game configuration.
Let's verify the imported types and configuration are properly defined.
✅ Verification successful
Let me verify the other import as well before making the final decision.
Imports are correctly defined and available
The imports are properly defined in the SDK:
BuildingType
enum is exported fromsdk/packages/eternum/src/constants/structures.ts
with all building typesEternumGlobalConfig
is exported fromsdk/packages/eternum/src/constants/global.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for BuildingType enum definition
ast-grep --pattern 'export enum BuildingType {
$$$
}'
Length of output: 1478
Script:
#!/bin/bash
# Search for EternumGlobalConfig export
ast-grep --pattern 'export $_ EternumGlobalConfig'
# Also check if it's exported from index
rg "export.*EternumGlobalConfig" -A 2
Length of output: 322
eternum-docs/src/utils/constants.tsx (3)
1-2
: LGTM!
The import statement correctly references the Resources type from the Eternum package.
10-10
: Verify image path resolution across different environments
All image paths are relative and start with "/" (e.g., "/2.png"). This might cause issues depending on the deployment setup and base URL configuration.
Consider:
- Using a constant for the base image path
- Ensuring paths work correctly in all deployment environments
Also applies to: 20-20, 29-29, 39-39, 49-49, 59-59, 68-68, 77-77, 87-87, 97-97, 107-107, 117-117, 127-127, 137-137, 147-147, 157-157, 167-167, 177-177, 187-187, 197-197, 207-207, 217-217, 226-226, 235-235, 244-244, 253-253, 262-262, 271-271, 280-280, 289-289
3-292
: Verify the significance of non-sequential resource IDs
The resource IDs have large gaps (e.g., jumps from 22 to 249) and Ancient Fragment (ID: 29) appears last despite having a lower ID. This might affect sorting and filtering operations in the codebase.
✅ Verification successful
Non-sequential resource IDs are used intentionally for filtering operations
Based on the codebase analysis, the non-sequential IDs are intentionally used as unique identifiers for filtering operations, particularly in bank and trading components. The ID gaps and ordering in the array don't affect functionality as resources are filtered by ID for specific purposes:
- Lords resource (ID 253) is specifically filtered in swap operations
- Resources are filtered based on user selection and search input
- Resources are separated into Lords and non-Lords categories for liquidity operations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check how resource IDs are used in the codebase
# Search for direct ID references
echo "Searching for direct ID references..."
rg -A 2 "id: \d+" --type tsx --type ts
# Search for array sorting/filtering operations on resources
echo "Searching for resource sorting/filtering operations..."
ast-grep --pattern 'resources.sort($$$)' --pattern 'resources.filter($$$)'
Length of output: 516
Script:
#!/bin/bash
# Search for direct ID references with correct file extensions
echo "Searching for direct ID references..."
rg -A 2 "id: \d+" --type typescript --type javascriptreact --type typescriptreact
# Search for resource sorting/filtering operations (one pattern at a time)
echo "Searching for resource sorting operations..."
ast-grep --pattern 'resources.sort($$$)'
echo "Searching for resource filtering operations..."
ast-grep --pattern 'resources.filter($$$)'
# Search for any usage of resources array
echo "Searching for resources array usage..."
rg "resources\." --type typescript --type javascriptreact --type typescriptreact -A 2
Length of output: 2071
export default function ResourceIcon({ name, id, size = 50 }: Props) { | ||
const imgPath = resources.find((r) => r.id === id)?.img; | ||
return ( | ||
<div className="flex self-center justify-center"> | ||
<img src={`/resources` + imgPath} alt={name} title={name} width={size} height={size} /> | ||
</div> | ||
); | ||
} |
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.
🛠️ Refactor suggestion
Add error handling and accessibility improvements
The component could benefit from:
- Error handling for missing resources
- Image loading error handling
- Better accessibility attributes
export default function ResourceIcon({ name, id, size = 50 }: Props) {
const imgPath = resources.find((r) => r.id === id)?.img;
+ if (!imgPath) {
+ console.warn(`Resource not found for id: ${id}`);
+ return null;
+ }
return (
<div className="flex self-center justify-center">
- <img src={`/resources` + imgPath} alt={name} title={name} width={size} height={size} />
+ <img
+ src={`/resources${imgPath}`}
+ alt={`${name} resource icon`}
+ title={name}
+ width={size}
+ height={size}
+ onError={(e) => {
+ console.error(`Failed to load resource icon: ${name}`);
+ e.currentTarget.style.display = 'none';
+ }}
+ role="img"
+ aria-label={`${name} resource icon`}
+ />
</div>
);
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export default function ResourceIcon({ name, id, size = 50 }: Props) { | |
const imgPath = resources.find((r) => r.id === id)?.img; | |
return ( | |
<div className="flex self-center justify-center"> | |
<img src={`/resources` + imgPath} alt={name} title={name} width={size} height={size} /> | |
</div> | |
); | |
} | |
export default function ResourceIcon({ name, id, size = 50 }: Props) { | |
const imgPath = resources.find((r) => r.id === id)?.img; | |
if (!imgPath) { | |
console.warn(`Resource not found for id: ${id}`); | |
return null; | |
} | |
return ( | |
<div className="flex self-center justify-center"> | |
<img | |
src={`/resources${imgPath}`} | |
alt={`${name} resource icon`} | |
title={name} | |
width={size} | |
height={size} | |
onError={(e) => { | |
console.error(`Failed to load resource icon: ${name}`); | |
e.currentTarget.style.display = 'none'; | |
}} | |
role="img" | |
aria-label={`${name} resource icon`} | |
/> | |
</div> | |
); | |
} |
export function formatNumberWithSpaces(number: number): string { | ||
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); | ||
} |
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.
🛠️ Refactor suggestion
Enhance number formatting to handle edge cases
The formatNumberWithSpaces
function doesn't handle negative numbers or decimal places correctly. Consider enhancing it to handle these cases.
export function formatNumberWithSpaces(number: number): string {
- return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
+ const parts = number.toString().split('.');
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
+ return parts.join('.');
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export function formatNumberWithSpaces(number: number): string { | |
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); | |
} | |
export function formatNumberWithSpaces(number: number): string { | |
const parts = number.toString().split('.'); | |
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " "); | |
return parts.join('.'); | |
} |
{costs.map((cost) => { | ||
const resource = findResourceById(cost.resource); | ||
return ( | ||
<div key={cost.resource} className="flex items-center gap-2 px-3 py-1.5"> | ||
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> | ||
<span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> | ||
</div> | ||
); | ||
})} |
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.
🛠️ Refactor suggestion
Enhance error handling and accessibility
Several improvements needed in the costs mapping logic:
- Add error handling for
findResourceById
- Make the cost display more dynamic (don't assume 'K' suffix)
- Add accessibility attributes
{costs.map((cost) => {
const resource = findResourceById(cost.resource);
+ if (!resource) return null;
return (
- <div key={cost.resource} className="flex items-center gap-2 px-3 py-1.5">
+ <div
+ key={cost.resource}
+ className="flex items-center gap-2 px-3 py-1.5"
+ role="listitem"
+ aria-label={`${resource.trait} cost: ${formatNumberWithSpaces(cost.amount)}000`}
+ >
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} />
- <span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span>
+ <span className="font-medium">
+ {formatNumberWithSpaces(cost.amount * 1000)}
+ </span>
</div>
);
})}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
{costs.map((cost) => { | |
const resource = findResourceById(cost.resource); | |
return ( | |
<div key={cost.resource} className="flex items-center gap-2 px-3 py-1.5"> | |
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> | |
<span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> | |
</div> | |
); | |
})} | |
{costs.map((cost) => { | |
const resource = findResourceById(cost.resource); | |
if (!resource) return null; | |
return ( | |
<div | |
key={cost.resource} | |
className="flex items-center gap-2 px-3 py-1.5" | |
role="listitem" | |
aria-label={`${resource.trait} cost: ${formatNumberWithSpaces(cost.amount)}000`} | |
> | |
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> | |
<span className="font-medium"> | |
{formatNumberWithSpaces(cost.amount * 1000)} | |
</span> | |
</div> | |
); | |
})} |
const resource = findResourceById(cost.resource); | ||
return ( | ||
<div key={cost.resource} className="flex items-center gap-1 px-2 py-1.5 rounded-md"> | ||
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> | ||
<span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> | ||
</div> |
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.
Add null check for resource trait access
The findResourceById
could return undefined, making the resource?.trait access potentially unsafe.
- <ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} />
- <span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span>
+ {resource && (
+ <>
+ <ResourceIcon size={24} id={cost.resource} name={resource.trait} />
+ <span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span>
+ </>
+ )}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const resource = findResourceById(cost.resource); | |
return ( | |
<div key={cost.resource} className="flex items-center gap-1 px-2 py-1.5 rounded-md"> | |
<ResourceIcon size={24} id={cost.resource} name={resource?.trait || ""} /> | |
<span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> | |
</div> | |
const resource = findResourceById(cost.resource); | |
return ( | |
<div key={cost.resource} className="flex items-center gap-1 px-2 py-1.5 rounded-md"> | |
{resource && ( | |
<> | |
<ResourceIcon size={24} id={cost.resource} name={resource.trait} /> | |
<span className="font-medium">{formatNumberWithSpaces(cost.amount)}K</span> | |
</> | |
)} | |
</div> |
<> | ||
{Object.entries(EternumGlobalConfig.questResources).map(([questType, rewards]) => { | ||
return ( | ||
<div className="my-4 p-3 "> |
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.
Add missing key prop for list iteration
React requires a unique key prop for elements in an iteration to maintain component state and optimize rendering.
- <div className="my-4 p-3 ">
+ <div key={questType} className="my-4 p-3">
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Biome (1.9.4)
[error] 14-14: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
cost: RESOURCE_INPUTS[resourceId].map((cost: any) => ({ | ||
...cost, | ||
amount: cost.amount * EternumGlobalConfig.resources.resourcePrecision, | ||
name: findResourceById(cost.resource)?.trait || "", | ||
})), |
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.
🛠️ Refactor suggestion
Improve type safety for cost mapping.
The any
type in the cost mapping could lead to runtime errors. Consider defining proper interfaces for the cost structure.
interface ResourceCost {
resource: number;
amount: number;
}
// Then use it in the mapping
cost: RESOURCE_INPUTS[resourceId].map((cost: ResourceCost) => ({
{resource.cost.map((cost) => ( | ||
<div className="grid grid-cols-2"> | ||
<ResourceIcon size={50} id={cost.resource} name={cost.name || ""} /> | ||
<div className="flex flex-col"> | ||
<span>{cost.amount}</span> | ||
<span className="font-bold">{cost.name}</span> | ||
</div> | ||
</div> | ||
))} |
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.
Add missing key prop in mapped elements.
React requires a unique key prop for elements in iterables. Add a key prop to the grid div.
-<div className="grid grid-cols-2">
+<div key={`${resource.resource_type}-${cost.resource}`} className="grid grid-cols-2">
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
{resource.cost.map((cost) => ( | |
<div className="grid grid-cols-2"> | |
<ResourceIcon size={50} id={cost.resource} name={cost.name || ""} /> | |
<div className="flex flex-col"> | |
<span>{cost.amount}</span> | |
<span className="font-bold">{cost.name}</span> | |
</div> | |
</div> | |
))} | |
{resource.cost.map((cost) => ( | |
<div key={`${resource.resource_type}-${cost.resource}`} className="grid grid-cols-2"> | |
<ResourceIcon size={50} id={cost.resource} name={cost.name || ""} /> | |
<div className="flex flex-col"> | |
<span>{cost.amount}</span> | |
<span className="font-bold">{cost.name}</span> | |
</div> | |
</div> | |
))} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
for (const resourceId of Object.keys(RESOURCE_INPUTS) as unknown as ResourcesIds[]) { | ||
if (resourceId == ResourcesIds.Lords) continue; |
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.
🛠️ Refactor suggestion
Add type safety for resource ID casting.
The type casting of Object.keys()
to ResourcesIds[]
could be unsafe. Consider using a type guard or Object.entries with proper typing.
-for (const resourceId of Object.keys(RESOURCE_INPUTS) as unknown as ResourcesIds[]) {
+for (const [resourceId, _] of Object.entries(RESOURCE_INPUTS) as [ResourcesIds, unknown][]) {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
for (const resourceId of Object.keys(RESOURCE_INPUTS) as unknown as ResourcesIds[]) { | |
if (resourceId == ResourcesIds.Lords) continue; | |
for (const [resourceId, _] of Object.entries(RESOURCE_INPUTS) as [ResourcesIds, unknown][]) { | |
if (resourceId == ResourcesIds.Lords) continue; |
const resourceCostsWheat = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Wood]; | ||
const resourceCostsFish = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Stone]; |
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.
🛠️ Refactor suggestion
Improve variable naming for clarity.
The variable names resourceCostsWheat
and resourceCostsFish
are misleading as they actually represent Wood and Stone costs.
-const resourceCostsWheat = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Wood];
-const resourceCostsFish = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Stone];
+const woodBuildingCosts = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Wood];
+const stoneBuildingCosts = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Stone];
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const resourceCostsWheat = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Wood]; | |
const resourceCostsFish = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Stone]; | |
const woodBuildingCosts = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Wood]; | |
const stoneBuildingCosts = EternumGlobalConfig.resources.resourceBuildingCosts[ResourcesIds.Stone]; |
@@ -1,4 +1,4 @@ | |||
import ResourceIcon from "../../../../components/ResourceIcon"; | |||
import ResourceIcon from "../../../../src/components/ResourceIcon"; |
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.
💡 Codebase verification
Import path needs to be updated
The ResourceIcon component exists at eternum-docs/src/components/ResourceIcon.tsx
, but the current import path in resources.mdx
is using four levels of parent directory traversal (../../../../
). Since both files are in the same repository, the import path should be relative to their locations:
- Current file:
eternum-docs/docs/pages/mechanics/resources/resources.mdx
- Component:
eternum-docs/src/components/ResourceIcon.tsx
- Correct relative path should be:
../../../../../src/components/ResourceIcon
🔗 Analysis chain
Verify ResourceIcon component import path.
The import path has been updated. Let's verify the component exists at the new location.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if ResourceIcon component exists in the new location
fd --type f "ResourceIcon.tsx" src/components/
Length of output: 149
Script:
#!/bin/bash
# Let's first find any file named ResourceIcon with various extensions
fd "ResourceIcon" --type f
# Also search for any imports of ResourceIcon to understand its location
rg "import.*ResourceIcon"
Length of output: 5044
Summary by CodeRabbit
Release Notes
New Features
Documentation Updates
Bug Fixes
These updates aim to improve user experience by providing clearer information and enhancing gameplay features.