feat: archon shard fusion #785

Merged
Sainan merged 2 commits from shard-fusion into main 2025-01-16 20:09:26 -08:00
Owner

Closes #744

Closes #744
coderabbitai[bot] commented 2025-01-16 06:23:08 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

The pull request introduces a comprehensive implementation for archon fusion functionality in an inventory management system. A new controller archonFusionController is created to handle fusion requests with two primary fusion types: "AFT_COALESCENT" and "AFT_ASCENT". The implementation includes a new route in the API router for the /archonFusion.php endpoint, supporting the fusion of archon shards and crystals. Supporting helper functions in shardHelper.ts provide color and shard mapping and combination logic. The changes enable two primary fusion scenarios: combining two archon crystals to create a new color variant and upgrading multiple normal archon crystals to a mythic variant.

Assessment against linked issues

Objective Addressed Explanation
Create endpoint for /archonFusion.php
Support "AFT_COALESCENT" fusion type
Support "AFT_ASCENT" fusion type
Handle color combination for archon crystals
Upgrade normal archon crystals to mythic

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cbda130c04 and 94c2232745.

📒 Files selected for processing (1)
  • src/controllers/api/archonFusionController.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/controllers/api/archonFusionController.ts

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 a comprehensive implementation for archon fusion functionality in an inventory management system. A new controller `archonFusionController` is created to handle fusion requests with two primary fusion types: "AFT_COALESCENT" and "AFT_ASCENT". The implementation includes a new route in the API router for the `/archonFusion.php` endpoint, supporting the fusion of archon shards and crystals. Supporting helper functions in `shardHelper.ts` provide color and shard mapping and combination logic. The changes enable two primary fusion scenarios: combining two archon crystals to create a new color variant and upgrading multiple normal archon crystals to a mythic variant. ## Assessment against linked issues | Objective | Addressed | Explanation | |----------|-----------|-------------| | Create endpoint for `/archonFusion.php` | ✅ | | | Support "AFT_COALESCENT" fusion type | ✅ | | | Support "AFT_ASCENT" fusion type | ✅ | | | Handle color combination for archon crystals | ✅ | | | Upgrade normal archon crystals to mythic | ✅ | | <!-- walkthrough_end --> --- <details> <summary>📜 Recent 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 cbda130c040a36cd833fc73e6f8a56f7031ff378 and 94c2232745404624db51a8a688877ba40f43f6c0. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/controllers/api/archonFusionController.ts` (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * src/controllers/api/archonFusionController.ts </details> </details> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAMzJaHlcmeEIcZHhXRnjcZEQM2OgAdwxUZFwhVk06RgUI+C986kddLGxMLEZ0RBUsSXjEGIb8JugsZyFWgHYADgBWLThx/kRWV0VeXCpeQmQvQnjG9Ds0VCI0Vl5ojgHMaETaHa9An1oYy7GvPIKMwWOqXSmWyVHoyGWAEF6PRNIUOn55AAaE6obZ+ALBULIcIYGGBZAHVDYRhMHz7WTnSpeSasaYCGYAFkZywAYoQBHkqN8BCp8LofMgUd8bPYmJ1ppgmExZAdGLRGj9CH5CCVEFgSNAAKq2AAyPAA2vB8PheMguAB6C0kTTwKpaFisC3IXgYGVYdUicrUGRUC0OV0ygBynowDh91At6J8FvmCwAugAKY2m81Wm1je2O52Biihg5UX3+3MhrBe8OFyPR2OLACUWmMhhMkBgFEYRzwRFIFFUdSU7E4PH4glE4kkMjkihYKho6k0Oj0TdMMAQvWJOAwBGI5EoND7jru3ACGBK0EqLjc0Aa09Uc+0un0ECMzbMwGQVCYFpYAyoyuiVGQC0MF4RAgI/YFWXyeEA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dNnMB4VQ1RI4mZFNZ5ZRVJsoJto4ptLhOYkZ+IBEYVShBUmM2VUUfJkAMVKgKUkDlggxEZhMcQTj9jUAtIUsJlShqBr5pVbNFJlBucGBWiFYdgmEFRn1fRkN31790Yv0pd4Qei60vAQTg1oMGII1cSfMlM+hdpl5PdpSdN5BQDlEID4DoCzNdFP8rNEDTFkDvBLESN0DnMHEnExhlAbCuCyiQI9jIjVk9gcRExYhLiRJrjbjeAGYV4riviG0qBawfC4kIi6A0sgihkmxQAWwbF2xAQtxEipsDxBxjxTwDlLxrxlBbwNB7xFwnwkyoB+wah8AyY+hkAyZAhUUyASgGAyY21uRHxnxlxmAhB6AMA8YABmAABiYEHMZEHIwH7IADYmB6A5h+z+z4gmAZh+yyBJz4g5gMAFg1yZhBz+y8YLl+z5gOzyyYAABORkJgDWDWfsjWJkBYMcxkScjWRkegIQBYPGDADcycuYH8mYGYd6Mc+IRkBc6cwc48k8yszQGs8Ees9lJslstsDsoAA=== --> <!-- 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-16 06:25:01 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/helpers/shardHelper.ts (1)

