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: endo pickups (#359)

d0b8c8a1
Sainan <sainan@calamity.gg>
提交于

代码差异

3 个文件 +30 -13
Modified src/controllers/api/missionInventoryUpdateController.ts +4 -1
@@ -4,6 +4,7 @@ import { combineRewardAndLootInventory, getRewards } from "@/src/services/missio
4 4 import { getJSONfromString } from "@/src/helpers/stringHelpers";
5 5 import { getAccountIdForRequest } from "@/src/services/loginService";
6 6 import { IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
7 import { logger } from "@/src/utils/logger";
7 8 /*
8 9 **** INPUT ****
9 10 - [ ] crossPlaySetting
@@ -52,6 +53,8 @@ const missionInventoryUpdateController: RequestHandler = async (req, res): Promi
52 53 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
53 54 const lootInventory = getJSONfromString(req.body.toString()) as IMissionInventoryUpdateRequest;
54 55
56 logger.debug("missionInventoryUpdate with lootInventory =", lootInventory);
57
55 58 const { InventoryChanges, MissionRewards } = getRewards(lootInventory);
56 59
57 60 const { combinedInventoryChanges, TotalCredits, CreditsBonus, MissionCredits, FusionPoints } =
@@ -66,7 +69,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res): Promi
66 69 TotalCredits,
67 70 CreditsBonus,
68 71 MissionCredits,
69 ...(FusionPoints !== undefined && { FusionPoints })
72 FusionPoints
70 73 });
71 74 } catch (err) {
72 75 console.error("Error parsing JSON data:", err);
Modified src/services/missionInventoryUpdateService.ts +22 -11
@@ -54,12 +54,22 @@ const combineRewardAndLootInventory = (
54 54 const missionCredits = lootInventory.RegularCredits || 0;
55 55 const creditsBonus = rewardInventory.RegularCredits || 0;
56 56 const totalCredits = missionCredits + creditsBonus;
57 const FusionPoints = (lootInventory.FusionPoints || 0) + (rewardInventory.FusionPoints || 0) || undefined;
57 let FusionPoints = rewardInventory.FusionPoints || 0;
58 58
59 lootInventory.RegularCredits = totalCredits;
60 if (FusionPoints) {
61 lootInventory.FusionPoints = FusionPoints;
59 // Discharge Endo picked up during the mission
60 if (lootInventory.FusionBundles) {
61 for (const fusionBundle of lootInventory.FusionBundles) {
62 if (fusionBundle.ItemType in fusionBundles) {
63 FusionPoints += fusionBundles[fusionBundle.ItemType] * fusionBundle.ItemCount;
64 } else {
65 logger.error(`unknown fusion bundle: ${fusionBundle.ItemType}`);
66 }
67 }
68 lootInventory.FusionBundles = undefined;
62 69 }
70
71 lootInventory.RegularCredits = totalCredits;
72 lootInventory.FusionPoints = FusionPoints;
63 73 inventoryFields.forEach((field: IInventoryFieldType) => {
64 74 if (rewardInventory[field] && !lootInventory[field]) {
65 75 lootInventory[field] = [];
@@ -72,7 +82,7 @@ const combineRewardAndLootInventory = (
72 82 TotalCredits: [totalCredits, totalCredits],
73 83 CreditsBonus: [creditsBonus, creditsBonus],
74 84 MissionCredits: [missionCredits, missionCredits],
75 ...(FusionPoints !== undefined && { FusionPoints })
85 FusionPoints: FusionPoints
76 86 };
77 87 };
78 88
@@ -123,8 +133,9 @@ const creditBundles: Record<string, number> = {
123 133 };
124 134
125 135 const fusionBundles: Record<string, number> = {
126 "/Lotus/StoreItems/Upgrades/Mods/FusionBundles/UncommonFusionBundle": 50,
127 "/Lotus/StoreItems/Upgrades/Mods/FusionBundles/RareFusionBundle": 80
136 "/Lotus/Upgrades/Mods/FusionBundles/CommonFusionBundle": 15,
137 "/Lotus/Upgrades/Mods/FusionBundles/UncommonFusionBundle": 50,
138 "/Lotus/Upgrades/Mods/FusionBundles/RareFusionBundle": 80
128 139 };
129 140
130 141 const formatRewardsToInventoryType = (
@@ -136,12 +147,12 @@ const formatRewardsToInventoryType = (
136 147 if (reward.type in creditBundles) {
137 148 InventoryChanges.RegularCredits ??= 0;
138 149 InventoryChanges.RegularCredits += creditBundles[reward.type] * reward.itemCount;
139 } else if (reward.type in fusionBundles) {
140 InventoryChanges.FusionPoints ??= 0;
141 InventoryChanges.FusionPoints += fusionBundles[reward.type] * reward.itemCount;
142 150 } else {
143 151 const type = reward.type.replace("/Lotus/StoreItems/", "/Lotus/");
144 if (type in ExportUpgrades) {
152 if (type in fusionBundles) {
153 InventoryChanges.FusionPoints ??= 0;
154 InventoryChanges.FusionPoints += fusionBundles[type] * reward.itemCount;
155 } else if (type in ExportUpgrades) {
145 156 addRewardResponse(InventoryChanges, MissionRewards, type, reward.itemCount, "RawUpgrades");
146 157 } else if (type in ExportGear) {
147 158 addRewardResponse(InventoryChanges, MissionRewards, type, reward.itemCount, "Consumables");
Modified src/types/requestTypes.ts +4 -1
@@ -7,6 +7,7 @@ import {
7 7 ICrewShipSalvagedWeaponSkin,
8 8 IEvolutionProgress,
9 9 IMiscItem,
10 ITypeCount,
10 11 IMission,
11 12 IRawUpgrade,
12 13 ISeasonChallenge
@@ -45,6 +46,7 @@ export interface IMissionInventoryUpdateRequest {
45 46 Pistols?: IEquipmentClient[];
46 47 Suits?: IEquipmentClient[];
47 48 Melee?: IEquipmentClient[];
49 FusionBundles?: ITypeCount[];
48 50 RawUpgrades?: IRawUpgrade[];
49 51 MiscItems?: IMiscItem[];
50 52 Consumables?: IConsumable[];
@@ -52,9 +54,10 @@ export interface IMissionInventoryUpdateRequest {
52 54 RegularCredits?: number;
53 55 ChallengeProgress?: IChallengeProgress[];
54 56 RewardInfo?: IMissionInventoryUpdateRequestRewardInfo;
55 FusionPoints?: number;
56 57 Missions?: IMission;
57 58 EvolutionProgress?: IEvolutionProgress[];
59
60 FusionPoints?: number; // Not a part of the request, but we put it in this struct as an intermediate storage.
58 61 }
59 62
60 63 export interface IMissionInventoryUpdateRequestRewardInfo {