feat: subsuming warframes #686

Merged
Sainan merged 1 commits from subsume into main 2025-01-02 20:22:56 -08:00
Owner

More work for #288

More work for #288
coderabbitai[bot] commented 2025-01-02 02:50:26 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

The pull request introduces significant modifications to the Infested Foundry feature across multiple files in the project. The changes primarily focus on enhancing the functionality of the Infested Foundry controller, updating inventory management, and refining data models and type definitions.

The modifications include adding new methods for handling warframe subsumption, introducing new cases in the controller for processing suit consumption and rushing the subsume process, and updating the inventory schema to support new fields like LastConsumedSuit and AbilityOverrideUnlockCooldown. The type definitions have been adjusted to accommodate these new features, with changes to interfaces such as IInventoryDatabase, IInfestedFoundry, and the addition of new properties to track recently converted resources and consumed suits.

These changes represent a comprehensive update to the Infested Foundry system, improving its functionality and data tracking capabilities.


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 The pull request introduces significant modifications to the Infested Foundry feature across multiple files in the project. The changes primarily focus on enhancing the functionality of the Infested Foundry controller, updating inventory management, and refining data models and type definitions. The modifications include adding new methods for handling warframe subsumption, introducing new cases in the controller for processing suit consumption and rushing the subsume process, and updating the inventory schema to support new fields like `LastConsumedSuit` and `AbilityOverrideUnlockCooldown`. The type definitions have been adjusted to accommodate these new features, with changes to interfaces such as `IInventoryDatabase`, `IInfestedFoundry`, and the addition of new properties to track recently converted resources and consumed suits. These changes represent a comprehensive update to the Infested Foundry system, improving its functionality and data tracking capabilities. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAMzJaHmRcIVTWRCwSaAB3V3iaDmRYvIxUVKFM/DpGBQj4L1xkakddLGxMLEZ0RBUsSX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L2HazwdKHBGxGJZ6GXq3r5qJHwG+apHv66zYGuHs6SifKUH1rXV6AuqAB+QZa66vFh9RielDLR2Rv+wuIxza+gcxuAZRxh5h9+mxz+shsZChuBmwPRqjJ0WpCGgYKGkEGG+gHGgmWQNx+PVYZkZHFIUzbIAAbmgGAYmCmGoEyfT3WTUZIfkoxppWxtkFxp1ECe4ZKKB0LnFuRM5KXzceWAVt304FcuseKbse5o7wrl0a7p4Z9QEcwNKy1twJf31rfyILcdAd5tsa/t6eymuU4pFVolgm+wfCfGQhfFLzWK/AGB4BoHwh52IlIjp3Ag0EomgholAFvE/GqCr2QAT0CAhC2gYATxWk+WvDuagGgAAGZXgAB2AABleBmH+bmAAE4hAgWABWOYDAAARjhaRaBcNThCYCBZmCEBmDhahbICEH+YwBBexYwERaBeonWfuawk0CeZeYcmGFyA+fvCpaAA= --> <!-- 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 2025-01-02 02:53:19 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/controllers/api/infestedFoundryController.ts (1)

120-163: Validate suit removal and resource deduction logic

  1. The logic to pull the consumed suit and decrement resource.Count for each secret ingredient looks correct, but be sure to handle negative resource counts gracefully elsewhere.
  2. At line 134, consider using optional chaining for safer access to nested properties:
