feat: dojo room energy & capacity costs & gains #633

Merged
Sainan merged 1 commits from dojo-cap into main 2024-12-23 14:12:21 -08:00
Owner

Fixes #630

Fixes #630
coderabbitai[bot] commented 2024-12-23 13:43:00 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

This pull request introduces enhancements to the dojo management system in the application. The changes primarily focus on adding dynamic capacity and energy tracking for guilds' dojos. The modifications span multiple files, including the package dependency, controller logic, guild model, and type definitions.

The update involves upgrading the warframe-public-export-plus dependency to version 0.5.14 and introducing new properties DojoCapacity and DojoEnergy to the guild schema and interfaces. The controllers for dojo component destruction and recipe starting have been updated to dynamically adjust these properties based on the rooms and components being processed, replacing previous hardcoded values with more flexible, context-aware calculations.

These changes aim to provide more granular and dynamic management of dojo resources within the application's guild system.


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.

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.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough This pull request introduces enhancements to the dojo management system in the application. The changes primarily focus on adding dynamic capacity and energy tracking for guilds' dojos. The modifications span multiple files, including the package dependency, controller logic, guild model, and type definitions. The update involves upgrading the `warframe-public-export-plus` dependency to version 0.5.14 and introducing new properties `DojoCapacity` and `DojoEnergy` to the guild schema and interfaces. The controllers for dojo component destruction and recipe starting have been updated to dynamically adjust these properties based on the rooms and components being processed, replacing previous hardcoded values with more flexible, context-aware calculations. These changes aim to provide more granular and dynamic management of dojo resources within the application's guild system. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAMzJaHnpCEUIAwjZoCmoSRQAyZgxeDCZNRRZkfFQikl0sZFjoAHcMVGRcIVZNOkYFCPgvXGRqRwbsTCxGdEQVLEl4xBiB/CHoLGchMYA2AGY9rTh1/k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3XQFFUC3Q2SKm5CrSbiAOLyGHOBeySXVgaAYDQT32IKw1ILjgJ1j3VjZ3bimxoLvR1HajaQg3lzZwcVg36hVyBUQxiU13iX6RgG7hXwQIxUN1BgBw73kB4AAG8Ig80yAeBsxB8qB9Qx9D8eAZ9oAABfcvZAKgwvM2Tg0vcvJjUmKvIPWvcPb3fQ8tMeMdDfE6RfL+KwmwrEewxw5wg/XwT8QKTw7w3wsXegAI7g+3EI8PMItmOvE+b3bJX3CTPJFBcFGvNmTbWQSPbJaPKWWPWWSiAzPpZWKEFPVjCzXOTPRnLvPPT1Uw9vKuTvUuSY9IMHVBOxJuAiP2M2NaWgNQFMBjXqcfSkfUK/coWRTQDoZgndbkd4GHbSekC/ZySZWgP1DAugeEE+HTd4MrJJIhcgD8ddUSAiTnWtLmBSTgbY6gXY6efvKld8CqYwxgAvMyc7eAhrGDSUeIeQblY47wG4O4LwfvWIbuA/IQaASsLQaIGQHwEcWIBKJKNUVKaZfWfqd4cAyQWRUQ4kAQdWUEhMMRSOVqQ1Cg1WUDGXJQhklQkJNQ2xDQhDOcdXHzHQtDKIww2I/DOY7mQHCwjYRw8vDkySBMUGFYgBdYmENNUYIIuo2wsos2ZoqrZ5dDAw7vGE+IzmBYngbfXZdGbUsEvU1Y9mDY404VYo4Meo2QRoy080yI6ACpDOB0jGeIHgfKF0AAbmgFDBsG0TUCJJJJG3JK1PKh1MpD1P+OuUBOWHtR+jNIaKAKtKqLxknFAGnBHTnAXCXBjx0yhIWB4BoB/C6MUCAhPFAg0HAkvCgjrKgA3B6HwAAH05hkAJye5lhJ56AJzItIJoJrxAJQQyAdghAAAOGKPYJgPYDAMgAAdgwB2HoAAE4SdQRkkmAAAmQKeIGKGKHYDAO80EQKY87cu878riFcmCGAd8TQKc+gGcuc95BgCc2cFcoAA --> <!-- internal state end --> <!-- tips_start --> --- 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? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - 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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#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. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-12-23 13:45:01 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/models/guildModel.ts (2)

16-16: Ensure indexing is handled if needed.

You may need to define an index or other constraints on the array field if you plan to query these components frequently by subdocument properties. Consider whether you need an index on subdocument fields.


17-18: Consider validating or bounding capacity and energy.

While default values are set, it’s often helpful to ensure capacity and energy remain within reason (e.g., non-negative, upper limit). This can be done via Mongoose validation or pre-save hooks.

src/controllers/api/startDojoRecipeController.ts (1)

16-21: Enforce budget checks before increment.

If you have any budget or limit on maximum capacity or energy, consider verifying your new capacity/energy won’t exceed that limit to keep data consistent.

src/types/guildTypes.ts (1)

35-35: Comment is clear and improves maintainability.

Adding a short clarifying note about "Prefab (.level)" helps future readers.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eeaac6f07e and b0e6b843c3.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • src/controllers/api/getGuildDojoController.ts (1 hunks)
  • src/controllers/api/queueDojoComponentDestructionController.ts (1 hunks)
  • src/controllers/api/startDojoRecipeController.ts (2 hunks)
  • src/models/guildModel.ts (1 hunks)
  • src/types/guildTypes.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (5)
