feat: implement upgrading & downgrading arcanes #520

Merged
Sainan merged 1 commits from arcanes into main 2024-10-06 08:43:43 -07:00
Owner

Closes #378

Closes #378
coderabbitai[bot] commented 2024-10-06 08:02:54 -07:00 (Migrated from github.com)
Author
Owner

Walkthrough

The changes introduce a new controller, arcaneCommonController, which manages upgrades and downgrades of arcane items in a user's inventory through an Express request handler. It processes requests based on the newRank value, allowing for both upgrades and downgrades. The controller is integrated into the API by adding a new route in api.ts, enabling clients to interact with this functionality via the /arcaneCommon.php endpoint.

Changes

File Change Summary
src/controllers/api/arcaneCommonController.ts Introduced arcaneCommonController for managing arcane item upgrades and downgrades. Added IArcaneCommonRequest interface.
src/routes/api.ts Added import for arcaneCommonController and registered it to handle POST requests at /arcaneCommon.php.

Assessment against linked issues

Objective Addressed Explanation
Implement upgrade functionality for arcane items (#378)
Implement downgrade functionality for arcane items (#378)

Poem

🐇 In the forest, upgrades bloom,
Arcane powers, dispel the gloom.
With a flick and a hop,
We’ll never stop,
Enhancing treasures, make room!
🌟


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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The changes introduce a new controller, `arcaneCommonController`, which manages upgrades and downgrades of arcane items in a user's inventory through an Express request handler. It processes requests based on the `newRank` value, allowing for both upgrades and downgrades. The controller is integrated into the API by adding a new route in `api.ts`, enabling clients to interact with this functionality via the `/arcaneCommon.php` endpoint. ## Changes | File | Change Summary | |-------------------------------|-------------------------------------------------------------------------------------------------------------| | src/controllers/api/arcaneCommonController.ts | Introduced `arcaneCommonController` for managing arcane item upgrades and downgrades. Added `IArcaneCommonRequest` interface. | | src/routes/api.ts | Added import for `arcaneCommonController` and registered it to handle POST requests at `/arcaneCommon.php`. | ## Assessment against linked issues | Objective | Addressed | Explanation | |----------------------------|-----------|-----------------------------------| | Implement upgrade functionality for arcane items (#378) | ✅ | | | Implement downgrade functionality for arcane items (#378) | ✅ | | ## Poem > 🐇 In the forest, upgrades bloom, > Arcane powers, dispel the gloom. > With a flick and a hop, > We’ll never stop, > Enhancing treasures, make room! > 🌟✨ <!-- walkthrough_end --><!-- This is an auto-generated comment: raw summary by coderabbit.ai --> <!-- ``` src/controllers/api/arcaneCommonController.ts: """ ## AI-generated summary of changes The new file `arcaneCommonController.ts` introduces an Express request handler that manages upgrades for arcane items in a user's inventory. The handler begins by extracting the account ID from the request and parsing the incoming JSON body into a structured format defined by the `IArcaneCommonRequest` interface. It retrieves the user's inventory and checks for an existing upgrade corresponding to the item ID provided in the request. The logic differentiates between two scenarios based on the `newRank` value. If `newRank` is -1, the handler processes a downgrade request. It verifies the existence of the upgrade and its fingerprint, removes the upgrade from the inventory, and adds a specified number of raw upgrades back to the inventory based on the upgrade's fingerprint level. The response includes the upgrade ID and the number of consumed raw upgrades. In the case where `newRank` is not -1, the handler processes an upgrade request. It calculates the number of raw upgrades to consume based on the new rank and checks if an upgrade already exists. If it does, it updates the upgrade's fingerprint and adjusts the number of consumed raw upgrades accordingly. If no upgrade exists, it creates a new upgrade entry in the inventory. The handler then removes the appropriate number of raw upgrades and responds with the new level, the number of consumed upgrades, and the upgrade ID. The file also defines a constant array `arcaneLevelCounts` that maps upgrade levels to the number of raw upgrades required for each level. Overall, this controller facilitates the management of arcane item upgrades and downgrades, ensuring that inventory states are accurately maintained and reflected in the responses sent to the client. ## Alterations to the declarations of exported or public entities - Method added: `arcaneCommonController: RequestHandler` in `src/controllers/api/arcaneCommonController.ts` - Interface added: `IArcaneCommonRequest` in `src/controllers/api/arcaneCommonController.ts` """ --- src/routes/api.ts: """ ## AI-generated summary of changes The diff introduces a new import statement for `arcaneCommonController` from the `arcaneCommonController` module, which is added to the list of imported controllers at the beginning of the `src/routes/api.ts` file. This controller is subsequently registered to handle POST requests at the endpoint `/arcaneCommon.php`. The addition of this route expands the API's functionality by allowing clients to interact with the `arcaneCommonController` through this specific endpoint. No other modifications to existing routes or controllers are present in the diff. ## Alterations to the declarations of exported or public entities - Method added: `apiRouter.post("/arcaneCommon.php", arcaneCommonController)` in `src/routes/api.ts` """ ``` --> <!-- end of auto-generated comment: raw summary by coderabbit.ai --><!-- This is an auto-generated comment: pr objectives by coderabbit.ai --> <!-- ## PR Summary The pull request titled "feat: implement upgrading & downgrading arcanes" was submitted by the user Sainan and is identified as number 520 on the SpaceNinjaServer GitHub repository. The primary purpose of this PR is to implement functionality that allows for the upgrading and downgrading of arcanes within the game. This feature is intended to enhance gameplay by providing players with more control over their arcanes. The PR is linked to issue number 378, which it aims to address. The description does not provide additional details beyond the title and the closure of the linked issue. ## Objectives from Linked Issues The linked issue, titled "Upgrade Arcanes," is identified as issue number 378. The objective of this issue is to facilitate the upgrading of arcanes, which are likely items or abilities within the game that players can enhance. The issue includes visual references, as indicated by the presence of images, which may illustrate the current state of arcanes or the desired outcome of the upgrade process. However, the specific details regarding the mechanics of the upgrade process or the expected benefits to gameplay are not provided in the summary. The implementation of this feature through the associated pull request aims to fulfill the objectives outlined in this issue, thereby improving the overall player experience in managing arcanes. --> <!-- end of auto-generated comment: pr objectives by coderabbit.ai --><!-- commit_ids_reviewed_start --> <!-- c565f6b81ef219f8056d68831ae1b77a3a233334 --> <!-- commit_ids_reviewed_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 resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) 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-10-06 08:09:40 -07:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (1)
src/controllers/api/arcaneCommonController.ts (1)

14-14: Clarify or remove redundant comments

The comments at lines 14 and 33:

  • Line 14: // Break down request?
  • Line 33: // Upgrade request?

These comments are either redundant or could be clarified for better understanding. Consider rephrasing them to more clearly describe the code blocks they annotate, or remove them if they do not add value.

Example:

-// Break down request?
+// Handle downgrade request

...

-// Upgrade request?
+// Handle upgrade request

This makes the intent of the code clearer to future readers.

Also applies to: 33-33

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 59389a991b and c565f6b81e.

📒 Files selected for processing (2)
  • src/controllers/api/arcaneCommonController.ts (1 hunks)
  • src/routes/api.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Check: build (22)
src/controllers/api/arcaneCommonController.ts

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value


[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (20)
src/controllers/api/arcaneCommonController.ts

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value


[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (18)
src/controllers/api/arcaneCommonController.ts

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value


[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🔇 Additional comments (3)
src/routes/api.ts (2)

3-3: LGTM: Import statement for arcaneCommonController

The import statement for arcaneCommonController is correctly placed and follows the existing pattern in the file. It uses the "@" alias for the import path, which is consistent with other imports.


105-105: LGTM: New POST route for arcaneCommon

The new POST route for /arcaneCommon.php is correctly implemented and follows the existing pattern in the file. It's placed in alphabetical order among other POST routes.

To ensure the arcaneCommonController is properly implemented, please run the following verification script:

This script will help verify:

  1. The existence of the controller file.
  2. The basic structure of the controller function.
  3. The presence of error handling in the controller.
src/controllers/api/arcaneCommonController.ts (1)

61-61: Check for potential errors when saving the inventory

At line 61, await inventory.save(); is called to persist changes. If an error occurs during saving, it could lead to unhandled promise rejections.

Ensure that errors during the save operation are properly caught and handled.

Example:

     }
-    await inventory.save();
+    try {
+        await inventory.save();
+    } catch (error) {
+        return next(error);
+    }
 };

This ensures that any errors during the save are passed to the error-handling middleware.

**Actionable comments posted: 7** <details> <summary>🧹 Outside diff range and nitpick comments (1)</summary><blockquote> <details> <summary>src/controllers/api/arcaneCommonController.ts (1)</summary><blockquote> `14-14`: **Clarify or remove redundant comments** The comments at lines 14 and 33: - Line 14: `// Break down request?` - Line 33: `// Upgrade request?` These comments are either redundant or could be clarified for better understanding. Consider rephrasing them to more clearly describe the code blocks they annotate, or remove them if they do not add value. Example: ```diff -// Break down request? +// Handle downgrade request ... -// Upgrade request? +// Handle upgrade request ``` This makes the intent of the code clearer to future readers. Also applies to: 33-33 </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Files that changed from the base of the PR and between 59389a991b594ec3e755cd1e7ea6adf3bbac4a09 and c565f6b81ef219f8056d68831ae1b77a3a233334. </details> <details> <summary>📒 Files selected for processing (2)</summary> * src/controllers/api/arcaneCommonController.ts (1 hunks) * src/routes/api.ts (2 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> <details> <summary>src/controllers/api/arcaneCommonController.ts</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value --- [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> <details> <summary>src/controllers/api/arcaneCommonController.ts</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value --- [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> <details> <summary>src/controllers/api/arcaneCommonController.ts</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value --- [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </blockquote></details> </details> <details> <summary>🔇 Additional comments (3)</summary><blockquote> <details> <summary>src/routes/api.ts (2)</summary><blockquote> `3-3`: **LGTM: Import statement for arcaneCommonController** The import statement for `arcaneCommonController` is correctly placed and follows the existing pattern in the file. It uses the "@" alias for the import path, which is consistent with other imports. --- `105-105`: **LGTM: New POST route for arcaneCommon** The new POST route for `/arcaneCommon.php` is correctly implemented and follows the existing pattern in the file. It's placed in alphabetical order among other POST routes. To ensure the `arcaneCommonController` is properly implemented, please run the following verification script: This script will help verify: 1. The existence of the controller file. 2. The basic structure of the controller function. 3. The presence of error handling in the controller. </blockquote></details> <details> <summary>src/controllers/api/arcaneCommonController.ts (1)</summary><blockquote> `61-61`: **Check for potential errors when saving the inventory** At line 61, `await inventory.save();` is called to persist changes. If an error occurs during saving, it could lead to unhandled promise rejections. Ensure that errors during the save operation are properly caught and handled. Example: ```diff } - await inventory.save(); + try { + await inventory.save(); + } catch (error) { + return next(error); + } }; ``` This ensures that any errors during the save are passed to the error-handling middleware. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -0,0 +7,4 @@
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const arcaneCommonController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const json = getJSONfromString(String(req.body)) as IArcaneCommonRequest;
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:39 -07:00
Author
Owner

💡 Codebase verification

Redundant Parsing of req.body Detected

Since the express.json() middleware is already in use (src/app.ts), you can use req.body directly without additional parsing in src/controllers/api/arcaneCommonController.ts.

  • Line 10: Remove getJSONfromString(String(req.body)).
🔗 Analysis chain

Verify the necessity of parsing req.body

At line 10, req.body is being converted to a string and then parsed with getJSONfromString. If the Express app is using body-parsing middleware like express.json(), req.body is already parsed as an object.

Ensure that req.body is not already parsed to avoid redundant parsing or potential errors.

Run the following script to check if express.json() middleware is in use:

If express.json() is already used, you can directly use req.body without additional parsing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the app uses express.json() middleware.

# Search for usage of express.json() in the project
rg "app\.use\(\s*express\.json\(\s*\)\s*\)" --type javascript --type typescript

Length of output: 116


Script:

#!/bin/bash
# Description: Check if the app uses express.json() middleware.

# Search for usage of express.json() in the project with correct file types
rg "app\.use\(\s*express\.json\(\s*\)\s*\)" --type js --type ts

Length of output: 101

_:bulb: Codebase verification_ **Redundant Parsing of `req.body` Detected** Since the `express.json()` middleware is already in use (`src/app.ts`), you can use `req.body` directly without additional parsing in `src/controllers/api/arcaneCommonController.ts`. - **Line 10**: Remove `getJSONfromString(String(req.body))`. <details> <summary>🔗 Analysis chain</summary> **Verify the necessity of parsing `req.body`** At line 10, `req.body` is being converted to a string and then parsed with `getJSONfromString`. If the Express app is using body-parsing middleware like `express.json()`, `req.body` is already parsed as an object. Ensure that `req.body` is not already parsed to avoid redundant parsing or potential errors. Run the following script to check if `express.json()` middleware is in use: If `express.json()` is already used, you can directly use `req.body` without additional parsing. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check if the app uses express.json() middleware. # Search for usage of express.json() in the project rg "app\.use\(\s*express\.json\(\s*\)\s*\)" --type javascript --type typescript ``` Length of output: 116 --- Script: ```shell #!/bin/bash # Description: Check if the app uses express.json() middleware. # Search for usage of express.json() in the project with correct file types rg "app\.use\(\s*express\.json\(\s*\)\s*\)" --type js --type ts ``` Length of output: 101 </details> <!-- This is an auto-generated reply by CodeRabbit -->
@ -0,0 +13,4 @@
if (json.newRank == -1) {
// Break down request?
if (!upgrade || !upgrade.UpgradeFingerprint) {
throw new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`);
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:39 -07:00
Author
Owner

⚠️ Potential issue

Handle errors properly in async Express middleware

At line 16, throwing an error with throw new Error(...) in an async Express middleware does not automatically send an error response to the client and may result in unhandled promise rejections.

Modify the function signature to include the next parameter and pass the error to it, allowing Express to handle it properly.

Example:

-export const arcaneCommonController: RequestHandler = async (req, res) => {
+export const arcaneCommonController: RequestHandler = async (req, res, next) => {
     ...
     if (!upgrade || !upgrade.UpgradeFingerprint) {
-        throw new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`);
+        return next(new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`));
     }
     ...

Ensure that all errors within the middleware are passed to next(error) for consistent error handling.

Committable suggestion was skipped due to low confidence.

_:warning: Potential issue_ **Handle errors properly in async Express middleware** At line 16, throwing an error with `throw new Error(...)` in an async Express middleware does not automatically send an error response to the client and may result in unhandled promise rejections. Modify the function signature to include the `next` parameter and pass the error to it, allowing Express to handle it properly. Example: ```diff -export const arcaneCommonController: RequestHandler = async (req, res) => { +export const arcaneCommonController: RequestHandler = async (req, res, next) => { ... if (!upgrade || !upgrade.UpgradeFingerprint) { - throw new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`); + return next(new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`)); } ... ``` Ensure that all errors within the middleware are passed to `next(error)` for consistent error handling. > Committable suggestion was skipped due to low confidence. <!-- This is an auto-generated reply by CodeRabbit -->
@ -0,0 +20,4 @@
inventory.Upgrades.pull({ _id: json.arcane.ItemId.$oid });
// Add RawUpgrades
const numRawUpgradesToGive = arcaneLevelCounts[JSON.parse(upgrade.UpgradeFingerprint).lvl];
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:39 -07:00
Author
Owner

⚠️ Potential issue

Define UpgradeFingerprint interface to ensure type safety

At line 23, you are parsing upgrade.UpgradeFingerprint and accessing .lvl, but since JSON.parse returns an any type, this leads to unsafe member access. To fix this, define a TypeScript interface for the UpgradeFingerprint and cast the parsed object accordingly.

First, define the interface after line 65:

 const arcaneLevelCounts = [0, 3, 6, 10, 15, 21];

+interface UpgradeFingerprint {
+    lvl: number;
+}

 interface IArcaneCommonRequest {
     arcane: {

Then, update line 23:

 const numRawUpgradesToGive = arcaneLevelCounts[
-    JSON.parse(upgrade.UpgradeFingerprint).lvl
+    (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl
 ];

This change ensures that TypeScript knows the structure of the parsed object, avoiding any type usage and the associated warnings.

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: build (22)

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value

🪛 GitHub Check: build (20)

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value

🪛 GitHub Check: build (18)

[warning] 23-23:
Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an any value


[warning] 23-23:
Unsafe member access .lvl on an any value

_:warning: Potential issue_ **Define `UpgradeFingerprint` interface to ensure type safety** At line 23, you are parsing `upgrade.UpgradeFingerprint` and accessing `.lvl`, but since `JSON.parse` returns an `any` type, this leads to unsafe member access. To fix this, define a TypeScript interface for the `UpgradeFingerprint` and cast the parsed object accordingly. First, define the interface after line 65: ```diff const arcaneLevelCounts = [0, 3, 6, 10, 15, 21]; +interface UpgradeFingerprint { + lvl: number; +} interface IArcaneCommonRequest { arcane: { ``` Then, update line 23: ```diff const numRawUpgradesToGive = arcaneLevelCounts[ - JSON.parse(upgrade.UpgradeFingerprint).lvl + (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl ]; ``` This change ensures that TypeScript knows the structure of the parsed object, avoiding `any` type usage and the associated warnings. > Committable suggestion was skipped due to low confidence. <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [warning] 23-23: Computed name [JSON.parse(upgrade.UpgradeFingerprint).lvl] resolves to an `any` value --- [warning] 23-23: Unsafe member access .lvl on an `any` value </blockquote></details> </details> <!-- This is an auto-generated reply by CodeRabbit -->
@ -0,0 +37,4 @@
// Have an existing Upgrade item?
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:38 -07:00
Author
Owner

⚠️ Potential issue

Cast parsed UpgradeFingerprint to UpgradeFingerprint interface

At line 39, existingLevel is assigned from JSON.parse(upgrade.UpgradeFingerprint).lvl, which is of type any, leading to unsafe member access and assignment. By casting the parsed object to UpgradeFingerprint, you ensure type safety.

Update the code as follows:

 const existingLevel = 
-    JSON.parse(upgrade.UpgradeFingerprint).lvl;
+    (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl;

 numConsumed -= arcaneLevelCounts[existingLevel];

This eliminates the unsafe any usage and ensures existingLevel is correctly typed as a number.

📝 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 existingLevel = (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl;
                numConsumed -= arcaneLevelCounts[existingLevel];
🧰 Tools
🪛 GitHub Check: build (22)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (20)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (18)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

_:warning: Potential issue_ **Cast parsed `UpgradeFingerprint` to `UpgradeFingerprint` interface** At line 39, `existingLevel` is assigned from `JSON.parse(upgrade.UpgradeFingerprint).lvl`, which is of type `any`, leading to unsafe member access and assignment. By casting the parsed object to `UpgradeFingerprint`, you ensure type safety. Update the code as follows: ```diff const existingLevel = - JSON.parse(upgrade.UpgradeFingerprint).lvl; + (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl; numConsumed -= arcaneLevelCounts[existingLevel]; ``` This eliminates the unsafe `any` usage and ensures `existingLevel` is correctly typed as a `number`. <!-- 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 existingLevel = (JSON.parse(upgrade.UpgradeFingerprint) as UpgradeFingerprint).lvl; numConsumed -= arcaneLevelCounts[existingLevel]; ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </details> <!-- This is an auto-generated reply by CodeRabbit -->
@ -0,0 +38,4 @@
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
}
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:39 -07:00
Author
Owner

⚠️ Potential issue

Add input validation for json.newRank to prevent potential errors

The value of json.newRank is used as an index into arcaneLevelCounts in lines 34 and 40. If json.newRank is out of bounds (e.g., negative or exceeding the array length), this will result in undefined behavior or runtime errors.

Consider adding input validation to ensure json.newRank is within the valid range.

Example:

 if (json.newRank == -1) {
     // Handle downgrade request
     ...
 } else {
+    if (json.newRank < 0 || json.newRank >= arcaneLevelCounts.length) {
+        return res.status(400).json({ error: `Invalid newRank value: ${json.newRank}` });
+    }
     // Handle upgrade request
     let numConsumed = arcaneLevelCounts[json.newRank];
     ...
 }

This validation will prevent unexpected errors and ensure that only valid ranks are processed.

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: build (22)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (20)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (18)

[warning] 39-39:
Unsafe assignment of an any value


[warning] 39-39:
Unsafe member access .lvl on an any value


[warning] 40-40:
Computed name [existingLevel] resolves to an any value

_:warning: Potential issue_ **Add input validation for `json.newRank` to prevent potential errors** The value of `json.newRank` is used as an index into `arcaneLevelCounts` in lines 34 and 40. If `json.newRank` is out of bounds (e.g., negative or exceeding the array length), this will result in undefined behavior or runtime errors. Consider adding input validation to ensure `json.newRank` is within the valid range. Example: ```diff if (json.newRank == -1) { // Handle downgrade request ... } else { + if (json.newRank < 0 || json.newRank >= arcaneLevelCounts.length) { + return res.status(400).json({ error: `Invalid newRank value: ${json.newRank}` }); + } // Handle upgrade request let numConsumed = arcaneLevelCounts[json.newRank]; ... } ``` This validation will prevent unexpected errors and ensure that only valid ranks are processed. > Committable suggestion was skipped due to low confidence. <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [warning] 39-39: Unsafe assignment of an `any` value --- [warning] 39-39: Unsafe member access .lvl on an `any` value --- [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </details> <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:39 -07:00
Author
Owner

⚠️ Potential issue

Ensure numConsumed does not become negative

At line 40, numConsumed is adjusted by subtracting arcaneLevelCounts[existingLevel]. If existingLevel is greater than json.newRank, numConsumed becomes negative, which may not be intended behavior.

Add a check to prevent numConsumed from being negative, or adjust the logic to handle downgrades appropriately.

Example:

 numConsumed -= arcaneLevelCounts[existingLevel];
+if (numConsumed < 0) {
+    numConsumed = 0;
+}

Alternatively, ensure that upgrades only proceed when json.newRank is greater than existingLevel, and handle downgrades in the appropriate block.

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: build (22)

[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (20)

[warning] 40-40:
Computed name [existingLevel] resolves to an any value

🪛 GitHub Check: build (18)

[warning] 40-40:
Computed name [existingLevel] resolves to an any value

_:warning: Potential issue_ **Ensure `numConsumed` does not become negative** At line 40, `numConsumed` is adjusted by subtracting `arcaneLevelCounts[existingLevel]`. If `existingLevel` is greater than `json.newRank`, `numConsumed` becomes negative, which may not be intended behavior. Add a check to prevent `numConsumed` from being negative, or adjust the logic to handle downgrades appropriately. Example: ```diff numConsumed -= arcaneLevelCounts[existingLevel]; +if (numConsumed < 0) { + numConsumed = 0; +} ``` Alternatively, ensure that upgrades only proceed when `json.newRank` is greater than `existingLevel`, and handle downgrades in the appropriate block. > Committable suggestion was skipped due to low confidence. <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [warning] 40-40: Computed name [existingLevel] resolves to an `any` value </blockquote></details> </details> <!-- This is an auto-generated reply by CodeRabbit -->
@ -1,5 +1,6 @@
import express from "express";
import { addFriendImageController } from "@/src/controllers/api/addFriendImageController";
import { arcaneCommonController } from "@/src/controllers/api/arcaneCommonController";
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:09:38 -07:00
Author
Owner

💡 Codebase verification

Missing Supporting Components and Tests for arcaneCommon Functionality

The implementation of the new "arcaneCommon" functionality in src/routes/api.ts adds the necessary controller logic. However, the following supporting components and tests are missing:

  • Related Model Files: No files found matching src/models/.*[Aa]rcane.*\.ts$.
  • Related Service Files: No files found matching src/services/.*[Aa]rcane.*\.ts$.
  • Unit Tests: No unit tests found matching tests/.*arcaneCommon.*\.test\.ts$.

To ensure complete and robust implementation:

  1. Add Model Files: Define the necessary data models for managing arcane entities.
  2. Add Service Files: Implement services to handle business logic related to arcane operations.
  3. Write Unit Tests: Create unit tests to verify the functionality of the new controller and related components.
🔗 Analysis chain

Summary: Implementation aligns with PR objectives

The changes in this file successfully add support for the new "arcaneCommon" functionality, which aligns with the PR objectives to implement upgrading & downgrading arcanes. The modifications are minimal and focused, following the existing patterns in the file.

To ensure full implementation:

  1. Verify that the arcaneCommonController is properly implemented with the necessary logic for upgrading and downgrading arcanes.
  2. Check if any related models or services have been updated or created to support this new functionality.
  3. Ensure that appropriate unit tests have been added for the new controller and any related components.

To verify the complete implementation, please run the following script:

This script will help verify:

  1. The existence of related model files.
  2. The existence of related service files.
  3. The presence of unit tests for the new functionality.
  4. The handling of both upgrade and downgrade operations in the controller.

Also applies to: 105-105

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the complete implementation of arcaneCommon functionality

# Test 1: Check for related model files
echo "Checking for related model files:"
fd -p "src/models/.*[Aa]rcane.*\.ts$"

# Test 2: Check for related service files
echo "Checking for related service files:"
fd -p "src/services/.*[Aa]rcane.*\.ts$"

# Test 3: Check for unit tests
echo "Checking for unit tests:"
fd -p "tests/.*arcaneCommon.*\.test\.ts$"

# Test 4: Verify the controller handles both upgrade and downgrade
echo "Verifying upgrade and downgrade handling in controller:"
rg -U "(?s)(upgrade|downgrade).*?newRank" src/controllers/api/arcaneCommonController.ts

Length of output: 2536

_:bulb: Codebase verification_ **Missing Supporting Components and Tests for arcaneCommon Functionality** The implementation of the new "arcaneCommon" functionality in `src/routes/api.ts` adds the necessary controller logic. However, the following supporting components and tests are missing: - **Related Model Files:** No files found matching `src/models/.*[Aa]rcane.*\.ts$`. - **Related Service Files:** No files found matching `src/services/.*[Aa]rcane.*\.ts$`. - **Unit Tests:** No unit tests found matching `tests/.*arcaneCommon.*\.test\.ts$`. To ensure complete and robust implementation: 1. **Add Model Files:** Define the necessary data models for managing arcane entities. 2. **Add Service Files:** Implement services to handle business logic related to arcane operations. 3. **Write Unit Tests:** Create unit tests to verify the functionality of the new controller and related components. <details> <summary>🔗 Analysis chain</summary> **Summary: Implementation aligns with PR objectives** The changes in this file successfully add support for the new "arcaneCommon" functionality, which aligns with the PR objectives to implement upgrading & downgrading arcanes. The modifications are minimal and focused, following the existing patterns in the file. To ensure full implementation: 1. Verify that the `arcaneCommonController` is properly implemented with the necessary logic for upgrading and downgrading arcanes. 2. Check if any related models or services have been updated or created to support this new functionality. 3. Ensure that appropriate unit tests have been added for the new controller and any related components. To verify the complete implementation, please run the following script: This script will help verify: 1. The existence of related model files. 2. The existence of related service files. 3. The presence of unit tests for the new functionality. 4. The handling of both upgrade and downgrade operations in the controller. Also applies to: 105-105 </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify the complete implementation of arcaneCommon functionality # Test 1: Check for related model files echo "Checking for related model files:" fd -p "src/models/.*[Aa]rcane.*\.ts$" # Test 2: Check for related service files echo "Checking for related service files:" fd -p "src/services/.*[Aa]rcane.*\.ts$" # Test 3: Check for unit tests echo "Checking for unit tests:" fd -p "tests/.*arcaneCommon.*\.test\.ts$" # Test 4: Verify the controller handles both upgrade and downgrade echo "Verifying upgrade and downgrade handling in controller:" rg -U "(?s)(upgrade|downgrade).*?newRank" src/controllers/api/arcaneCommonController.ts ``` Length of output: 2536 </details> <!-- This is an auto-generated reply by CodeRabbit -->
Sainan reviewed 2024-10-06 08:20:17 -07:00
@ -1,5 +1,6 @@
import express from "express";
import { addFriendImageController } from "@/src/controllers/api/addFriendImageController";
import { arcaneCommonController } from "@/src/controllers/api/arcaneCommonController";
Author
Owner

kill yourself

kill yourself
Sainan reviewed 2024-10-06 08:20:22 -07:00
@ -0,0 +37,4 @@
// Have an existing Upgrade item?
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
Author
Owner

kill yourself

kill yourself
Sainan reviewed 2024-10-06 08:20:28 -07:00
@ -0,0 +38,4 @@
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
}
Author
Owner

kill yourself

kill yourself
Sainan reviewed 2024-10-06 08:20:36 -07:00
@ -0,0 +13,4 @@
if (json.newRank == -1) {
// Break down request?
if (!upgrade || !upgrade.UpgradeFingerprint) {
throw new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`);
Author
Owner

kill yourself

kill yourself
Sainan reviewed 2024-10-06 08:20:41 -07:00
@ -0,0 +20,4 @@
inventory.Upgrades.pull({ _id: json.arcane.ItemId.$oid });
// Add RawUpgrades
const numRawUpgradesToGive = arcaneLevelCounts[JSON.parse(upgrade.UpgradeFingerprint).lvl];
Author
Owner

kill yourself

kill yourself
Sainan reviewed 2024-10-06 08:20:44 -07:00
@ -0,0 +7,4 @@
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const arcaneCommonController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const json = getJSONfromString(String(req.body)) as IArcaneCommonRequest;
Author
Owner

kill yourself

kill yourself
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:20:48 -07:00
@ -1,5 +1,6 @@
import express from "express";
import { addFriendImageController } from "@/src/controllers/api/addFriendImageController";
import { arcaneCommonController } from "@/src/controllers/api/arcaneCommonController";
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:20:48 -07:00
Author
Owner

@Sainan, understood.

(_/)
(•_•)
/ \

@Sainan, understood. (\_/) (•_•) / \ <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:20:51 -07:00
@ -0,0 +37,4 @@
// Have an existing Upgrade item?
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:20:50 -07:00
Author
Owner

@Sainan

Understood.

(_/)
( •_•)
/ 💙

@Sainan Understood. (\_/) ( •_•) / 💙 <!-- This is an auto-generated reply by CodeRabbit -->
Sainan reviewed 2024-10-06 08:20:54 -07:00
@ -0,0 +38,4 @@
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
}
Author
Owner

kill yourself

kill yourself
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:20:56 -07:00
@ -0,0 +38,4 @@
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
}
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:20:56 -07:00
Author
Owner

@Sainan, I'm here to help if there's anything you need assistance with.

(•́_•̀)

@Sainan, I'm here to help if there's anything you need assistance with. (•́_•̀) <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:21:06 -07:00
@ -0,0 +13,4 @@
if (json.newRank == -1) {
// Break down request?
if (!upgrade || !upgrade.UpgradeFingerprint) {
throw new Error(`Failed to find upgrade with OID ${json.arcane.ItemId.$oid}`);
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:21:06 -07:00
Author
Owner

@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know.

(_/)
( •_•)
(/ )💭

@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know. (\_/) ( •_•) (/ \)💭 <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:21:09 -07:00
@ -0,0 +20,4 @@
inventory.Upgrades.pull({ _id: json.arcane.ItemId.$oid });
// Add RawUpgrades
const numRawUpgradesToGive = arcaneLevelCounts[JSON.parse(upgrade.UpgradeFingerprint).lvl];
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:21:09 -07:00
Author
Owner

@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know.

(\_/)
( •_•)
(/    Concerned bunny is here for you.)
@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know. ``` (\_/) ( •_•) (/ Concerned bunny is here for you.) ``` <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:21:25 -07:00
@ -0,0 +38,4 @@
if (upgrade.UpgradeFingerprint) {
const existingLevel = JSON.parse(upgrade.UpgradeFingerprint).lvl;
numConsumed -= arcaneLevelCounts[existingLevel];
}
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:21:25 -07:00
Author
Owner

@Sainan, understood. If you need any assistance, please let me know.

( ._.)

@Sainan, understood. If you need any assistance, please let me know. ( ._.) <!-- This is an auto-generated reply by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-06 08:22:50 -07:00
@ -0,0 +7,4 @@
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const arcaneCommonController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const json = getJSONfromString(String(req.body)) as IArcaneCommonRequest;
coderabbitai[bot] (Migrated from github.com) commented 2024-10-06 08:22:49 -07:00
Author
Owner

@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know.

(/._.)

@Sainan, I'm sorry to hear that you're feeling this way. If there's anything I can assist you with, please let me know. (/._.) <!-- This is an auto-generated reply by CodeRabbit -->
Sign in to join this conversation.
No description provided.