feat: replace infiniteResources with infiniteCredits & infinitePlatinum #588

Merged
Sainan merged 1 commits from split-infiniteResources into main 2024-12-21 15:34:19 -08:00
Owner

Closes #346

Closes #346
coderabbitai[bot] commented 2024-12-20 12:17:14 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

The pull request introduces a significant modification to the resource management system by replacing the generic infiniteResources configuration with two more specific options: infiniteCredits and infinitePlatinum. This change is implemented across multiple files including the configuration example, controllers, services, and web interface.

The primary modifications involve updating the configuration interface in configService.ts, adjusting the logic in getCreditsController.ts and inventoryController.ts to handle the new configuration options, and updating the web interface in index.html and script.js to reflect these changes. The new configuration allows for more granular control over infinite resources, specifically separating regular credits from premium platinum.

The changes impact how currency is managed and displayed, with new conditional logic to set credit and platinum amounts based on the new configuration flags. The web interface now provides separate checkboxes for infinite credits and infinite platinum, offering users more precise control over their in-game resources.

Assessment against linked issues

Objective Addressed Explanation
Add Infinite Platinum Option [#346]
  • #579: Changes in inventoryController.ts related to resource handling, which aligns with the current modifications to infinite resource management.

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 significant modification to the resource management system by replacing the generic `infiniteResources` configuration with two more specific options: `infiniteCredits` and `infinitePlatinum`. This change is implemented across multiple files including the configuration example, controllers, services, and web interface. The primary modifications involve updating the configuration interface in `configService.ts`, adjusting the logic in `getCreditsController.ts` and `inventoryController.ts` to handle the new configuration options, and updating the web interface in `index.html` and `script.js` to reflect these changes. The new configuration allows for more granular control over infinite resources, specifically separating regular credits from premium platinum. The changes impact how currency is managed and displayed, with new conditional logic to set credit and platinum amounts based on the new configuration flags. The web interface now provides separate checkboxes for infinite credits and infinite platinum, offering users more precise control over their in-game resources. ## Assessment against linked issues | Objective | Addressed | Explanation | |-----------|-----------|-------------| | Add Infinite Platinum Option [#346] | ✅ | | ## Possibly related PRs - **#579**: Changes in `inventoryController.ts` related to resource handling, which aligns with the current modifications to infinite resource management. <!-- walkthrough_end --> <!-- announcements_start --> > [!TIP] > CodeRabbit's [docstrings feature](https://docs.coderabbit.ai/finishing-touches/docstrings) is now available as part of our [Early Access Program](https://docs.coderabbit.ai/early-access)! Simply use the command `@coderabbitai generate docstrings` to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on [Discord](https://discord.com/channels/1134356397673414807/1317286905557287022). <!-- announcements_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAMzJaHkDeHwwmL0QseOzNMltZQlwqTNQAd014NBy8ugBhQPpNVAAyGtysfOt0ySxnWOhyjFRkXCFWTTpGBQj4L1xkakddLGxMLEZ0RBUsSVyY2fx56H7WIWWAVgAOa604E/5EVldFXhLeQiXBeLn0OzQqCIATIaQyXmOXjIAA8UH0SNBErQSl5CL9sp18oVkMVSrIhlUIuVCKcyOVEUl8CjkDwMXUyI0GC0Nltal06D1aNlnPcEOgmPBsORMM8gSSKIKsJk5l54rgpZJCGsfJpFGiZY5eOCAHLZEQYBzUGQCfiEMQSLTGACC9GaiuVPnkABo/qh3n4QSEwphbYFkEtUNhGEwfF98Sgxl4zhcBABmAAsADYXdlmkwuVgEcdaGhwn7CD4ZIHoMheOJELkmHwqMJoqxBAJAl7kOFs+Fhm7AlJEMVkI7oPRCExnJwYtkNabzfgAOSoCOhCI0JgAa2ovJOAPTOAumCYZSWjGONdwJGqkMRBdDlUz0AAqrYADI8ADa8Hw+F4NIA9F+SFVxloLCsF+pbgl0WD6ksVDGl+DhapkuoQQaRrUF+7o+F+NzXAAugAFG+H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H+Z8EBfx3L3qi7C1jBLICtAIHgGtnxR/qpk2akZVaGLqmvEHHKB0HVc1Yp32T2KYNS1hZpfhbwEhFw2mjhkWYhf6U4JBXWZZjBcFuwEa2BFJ01ToAtapxqA9cUCepmkeheMjl4sIVX2phaCpXOzsSxcJEnz5RxqFS+3yH+QBnhPOyMun2OWaFLD1pIp91miuXV0QG1JIAaVcBoEUB9ezMhaLhqOlAiaxEq3vkTy7Zvjo1JvO37dAW6OppqDTHJzeiWIrBWPGP+PWNlo/W2PnSta+2nq+oy0WcHEwcKkNHS0zAaTGZwFNH3B2esoXPKkKvjk+DphlH+W2qGlomeyuJqojRJGeO+UxRqbWozvCBVBbDjKKT7nmawHeFBwOWkqzsvoLpvvYK+R2DR1juG2YEdKaCkaqlA4xOeu3cICtCYDr0CAAHVXB4gaAOA1dBx8PCOyAiOkhPEbVzslm8OCPaHAhFdlA2XnaRUvAt7FYkhRrsg22okv2bigllXIlhJ1XzYbZIkY9zZnYMAg9QZgg9cm4MgaPcxwkq3gB80dafA8tF8XKwZ5jEZ+nc5yzooawM4ERp7TJKkeq7ZHpw3CNXZPa9hk3gw1jIkI6WLE83oQc12MWep0BMOoJkrdp59uZ4BjxTwahwOKcVQwSWZEXat6A2dUkOApYUBfcoHa4MSGnH3ESErf18TUqiCUGcM0HR4YAAA1SnNd1tmk2huthpNxrhtJlpzJ9p0KLqXVz9mJfERedo4RQx6lEdqJmBQDxmVmYbxVMh2QZRljVBXiUAfiHDISX4UyMSOM1w6yWSAIeyBM2atSa4zSDQTyXSHyNbqAaSVOgAfR2GQHu+zjJAYHu93T2m8l8n0mgAACY/u9ymAN0ABGIQWMJgeMP7jdDAJIWMMgWMDIWMa4LdP7gAdj+9h5uHjHiGuHiETA3UTDNW+78hgGsk0Ee/oGe9e94voHu8Em+6AA=== --> <!-- 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-20 12:18:59 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 1

🧹 Nitpick comments (4)
config.json.example (1)

19-20: LGTM! Consider adding documentation.

The new configuration options correctly replace infiniteResources with more specific controls. Consider adding comments to document the purpose and impact of each setting.

+  // Enables unlimited regular credits
   "infiniteCredits": true,
+  // Enables unlimited premium credits (platinum)
   "infinitePlatinum": true,
src/controllers/api/getCreditsController.ts (1)

18-23: Add inventory object validation.

The code assumes all required properties exist on the inventory object. Consider adding validation to handle potential undefined values gracefully.

+    // Ensure all required properties exist with default values
     const response = {
-        RegularCredits: inventory.RegularCredits,
-        TradesRemaining: inventory.TradesRemaining,
-        PremiumCreditsFree: inventory.PremiumCreditsFree,
-        PremiumCredits: inventory.PremiumCredits
+        RegularCredits: inventory.RegularCredits ?? 0,
+        TradesRemaining: inventory.TradesRemaining ?? 0,
+        PremiumCreditsFree: inventory.PremiumCreditsFree ?? 0,
+        PremiumCredits: inventory.PremiumCredits ?? 0
     };
src/controllers/api/inventoryController.ts (1)

39-42: Consider using a constant for the maximum value

The magic number 999999999 is used in multiple places. Consider extracting it to a named constant for better maintainability.

+const MAX_CURRENCY_VALUE = 999999999;
+
 if (config.infiniteCredits) {
-    inventoryResponse.RegularCredits = 999999999;
+    inventoryResponse.RegularCredits = MAX_CURRENCY_VALUE;
 }
 if (config.infinitePlatinum) {
-    inventoryResponse.PremiumCreditsFree = 999999999;
-    inventoryResponse.PremiumCredits = 999999999;
+    inventoryResponse.PremiumCreditsFree = MAX_CURRENCY_VALUE;
+    inventoryResponse.PremiumCredits = MAX_CURRENCY_VALUE;
 }
src/services/inventoryService.ts (1)

422-422: Consider improving readability of the condition

While functional, the ternary operator makes the condition slightly harder to read. Consider using a more explicit if-else structure or extracting the condition to a named variable.

-    if (usePremium ? config.infinitePlatinum : config.infiniteCredits) {
+    const hasInfiniteCurrency = usePremium ? config.infinitePlatinum : config.infiniteCredits;
+    if (hasInfiniteCurrency) {
         return {};
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 144ac5850c and 22ffc01b3c.

📒 Files selected for processing (7)
  • config.json.example (1 hunks)
  • src/controllers/api/getCreditsController.ts (1 hunks)
  • src/controllers/api/inventoryController.ts (1 hunks)
  • src/services/configService.ts (1 hunks)
  • src/services/inventoryService.ts (1 hunks)
  • static/webui/index.html (1 hunks)
  • static/webui/script.js (1 hunks)
🔇 Additional comments (5)
src/services/configService.ts (2)

36-37: LGTM! Interface changes are correct.

The new optional boolean properties properly replace the previous infiniteResources property while maintaining backward compatibility.


36-37: Verify complete removal of infiniteResources.

Let's ensure all references to the old property have been updated.

Verification successful

Let me check the actual usage of these new properties to ensure the migration is complete.


Migration from infiniteResources to separate properties is complete and correct

The verification shows that:

  • No references to the old infiniteResources property exist in the codebase
  • The new properties infiniteCredits and infinitePlatinum are:
    • Properly defined in configService.ts
    • Correctly used in inventoryService.ts for conditional logic
    • Properly implemented in controllers (getCreditsController.ts and inventoryController.ts)
    • Correctly exposed in the web UI (index.html and script.js)
    • Properly exemplified in the config template (config.json.example)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to infiniteResources
echo "Checking for remaining infiniteResources references..."
rg -l "infiniteResources"

# Search for all files that might handle credits/platinum
echo "Checking files that might need updates..."
rg -l -g "!*.{json,md}" "(?i)(credits?|platinum)"

Length of output: 1077


Script:

#!/bin/bash
# Check for actual usage of infiniteCredits and infinitePlatinum
echo "Checking usage of new properties..."
rg -A 2 "infinite(Credits|Platinum)"

# Let's also check the type definition and its usage
echo "Checking ConfigService type definition..."
ast-grep --pattern 'interface $_Config {
  $$$
}'

Length of output: 2953

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

36-38: LGTM: Correctly implements infiniteCredits feature

The implementation properly sets RegularCredits to a high value when infiniteCredits is enabled.

static/webui/index.html (1)

212-217: LGTM: UI changes align with backend implementation

The checkbox additions for infiniteCredits and infinitePlatinum are properly implemented with correct IDs and labels.

static/webui/script.js (1)

739-740: LGTM! Verify the server-side handling of new configs.

The addition of infiniteCredits and infinitePlatinum configs aligns with the PR objectives to replace infiniteResources.

Let's verify the server-side handling of these new configs:

Verification successful

Server-side handling is properly implemented for the new configs

The new configs infiniteCredits and infinitePlatinum are well integrated across the codebase:

  • Defined in config.json.example and src/services/configService.ts
  • UI elements present in static/webui/index.html
  • Properly handled in server-side logic:
    • src/controllers/api/getCreditsController.ts sets appropriate credit values
    • src/controllers/api/inventoryController.ts handles inventory responses
    • src/services/inventoryService.ts implements the premium logic
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the implementation and usage of the new configs

# Check for server-side handling of infiniteCredits and infinitePlatinum
rg -A 5 "infiniteCredits|infinitePlatinum" 

# Check for any remaining usage of infiniteResources
rg "infiniteResources"

Length of output: 4110

**Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (4)</summary><blockquote> <details> <summary>config.json.example (1)</summary><blockquote> `19-20`: **LGTM! Consider adding documentation.** The new configuration options correctly replace `infiniteResources` with more specific controls. Consider adding comments to document the purpose and impact of each setting. ```diff + // Enables unlimited regular credits "infiniteCredits": true, + // Enables unlimited premium credits (platinum) "infinitePlatinum": true, ``` </blockquote></details> <details> <summary>src/controllers/api/getCreditsController.ts (1)</summary><blockquote> `18-23`: **Add inventory object validation.** The code assumes all required properties exist on the inventory object. Consider adding validation to handle potential undefined values gracefully. ```diff + // Ensure all required properties exist with default values const response = { - RegularCredits: inventory.RegularCredits, - TradesRemaining: inventory.TradesRemaining, - PremiumCreditsFree: inventory.PremiumCreditsFree, - PremiumCredits: inventory.PremiumCredits + RegularCredits: inventory.RegularCredits ?? 0, + TradesRemaining: inventory.TradesRemaining ?? 0, + PremiumCreditsFree: inventory.PremiumCreditsFree ?? 0, + PremiumCredits: inventory.PremiumCredits ?? 0 }; ``` </blockquote></details> <details> <summary>src/controllers/api/inventoryController.ts (1)</summary><blockquote> `39-42`: **Consider using a constant for the maximum value** The magic number 999999999 is used in multiple places. Consider extracting it to a named constant for better maintainability. ```diff +const MAX_CURRENCY_VALUE = 999999999; + if (config.infiniteCredits) { - inventoryResponse.RegularCredits = 999999999; + inventoryResponse.RegularCredits = MAX_CURRENCY_VALUE; } if (config.infinitePlatinum) { - inventoryResponse.PremiumCreditsFree = 999999999; - inventoryResponse.PremiumCredits = 999999999; + inventoryResponse.PremiumCreditsFree = MAX_CURRENCY_VALUE; + inventoryResponse.PremiumCredits = MAX_CURRENCY_VALUE; } ``` </blockquote></details> <details> <summary>src/services/inventoryService.ts (1)</summary><blockquote> `422-422`: **Consider improving readability of the condition** While functional, the ternary operator makes the condition slightly harder to read. Consider using a more explicit if-else structure or extracting the condition to a named variable. ```diff - if (usePremium ? config.infinitePlatinum : config.infiniteCredits) { + const hasInfiniteCurrency = usePremium ? config.infinitePlatinum : config.infiniteCredits; + if (hasInfiniteCurrency) { return {}; } ``` </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 144ac5850c17d083328fc057b220eab15796fe2a and 22ffc01b3c420aea3e3ac3800272ae584f8f6069. </details> <details> <summary>📒 Files selected for processing (7)</summary> * `config.json.example` (1 hunks) * `src/controllers/api/getCreditsController.ts` (1 hunks) * `src/controllers/api/inventoryController.ts` (1 hunks) * `src/services/configService.ts` (1 hunks) * `src/services/inventoryService.ts` (1 hunks) * `static/webui/index.html` (1 hunks) * `static/webui/script.js` (1 hunks) </details> <details> <summary>🔇 Additional comments (5)</summary> <details> <summary>src/services/configService.ts (2)</summary> `36-37`: **LGTM! Interface changes are correct.** The new optional boolean properties properly replace the previous `infiniteResources` property while maintaining backward compatibility. --- `36-37`: **Verify complete removal of infiniteResources.** Let's ensure all references to the old property have been updated. <details> <summary>✅ Verification successful</summary> Let me check the actual usage of these new properties to ensure the migration is complete. --- **Migration from `infiniteResources` to separate properties is complete and correct** The verification shows that: - No references to the old `infiniteResources` property exist in the codebase - The new properties `infiniteCredits` and `infinitePlatinum` are: - Properly defined in `configService.ts` - Correctly used in `inventoryService.ts` for conditional logic - Properly implemented in controllers (`getCreditsController.ts` and `inventoryController.ts`) - Correctly exposed in the web UI (`index.html` and `script.js`) - Properly exemplified in the config template (`config.json.example`) </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Search for any remaining references to infiniteResources echo "Checking for remaining infiniteResources references..." rg -l "infiniteResources" # Search for all files that might handle credits/platinum echo "Checking files that might need updates..." rg -l -g "!*.{json,md}" "(?i)(credits?|platinum)" ``` Length of output: 1077 --- Script: ```shell #!/bin/bash # Check for actual usage of infiniteCredits and infinitePlatinum echo "Checking usage of new properties..." rg -A 2 "infinite(Credits|Platinum)" # Let's also check the type definition and its usage echo "Checking ConfigService type definition..." ast-grep --pattern 'interface $_Config { $$$ }' ``` Length of output: 2953 </details> </details> <details> <summary>src/controllers/api/inventoryController.ts (1)</summary> `36-38`: **LGTM: Correctly implements infiniteCredits feature** The implementation properly sets RegularCredits to a high value when infiniteCredits is enabled. </details> <details> <summary>static/webui/index.html (1)</summary> `212-217`: **LGTM: UI changes align with backend implementation** The checkbox additions for infiniteCredits and infinitePlatinum are properly implemented with correct IDs and labels. </details> <details> <summary>static/webui/script.js (1)</summary> `739-740`: **LGTM! Verify the server-side handling of new configs.** The addition of `infiniteCredits` and `infinitePlatinum` configs aligns with the PR objectives to replace `infiniteResources`. Let's verify the server-side handling of these new configs: <details> <summary>✅ Verification successful</summary> **Server-side handling is properly implemented for the new configs** The new configs `infiniteCredits` and `infinitePlatinum` are well integrated across the codebase: - Defined in `config.json.example` and `src/services/configService.ts` - UI elements present in `static/webui/index.html` - Properly handled in server-side logic: - `src/controllers/api/getCreditsController.ts` sets appropriate credit values - `src/controllers/api/inventoryController.ts` handles inventory responses - `src/services/inventoryService.ts` implements the premium logic </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check for the implementation and usage of the new configs # Check for server-side handling of infiniteCredits and infinitePlatinum rg -A 5 "infiniteCredits|infinitePlatinum" # Check for any remaining usage of infiniteResources rg "infiniteResources" ``` Length of output: 4110 </details> </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
coderabbitai[bot] (Migrated from github.com) commented 2024-12-20 12:18:58 -08:00
Author
Owner

🛠️ Refactor suggestion

Extract magic number to a named constant.

The value 999999999 is used multiple times and should be extracted to a named constant for better maintainability and clarity.

+const INFINITE_CURRENCY_AMOUNT = 999999999;

 if (config.infiniteCredits) {
-    response.RegularCredits = 999999999;
+    response.RegularCredits = INFINITE_CURRENCY_AMOUNT;
 }
 if (config.infinitePlatinum) {
-    response.PremiumCreditsFree = 999999999;
-    response.PremiumCredits = 999999999;
+    response.PremiumCreditsFree = INFINITE_CURRENCY_AMOUNT;
+    response.PremiumCredits = INFINITE_CURRENCY_AMOUNT;
 }
📝 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.

const INFINITE_CURRENCY_AMOUNT = 999999999;

    if (config.infiniteCredits) {
        response.RegularCredits = INFINITE_CURRENCY_AMOUNT;
    }
    if (config.infinitePlatinum) {
        response.PremiumCreditsFree = INFINITE_CURRENCY_AMOUNT;
        response.PremiumCredits = INFINITE_CURRENCY_AMOUNT;
    }
_:hammer_and_wrench: Refactor suggestion_ **Extract magic number to a named constant.** The value 999999999 is used multiple times and should be extracted to a named constant for better maintainability and clarity. ```diff +const INFINITE_CURRENCY_AMOUNT = 999999999; if (config.infiniteCredits) { - response.RegularCredits = 999999999; + response.RegularCredits = INFINITE_CURRENCY_AMOUNT; } if (config.infinitePlatinum) { - response.PremiumCreditsFree = 999999999; - response.PremiumCredits = 999999999; + response.PremiumCreditsFree = INFINITE_CURRENCY_AMOUNT; + response.PremiumCredits = INFINITE_CURRENCY_AMOUNT; } ``` <!-- 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 const INFINITE_CURRENCY_AMOUNT = 999999999; if (config.infiniteCredits) { response.RegularCredits = INFINITE_CURRENCY_AMOUNT; } if (config.infinitePlatinum) { response.PremiumCreditsFree = INFINITE_CURRENCY_AMOUNT; response.PremiumCredits = INFINITE_CURRENCY_AMOUNT; } ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.