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

fix bugs #2659

Merged
merged 4 commits into from
Jan 22, 2025
Merged

fix bugs #2659

merged 4 commits into from
Jan 22, 2025

Conversation

aymericdelab
Copy link
Collaborator

@aymericdelab aymericdelab commented Jan 22, 2025

Summary by CodeRabbit

Based on the comprehensive summary, here are the updated release notes:

  • Performance Improvements

    • Optimized quest computation to dynamically update based on quest status.
    • Simplified troop management logic in army management interface.
  • Configuration Updates

    • Refined food consumption calculations for troops during exploration and travel.
    • Introduced a new constant for troop food consumption rates.
  • Code Cleanup

    • Removed unnecessary console log statements.
    • Simplified import statements.
    • Removed deprecated configuration management file.

These updates enhance the application's performance and maintainability while providing more responsive quest and troop management functionality.

Copy link

vercel bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2025 7:01pm
eternum-docs ❌ Failed (Inspect) Jan 22, 2025 7:01pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Jan 22, 2025 7:01pm

Copy link
Contributor

mentatbot bot commented Jan 22, 2025

Hi @aymericdelab! You need to be added as a user to interact with me. Please ask @ponderingdemocritus to add you on the settings page.

You are receiving this comment because I am set to review all PRs. That is configurable here.

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Caution

Review failed

The pull request is closed.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

client/apps/game/src/ui/elements/number-input.tsx

