返回提交历史
Modified
src/models/inventoryModels/loadoutModel.ts
+2
-1
Modified
src/services/saveLoadoutService.ts
+6
-2
Modified
src/types/saveLoadoutTypes.ts
+12
-10
XFEstudio/XFESpaceNinjaServer
feat: unequipping weapons & deleting loadout configs (#160)
9bded04d
代码差异
3 个文件
+20
-13
@@ -19,7 +19,8 @@ const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
19
19
default: { $oid: "000000000000000000000000" }
20
20
},
21
21
mod: Number,
22
cus: Number
22
cus: Number,
23
hide: Boolean
23
24
},
24
25
{
25
26
_id: false
@@ -77,6 +77,11 @@ export const handleInventoryItemConfigChange = async (
77
77
78
78
// all non-empty entries are one loadout slot
79
79
for (const [loadoutId, loadoutConfig] of Object.entries(newLoadout)) {
80
if (loadoutConfig.Remove) {
81
loadout[loadoutSlot].pull({ _id: loadoutId });
82
continue;
83
}
84
80
85
const oldLoadoutConfig = loadout[loadoutSlot].find(
81
86
loadout => loadout._id.toString() === loadoutId
82
87
);
@@ -106,8 +111,7 @@ export const handleInventoryItemConfigChange = async (
106
111
throw new Error("loadout index not found");
107
112
}
108
113
109
//perhaps .overwrite() is better
110
loadout[loadoutSlot][loadoutIndex].set(loadoutConfig);
114
loadout[loadoutSlot][loadoutIndex].overwrite(loadoutConfig);
111
115
}
112
116
}
113
117
await loadout.save();
@@ -76,17 +76,19 @@ export interface ILoadoutConfigDatabase extends Omit<ILoadoutConfigClient, "Item
76
76
// for request and response from and to client
77
77
export interface ILoadoutConfigClient {
78
78
ItemId: IOid;
79
n: string;
80
PresetIcon: string;
81
Favorite: boolean;
82
s: IEquipmentSelection;
83
p: IEquipmentSelection;
84
l: IEquipmentSelection;
85
m: IEquipmentSelection;
79
Remove?: boolean; // when client wants to remove a config, it only includes ItemId & Remove.
80
n?: string;
81
PresetIcon?: string;
82
Favorite?: boolean;
83
s?: IEquipmentSelection;
84
p?: IEquipmentSelection;
85
l?: IEquipmentSelection;
86
m?: IEquipmentSelection;
86
87
}
87
88
88
89
export interface IEquipmentSelection {
89
ItemId: IOid;
90
mod: number;
91
cus: number;
90
ItemId?: IOid;
91
mod?: number;
92
cus?: number;
93
hide?: boolean;
92
94
}