返回提交历史
Modified
src/constants/timeConstants.ts
+1
-0
Modified
src/controllers/api/inventoryController.ts
+26
-1
Modified
src/controllers/api/updateChallengeProgressController.ts
+11
-2
Modified
src/services/inventoryService.ts
+27
-3
Modified
src/services/missionInventoryUpdateService.ts
+5
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+7
-0
Modified
src/types/requestTypes.ts
+3
-1
XFEstudio/SpaceNinjaServer
feat: kahl reset & challenge rewards (#3405)
Closes #2544 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3405 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
bafa578e
代码差异
7 个文件
+80
-7
@@ -1,4 +1,5 @@
1
1
export const EPOCH = 1734307200_000; // Monday, Dec 16, 2024 @ 00:00 UTC+0; should logically be the start of winter in 1999 iteration 0
2
export const KAHL_EPOCH = 1391990400_000; // Monday, Feb 10, 2014 @ 00:00 UTC+0; should logically be WeekCount 0 for KahlSyndicate
2
3
3
4
const millisecondsPerSecond = 1000;
4
5
const secondsPerMinute = 60;
@@ -43,7 +43,7 @@ import {
43
43
version_compare
44
44
} from "../../helpers/inventoryHelpers.ts";
45
45
import { Inbox } from "../../models/inboxModel.ts";
46
import { unixTimesInMs } from "../../constants/timeConstants.ts";
46
import { KAHL_EPOCH, unixTimesInMs } from "../../constants/timeConstants.ts";
47
47
import { DailyDeal } from "../../models/worldStateModel.ts";
48
48
import { EquipmentFeatures } from "../../types/equipmentTypes.ts";
49
49
import { generateRewardSeed } from "../../services/rngService.ts";
@@ -130,6 +130,31 @@ export const inventoryController: RequestHandler = async (request, response) =>
130
130
inventory.UsedDailyDeals = [];
131
131
}
132
132
}
133
134
// Handle weekly reset
135
const lastLoginWeek = Math.trunc(
136
(inventory.NextRefill.getTime() - (86400000 + KAHL_EPOCH)) / unixTimesInMs.week
137
);
138
const currentWeek = Math.trunc((Date.now() - KAHL_EPOCH) / unixTimesInMs.week);
139
if (lastLoginWeek != currentWeek) {
140
const kahl = inventory.Affiliations.find(x => x.Tag == "KahlSyndicate");
141
if (kahl && kahl.WeeklyMissions) {
142
const mission = kahl.WeeklyMissions[kahl.WeeklyMissions.length - 1];
143
if (mission.CompletedMission) {
144
if (kahl.WeeklyMissions.length == 2) {
145
kahl.WeeklyMissions.splice(0, 1);
146
}
147
mission.ChallengesReset = true;
148
kahl.WeeklyMissions.push({
149
MissionIndex: mission.MissionIndex + 1,
150
CompletedMission: false,
151
JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
152
Challenges: [],
153
WeekCount: currentWeek
154
});
155
}
156
}
157
}
133
158
}
134
159
135
160
// TODO: Setup CalendarProgress as part of 1999 mission completion?
@@ -1,8 +1,12 @@
1
1
import type { RequestHandler } from "express";
2
2
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
3
3
import { getAccountForRequest } from "../../services/loginService.ts";
4
import { addCalendarProgress, addChallenges, getInventory } from "../../services/inventoryService.ts";
5
import type { IChallengeProgress, ISeasonChallenge } from "../../types/inventoryTypes/inventoryTypes.ts";
4
import { addCalendarProgress, addChallenges, addKahlProgress, getInventory } from "../../services/inventoryService.ts";
5
import type {
6
IChallengeProgress,
7
ISeasonChallenge,
8
IWeeklyMissionChallengeInfo
9
} from "../../types/inventoryTypes/inventoryTypes.ts";
6
10
import type { IAffiliationMods, IInventoryChanges } from "../../types/purchaseTypes.ts";
7
11
import { getEntriesUnsafe } from "../../utils/ts-utils.ts";
8
12
import { logger } from "../../utils/logger.ts";
@@ -52,6 +56,10 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
52
56
addCalendarProgress(inventory, value);
53
57
break;
54
58
59
case "WeeklyMissionChallengeInfo":
60
addKahlProgress(inventory, value, inventoryChanges);
61
break;
62
55
63
case "ChallengeProgress":
56
64
case "SeasonChallengeCompletions":
57
65
case "ChallengePTS":
@@ -76,5 +84,6 @@ interface IUpdateChallengeProgressRequest {
76
84
SeasonChallengeHistory?: ISeasonChallenge[];
77
85
SeasonChallengeCompletions?: ISeasonChallenge[];
78
86
CalendarProgress?: { challenge: string }[];
87
WeeklyMissionChallengeInfo?: IWeeklyMissionChallengeInfo[];
79
88
crossPlaySetting?: string;
80
89
}
@@ -26,7 +26,8 @@ import type {
26
26
INemesisWeaponTargetFingerprint,
27
27
INemesisPetTargetFingerprint,
28
28
IDialogueDatabase,
29
IKubrowPetPrintClient
29
IKubrowPetPrintClient,
30
IWeeklyMissionChallengeInfo
30
31
} from "../types/inventoryTypes/inventoryTypes.ts";
31
32
import { InventorySlot, equipmentKeys } from "../types/inventoryTypes/inventoryTypes.ts";
32
33
import type { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate.ts";
@@ -82,7 +83,7 @@ import type { ICalendarSeason } from "../types/worldStateTypes.ts";
82
83
import type { INemesisProfile } from "../helpers/nemesisHelpers.ts";
83
84
import { generateNemesisProfile } from "../helpers/nemesisHelpers.ts";
84
85
import type { TAccountDocument } from "./loginService.ts";
85
import { unixTimesInMs } from "../constants/timeConstants.ts";
86
import { KAHL_EPOCH, unixTimesInMs } from "../constants/timeConstants.ts";
86
87
import { addString } from "../helpers/stringHelpers.ts";
87
88
import type {
88
89
IEquipmentClient,
@@ -2471,6 +2472,29 @@ export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value
2471
2472
checkCalendarAutoAdvance(inventory, currentSeason);
2472
2473
};
2473
2474
2475
export const addKahlProgress = (
2476
inventory: TInventoryDatabaseDocument,
2477
value: IWeeklyMissionChallengeInfo[],
2478
inventoryChanges: IInventoryChanges
2479
): void => {
2480
for (const info of value) {
2481
let stockEarned = 0;
2482
const affiliation = inventory.Affiliations.find(x => x.Tag == info.Syndicate);
2483
const mission = affiliation!.WeeklyMissions![0];
2484
if (info.ResetChallenges) {
2485
mission.CompletedMission = true;
2486
}
2487
for (const challenge of info.CompletedChallenges) {
2488
if (mission.Challenges.indexOf(challenge) == -1) {
2489
stockEarned += challenge == "/Lotus/Types/Challenges/KahlMissions/NoDeathKahlChallenge" ? 30 : 15;
2490
mission.Challenges.push(challenge);
2491
}
2492
}
2493
logger.debug(`adding ${stockEarned} stock for kahl challenges`);
2494
addMiscItem(inventory, "/Lotus/Types/Items/MiscItems/KahlCreds", stockEarned, inventoryChanges);
2495
}
2496
};
2497
2474
2498
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
2475
2499
const { Missions } = inventory;
2476
2500
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
@@ -2587,7 +2611,7 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void
2587
2611
MissionIndex: 0,
2588
2612
CompletedMission: false,
2589
2613
JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
2590
WeekCount: 0,
2614
WeekCount: Math.trunc((Date.now() - KAHL_EPOCH) / unixTimesInMs.week),
2591
2615
Challenges: []
2592
2616
}
2593
2617
],
@@ -31,6 +31,7 @@ import {
31
31
addFusionPoints,
32
32
addFusionTreasures,
33
33
addItem,
34
addKahlProgress,
34
35
addLevelKeys,
35
36
addLoreFragmentScans,
36
37
addMiscItems,
@@ -872,6 +873,10 @@ export const addMissionInventoryUpdates = async (
872
873
addCalendarProgress(inventory, value);
873
874
break;
874
875
}
876
case "WeeklyMissionChallengeInfo": {
877
addKahlProgress(inventory, value, inventoryChanges);
878
break;
879
}
875
880
case "duviriCaveOffers": {
876
881
// Duviri cave offers (generated with the duviri seed) change after completing one of its game modes (not when aborting).
877
882
if (inventoryUpdates.MissionStatus != "GS_QUIT") {
@@ -515,6 +515,13 @@ export interface IWeeklyMission {
515
515
WeekCount: number;
516
516
}
517
517
518
export interface IWeeklyMissionChallengeInfo {
519
Syndicate: "KahlSyndicate";
520
WeekCount: number;
521
ResetChallenges?: boolean;
522
CompletedChallenges: string[];
523
}
524
518
525
export interface IAlignment {
519
526
Wisdom: number;
520
527
Alignment: number;
@@ -23,7 +23,8 @@ import type {
23
23
IKubrowPetEggClient,
24
24
INemesisClient,
25
25
IUpgradeClient,
26
IChallengeInstanceStateClient
26
IChallengeInstanceStateClient,
27
IWeeklyMissionChallengeInfo
27
28
} from "./inventoryTypes/inventoryTypes.ts";
28
29
import type { IGroup } from "./loginTypes.ts";
29
30
import type { ILoadOutPresets } from "./saveLoadoutTypes.ts";
@@ -61,6 +62,7 @@ export type IMissionInventoryUpdateRequest = {
61
62
SortieId?: string;
62
63
CalendarProgress?: { challenge: string }[];
63
64
SeasonChallengeCompletions?: ISeasonChallenge[];
65
WeeklyMissionChallengeInfo?: IWeeklyMissionChallengeInfo[];
64
66
AffiliationChanges?: IAffiliationChange[];
65
67
crossPlaySetting?: string;
66
68
rewardsMultiplier?: number;