XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: handle saveDialogue request without Data or Gift (#1853)

Needed to just set booleans when starting dating. Closes #1852 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1853 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

95c0ad78
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +23 -26
Modified src/controllers/api/saveDialogueController.ts +23 -26
@@ -4,7 +4,6 @@ import { addEmailItem, getInventory, updateCurrency } from "@/src/services/inven
4 4 import { getAccountIdForRequest } from "@/src/services/loginService";
5 5 import { ICompletedDialogue, IDialogueDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
6 6 import { IInventoryChanges } from "@/src/types/purchaseTypes";
7 import { logger } from "@/src/utils/logger";
8 7 import { RequestHandler } from "express";
9 8
10 9 export const saveDialogueController: RequestHandler = async (req, res) => {
@@ -27,33 +26,33 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
27 26 const dialogue = getDialogue(inventory, request.DialogueName);
28 27 dialogue.Rank = request.Rank;
29 28 dialogue.Chemistry = request.Chemistry;
30 if (request.Data) {
31 dialogue.QueuedDialogues = request.QueuedDialogues;
32 for (const bool of request.Booleans) {
33 dialogue.Booleans.push(bool);
34 if (bool == "LizzieShawzin") {
35 await addEmailItem(
36 inventory,
37 "/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem",
38 inventoryChanges
39 );
40 }
29 dialogue.QueuedDialogues = request.QueuedDialogues;
30 for (const bool of request.Booleans) {
31 dialogue.Booleans.push(bool);
32 if (bool == "LizzieShawzin") {
33 await addEmailItem(
34 inventory,
35 "/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem",
36 inventoryChanges
37 );
38 }
39 }
40 for (const bool of request.ResetBooleans) {
41 const index = dialogue.Booleans.findIndex(x => x == bool);
42 if (index != -1) {
43 dialogue.Booleans.splice(index, 1);
41 44 }
42 for (const bool of request.ResetBooleans) {
43 const index = dialogue.Booleans.findIndex(x => x == bool);
44 if (index != -1) {
45 dialogue.Booleans.splice(index, 1);
46 }
45 }
46 for (const info of request.OtherDialogueInfos) {
47 const otherDialogue = getDialogue(inventory, info.Dialogue);
48 if (info.Tag != "") {
49 otherDialogue.QueuedDialogues.push(info.Tag);
47 50 }
51 otherDialogue.Chemistry += info.Value; // unsure
52 }
53 if (request.Data) {
48 54 dialogue.Completed.push(request.Data);
49 55 dialogue.AvailableDate = new Date(tomorrowAt0Utc);
50 for (const info of request.OtherDialogueInfos) {
51 const otherDialogue = getDialogue(inventory, info.Dialogue);
52 if (info.Tag != "") {
53 otherDialogue.QueuedDialogues.push(info.Tag);
54 }
55 otherDialogue.Chemistry += info.Value; // unsure
56 }
57 56 await inventory.save();
58 57 res.json({
59 58 InventoryChanges: inventoryChanges,
@@ -73,8 +72,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
73 72 InventoryChanges: inventoryChanges,
74 73 AvailableGiftDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } }
75 74 });
76 } else {
77 logger.error(`saveDialogue request not fully handled: ${String(req.body)}`);
78 75 }
79 76 }
80 77 };