返回提交历史
Modified
src/controllers/api/saveDialogueController.ts
+11
-2
XFEstudio/SpaceNinjaServer
feat: LizzieShawzin (#1525)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1525 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
541b8d32
代码差异
1 个文件
+11
-2
@@ -1,6 +1,7 @@
1
import { getInventory } from "@/src/services/inventoryService";
1
import { addEmailItem, getInventory } from "@/src/services/inventoryService";
2
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { ICompletedDialogue } from "@/src/types/inventoryTypes/inventoryTypes";
4
import { IInventoryChanges } from "@/src/types/purchaseTypes";
4
5
import { logger } from "@/src/utils/logger";
5
6
import { RequestHandler } from "express";
6
7
@@ -24,6 +25,7 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
24
25
if (request.OtherDialogueInfos.length != 0) {
25
26
logger.error(`saveDialogue request not fully handled: ${String(req.body)}`);
26
27
}
28
const inventoryChanges: IInventoryChanges = {};
27
29
inventory.DialogueHistory.Dialogues ??= [];
28
30
let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == request.DialogueName);
29
31
if (!dialogue) {
@@ -49,6 +51,13 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
49
51
dialogue.QueuedDialogues = request.QueuedDialogues;
50
52
for (const bool of request.Booleans) {
51
53
dialogue.Booleans.push(bool);
54
if (bool == "LizzieShawzin") {
55
await addEmailItem(
56
inventory,
57
"/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem",
58
inventoryChanges
59
);
60
}
52
61
}
53
62
for (const bool of request.ResetBooleans) {
54
63
const index = dialogue.Booleans.findIndex(x => x == bool);
@@ -61,7 +70,7 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
61
70
dialogue.AvailableDate = new Date(tomorrowAt0Utc);
62
71
await inventory.save();
63
72
res.json({
64
InventoryChanges: [],
73
InventoryChanges: inventoryChanges,
65
74
AvailableDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } }
66
75
});
67
76
}