返回提交历史
Modified
src/services/inventoryService.ts
+29
-14
XFEstudio/XFESpaceNinjaServer
fix: ensure affiliation tags are unique (#3404)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3404 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
70f78c34
代码差异
1 个文件
+29
-14
@@ -2576,20 +2576,24 @@ export const createLibraryDailyTask = (): ILibraryDailyTaskInfo => {
2576
2576
};
2577
2577
2578
2578
export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void => {
2579
inventory.Affiliations.push({
2580
Title: 1,
2581
Standing: 1,
2582
WeeklyMissions: [
2583
{
2584
MissionIndex: 0,
2585
CompletedMission: false,
2586
JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
2587
WeekCount: 0,
2588
Challenges: []
2589
}
2590
],
2591
Tag: "KahlSyndicate"
2592
});
2579
if (inventory.Affiliations.some(x => x.Tag == "KahlSyndicate")) {
2580
logger.debug(`refusing to setup KahlSyndicate. it's already set up.`);
2581
} else {
2582
inventory.Affiliations.push({
2583
Title: 1,
2584
Standing: 1,
2585
WeeklyMissions: [
2586
{
2587
MissionIndex: 0,
2588
CompletedMission: false,
2589
JobManifest: "/Lotus/Syndicates/Kahl/KahlJobManifestVersionThree",
2590
WeekCount: 0,
2591
Challenges: []
2592
}
2593
],
2594
Tag: "KahlSyndicate"
2595
});
2596
}
2593
2597
};
2594
2598
2595
2599
export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): Promise<void> => {
@@ -2609,6 +2613,17 @@ export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): P
2609
2613
setupKahlSyndicate(inventory);
2610
2614
}
2611
2615
2616
const set = new Set<string>();
2617
for (let i = 0; i != inventory.Affiliations.length; ) {
2618
if (set.has(inventory.Affiliations[i].Tag)) {
2619
logger.debug(`removing duplicate affiliation for ${inventory.Affiliations[i].Tag}`);
2620
inventory.Affiliations.splice(i, 1);
2621
} else {
2622
set.add(inventory.Affiliations[i].Tag);
2623
++i;
2624
}
2625
}
2626
2612
2627
const LibrarySyndicate = inventory.Affiliations.find(x => x.Tag == "LibrarySyndicate");
2613
2628
if (LibrarySyndicate && LibrarySyndicate.FreeFavorsEarned) {
2614
2629
logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`);