返回提交历史
Modified
src/controllers/api/evolveWeaponController.ts
+2
-2
Modified
src/controllers/api/focusController.ts
+9
-11
Modified
src/controllers/api/infestedFoundryController.ts
+2
-2
Modified
src/controllers/api/nameWeaponController.ts
+1
-3
Modified
src/controllers/api/setWeaponSkillTreeController.ts
+2
-4
Modified
src/controllers/custom/popArchonCrystalUpgradeController.ts
+1
-1
Modified
src/controllers/custom/pushArchonCrystalUpgradeController.ts
+1
-1
Modified
src/services/saveLoadoutService.ts
+1
-3
Modified
src/services/shipCustomizationsService.ts
+5
-7
XFEstudio/SpaceNinjaServer
chore: use SubdocumentArray.id in some more places (#1400)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1400 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
04d39ed9
代码差异
9 个文件
+24
-34
@@ -17,7 +17,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
17
17
recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
18
18
);
19
19
20
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
20
const item = inventory[payload.Category].id(req.query.ItemId as string)!;
21
21
item.Features ??= 0;
22
22
item.Features |= EquipmentFeatures.INCARNON_GENESIS;
23
23
@@ -39,7 +39,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
39
39
}
40
40
]);
41
41
42
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
42
const item = inventory[payload.Category].id(req.query.ItemId as string)!;
43
43
item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
44
44
} else {
45
45
throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
@@ -18,17 +18,15 @@ export const focusController: RequestHandler = async (req, res) => {
18
18
case FocusOperation.InstallLens: {
19
19
const request = JSON.parse(String(req.body)) as ILensInstallRequest;
20
20
const inventory = await getInventory(accountId);
21
for (const item of inventory[request.Category]) {
22
if (item._id.toString() == request.WeaponId) {
23
item.FocusLens = request.LensType;
24
addMiscItems(inventory, [
25
{
26
ItemType: request.LensType,
27
ItemCount: -1
28
} satisfies IMiscItem
29
]);
30
break;
31
}
21
const item = inventory[request.Category].id(request.WeaponId);
22
if (item) {
23
item.FocusLens = request.LensType;
24
addMiscItems(inventory, [
25
{
26
ItemType: request.LensType,
27
ItemCount: -1
28
} satisfies IMiscItem
29
]);
32
30
}
33
31
await inventory.save();
34
32
res.json({
@@ -28,7 +28,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
28
28
// shard installation
29
29
const request = getJSONfromString<IShardInstallRequest>(String(req.body));
30
30
const inventory = await getInventory(accountId);
31
const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
31
const suit = inventory.Suits.id(request.SuitId.$oid)!;
32
32
if (!suit.ArchonCrystalUpgrades || suit.ArchonCrystalUpgrades.length != 5) {
33
33
suit.ArchonCrystalUpgrades = [{}, {}, {}, {}, {}];
34
34
}
@@ -56,7 +56,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
56
56
// shard removal
57
57
const request = getJSONfromString<IShardUninstallRequest>(String(req.body));
58
58
const inventory = await getInventory(accountId);
59
const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
59
const suit = inventory.Suits.id(request.SuitId.$oid)!;
60
60
61
61
const miscItemChanges: IMiscItem[] = [];
62
62
if (suit.ArchonCrystalUpgrades![request.Slot].Color) {
@@ -12,9 +12,7 @@ export const nameWeaponController: RequestHandler = async (req, res) => {
12
12
const accountId = await getAccountIdForRequest(req);
13
13
const inventory = await getInventory(accountId);
14
14
const body = getJSONfromString<INameWeaponRequest>(String(req.body));
15
const item = inventory[req.query.Category as string as TEquipmentKey].find(
16
item => item._id.toString() == (req.query.ItemId as string)
17
)!;
15
const item = inventory[req.query.Category as string as TEquipmentKey].id(req.query.ItemId as string)!;
18
16
if (body.ItemName != "") {
19
17
item.ItemName = body.ItemName;
20
18
} else {
@@ -6,12 +6,10 @@ import { WeaponTypeInternal } from "@/src/services/itemDataService";
6
6
7
7
export const setWeaponSkillTreeController: RequestHandler = async (req, res) => {
8
8
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId);
9
const inventory = await getInventory(accountId, req.query.Category as string);
10
10
const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
11
11
12
const item = inventory[req.query.Category as WeaponTypeInternal].find(
13
item => item._id.toString() == (req.query.ItemId as string)
14
)!;
12
const item = inventory[req.query.Category as WeaponTypeInternal].id(req.query.ItemId as string)!;
15
13
item.SkillTree = payload.SkillTree;
16
14
17
15
await inventory.save();
@@ -5,7 +5,7 @@ import { getInventory } from "@/src/services/inventoryService";
5
5
export const popArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
6
6
const accountId = await getAccountIdForRequest(req);
7
7
const inventory = await getInventory(accountId);
8
const suit = inventory.Suits.find(suit => suit._id.toString() == (req.query.oid as string));
8
const suit = inventory.Suits.id(req.query.oid as string);
9
9
if (suit && suit.ArchonCrystalUpgrades) {
10
10
suit.ArchonCrystalUpgrades = suit.ArchonCrystalUpgrades.filter(
11
11
x => x.UpgradeType != (req.query.type as string)
@@ -5,7 +5,7 @@ import { getInventory } from "@/src/services/inventoryService";
5
5
export const pushArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
6
6
const accountId = await getAccountIdForRequest(req);
7
7
const inventory = await getInventory(accountId);
8
const suit = inventory.Suits.find(suit => suit._id.toString() == (req.query.oid as string));
8
const suit = inventory.Suits.id(req.query.oid as string);
9
9
if (suit) {
10
10
suit.ArchonCrystalUpgrades ??= [];
11
11
const count = (req.query.count as number | undefined) ?? 1;
@@ -84,9 +84,7 @@ export const handleInventoryItemConfigChange = async (
84
84
continue;
85
85
}
86
86
87
const oldLoadoutConfig = loadout[loadoutSlot].find(
88
loadout => loadout._id.toString() === loadoutId
89
);
87
const oldLoadoutConfig = loadout[loadoutSlot].id(loadoutId);
90
88
91
89
const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
92
90
const loadoutConfigDatabase: ILoadoutConfigDatabase = {
@@ -61,19 +61,17 @@ export const handleSetShipDecorations = async (
61
61
if (placedDecoration.MoveId) {
62
62
//moved within the same room
63
63
if (placedDecoration.OldRoom === placedDecoration.Room) {
64
const existingDecorationIndex = roomToPlaceIn.PlacedDecos.findIndex(
65
deco => deco._id.toString() === placedDecoration.MoveId
66
);
64
const existingDecoration = roomToPlaceIn.PlacedDecos.id(placedDecoration.MoveId);
67
65
68
if (existingDecorationIndex === -1) {
66
if (!existingDecoration) {
69
67
throw new Error("decoration to be moved not found");
70
68
}
71
69
72
roomToPlaceIn.PlacedDecos[existingDecorationIndex].Pos = placedDecoration.Pos;
73
roomToPlaceIn.PlacedDecos[existingDecorationIndex].Rot = placedDecoration.Rot;
70
existingDecoration.Pos = placedDecoration.Pos;
71
existingDecoration.Rot = placedDecoration.Rot;
74
72
75
73
if (placedDecoration.Scale) {
76
roomToPlaceIn.PlacedDecos[existingDecorationIndex].Scale = placedDecoration.Scale;
74
existingDecoration.Scale = placedDecoration.Scale;
77
75
}
78
76
79
77
await personalRooms.save();