- if (suit.Configs && suit.Configs[0] && suit.Configs[0].pricol) {
+ if (suit.Configs?.[0]?.pricol) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 134-134: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/controllers/api/inventoryController.ts (2)

18-18: Import of handleSubsumeCompletion
This is a neat integration point between controllers. Keep an eye on cyclical imports if the code grows further.


61-69: Handle Infested Foundry finalization

  1. Good approach to check AbilityOverrideUnlockCooldown and finalize the subsume when the cooldown expires.
  2. Consider optional chaining to simplify:
- if (
-    inventory.InfestedFoundry &&
-    inventory.InfestedFoundry.AbilityOverrideUnlockCooldown &&
-    new Date() >= inventory.InfestedFoundry.AbilityOverrideUnlockCooldown
- ) {
+ if (new Date() >= inventory.InfestedFoundry?.AbilityOverrideUnlockCooldown!) {

However, confirm that short-circuiting through optional chaining covers all fallback branches.

🧰 Tools
🪛 Biome (1.9.4)

[error] 62-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 52d1b72701 and 327026389b.

📒 Files selected for processing (4)
  • src/controllers/api/infestedFoundryController.ts (3 hunks)
  • src/controllers/api/inventoryController.ts (3 hunks)
  • src/models/inventoryModels/inventoryModel.ts (2 hunks)
  • src/types/inventoryTypes/inventoryTypes.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/controllers/api/inventoryController.ts

[error] 62-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/controllers/api/infestedFoundryController.ts

[error] 134-134: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (11)
src/controllers/api/infestedFoundryController.ts (5)

4-4: Good addition of new imports for Infested Foundry functionality.
These services seem cohesive with the new feature.


6-13: Imports from inventory types
These additional type imports (e.g., IConsumedSuit, IInfestedFoundry) support the new logic. Ensure they're also used consistently in the rest of the codebase.


165-179: Check edge cases for rushing subsume
The case "r" logic looks straightforward. However, ensure that 50 credits is an appropriate cost to rush and confirm that all references to recipeChanges are consistent with the returned data from handleSubsumeCompletion.


237-240: Interface for subsume request
The IHelminthSubsumeRequest interface seems concise. Verify that any optional fields or newly introduced properties in the request body are added here if needed.


242-258: Ensure handleSubsumeCompletion covers all relevant recipes
The function currently locates precisely one recipe based on the LastConsumedSuit item type. Confirm that only one matching recipe is possible in your data set. Consider error handling if multiple matches are found or if none exist.

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

8-8: Added import for IInventoryDatabaseDocument
Ensure that casting the retrieved inventory to IInventoryDatabaseDocument is valid in all usage scenarios to avoid runtime issues.

src/types/inventoryTypes/inventoryTypes.ts (2)

524-527: RecentlyConvertedResources addition
Storing item type and date for recently converted resources is a useful history mechanism. Make sure the UI or other layers retrieve this data if needed.


539-540: New LastConsumedSuit and AbilityOverrideUnlockCooldown
These fields align with the new Infested Foundry logic. Make sure to handle undefined states where LastConsumedSuit or AbilityOverrideUnlockCooldown hasn’t been set yet.

src/models/inventoryModels/inventoryModel.ts (3)

462-468: consumedSchuitsSchema set _id: false
This helps reduce schema overhead for a subdocument. No issues found.


481-483: Added LastConsumedSuit & AbilityOverrideUnlockCooldown fields
Well-arranged in the schema to mirror interface definitions. Confirm that the Helminth UI or code sets these fields properly before read operations.


488-496: Transform AbilityOverrideUnlockCooldown to Mongo date
The transformation to MongoDB date format is consistent with your existing approach. Double-check the correctness of local time vs UTC for these transformations.

**Actionable comments posted: 0** <details> <summary>🧹 Nitpick comments (3)</summary><blockquote> <details> <summary>src/controllers/api/infestedFoundryController.ts (1)</summary><blockquote> `120-163`: **Validate suit removal and resource deduction logic** 1. The logic to pull the consumed suit and decrement `resource.Count` for each secret ingredient looks correct, but be sure to handle negative resource counts gracefully elsewhere. 2. At line 134, consider using optional chaining for safer access to nested properties: ```diff - if (suit.Configs && suit.Configs[0] && suit.Configs[0].pricol) { + if (suit.Configs?.[0]?.pricol) { ``` <details> <summary>🧰 Tools</summary> <details> <summary>🪛 Biome (1.9.4)</summary> [error] 134-134: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) </details> </details> </blockquote></details> <details> <summary>src/controllers/api/inventoryController.ts (2)</summary><blockquote> `18-18`: **Import of `handleSubsumeCompletion`** This is a neat integration point between controllers. Keep an eye on cyclical imports if the code grows further. --- `61-69`: **Handle Infested Foundry finalization** 1. Good approach to check `AbilityOverrideUnlockCooldown` and finalize the subsume when the cooldown expires. 2. Consider optional chaining to simplify: ```diff - if ( - inventory.InfestedFoundry && - inventory.InfestedFoundry.AbilityOverrideUnlockCooldown && - new Date() >= inventory.InfestedFoundry.AbilityOverrideUnlockCooldown - ) { + if (new Date() >= inventory.InfestedFoundry?.AbilityOverrideUnlockCooldown!) { ``` However, confirm that short-circuiting through optional chaining covers all fallback branches. <details> <summary>🧰 Tools</summary> <details> <summary>🪛 Biome (1.9.4)</summary> [error] 62-63: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) </details> </details> </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 52d1b72701af55329e7b1f494d4d64b4bf488b0e and 327026389b758a1517ffcac76b659eb3a076a8a7. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `src/controllers/api/infestedFoundryController.ts` (3 hunks) * `src/controllers/api/inventoryController.ts` (3 hunks) * `src/models/inventoryModels/inventoryModel.ts` (2 hunks) * `src/types/inventoryTypes/inventoryTypes.ts` (2 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 Biome (1.9.4)</summary> <details> <summary>src/controllers/api/inventoryController.ts</summary> [error] 62-63: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) </details> <details> <summary>src/controllers/api/infestedFoundryController.ts</summary> [error] 134-134: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) </details> </details> </details> <details> <summary>🔇 Additional comments (11)</summary><blockquote> <details> <summary>src/controllers/api/infestedFoundryController.ts (5)</summary> `4-4`: **Good addition of new imports for Infested Foundry functionality.** These services seem cohesive with the new feature. --- `6-13`: **Imports from inventory types** These additional type imports (e.g., `IConsumedSuit`, `IInfestedFoundry`) support the new logic. Ensure they're also used consistently in the rest of the codebase. --- `165-179`: **Check edge cases for rushing subsume** The `case "r"` logic looks straightforward. However, ensure that 50 credits is an appropriate cost to rush and confirm that all references to `recipeChanges` are consistent with the returned data from `handleSubsumeCompletion`. --- `237-240`: **Interface for subsume request** The `IHelminthSubsumeRequest` interface seems concise. Verify that any optional fields or newly introduced properties in the request body are added here if needed. --- `242-258`: **Ensure `handleSubsumeCompletion` covers all relevant recipes** The function currently locates precisely one recipe based on the `LastConsumedSuit` item type. Confirm that only one matching recipe is possible in your data set. Consider error handling if multiple matches are found or if none exist. </details> <details> <summary>src/controllers/api/inventoryController.ts (1)</summary> `8-8`: **Added import for IInventoryDatabaseDocument** Ensure that casting the retrieved `inventory` to `IInventoryDatabaseDocument` is valid in all usage scenarios to avoid runtime issues. </details> <details> <summary>src/types/inventoryTypes/inventoryTypes.ts (2)</summary> `524-527`: **`RecentlyConvertedResources` addition** Storing item type and date for recently converted resources is a useful history mechanism. Make sure the UI or other layers retrieve this data if needed. --- `539-540`: **New `LastConsumedSuit` and `AbilityOverrideUnlockCooldown`** These fields align with the new Infested Foundry logic. Make sure to handle undefined states where `LastConsumedSuit` or `AbilityOverrideUnlockCooldown` hasn’t been set yet. </details> <details> <summary>src/models/inventoryModels/inventoryModel.ts (3)</summary> `462-468`: **`consumedSchuitsSchema` set `_id: false`** This helps reduce schema overhead for a subdocument. No issues found. --- `481-483`: **Added `LastConsumedSuit` & `AbilityOverrideUnlockCooldown` fields** Well-arranged in the schema to mirror interface definitions. Confirm that the Helminth UI or code sets these fields properly before read operations. --- `488-496`: **Transform `AbilityOverrideUnlockCooldown` to Mongo date** The transformation to MongoDB date format is consistent with your existing approach. Double-check the correctness of local time vs UTC for these transformations. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Sign in to join this conversation.
No description provided.