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

min troops #2424

Merged
merged 1 commit into from
Dec 11, 2024
Merged

min troops #2424

merged 1 commit into from
Dec 11, 2024

Conversation

aymericdelab
Copy link
Collaborator

@aymericdelab aymericdelab commented Dec 11, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a minimum troop requirement of 100 troops for initiating raids and attacks.
    • Added new tooltip functionality to enhance user feedback during battle actions, including warnings about troop losses.
  • Bug Fixes

    • Improved clarity of tooltips related to raid status and army engagement.
  • Documentation

    • Updated enums to reflect new minimum troop status for raids and battles.

Copy link

vercel bot commented Dec 11, 2024

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

Name Status Preview Comments Updated (UTC)
eternum ❌ Failed (Inspect) Dec 11, 2024 1:56pm
eternum-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 1:56pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Dec 11, 2024 1:56pm

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request involve modifications to the BattleManager class, the BattleActions component, and the addition of a new constant in the global constants file. The BattleManager now includes checks for a minimum troop requirement of 100 troops for raids and attacks, reflected in updated enums and logic. The BattleActions component's tooltip functionality has been refined for better user feedback during battle actions. A new constant, MIN_TROOPS_BATTLE, has been introduced to establish a troop threshold for gameplay mechanics.

Changes

File Path Change Summary
client/src/dojo/modelManager/BattleManager.ts - Added troop management checks with MIN_TROOPS_BATTLE constant.
- Updated RaidStatus and BattleStartStatus enums to include MinTroops.
client/src/ui/modules/military/battle-view/BattleActions.tsx - Enhanced tooltip handling for raid actions, including conditional content based on raid status.
sdk/packages/eternum/src/constants/global.ts - Added constant MIN_TROOPS_BATTLE with a value of 100_000.

Possibly related PRs

Suggested reviewers

  • edisontim

🐇 In the land of battles, where troops must align,
A hundred strong soldiers, for victory to shine.
With tooltips now clearer, and statuses bright,
We march into combat, ready to fight!
For every brave bunny, with courage so true,
The path to great glory is waiting for you! 🌟


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. (Experiment)
  • @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
Contributor

mentatbot bot commented Dec 11, 2024

You are out of MentatBot reviews. Your usage will refresh December 16 at 08:00 AM.

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: 0

🧹 Outside diff range and nitpick comments (2)
client/src/dojo/modelManager/BattleManager.ts (2)

317-323: Consider extracting the troop calculation logic

The total troops calculation is duplicated in both isRaidable and isAttackable methods.

Consider extracting this into a private method:

+  private calculateTotalTroops(army: ArmyInfo | undefined): number {
+    return army?.troops
+      ? Object.values(army.troops).reduce((sum, count) => sum + Number(count), 0)
+      : 0;
+  }

   public isRaidable(...): RaidStatus {
     // ...
-    const totalTroops = selectedArmy.troops
-      ? Object.values(selectedArmy.troops).reduce((sum, count) => sum + Number(count), 0)
-      : 0;
+    const totalTroops = this.calculateTotalTroops(selectedArmy);

     if (totalTroops < MIN_TROOPS_BATTLE) return RaidStatus.MinTroops;
     // ...
   }

335-343: Use extracted method for consistency

Similar to the previous comment, use the extracted method here as well.

Apply the same refactoring:

   public isAttackable(...): BattleStartStatus {
     if (!selectedArmy) return BattleStartStatus.NothingToAttack;

-    const totalTroops = selectedArmy.troops
-      ? Object.values(selectedArmy.troops).reduce((sum, count) => sum + Number(count), 0)
-      : 0;
+    const totalTroops = this.calculateTotalTroops(selectedArmy);

     if (totalTroops < MIN_TROOPS_BATTLE) return BattleStartStatus.MinTroops;
     // ...
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 55b459e and 92efe4b.

📒 Files selected for processing (3)
  • client/src/dojo/modelManager/BattleManager.ts (5 hunks)
  • client/src/ui/modules/military/battle-view/BattleActions.tsx (1 hunks)
  • sdk/packages/eternum/src/constants/global.ts (1 hunks)
🔇 Additional comments (4)
sdk/packages/eternum/src/constants/global.ts (1)

17-17: Verify the minimum troop requirement value

The MIN_TROOPS_BATTLE constant is set to 100,000 troops, which seems quite high and could significantly impact gameplay. Please verify if this value aligns with the game design requirements.

Consider making this value configurable per environment (development/staging/production) to allow for easier testing and balancing.

client/src/ui/modules/military/battle-view/BattleActions.tsx (2)

251-253: LGTM: Improved tooltip text alignment

The centered tooltip text provides better visual feedback.


255-260: LGTM: Clear warning about army losses

Good addition of a warning message about the 25% army loss during raids. This helps users make informed decisions.

client/src/dojo/modelManager/BattleManager.ts (1)

41-41: LGTM: Clear status messages for minimum troop requirement

The addition of MinTroops status to both enums with consistent messaging is good for user feedback.

Also applies to: 52-52

Copy link

Failed to generate code suggestions for PR

@ponderingdemocritus ponderingdemocritus merged commit bbfe2b6 into next Dec 11, 2024
10 of 12 checks passed
@ponderingdemocritus ponderingdemocritus deleted the client-fix branch December 11, 2024 14:48
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.

3 participants