1-14: Consider using TypeScript enums for colors.

The color and shard mappings use string literals. Using enums would provide better type safety and autocompletion.

Consider defining enums:

enum ArchonColor {
    RED = "ACC_RED",
    RED_MYTHIC = "ACC_RED_MYTHIC",
    YELLOW = "ACC_YELLOW",
    YELLOW_MYTHIC = "ACC_YELLOW_MYTHIC",
    // ... other colors
}

enum ShardPath {
    RED = "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar",
    RED_MYTHIC = "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic",
    // ... other paths
}

Also applies to: 16-29

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9633d307a2 and cbda130c04.

📒 Files selected for processing (4)
  • src/controllers/api/archonFusionController.ts (1 hunks)
  • src/controllers/api/infestedFoundryController.ts (1 hunks)
  • src/helpers/shardHelper.ts (1 hunks)
  • src/routes/api.ts (2 hunks)
🔇 Additional comments (4)
src/controllers/api/archonFusionController.ts (1)

45-49: Clarify the StatResultType field usage.

The comment // ??? suggests uncertainty about the StatResultType field. Additionally, it's hardcoded to "SRT_NEW_STAT" but its purpose is unclear.

Could you clarify:

  1. Is this field actually used in the fusion logic?
  2. Are there other possible values for StatResultType?
  3. Should we validate this field in the request?
src/helpers/shardHelper.ts (1)

31-36: Handle invalid mythic combinations.

The combineColors function assumes that if either color has "_MYTHIC" suffix, the result should be mythic. This might not be valid for all combinations.

Please clarify:

  1. Can two mythic shards be combined?
  2. Should the result always be mythic if either input is mythic?
src/routes/api.ts (1)

118-118: LGTM! Route addition follows existing patterns.

The new route is correctly added to the POST routes section, maintaining consistency with other similar endpoints.

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

18-18: LGTM! Good refactoring of shared functionality.

Moving the colorToShard mapping to a shared helper improves code organization and maintainability.

**Actionable comments posted: 3** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>src/helpers/shardHelper.ts (1)</summary><blockquote> `1-14`: **Consider using TypeScript enums for colors.** The color and shard mappings use string literals. Using enums would provide better type safety and autocompletion. Consider defining enums: ```typescript enum ArchonColor { RED = "ACC_RED", RED_MYTHIC = "ACC_RED_MYTHIC", YELLOW = "ACC_YELLOW", YELLOW_MYTHIC = "ACC_YELLOW_MYTHIC", // ... other colors } enum ShardPath { RED = "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar", RED_MYTHIC = "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic", // ... other paths } ``` Also applies to: 16-29 </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 9633d307a20f972f272cb68c988bb56688bc153c and cbda130c040a36cd833fc73e6f8a56f7031ff378. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `src/controllers/api/archonFusionController.ts` (1 hunks) * `src/controllers/api/infestedFoundryController.ts` (1 hunks) * `src/helpers/shardHelper.ts` (1 hunks) * `src/routes/api.ts` (2 hunks) </details> <details> <summary>🔇 Additional comments (4)</summary><blockquote> <details> <summary>src/controllers/api/archonFusionController.ts (1)</summary> `45-49`: **Clarify the StatResultType field usage.** The comment `// ???` suggests uncertainty about the `StatResultType` field. Additionally, it's hardcoded to `"SRT_NEW_STAT"` but its purpose is unclear. Could you clarify: 1. Is this field actually used in the fusion logic? 2. Are there other possible values for StatResultType? 3. Should we validate this field in the request? </details> <details> <summary>src/helpers/shardHelper.ts (1)</summary> `31-36`: **Handle invalid mythic combinations.** The `combineColors` function assumes that if either color has "_MYTHIC" suffix, the result should be mythic. This might not be valid for all combinations. Please clarify: 1. Can two mythic shards be combined? 2. Should the result always be mythic if either input is mythic? </details> <details> <summary>src/routes/api.ts (1)</summary> `118-118`: **LGTM! Route addition follows existing patterns.** The new route is correctly added to the POST routes section, maintaining consistency with other similar endpoints. </details> <details> <summary>src/controllers/api/infestedFoundryController.ts (1)</summary> `18-18`: **LGTM! Good refactoring of shared functionality.** Moving the colorToShard mapping to a shared helper improves code organization and maintainability. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
coderabbitai[bot] (Migrated from github.com) commented 2025-01-16 06:25:00 -08:00
Author
Owner

🛠️ Refactor suggestion

Add input validation for the request.

The controller needs validation for:

  1. Empty or undefined request.Consumed array
  2. Minimum required items for each fusion type
  3. Invalid color combinations that could crash the combineColors function

