返回提交历史
Modified
src/services/inventoryService.ts
+15
-12
XFEstudio/SpaceNinjaServer
fix: refuse to add items non-fatally (#1476)
This is needed to complete to the railjack quest when already owning a railjack Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1476 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
b2497ded
代码差异
1 个文件
+15
-12
@@ -1060,11 +1060,12 @@ const addCrewShip = (
1060
1060
inventoryChanges: IInventoryChanges = {}
1061
1061
): IInventoryChanges => {
1062
1062
if (inventory.CrewShips.length != 0) {
1063
throw new Error("refusing to add CrewShip because account already has one");
1063
logger.warn("refusing to add CrewShip because account already has one");
1064
} else {
1065
const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
1066
inventoryChanges.CrewShips ??= [];
1067
inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
1064
1068
}
1065
const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
1066
inventoryChanges.CrewShips ??= [];
1067
inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
1068
1069
return inventoryChanges;
1069
1070
};
1070
1071
@@ -1074,11 +1075,12 @@ const addCrewShipHarness = (
1074
1075
inventoryChanges: IInventoryChanges = {}
1075
1076
): IInventoryChanges => {
1076
1077
if (inventory.CrewShipHarnesses.length != 0) {
1077
throw new Error("refusing to add CrewShipHarness because account already has one");
1078
logger.warn("refusing to add CrewShipHarness because account already has one");
1079
} else {
1080
const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
1081
inventoryChanges.CrewShipHarnesses ??= [];
1082
inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
1078
1083
}
1079
const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
1080
inventoryChanges.CrewShipHarnesses ??= [];
1081
inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
1082
1084
return inventoryChanges;
1083
1085
};
1084
1086
@@ -1088,11 +1090,12 @@ const addMotorcycle = (
1088
1090
inventoryChanges: IInventoryChanges = {}
1089
1091
): IInventoryChanges => {
1090
1092
if (inventory.Motorcycles.length != 0) {
1091
throw new Error("refusing to add Motorcycle because account already has one");
1093
logger.warn("refusing to add Motorcycle because account already has one");
1094
} else {
1095
const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
1096
inventoryChanges.Motorcycles ??= [];
1097
inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
1092
1098
}
1093
const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
1094
inventoryChanges.Motorcycles ??= [];
1095
inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
1096
1099
return inventoryChanges;
1097
1100
};
1098
1101