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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

fix: handle saveDialogue without YearIteration having been supplied (#1774)

This is needed for The Hex rank up dialogues, which are independent of the year iterations. Fixes #1773 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1774 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

3b20a109
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +6 -11
Modified src/controllers/api/saveDialogueController.ts +3 -8
@@ -12,22 +12,17 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
12 12 const request = JSON.parse(String(req.body)) as SaveDialogueRequest;
13 13 if ("YearIteration" in request) {
14 14 const inventory = await getInventory(accountId, "DialogueHistory");
15 if (inventory.DialogueHistory) {
16 inventory.DialogueHistory.YearIteration = request.YearIteration;
17 } else {
18 inventory.DialogueHistory = { YearIteration: request.YearIteration };
19 }
15 inventory.DialogueHistory ??= {};
16 inventory.DialogueHistory.YearIteration = request.YearIteration;
20 17 await inventory.save();
21 18 res.end();
22 19 } else {
23 20 const inventory = await getInventory(accountId);
24 if (!inventory.DialogueHistory) {
25 throw new Error("bad inventory state");
26 }
27 21 const inventoryChanges: IInventoryChanges = {};
28 22 const tomorrowAt0Utc = config.noKimCooldowns
29 23 ? Date.now()
30 24 : (Math.trunc(Date.now() / 86400_000) + 1) * 86400_000;
25 inventory.DialogueHistory ??= {};
31 26 inventory.DialogueHistory.Dialogues ??= [];
32 27 const dialogue = getDialogue(inventory, request.DialogueName);
33 28 dialogue.Rank = request.Rank;
Modified src/models/inventoryModels/inventoryModel.ts +1 -1
@@ -909,7 +909,7 @@ dialogueSchema.set("toJSON", {
909 909
910 910 const dialogueHistorySchema = new Schema<IDialogueHistoryDatabase>(
911 911 {
912 YearIteration: { type: Number, required: true },
912 YearIteration: Number,
913 913 Resets: Number,
914 914 Dialogues: { type: [dialogueSchema], required: false }
915 915 },
Modified src/types/inventoryTypes/inventoryTypes.ts +2 -2
@@ -1130,13 +1130,13 @@ export interface IEndlessXpProgress {
1130 1130 }
1131 1131
1132 1132 export interface IDialogueHistoryClient {
1133 YearIteration: number;
1133 YearIteration?: number;
1134 1134 Resets?: number; // added in 38.5.0
1135 1135 Dialogues?: IDialogueClient[];
1136 1136 }
1137 1137
1138 1138 export interface IDialogueHistoryDatabase {
1139 YearIteration: number;
1139 YearIteration?: number;
1140 1140 Resets?: number;
1141 1141 Dialogues?: IDialogueDatabase[];
1142 1142 }