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: include OneTimePurchases in inventoryChanges (#3180)

Closes #3178 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3180 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

b7c1bba3
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

2 个文件 +15 -21
Modified src/services/inventoryService.ts +9 -20
@@ -170,56 +170,45 @@ const setupAntique = (
170 170 inventory: TInventoryDatabaseDocument,
171 171 weaponType: string,
172 172 weaponId: Types.ObjectId,
173 inventoryChanges?: IInventoryChanges
173 inventoryChanges: IInventoryChanges
174 174 ): void => {
175 175 const meta = operatorAntiqueMeta[weaponType];
176 176 if (!meta) {
177 177 throw new Error(`unknown antique: ${weaponType}`);
178 178 }
179 179
180 const focusUpgradesAdded: object[] = [];
181 const focusLoadoutsAdded: object[] = [];
182
183 180 inventory.OneTimePurchases ??= [];
184 181 if (!inventory.OneTimePurchases.includes(weaponType)) {
185 182 inventory.OneTimePurchases.push(weaponType);
183 inventoryChanges.OneTimePurchases ??= [];
184 inventoryChanges.OneTimePurchases.push(weaponType);
186 185 }
187 186
188 187 if (!inventory.FocusUpgrades.some(x => x.ItemType === meta.focusAbility)) {
189 188 inventory.FocusUpgrades.push({ ItemType: meta.focusAbility });
190 focusUpgradesAdded.push({ ItemType: meta.focusAbility });
189 inventoryChanges.FocusUpgrades ??= [];
190 inventoryChanges.FocusUpgrades.push({ ItemType: meta.focusAbility });
191 191 }
192 192 for (const upgradeType of meta.ultimateUpgrades) {
193 193 if (!inventory.FocusUpgrades.some(x => x.ItemType === upgradeType)) {
194 194 inventory.FocusUpgrades.push({ ItemType: upgradeType, Level: 0 });
195 focusUpgradesAdded.push({ ItemType: upgradeType, Level: 0 });
195 inventoryChanges.FocusUpgrades ??= [];
196 inventoryChanges.FocusUpgrades.push({ ItemType: upgradeType, Level: 0 });
196 197 }
197 198 }
198 199
199 200 inventory.FocusLoadouts ??= [];
201 inventoryChanges.FocusLoadouts ??= [];
200 202 if (!inventory.FocusLoadouts.some(x => x.FocusAbility === meta.focusAbility)) {
201 203 inventory.FocusLoadouts.push({
202 204 FocusAbility: meta.focusAbility,
203 205 Preset: { ItemId: weaponId, mod: 0, cus: 0 }
204 206 });
205 focusLoadoutsAdded.push({
207 inventoryChanges.FocusLoadouts.push({
206 208 FocusAbility: meta.focusAbility,
207 209 Preset: { ItemId: toOid(weaponId), mod: 0, cus: 0 }
208 210 });
209 211 }
210
211 if (inventoryChanges) {
212 if (focusUpgradesAdded.length) {
213 const key = "FocusUpgrades";
214 const existing = inventoryChanges[key] as object[] | undefined;
215 inventoryChanges[key] = existing ? existing.concat(focusUpgradesAdded) : focusUpgradesAdded;
216 }
217 if (focusLoadoutsAdded.length) {
218 const key = "FocusLoadouts";
219 const existing = inventoryChanges[key] as object[] | undefined;
220 inventoryChanges[key] = existing ? existing.concat(focusLoadoutsAdded) : focusLoadoutsAdded;
221 }
222 }
223 212 };
224 213
225 214 export const createInventory = async (
Modified src/types/purchaseTypes.ts +6 -1
@@ -11,7 +11,9 @@ import type {
11 11 IKubrowPetPrintClient,
12 12 IUpgradeClient,
13 13 IQuestKeyClient,
14 IRawUpgrade
14 IRawUpgrade,
15 IFocusUpgrade,
16 IFocusLoadoutClient
15 17 } from "./inventoryTypes/inventoryTypes.ts";
16 18
17 19 export enum PurchaseSource {
@@ -88,6 +90,9 @@ export type IInventoryChanges = {
88 90 RawUpgrades?: IRawUpgrade[];
89 91 Upgrades?: IUpgradeClient[]; // TOVERIFY
90 92 QuestKeys?: IQuestKeyClient[];
93 OneTimePurchases?: string[];
94 FocusUpgrades?: IFocusUpgrade[];
95 FocusLoadouts?: IFocusLoadoutClient[];
91 96 } & Record<
92 97 Exclude<
93 98 string,