返回提交历史
Modified
src/controllers/api/inventoryController.ts
+1
-1
Modified
src/controllers/api/trainingResultController.ts
+5
-2
Modified
src/services/configService.ts
+21
-5
Modified
src/services/inventoryService.ts
+10
-5
Modified
src/services/itemDataService.ts
+3
-3
Modified
src/services/missionInventoryUpdateService.ts
+9
-6
XFEstudio/SpaceNinjaServer
chore: handle server-side QoL configs being set to null (#4380)
In this case, the behaviour is decided by the client version. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4380 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
395533fb
代码差异
6 个文件
+49
-22
@@ -97,7 +97,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
97
97
inventory.TradesRemaining += 2;
98
98
}
99
99
100
inventory.LibraryAvailableDailyTaskInfo = createLibraryDailyTask();
100
inventory.LibraryAvailableDailyTaskInfo = createLibraryDailyTask(buildLabel);
101
101
102
102
if (inventory.NextRefill) {
103
103
const lastLoginDay = Math.trunc(inventory.NextRefill.getTime() / 86400000) - 1;
@@ -7,7 +7,8 @@ import { unixTimesInMs } from "../../constants/timeConstants.ts";
7
7
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
8
8
import { createMessage } from "../../services/inboxService.ts";
9
9
import { toMongoDate2 } from "../../helpers/inventoryHelpers.ts";
10
import { config } from "../../services/configService.ts";
10
import { shouldDoServerQol } from "../../services/configService.ts";
11
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
11
12
import gameToBuildVersionInt from "../../constants/gameToBuildVersionInt.ts";
12
13
13
14
interface ITrainingResultsRequest {
@@ -35,7 +36,9 @@ const handleTrainingProgress = async (
35
36
if (!inventory.noMasteryRankUpCooldown) {
36
37
time +=
37
38
unixTimesInMs.hour *
38
((config.serversideQualityOfLife?.twentythreeHourMasteryRankCooldown ?? true) ? 23 : 24);
39
(shouldDoServerQol("twentythreeHourMasteryRankCooldown", buildLabel, gameToBuildVersion["38.0.0"])
40
? 23
41
: 24);
39
42
}
40
43
inventory.TrainingDate = new Date(time);
41
44
@@ -3,6 +3,7 @@ import path from "path";
3
3
import { repoDir } from "../helpers/pathHelper.ts";
4
4
import { args } from "../helpers/commandLineArguments.ts";
5
5
import type { Request } from "express";
6
import { version_compare } from "../helpers/inventoryHelpers.ts";
6
7
7
8
export type TRegionId = "ASIA" | "OCEANIA" | "EUROPE" | "RUSSIA" | "NORTH_AMERICA" | "SOUTH_AMERICA";
8
9
@@ -21,6 +22,11 @@ export interface IWebuiConfig {
21
22
22
23
export type TLogLevel = "error" | "warn" | "info" | "http" | "debug" | "trace";
23
24
25
type TQolConfigKey =
26
| "twentythreeHourMasteryRankCooldown"
27
| "doubleDailySynthesisEndoReward"
28
| "tylRegorDropsTwoEquinoxParts";
29
24
30
export interface IConfig {
25
31
/** @deprecated */ mongodbUrl?: string;
26
32
database:
@@ -135,11 +141,7 @@ export interface IConfig {
135
141
snowdayShowdown?: boolean;
136
142
breedingGrounds?: boolean;
137
143
};
138
serversideQualityOfLife?: {
139
twentythreeHourMasteryRankCooldown?: boolean;
140
doubleDailySynthesisEndoReward?: boolean;
141
tylRegorDropsTwoEquinoxParts?: boolean;
142
};
144
serversideQualityOfLife?: Record<TQolConfigKey, boolean | null>;
143
145
inventoryDefaults?: Record<string, any>;
144
146
tunables?: {
145
147
useLoginToken?: boolean;
@@ -320,3 +322,17 @@ export const getNrsAddresses = (): [string, number][] => {
320
322
return [nrsAddr, nrsPort];
321
323
});
322
324
};
325
326
export const shouldDoServerQol = (
327
key: TQolConfigKey,
328
clientBuildLabel: string,
329
introducedInBuildLabel: string
330
): boolean => {
331
if (config.serversideQualityOfLife) {
332
if (config.serversideQualityOfLife[key] === null) {
333
return version_compare(clientBuildLabel, introducedInBuildLabel) >= 0;
334
}
335
return config.serversideQualityOfLife[key];
336
}
337
return true;
338
};
@@ -1,6 +1,6 @@
1
1
import type { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel.ts";
2
2
import { Inventory } from "../models/inventoryModels/inventoryModel.ts";
3
import { config } from "./configService.ts";
3
import { config, shouldDoServerQol } from "./configService.ts";
4
4
import { Types } from "mongoose";
5
5
import type { IInventoryChanges, IBinChanges, IAffiliationMods } from "../types/purchaseTypes.ts";
6
6
import type {
@@ -251,7 +251,7 @@ export const createInventory = async (
251
251
Ships: [defaultItemReferences.ship]
252
252
});
253
253
254
inventory.LibraryAvailableDailyTaskInfo = createLibraryDailyTask();
254
inventory.LibraryAvailableDailyTaskInfo = createLibraryDailyTask(BL_LATEST);
255
255
inventory.RewardSeed = generateRewardSeed();
256
256
inventory.DuviriInfo = {
257
257
Seed: generateRewardSeed(),
@@ -2910,12 +2910,17 @@ export const addKeyChainItems = async (
2910
2910
return inventoryChanges;
2911
2911
};
2912
2912
2913
export const createLibraryDailyTask = (): ILibraryDailyTaskInfo => {
2913
export const createLibraryDailyTask = (buildLabel: string): ILibraryDailyTaskInfo => {
2914
2914
const enemyTypes = getRandomElement(libraryDailyTasks)!;
2915
2915
const enemyAvatar = ExportEnemies.avatars[enemyTypes[0]];
2916
2916
const scansRequired = getRandomInt(2, 4);
2917
const rewardQuantityMultiplier =
2918
(config.serversideQualityOfLife?.doubleDailySynthesisEndoReward ?? true) ? 2.5 : 1.25;
2917
const rewardQuantityMultiplier = shouldDoServerQol(
2918
"doubleDailySynthesisEndoReward",
2919
buildLabel,
2920
gameToBuildVersion["22.13.4"] // change actually made in 22.13.3
2921
)
2922
? 2.5
2923
: 1.25;
2919
2924
return {
2920
2925
EnemyTypes: enemyTypes,
2921
2926
EnemyLocTag: enemyAvatar.name,
@@ -82,7 +82,7 @@ import { promises as fs } from "fs";
82
82
import path from "path";
83
83
import { BL_LATEST } from "../constants/gameVersions.ts";
84
84
import type { TInventorySlot } from "../types/inventoryTypes/inventoryTypes.ts";
85
import { config } from "./configService.ts";
85
import { shouldDoServerQol } from "./configService.ts";
86
86
import { buildLabelToVersionInt, wikiDateToBuildVersionInt } from "../helpers/versionHelper.ts";
87
87
import baro from "../../static/fixed_responses/worldState/baro.json" with { type: "json" };
88
88
@@ -3380,10 +3380,10 @@ export const getKey = (uniqueName: string, buildLabel: string = BL_LATEST): IKey
3380
3380
return ExportKeys[uniqueName] ?? supplementalKeys[uniqueName];
3381
3381
};
3382
3382
3383
export const getMissionDeck = (uniqueName: string): TMissionDeck | undefined => {
3383
export const getMissionDeck = (uniqueName: string, buildLabel: string): TMissionDeck | undefined => {
3384
3384
if (
3385
3385
uniqueName == "/Lotus/Types/Game/MissionDecks/BossMissionRewards/YinYangRewards" &&
3386
!(config.serversideQualityOfLife?.tylRegorDropsTwoEquinoxParts ?? true)
3386
!shouldDoServerQol("tylRegorDropsTwoEquinoxParts", buildLabel, gameToBuildVersion["42.0.0"])
3387
3387
) {
3388
3388
return preU42YinYangRewards;
3389
3389
}
@@ -96,7 +96,7 @@ import {
96
96
pushClassicBounties,
97
97
populateAlerts
98
98
} from "./worldStateService.ts";
99
import { config } from "./configService.ts";
99
import { config, shouldDoServerQol } from "./configService.ts";
100
100
import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json" with { type: "json" };
101
101
import type { IGoal, ISyndicateJob, ISyndicateMissionInfo } from "../types/worldStateTypes.ts";
102
102
import {
@@ -167,7 +167,10 @@ const getRotations = async (rewardInfo: IRewardInfo, buildLabel: string, tierOve
167
167
}
168
168
}
169
169
170
if (rewardInfo.node == "SolNode105" && (config.serversideQualityOfLife?.tylRegorDropsTwoEquinoxParts ?? true)) {
170
if (
171
rewardInfo.node == "SolNode105" &&
172
shouldDoServerQol("tylRegorDropsTwoEquinoxParts", buildLabel, gameToBuildVersion["42.0.0"])
173
) {
171
174
// U42 QoL change:
172
175
// Defeating Tyl Regor now rewards two Equinox Component Blueprints — one guaranteed for the Night and Day Aspect each.
173
176
return [0, 1];
@@ -1883,7 +1886,7 @@ export const addFixedLevelRewards = async (
1883
1886
}
1884
1887
}
1885
1888
if (rewards.droptable) {
1886
const droptable = getMissionDeck(rewards.droptable);
1889
const droptable = getMissionDeck(rewards.droptable, buildLabel);
1887
1890
if (droptable) {
1888
1891
const rotations: number[] = rewardInfo ? await getRotations(rewardInfo, buildLabel) : [0];
1889
1892
if (rewards.droptable.startsWith("/Lotus/Types/Game/MissionDecks/VoidKeyMissionRewards/")) {
@@ -2233,7 +2236,7 @@ async function getRandomMissionDrops(
2233
2236
}*/
2234
2237
const rng = new SRng(BigInt(RewardInfo.rewardSeed ?? generateRewardSeed()) ^ 0xffffffffffffffffn);
2235
2238
rewardManifests.forEach(name => {
2236
const table = getMissionDeck(name);
2239
const table = getMissionDeck(name, buildLabel);
2237
2240
if (!table) {
2238
2241
logger.error(`unknown droptable: ${name}`);
2239
2242
return;
@@ -2503,7 +2506,7 @@ async function getRandomMissionDrops(
2503
2506
if (!keyMeta) {
2504
2507
logger.error(`unknown levelKey ${currentMissionKey} while proccesing EnemyCachesFound`);
2505
2508
} else if (keyMeta.cacheRewardManifest) {
2506
const deck = getMissionDeck(keyMeta.cacheRewardManifest);
2509
const deck = getMissionDeck(keyMeta.cacheRewardManifest, buildLabel);
2507
2510
if (!deck) {
2508
2511
logger.error(
2509
2512
`unknown droptable ${keyMeta.cacheRewardManifest} while proccesing EnemyCachesFound`
@@ -2545,7 +2548,7 @@ async function getRandomMissionDrops(
2545
2548
if (!keyMeta) {
2546
2549
logger.error(`unknown levelKey ${levelKeyName} while proccesing EnemyCachesFound`);
2547
2550
} else if (keyMeta.cacheRewardManifest) {
2548
const deck = getMissionDeck(keyMeta.cacheRewardManifest);
2551
const deck = getMissionDeck(keyMeta.cacheRewardManifest, buildLabel);
2549
2552
if (!deck) {
2550
2553
logger.error(`unknown droptable ${keyMeta.cacheRewardManifest} while proccesing EnemyCachesFound`);
2551
2554
} else {