src/controllers/api/queueDojoComponentDestructionController.ts (2)

3-3: Import appears correct and consistent with usage.

No additional data structure or default handling needed here.


8-11: Check for possible -1 index results.

If the componentId isn’t found, findIndex will return -1, removing the last element from the array. Ensure it’s intended or handle it gracefully.

src/controllers/api/startDojoRecipeController.ts (1)

5-5: Import is aligned with your usage.

No issues to report here.

src/types/guildTypes.ts (1)

12-13: Ensure typed values align with Mongoose schema.

The newly introduced properties match the Mongoose defaults, ensuring correct alignment. Looks fine.

src/controllers/api/getGuildDojoController.ts (1)

36-37: 🛠️ Refactor suggestion

Add null checks and documentation for DojoEnergy and DojoCapacity

The change from hardcoded values to dynamic properties is good, but we should ensure proper error handling and documentation.

Apply this diff to add null checks with default values:

-        Energy: guild.DojoEnergy,
-        Capacity: guild.DojoCapacity,
+        Energy: guild.DojoEnergy ?? 5, // Default to original value if undefined
+        Capacity: guild.DojoCapacity ?? 100, // Default to original value if undefined

Let's verify these properties exist in the Guild model:

Consider adding JSDoc comments to document:

  • Valid ranges for Energy and Capacity
  • Whether negative values are allowed
  • How these values interact with other dojo operations
**Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (4)</summary><blockquote> <details> <summary>src/models/guildModel.ts (2)</summary><blockquote> `16-16`: **Ensure indexing is handled if needed.** You may need to define an index or other constraints on the array field if you plan to query these components frequently by subdocument properties. Consider whether you need an index on subdocument fields. --- `17-18`: **Consider validating or bounding capacity and energy.** While default values are set, it’s often helpful to ensure capacity and energy remain within reason (e.g., non-negative, upper limit). This can be done via Mongoose validation or pre-save hooks. </blockquote></details> <details> <summary>src/controllers/api/startDojoRecipeController.ts (1)</summary><blockquote> `16-21`: **Enforce budget checks before increment.** If you have any budget or limit on maximum capacity or energy, consider verifying your new capacity/energy won’t exceed that limit to keep data consistent. </blockquote></details> <details> <summary>src/types/guildTypes.ts (1)</summary><blockquote> `35-35`: **Comment is clear and improves maintainability.** Adding a short clarifying note about "Prefab (.level)" helps future readers. </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between eeaac6f07ef33237c4854e0759edd910da2880d5 and b0e6b843c3ae7a6d9ef0adc25f446a20578282da. </details> <details> <summary>⛔ Files ignored due to path filters (1)</summary> * `package-lock.json` is excluded by `!**/package-lock.json` </details> <details> <summary>📒 Files selected for processing (6)</summary> * `package.json` (1 hunks) * `src/controllers/api/getGuildDojoController.ts` (1 hunks) * `src/controllers/api/queueDojoComponentDestructionController.ts` (1 hunks) * `src/controllers/api/startDojoRecipeController.ts` (2 hunks) * `src/models/guildModel.ts` (1 hunks) * `src/types/guildTypes.ts` (2 hunks) </details> <details> <summary>✅ Files skipped from review due to trivial changes (1)</summary> * package.json </details> <details> <summary>🔇 Additional comments (5)</summary> <details> <summary>src/controllers/api/queueDojoComponentDestructionController.ts (2)</summary> `3-3`: **Import appears correct and consistent with usage.** No additional data structure or default handling needed here. --- `8-11`: **Check for possible -1 index results.** If the componentId isn’t found, `findIndex` will return -1, removing the last element from the array. Ensure it’s intended or handle it gracefully. </details> <details> <summary>src/controllers/api/startDojoRecipeController.ts (1)</summary> `5-5`: **Import is aligned with your usage.** No issues to report here. </details> <details> <summary>src/types/guildTypes.ts (1)</summary> `12-13`: **Ensure typed values align with Mongoose schema.** The newly introduced properties match the Mongoose defaults, ensuring correct alignment. Looks fine. </details> <details> <summary>src/controllers/api/getGuildDojoController.ts (1)</summary> `36-37`: _:hammer_and_wrench: Refactor suggestion_ **Add null checks and documentation for DojoEnergy and DojoCapacity** The change from hardcoded values to dynamic properties is good, but we should ensure proper error handling and documentation. Apply this diff to add null checks with default values: ```diff - Energy: guild.DojoEnergy, - Capacity: guild.DojoCapacity, + Energy: guild.DojoEnergy ?? 5, // Default to original value if undefined + Capacity: guild.DojoCapacity ?? 100, // Default to original value if undefined ``` Let's verify these properties exist in the Guild model: Consider adding JSDoc comments to document: - Valid ranges for Energy and Capacity - Whether negative values are allowed - How these values interact with other dojo operations </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -11,2 +17,4 @@
}
}
await guild.save();
res.json({
coderabbitai[bot] (Migrated from github.com) commented 2024-12-23 13:45:00 -08:00
Author
Owner

🛠️ Refactor suggestion

Validate post-destruction capacity and energy bounds.

If a destroyed room’s capacity or energy is higher than the guild’s current capacity or energy, you might end up with negative values. Consider adding a floor check or validation.

_:hammer_and_wrench: Refactor suggestion_ **Validate post-destruction capacity and energy bounds.** If a destroyed room’s capacity or energy is higher than the guild’s current capacity or energy, you might end up with negative values. Consider adding a floor check or validation. <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.