Consider adding this validation at the start of the controller:

if (!request.Consumed?.length) {
    throw new Error("No items provided for fusion");
}

switch (request.FusionType) {
    case "AFT_ASCENT":
        if (request.Consumed.length < 1) {
            throw new Error("AFT_ASCENT requires at least 1 item");
        }
        break;
    case "AFT_COALESCENT":
        if (request.Consumed.length < 2) {
            throw new Error("AFT_COALESCENT requires at least 2 items");
        }
        // Validate colors exist in shardToColor mapping
        const color1 = shardToColor[request.Consumed[0].ItemType];
        const color2 = shardToColor[request.Consumed[1].ItemType];
        if (!color1 || !color2) {
            throw new Error("Invalid shard types provided");
        }
        break;
    default:
        throw new Error(`Unknown fusion type: ${request.FusionType}`);
}
_:hammer_and_wrench: Refactor suggestion_ **Add input validation for the request.** The controller needs validation for: 1. Empty or undefined `request.Consumed` array 2. Minimum required items for each fusion type 3. Invalid color combinations that could crash the `combineColors` function Consider adding this validation at the start of the controller: ```typescript if (!request.Consumed?.length) { throw new Error("No items provided for fusion"); } switch (request.FusionType) { case "AFT_ASCENT": if (request.Consumed.length < 1) { throw new Error("AFT_ASCENT requires at least 1 item"); } break; case "AFT_COALESCENT": if (request.Consumed.length < 2) { throw new Error("AFT_COALESCENT requires at least 2 items"); } // Validate colors exist in shardToColor mapping const color1 = shardToColor[request.Consumed[0].ItemType]; const color2 = shardToColor[request.Consumed[1].ItemType]; if (!color1 || !color2) { throw new Error("Invalid shard types provided"); } break; default: throw new Error(`Unknown fusion type: ${request.FusionType}`); } ``` <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) commented 2025-01-16 06:25:00 -08:00
Author
Owner

⚠️ Potential issue

Fix the item count negation logic.

The line request.Consumed.forEach(x => x.ItemCount * -1) performs the multiplication but doesn't assign the result back to x.ItemCount.

Apply this diff to fix the negation:

-request.Consumed.forEach(x => x.ItemCount * -1);
+request.Consumed.forEach(x => x.ItemCount = x.ItemCount * -1);
📝 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.

    request.Consumed.forEach(x => x.ItemCount = x.ItemCount * -1);
_:warning: Potential issue_ **Fix the item count negation logic.** The line `request.Consumed.forEach(x => x.ItemCount * -1)` performs the multiplication but doesn't assign the result back to `x.ItemCount`. Apply this diff to fix the negation: ```diff -request.Consumed.forEach(x => x.ItemCount * -1); +request.Consumed.forEach(x => x.ItemCount = x.ItemCount * -1); ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **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. `````suggestion request.Consumed.forEach(x => x.ItemCount = x.ItemCount * -1); ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -0,0 +63,4 @@
break;
}
throw new Error(`invalid color combination request: ${a} and ${b}`);
};
coderabbitai[bot] (Migrated from github.com) commented 2025-01-16 06:25:00 -08:00
Author
Owner

🛠️ Refactor suggestion

Complete the color combination matrix.

The combinePlainColors function only handles some color combinations. It's missing:

  1. Reverse combinations (e.g., YELLOW + RED should equal ORANGE)
  2. Invalid combinations should be explicitly handled

Consider this more complete implementation:

const combinePlainColors = (a: string, b: string): string => {
    // Normalize order for consistent combinations
    const [color1, color2] = [a, b].sort();
    
    const combination = `${color1}:${color2}`;
    switch (combination) {
        case "ACC_RED:ACC_YELLOW":
            return "ACC_ORANGE";
        case "ACC_RED:ACC_BLUE":
            return "ACC_PURPLE";
        case "ACC_YELLOW:ACC_BLUE":
            return "ACC_GREEN";
        default:
            throw new Error(`Invalid color combination: ${a} and ${b}`);
    }
};
_:hammer_and_wrench: Refactor suggestion_ **Complete the color combination matrix.** The `combinePlainColors` function only handles some color combinations. It's missing: 1. Reverse combinations (e.g., YELLOW + RED should equal ORANGE) 2. Invalid combinations should be explicitly handled Consider this more complete implementation: ```typescript const combinePlainColors = (a: string, b: string): string => { // Normalize order for consistent combinations const [color1, color2] = [a, b].sort(); const combination = `${color1}:${color2}`; switch (combination) { case "ACC_RED:ACC_YELLOW": return "ACC_ORANGE"; case "ACC_RED:ACC_BLUE": return "ACC_PURPLE"; case "ACC_YELLOW:ACC_BLUE": return "ACC_GREEN"; default: throw new Error(`Invalid color combination: ${a} and ${b}`); } }; ``` <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.