返回提交历史
Modified
src/controllers/api/missionInventoryUpdateController.ts
+16
-3
Modified
src/services/missionInventoryUpdateService.ts
+52
-44
Modified
src/types/requestTypes.ts
+9
-1
XFEstudio/XFESpaceNinjaServer
fix: show conservation standing in progress screen, missing reward multiplications (#2776)
Closes #2774 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2776 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
d2aff211
代码差异
3 个文件
+77
-48
@@ -2,7 +2,11 @@ import type { RequestHandler } from "express";
2
2
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
3
3
import { getAccountForRequest } from "../../services/loginService.ts";
4
4
import type { IMissionInventoryUpdateRequest } from "../../types/requestTypes.ts";
5
import { addMissionInventoryUpdates, addMissionRewards } from "../../services/missionInventoryUpdateService.ts";
5
import {
6
addMissionInventoryUpdates,
7
addMissionRewards,
8
handleConservation
9
} from "../../services/missionInventoryUpdateService.ts";
6
10
import { getInventory } from "../../services/inventoryService.ts";
7
11
import { getInventoryResponse } from "./inventoryController.ts";
8
12
import { logger } from "../../utils/logger.ts";
@@ -94,6 +98,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
94
98
SyndicateXPItemReward,
95
99
ConquestCompletedMissionsCount
96
100
} = await addMissionRewards(account, inventory, missionReport, firstCompletion);
101
handleConservation(inventory, missionReport, AffiliationMods); // Conservation reports have GS_SUCCESS
97
102
98
103
if (missionReport.EndOfMatchUpload) {
99
104
inventory.RewardSeed = generateRewardSeed();
@@ -111,8 +116,16 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
111
116
AffiliationMods,
112
117
ConquestCompletedMissionsCount
113
118
};
114
if (missionReport.RJ) {
115
logger.debug(`railjack interstitial request, sending only deltas`, deltas);
119
if (
120
missionReport.BMI ||
121
missionReport.TNT ||
122
missionReport.SSC ||
123
missionReport.RJ ||
124
missionReport.SS ||
125
missionReport.CMI ||
126
missionReport.EJC
127
) {
128
logger.debug(`interstitial request, sending only deltas`, deltas);
116
129
res.json(deltas);
117
130
} else if (missionReport.RewardInfo) {
118
131
logger.debug(`classic mission completion, sending everything`);
@@ -517,46 +517,6 @@ export const addMissionInventoryUpdates = async (
517
517
}
518
518
break;
519
519
}
520
case "CapturedAnimals": {
521
for (const capturedAnimal of value) {
522
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
523
const meta = ExportAnimals[capturedAnimal.AnimalType]?.conservation;
524
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
525
if (meta) {
526
if (capturedAnimal.NumTags) {
527
addMiscItems(inventory, [
528
{
529
ItemType: meta.itemReward,
530
ItemCount: capturedAnimal.NumTags
531
}
532
]);
533
}
534
if (capturedAnimal.NumExtraRewards) {
535
if (meta.woundedAnimalReward) {
536
addMiscItems(inventory, [
537
{
538
ItemType: meta.woundedAnimalReward,
539
ItemCount: capturedAnimal.NumExtraRewards
540
}
541
]);
542
} else {
543
logger.warn(
544
`client attempted to claim unknown extra rewards for conservation of ${capturedAnimal.AnimalType}`
545
);
546
}
547
}
548
if (meta.standingReward) {
549
const syndicateTag =
550
inventoryUpdates.Missions!.Tag == "SolNode129" ? "SolarisSyndicate" : "CetusSyndicate";
551
logger.debug(`adding ${meta.standingReward} standing to ${syndicateTag} for conservation`);
552
addStanding(inventory, syndicateTag, meta.standingReward);
553
}
554
} else {
555
logger.warn(`ignoring conservation of unknown AnimalType: ${capturedAnimal.AnimalType}`);
556
}
557
}
558
break;
559
}
560
520
case "KubrowPetEggs": {
561
521
for (const egg of value) {
562
522
inventory.KubrowPetEggs.push({
@@ -961,7 +921,7 @@ interface AddMissionRewardsReturnType {
961
921
MissionRewards: IMissionReward[];
962
922
inventoryChanges?: IInventoryChanges;
963
923
credits?: IMissionCredits;
964
AffiliationMods?: IAffiliationMods[];
924
AffiliationMods: IAffiliationMods[];
965
925
SyndicateXPItemReward?: number;
966
926
ConquestCompletedMissionsCount?: number;
967
927
}
@@ -1137,10 +1097,12 @@ export const addMissionRewards = async (
1137
1097
}: IMissionInventoryUpdateRequest,
1138
1098
firstCompletion: boolean
1139
1099
): Promise<AddMissionRewardsReturnType> => {
1100
AffiliationMods ??= [];
1101
1140
1102
if (!rewardInfo) {
1141
1103
//TODO: if there is a case where you can have credits collected during a mission but no rewardInfo, add credits needs to be handled earlier
1142
1104
logger.debug(`Mission ${missions!.Tag} did not have Reward Info `);
1143
return { MissionRewards: [] };
1105
return { MissionRewards: [], AffiliationMods };
1144
1106
}
1145
1107
1146
1108
//TODO: check double reward merging
@@ -1450,8 +1412,6 @@ export const addMissionRewards = async (
1450
1412
}
1451
1413
}
1452
1414
1453
AffiliationMods ??= [];
1454
1455
1415
if (rewardInfo.JobStage != undefined && rewardInfo.jobId) {
1456
1416
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1457
1417
const [jobType, unkIndex, hubNode, syndicateMissionId] = rewardInfo.jobId.split("_");
@@ -2252,6 +2212,54 @@ function getRandomMissionDrops(
2252
2212
return drops;
2253
2213
}
2254
2214
2215
export const handleConservation = (
2216
inventory: TInventoryDatabaseDocument,
2217
missionReport: IMissionInventoryUpdateRequest,
2218
AffiliationMods: IAffiliationMods[]
2219
): void => {
2220
if (missionReport.CapturedAnimals) {
2221
for (const capturedAnimal of missionReport.CapturedAnimals) {
2222
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
2223
const meta = ExportAnimals[capturedAnimal.AnimalType]?.conservation;
2224
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
2225
if (meta) {
2226
if (capturedAnimal.NumTags) {
2227
addMiscItems(inventory, [
2228
{
2229
ItemType: meta.itemReward,
2230
ItemCount: capturedAnimal.NumTags * capturedAnimal.Count
2231
}
2232
]);
2233
}
2234
if (capturedAnimal.NumExtraRewards) {
2235
if (meta.woundedAnimalReward) {
2236
addMiscItems(inventory, [
2237
{
2238
ItemType: meta.woundedAnimalReward,
2239
ItemCount: capturedAnimal.NumExtraRewards * capturedAnimal.Count
2240
}
2241
]);
2242
} else {
2243
logger.warn(
2244
`client attempted to claim unknown extra rewards for conservation of ${capturedAnimal.AnimalType}`
2245
);
2246
}
2247
}
2248
if (meta.standingReward) {
2249
addStanding(
2250
inventory,
2251
missionReport.Missions!.Tag == "SolNode129" ? "SolarisSyndicate" : "CetusSyndicate",
2252
[2, 1.5, 1][capturedAnimal.CaptureRating] * meta.standingReward * capturedAnimal.Count,
2253
AffiliationMods
2254
);
2255
}
2256
} else {
2257
logger.warn(`ignoring conservation of unknown AnimalType: ${capturedAnimal.AnimalType}`);
2258
}
2259
}
2260
}
2261
};
2262
2255
2263
const corruptedMods = [
2256
2264
"/Lotus/StoreItems/Upgrades/Mods/Melee/DualStat/CorruptedHeavyDamageChargeSpeedMod", // Corrupt Charge
2257
2265
"/Lotus/StoreItems/Upgrades/Mods/Pistol/DualStat/CorruptedCritDamagePistol", // Hollow Point
@@ -45,6 +45,15 @@ export type IMissionInventoryUpdateRequest = {
45
45
EmailItems?: ITypeCount[];
46
46
ShipDecorations?: ITypeCount[];
47
47
48
// flags for interstitial requests
49
BMI?: boolean;
50
TNT?: boolean; // Conservation; definitely need to include AffiliationMods in this case, so a normal 'inventory sync' would not work here.
51
SSC?: boolean; // K-Drive race?
52
RJ?: boolean; // Railjack. InventoryJson should only be returned when going back to dojo.
53
SS?: boolean;
54
CMI?: boolean;
55
EJC?: boolean;
56
48
57
SyndicateId?: string;
49
58
SortieId?: string;
50
59
CalendarProgress?: { challenge: string }[];
@@ -149,7 +158,6 @@ export type IMissionInventoryUpdateRequest = {
149
158
MultiProgress: unknown[];
150
159
}[];
151
160
InvasionProgress?: IInvasionProgressClient[];
152
RJ?: boolean;
153
161
ConquestMissionsCompleted?: number;
154
162
duviriSuitSelection?: string;
155
163
duviriPistolSelection?: string;