Oops! Something went wrong! :(

ESLint: 9.18.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request encompasses multiple changes across different files in the game configuration and client-side code. The modifications include updating quest-related hooks, removing console log statements, simplifying troop management logic, and introducing a new constant for troop food consumption. The most significant change is the deletion of the config/environments/index.ts file, which removes a comprehensive configuration management system. The changes aim to streamline code, improve dependency tracking, and remove unnecessary complexity in configuration and component management.

Changes

File Change Summary
client/apps/game/src/hooks/helpers/use-quests.ts Updated useMemo dependency array to include questStatus for more responsive quest computation
client/apps/game/src/hooks/helpers/use-starting-tutorial.ts Added import for QuestStatus and QuestType from @bibliothecadao/eternum
client/apps/game/src/ui/components/military/army-management-card.tsx Removed useCallback and useMemo hooks, simplified troop management logic
config/deployer/config.ts Removed multiplication by resourcePrecision for food consumption configuration
config/environments/_shared_.ts Removed two console log statements
config/environments/index.ts Deleted entire configuration management file
config/environments/utils/troop.ts Added TROOPS_FOOD_CONSUMPTION constant for troop food consumption rates
client/apps/game/src/ui/elements/number-input.tsx Updated logic for setting displayValue to enhance input value representation

Sequence Diagram

sequenceDiagram
    participant Client as Game Client
    participant Hooks as Quest Hooks
    participant Config as Configuration
    
    Client->>Hooks: Request quest status
    Hooks->>Config: Retrieve quest configuration
    Config-->>Hooks: Return quest configuration
    Hooks->>Hooks: Compute memoized quests
    Hooks-->>Client: Return updated quests
Loading

Possibly related PRs

  • [client] 3d models code and assets cleanup #2633: The changes in this PR involve modifications to the useQuests function, specifically updating the dependency array of the useMemo hook to include questStatus, which is relevant to the main PR's focus on enhancing the responsiveness of quest-related computations.
  • ++Refactor use-armies and clean battles #2640: This PR refactors the useArmies hook, which is related to the main PR's changes in the useQuests function as both involve managing state and dependencies in hooks that affect game mechanics.
  • fix bugs #2653: The updates in this PR to the .env.sepolia file, particularly the changes to environment variables that may affect game configurations, could indirectly relate to the quest management system's responsiveness and functionality.

Suggested reviewers

  • bob0005

Poem

🐰 A Rabbit's Configuration Tale 🎲

Hooks dancing, configs take flight,
Memoized quests now shine so bright
Troop management, lean and clean
In CodeRabbit's code-verse supreme!

Hop hop hooray! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d62a9f7 and abf6fad.

📒 Files selected for processing (1)
  • client/apps/game/src/ui/elements/number-input.tsx (1 hunks)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Failed to generate code suggestions for PR

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
client/apps/game/src/hooks/helpers/use-quests.ts (1)

Remove duplicate QuestStatus enum definition

The QuestStatus enum in use-quests.ts is indeed unused as flagged by knip. This is because it's already defined in @bibliothecadao/eternum (packages/core/src/types/common.ts), and all other files are importing it from there. You should:

  • Remove the local enum definition
  • Import QuestStatus from @bibliothecadao/eternum instead
🔗 Analysis chain

Line range hint 10-14: Verify if QuestStatus export is needed.

The QuestStatus enum is flagged as unused by the knip tool. While it's used internally in this file, please verify if the export is necessary for other components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for QuestStatus usage in other files
rg "QuestStatus" --type ts

Length of output: 1633

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e125425 and d62a9f7.

📒 Files selected for processing (7)
  • client/apps/game/src/hooks/helpers/use-quests.ts (1 hunks)
  • client/apps/game/src/hooks/helpers/use-starting-tutorial.ts (1 hunks)
  • client/apps/game/src/ui/components/military/army-management-card.tsx (2 hunks)
  • config/deployer/config.ts (1 hunks)
  • config/environments/_shared_.ts (0 hunks)
  • config/environments/index.ts (0 hunks)
  • config/environments/utils/troop.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • config/environments/shared.ts
  • config/environments/index.ts
✅ Files skipped from review due to trivial changes (1)
  • client/apps/game/src/hooks/helpers/use-starting-tutorial.ts
🧰 Additional context used
🪛 GitHub Actions: knip
client/apps/game/src/hooks/helpers/use-quests.ts

[warning] 10-10: Unused exported type 'QuestStatus'

🔇 Additional comments (4)
client/apps/game/src/hooks/helpers/use-quests.ts (1)

36-36: LGTM! Correct dependency array update.

Adding questStatus to the dependency array is necessary since the memoized value depends on questStatus.questClaimStatus. This fix ensures the quests array updates properly when the claim status changes.

config/environments/utils/troop.ts (2)

9-10: Well-documented constant with clear purpose and example!

The comment clearly explains the purpose of the constant and provides a helpful example of how the consumption rates relate to resource precision.


Line range hint 11-31: Verify food consumption rates across troop types.

The consumption rates show that:

  • Paladin and Knight have identical exploration costs (10 each for wheat/fish)
  • Knight has higher travel costs than Paladin (5 vs 4)
  • Crossbowman has significantly lower costs overall

Please verify if these relative consumption rates align with the intended game balance.

✅ Verification successful

Food consumption rates correctly implement documented troop characteristics

The consumption rates in the code accurately reflect the documented game design:

  • Crossbowmen's 50% reduced rates (6/3 vs standard 10/5)
  • Knights as the baseline with standard rates (10/5)
  • Paladins with efficient travel (4 vs 5) matching their "extended movement" trait
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any references to troop food consumption rates in documentation or balance discussions
rg -A 5 "food.*consumption|consumption.*rate" .

Length of output: 10611


Script:

#!/bin/bash
# Search for documentation about specific troop types and their characteristics
rg -i -A 5 "paladin|knight|crossbow" ./client/apps/game-docs

Length of output: 9595

client/apps/game/src/ui/components/military/army-management-card.tsx (1)

244-244: Verify the impact of simplified troop count calculation.

The max troop count calculation has been simplified to only consider the balance. Please verify that removing the additional conditions doesn't impact:

  1. Defending army restrictions
  2. Remaining troop count limitations
  3. Army status-based restrictions
✅ Verification successful

Troop count restrictions remain properly enforced

The simplified max calculation is safe as the core troop count restrictions are enforced at the contract and system levels through:

  • Global max troop count in TroopConfig
  • Battle system validations
  • Army management restrictions
  • Troop count normalization

The balance-based limit is sufficient at the UI level since the underlying systems will enforce all necessary restrictions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any other troop count restrictions or validations
rg -A 5 "max.*troop|troop.*count|army.*restrict" .

Length of output: 70963

Comment on lines +775 to +778
explore_wheat_burn_amount: costs.explore_wheat_burn_amount,
explore_fish_burn_amount: costs.explore_fish_burn_amount,
travel_wheat_burn_amount: costs.travel_wheat_burn_amount,
travel_fish_burn_amount: costs.travel_fish_burn_amount,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Food burn amounts should maintain resource precision multiplication

The food consumption values should be multiplied by resourcePrecision to maintain consistency with how other resource amounts are handled throughout the config. All other resource-related values (rewards, costs, bounds) are consistently scaled by resourcePrecision.

  • Consider updating lines 775-778 to multiply each burn amount by config.config.resources.resourcePrecision
🔗 Analysis chain

Verify removal of resource precision multiplication.

The food consumption values are now used directly without multiplying by resourcePrecision. This change needs verification:

  1. Does this align with how other resource amounts are handled in the config?
  2. Could this lead to precision loss in calculations?
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how resource precision is handled in other config settings
rg "resourcePrecision.*\*|config\.resources\.resourcePrecision" .

Length of output: 2555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants