返回提交历史
Modified
.eslintrc
+0
-1
Modified
src/controllers/api/giveStartingGearController.ts
+1
-1
Modified
src/services/inventoryService.ts
+49
-21
Modified
src/services/itemDataService.ts
+0
-9
XFEstudio/SpaceNinjaServer
fix: give non-exalted additional items when acquiring warframe (#1408)
Also upgraded `no-misused-promises` to an error and added `IsNew` field to powersuits. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1408 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
3d698286
代码差异
4 个文件
+50
-32
@@ -16,7 +16,6 @@
16
16
"@typescript-eslint/restrict-plus-operands": "warn",
17
17
"@typescript-eslint/no-unsafe-member-access": "warn",
18
18
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "caughtErrors": "none" }],
19
"@typescript-eslint/no-misused-promises": "warn",
20
19
"@typescript-eslint/no-unsafe-argument": "error",
21
20
"@typescript-eslint/no-unsafe-call": "warn",
22
21
"@typescript-eslint/no-unsafe-assignment": "warn",
@@ -53,7 +53,7 @@ export const addStartingGear = async (
53
53
addEquipment(inventory, "LongGuns", LongGuns[0].ItemType, undefined, inventoryChanges);
54
54
addEquipment(inventory, "Pistols", Pistols[0].ItemType, undefined, inventoryChanges);
55
55
addEquipment(inventory, "Melee", Melee[0].ItemType, undefined, inventoryChanges);
56
addPowerSuit(inventory, Suits[0].ItemType, inventoryChanges);
56
await addPowerSuit(inventory, Suits[0].ItemType, inventoryChanges);
57
57
addEquipment(
58
58
inventory,
59
59
"DataKnives",
@@ -30,7 +30,7 @@ import {
30
30
import { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate";
31
31
import { IMissionInventoryUpdateRequest } from "../types/requestTypes";
32
32
import { logger } from "@/src/utils/logger";
33
import { convertInboxMessage, fromStoreItem, getExalted, getKeyChainItems } from "@/src/services/itemDataService";
33
import { convertInboxMessage, fromStoreItem, getKeyChainItems } from "@/src/services/itemDataService";
34
34
import {
35
35
EquipmentFeatures,
36
36
IEquipmentClient,
@@ -55,8 +55,10 @@ import {
55
55
ExportSentinels,
56
56
ExportSyndicates,
57
57
ExportUpgrades,
58
ExportWarframes,
58
59
ExportWeapons,
59
60
IDefaultUpgrade,
61
IPowersuit,
60
62
TStandingLimitBin
61
63
} from "warframe-public-export-plus";
62
64
import { createShip } from "./shipService";
@@ -481,12 +483,12 @@ export const addItem = async (
481
483
switch (typeName.substr(1).split("/")[2]) {
482
484
default: {
483
485
return {
484
...addPowerSuit(
486
...(await addPowerSuit(
485
487
inventory,
486
488
typeName,
487
489
{},
488
490
premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
489
),
491
)),
490
492
...occupySlot(inventory, InventorySlot.SUITS, premiumPurchase)
491
493
};
492
494
}
@@ -504,12 +506,12 @@ export const addItem = async (
504
506
}
505
507
case "EntratiMech": {
506
508
return {
507
...addMechSuit(
509
...(await addMechSuit(
508
510
inventory,
509
511
typeName,
510
512
{},
511
513
premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
512
),
514
)),
513
515
...occupySlot(inventory, InventorySlot.MECHSUITS, premiumPurchase)
514
516
};
515
517
}
@@ -697,40 +699,65 @@ const addSentinelWeapon = (
697
699
inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON<IEquipmentClient>());
698
700
};
699
701
700
export const addPowerSuit = (
702
export const addPowerSuit = async (
701
703
inventory: TInventoryDatabaseDocument,
702
704
powersuitName: string,
703
705
inventoryChanges: IInventoryChanges = {},
704
706
features: number | undefined = undefined
705
): IInventoryChanges => {
706
const specialItems = getExalted(powersuitName);
707
if (specialItems) {
708
for (const specialItem of specialItems) {
709
addSpecialItem(inventory, specialItem, inventoryChanges);
707
): Promise<IInventoryChanges> => {
708
const powersuit = ExportWarframes[powersuitName] as IPowersuit | undefined;
709
const exalted = powersuit?.exalted ?? [];
710
for (const specialItem of exalted) {
711
addSpecialItem(inventory, specialItem, inventoryChanges);
712
}
713
if (powersuit?.additionalItems) {
714
for (const item of powersuit.additionalItems) {
715
if (exalted.indexOf(item) == -1) {
716
combineInventoryChanges(inventoryChanges, await addItem(inventory, item, 1));
717
}
710
718
}
711
719
}
712
720
const suitIndex =
713
inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) - 1;
721
inventory.Suits.push({
722
ItemType: powersuitName,
723
Configs: [],
724
UpgradeVer: 101,
725
XP: 0,
726
Features: features,
727
IsNew: true
728
}) - 1;
714
729
inventoryChanges.Suits ??= [];
715
730
inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
716
731
return inventoryChanges;
717
732
};
718
733
719
export const addMechSuit = (
734
export const addMechSuit = async (
720
735
inventory: TInventoryDatabaseDocument,
721
736
mechsuitName: string,
722
737
inventoryChanges: IInventoryChanges = {},
723
738
features: number | undefined = undefined
724
): IInventoryChanges => {
725
const specialItems = getExalted(mechsuitName);
726
if (specialItems) {
727
for (const specialItem of specialItems) {
728
addSpecialItem(inventory, specialItem, inventoryChanges);
739
): Promise<IInventoryChanges> => {
740
const powersuit = ExportWarframes[mechsuitName] as IPowersuit | undefined;
741
const exalted = powersuit?.exalted ?? [];
742
for (const specialItem of exalted) {
743
addSpecialItem(inventory, specialItem, inventoryChanges);
744
}
745
if (powersuit?.additionalItems) {
746
for (const item of powersuit.additionalItems) {
747
if (exalted.indexOf(item) == -1) {
748
combineInventoryChanges(inventoryChanges, await addItem(inventory, item, 1));
749
}
729
750
}
730
751
}
731
752
const suitIndex =
732
inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) -
733
1;
753
inventory.MechSuits.push({
754
ItemType: mechsuitName,
755
Configs: [],
756
UpgradeVer: 101,
757
XP: 0,
758
Features: features,
759
IsNew: true
760
}) - 1;
734
761
inventoryChanges.MechSuits ??= [];
735
762
inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
736
763
return inventoryChanges;
@@ -768,7 +795,8 @@ export const addSpaceSuit = (
768
795
Configs: [],
769
796
UpgradeVer: 101,
770
797
XP: 0,
771
Features: features
798
Features: features,
799
IsNew: true
772
800
}) - 1;
773
801
inventoryChanges.SpaceSuits ??= [];
774
802
inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
@@ -31,7 +31,6 @@ import {
31
31
IDefaultUpgrade,
32
32
IInboxMessage,
33
33
IMissionReward,
34
IPowersuit,
35
34
IRecipe,
36
35
TReward
37
36
} from "warframe-public-export-plus";
@@ -56,10 +55,6 @@ export const getRecipeByResult = (resultType: string): IRecipe | undefined => {
56
55
return Object.values(ExportRecipes).find(x => x.resultType == resultType);
57
56
};
58
57
59
export const getExalted = (uniqueName: string): string[] | undefined => {
60
return getSuitByUniqueName(uniqueName)?.exalted;
61
};
62
63
58
export const getItemCategoryByUniqueName = (uniqueName: string): string => {
64
59
//Lotus/Types/Items/MiscItems/PolymerBundle
65
60
@@ -76,10 +71,6 @@ export const getItemCategoryByUniqueName = (uniqueName: string): string => {
76
71
return category;
77
72
};
78
73
79
export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined => {
80
return ExportWarframes[uniqueName];
81
};
82
83
74
export const getItemName = (uniqueName: string): string | undefined => {
84
75
if (uniqueName in ExportArcanes) {
85
76
return ExportArcanes[uniqueName].name;