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 kahl weekly reset while completed kahl mission (#4462)

Two weeks ago (week 649), I tested the impact of the Kahl mission on inventory on the official server and discovered two differences. Firstly, when running the Kahl mission for the first time each week, ResetChallenges = true. Secondly, Kahl reset does not occur at login, but at mission completed. Therefore, this week (week 651), I specifically skipped a week to conduct testing, and also tested whether mission failure affects challengesreset and Kahl reset. It was confirmed that regardless of whether the mission is successful or not, challengesreset will always be set to true, and Kahl reset only occurs after the mission is successful. The original addkahlprocess and kahl weekly reset would cause the client to return ResetChallenges = true and CompletedMission=true whenever the first mission was started, even if you immediately exited. This would trigger the kahl weekly reset when logging in the following week. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4462 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: yhhkevin <235+yhhkevin@noreply.localhost> Co-committed-by: yhhkevin <235+yhhkevin@noreply.localhost>

cb02b999
yhhkevin <235+yhhkevin@noreply.localhost>
提交于

代码差异

3 个文件 +32 -28
Modified src/controllers/api/inventoryController.ts +1 -26
@@ -62,7 +62,7 @@ import {
62 62 version_compare
63 63 } from "../../helpers/inventoryHelpers.ts";
64 64 import { Inbox } from "../../models/inboxModel.ts";
65 import { KAHL_EPOCH, unixTimesInMs } from "../../constants/timeConstants.ts";
65 import { unixTimesInMs } from "../../constants/timeConstants.ts";
66 66 import { DailyDeal } from "../../models/worldStateModel.ts";
67 67 import { eEquipmentFeatures } from "../../types/equipmentTypes.ts";
68 68 import { generateRewardSeed } from "../../services/rngService.ts";
@@ -160,31 +160,6 @@ export const inventoryController: RequestHandler = async (request, response) =>
160 160 suit.ExtraRemaining = undefined;
161 161 }
162 162 }
163
164 // Handle weekly reset
165 const lastLoginWeek = Math.trunc(
166 (inventory.NextRefill.getTime() - (86400000 + KAHL_EPOCH)) / unixTimesInMs.week
167 );
168 const currentWeek = Math.trunc((Date.now() - KAHL_EPOCH) / unixTimesInMs.week);
169 if (lastLoginWeek != currentWeek) {
170 const kahl = inventory.Affiliations.find(x => x.Tag == "KahlSyndicate");
171 if (kahl && kahl.WeeklyMissions) {
172 const mission = kahl.WeeklyMissions[kahl.WeeklyMissions.length - 1];
173 if (mission.CompletedMission) {
174 if (kahl.WeeklyMissions.length == 2) {
175 kahl.WeeklyMissions.splice(0, 1);
176 }
177 mission.ChallengesReset = true;
178 kahl.WeeklyMissions.push({
179 MissionIndex: mission.MissionIndex + 1,
180 CompletedMission: false,
181 JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
182 Challenges: [],
183 WeekCount: currentWeek
184 });
185 }
186 }
187 }
188 163 }
189 164
190 165 // TODO: Setup CalendarProgress as part of 1999 mission completion?
Modified src/services/inventoryService.ts +27 -2
@@ -2873,6 +2873,31 @@ export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value
2873 2873 checkCalendarAutoAdvance(inventory, currentSeason);
2874 2874 };
2875 2875
2876 export const resetKahlWeeklyMission = (
2877 inventory: Pick<TInventoryDatabaseDocument, "Affiliations">,
2878 value: string
2879 ): void => {
2880 const currentWeek = Math.trunc((Date.now() - KAHL_EPOCH) / unixTimesInMs.week);
2881 const kahl = inventory.Affiliations.find(x => x.Tag == "KahlSyndicate");
2882 if (kahl && kahl.WeeklyMissions) {
2883 const index = kahl.WeeklyMissions.findIndex(i => i.WeekCount == Number(value.slice("KahlSyndicate_".length)));
2884 if (index !== -1) {
2885 logger.debug(`kahl weekly mission completed, handling weekly reset`);
2886 kahl.WeeklyMissions[index].CompletedMission = true;
2887 if (kahl.WeeklyMissions.findIndex(i => i.WeekCount == currentWeek + 1) == -1) {
2888 kahl.WeeklyMissions.splice(0, kahl.WeeklyMissions.length, kahl.WeeklyMissions[index]);
2889 kahl.WeeklyMissions.push({
2890 MissionIndex: kahl.WeeklyMissions[kahl.WeeklyMissions.length - 1].MissionIndex + 1,
2891 CompletedMission: false,
2892 JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
2893 Challenges: [],
2894 WeekCount: currentWeek + 1
2895 });
2896 }
2897 }
2898 }
2899 };
2900
2876 2901 export const addKahlProgress = (
2877 2902 inventory: Pick<TInventoryDatabaseDocument, "Affiliations" | "MiscItems">,
2878 2903 value: IWeeklyMissionChallengeInfo[],
@@ -2881,9 +2906,9 @@ export const addKahlProgress = (
2881 2906 for (const info of value) {
2882 2907 let stockEarned = 0;
2883 2908 const kahl = inventory.Affiliations.find(x => x.Tag == info.Syndicate)!;
2884 const mission = kahl.WeeklyMissions![kahl.WeeklyMissions!.length - 1];
2909 const mission = kahl.WeeklyMissions!.find(i => i.WeekCount == info.WeekCount)!;
2885 2910 if (info.ResetChallenges) {
2886 mission.CompletedMission = true;
2911 mission.ChallengesReset = true;
2887 2912 }
2888 2913 for (const challenge of info.CompletedChallenges) {
2889 2914 if (mission.Challenges.indexOf(challenge) == -1) {
Modified src/services/missionInventoryUpdateService.ts +4 -0
@@ -59,6 +59,7 @@ import {
59 59 giveThousandYearFishDeco,
60 60 isEligibleForThousandYearFishDeco,
61 61 processGoalProgressUpdates,
62 resetKahlWeeklyMission,
62 63 updateCurrency,
63 64 updateEntratiVault,
64 65 updateIncentiveStates,
@@ -675,6 +676,9 @@ export const addMissionInventoryUpdates = async (
675 676 if (!inventory.syndicateMissionsRepeatable && !inventory.CompletedSyndicates.includes(value)) {
676 677 inventory.CompletedSyndicates.push(value);
677 678 }
679 if (value.includes("KahlSyndicate")) {
680 resetKahlWeeklyMission(inventory, value);
681 }
678 682 break;
679 683 }
680 684 case "SortieId": {