返回提交历史
Modified
src/controllers/api/clearDialogueHistoryController.ts
+5
-6
Modified
src/services/inventoryService.ts
+18
-13
XFEstudio/SpaceNinjaServer
fix: create new dialogue object when resetting its history (#4003)
I'm not sure why the spread operator was not working here, but I think the logic was wrong anyway. Closes #4002 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4003 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
fba0d18d
代码差异
2 个文件
+23
-19
@@ -1,4 +1,4 @@
1
import { getInventory } from "../../services/inventoryService.ts";
1
import { createDefaultDialogue, getInventory } from "../../services/inventoryService.ts";
2
2
import { getAccountIdForRequest } from "../../services/loginService.ts";
3
3
import type { RequestHandler } from "express";
4
4
import type { IInventoryClient, IDialogueResetDateClient } from "../../types/inventoryTypes/inventoryTypes.ts";
@@ -36,11 +36,10 @@ export const clearDialogueHistoryController: RequestHandler = async (req, res) =
36
36
if (request.ClearPersist) {
37
37
inventory.DialogueHistory.Dialogues.splice(index, 1);
38
38
} else {
39
inventory.DialogueHistory.Dialogues[index] = {
40
...inventory.DialogueHistory.Dialogues[index],
41
Counters: inventory.DialogueHistory.Dialogues[index].Counters?.filter(x => x.Persist),
42
Completed: inventory.DialogueHistory.Dialogues[index].Completed.filter(x => x.Persist)
43
};
39
const newObject = createDefaultDialogue(dialogueName);
40
newObject.Counters = inventory.DialogueHistory.Dialogues[index].Counters?.filter(x => x.Persist);
41
newObject.Completed = inventory.DialogueHistory.Dialogues[index].Completed.filter(x => x.Persist);
42
inventory.DialogueHistory.Dialogues[index] = newObject;
44
43
}
45
44
}
46
45
}
@@ -2931,6 +2931,23 @@ export const migrateFusionTreasures = (
2931
2931
addFusionTreasures(inventory, arr);
2932
2932
};
2933
2933
2934
export const createDefaultDialogue = (dialogueName: string): IDialogueDatabase => {
2935
return {
2936
Rank: 1,
2937
Chemistry: 0,
2938
AvailableDate: new Date(0),
2939
AvailableGiftDate: new Date(0),
2940
RankUpExpiry: new Date(0),
2941
BountyChemExpiry: new Date(0),
2942
QueuedDialogues: [],
2943
Gifts: [],
2944
Booleans: [],
2945
Completed: [],
2946
Counters: [],
2947
DialogueName: dialogueName
2948
};
2949
};
2950
2934
2951
export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
2935
2952
inventory.DialogueHistory ??= {};
2936
2953
inventory.DialogueHistory.Dialogues ??= [];
@@ -2938,19 +2955,7 @@ export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName:
2938
2955
if (!dialogue) {
2939
2956
dialogue =
2940
2957
inventory.DialogueHistory.Dialogues[
2941
inventory.DialogueHistory.Dialogues.push({
2942
Rank: 0,
2943
Chemistry: 0,
2944
AvailableDate: new Date(0),
2945
AvailableGiftDate: new Date(0),
2946
RankUpExpiry: new Date(0),
2947
BountyChemExpiry: new Date(0),
2948
QueuedDialogues: [],
2949
Gifts: [],
2950
Booleans: [],
2951
Completed: [],
2952
DialogueName: dialogueName
2953
}) - 1
2958
inventory.DialogueHistory.Dialogues.push(createDefaultDialogue(dialogueName)) - 1
2954
2959
];
2955
2960
}
2956
2961
return dialogue;