feat: archon shard fusion #785
@ -8,7 +8,9 @@ export const archonFusionController: RequestHandler = async (req, res) => {
|
||||
|
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const request = JSON.parse(String(req.body)) as IArchonFusionRequest;
|
||||
const inventory = await getInventory(accountId);
|
||||
request.Consumed.forEach(x => x.ItemCount * -1);
|
||||
|
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
|
||||
request.Consumed.forEach(x => {
|
||||
|
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
|
||||
x.ItemCount *= -1;
|
||||
|
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
|
||||
});
|
||||
|
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
|
||||
addMiscItems(inventory, request.Consumed);
|
||||
const newArchons: IMiscItem[] = [];
|
||||
switch (request.FusionType) {
|
||||
|
||||
|
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
🛠️ Refactor suggestion Add input validation for the request. The controller needs validation for:
Consider adding this validation at the start of the controller:
_: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 -->
⚠️ Potential issue Fix the item count negation logic. The line Apply this diff to fix the negation:
📝 Committable suggestion
_: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 -->
|
||||
🛠️ Refactor suggestion
Add input validation for the request.
The controller needs validation for:
request.ConsumedarraycombineColorsfunctionConsider adding this validation at the start of the controller:
⚠️ 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 tox.ItemCount.Apply this diff to fix the negation:
📝 Committable suggestion
🛠️ Refactor suggestion
Add input validation for the request.
The controller needs validation for:
request.ConsumedarraycombineColorsfunctionConsider adding this validation at the start of the controller:
⚠️ 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 tox.ItemCount.Apply this diff to fix the negation:
📝 Committable suggestion