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: preinstall potatoes on non-crafted equipment (#1037)

Fixes #1028 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1037 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>

32cc8dc6
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +61 -14
Modified src/services/inventoryService.ts +61 -14
@@ -36,7 +36,12 @@ import {
36 36 } from "../types/requestTypes";
37 37 import { logger } from "@/src/utils/logger";
38 38 import { getExalted, getKeyChainItems } from "@/src/services/itemDataService";
39 import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
39 import {
40 EquipmentFeatures,
41 IEquipmentClient,
42 IEquipmentDatabase,
43 IItemConfig
44 } from "../types/inventoryTypes/commonInventoryTypes";
40 45 import {
41 46 ExportArcanes,
42 47 ExportBundles,
@@ -341,7 +346,14 @@ export const addItem = async (
341 346 if (typeName in ExportWeapons) {
342 347 const weapon = ExportWeapons[typeName];
343 348 if (weapon.totalDamage != 0) {
344 const inventoryChanges = addEquipment(inventory, weapon.productCategory, typeName);
349 const inventoryChanges = addEquipment(
350 inventory,
351 weapon.productCategory,
352 typeName,
353 [],
354 {},
355 premiumPurchase ? { Features: EquipmentFeatures.DOUBLE_CAPACITY } : {}
356 );
345 357 if (weapon.additionalItems) {
346 358 for (const item of weapon.additionalItems) {
347 359 combineInventoryChanges(inventoryChanges, (await addItem(inventory, item, 1)).InventoryChanges);
@@ -421,7 +433,12 @@ export const addItem = async (
421 433 default: {
422 434 return {
423 435 InventoryChanges: {
424 ...addPowerSuit(inventory, typeName),
436 ...addPowerSuit(
437 inventory,
438 typeName,
439 {},
440 premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
441 ),
425 442 ...occupySlot(inventory, InventorySlot.SUITS, premiumPurchase)
426 443 }
427 444 };
@@ -429,7 +446,12 @@ export const addItem = async (
429 446 case "Archwing": {
430 447 return {
431 448 InventoryChanges: {
432 ...addSpaceSuit(inventory, typeName),
449 ...addSpaceSuit(
450 inventory,
451 typeName,
452 {},
453 premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
454 ),
433 455 ...occupySlot(inventory, InventorySlot.SPACESUITS, premiumPurchase)
434 456 }
435 457 };
@@ -437,7 +459,12 @@ export const addItem = async (
437 459 case "EntratiMech": {
438 460 return {
439 461 InventoryChanges: {
440 ...addMechSuit(inventory, typeName),
462 ...addMechSuit(
463 inventory,
464 typeName,
465 {},
466 premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
467 ),
441 468 ...occupySlot(inventory, InventorySlot.MECHSUITS, premiumPurchase)
442 469 }
443 470 };
@@ -471,7 +498,12 @@ export const addItem = async (
471 498 case "Sentinels": {
472 499 return {
473 500 InventoryChanges: {
474 ...addSentinel(inventory, typeName),
501 ...addSentinel(
502 inventory,
503 typeName,
504 {},
505 premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
506 ),
475 507 ...occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase)
476 508 }
477 509 };
@@ -572,7 +604,8 @@ export const applyDefaultUpgrades = (
572 604 export const addSentinel = (
573 605 inventory: TInventoryDatabaseDocument,
574 606 sentinelName: string,
575 inventoryChanges: IInventoryChanges = {}
607 inventoryChanges: IInventoryChanges = {},
608 features: number | undefined = undefined
576 609 ): IInventoryChanges => {
577 610 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
578 611 if (ExportSentinels[sentinelName]?.defaultWeapon) {
@@ -582,7 +615,8 @@ export const addSentinel = (
582 615 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
583 616 const configs: IItemConfig[] = applyDefaultUpgrades(inventory, ExportSentinels[sentinelName]?.defaultUpgrades);
584 617
585 const sentinelIndex = inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0 }) - 1;
618 const sentinelIndex =
619 inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0, Features: features }) - 1;
586 620 inventoryChanges.Sentinels ??= [];
587 621 inventoryChanges.Sentinels.push(inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>());
588 622
@@ -602,7 +636,8 @@ export const addSentinelWeapon = (
602 636 export const addPowerSuit = (
603 637 inventory: TInventoryDatabaseDocument,
604 638 powersuitName: string,
605 inventoryChanges: IInventoryChanges = {}
639 inventoryChanges: IInventoryChanges = {},
640 features: number | undefined = undefined
606 641 ): IInventoryChanges => {
607 642 const specialItems = getExalted(powersuitName);
608 643 if (specialItems) {
@@ -610,7 +645,8 @@ export const addPowerSuit = (
610 645 addSpecialItem(inventory, specialItem, inventoryChanges);
611 646 }
612 647 }
613 const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
648 const suitIndex =
649 inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) - 1;
614 650 inventoryChanges.Suits ??= [];
615 651 inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
616 652 return inventoryChanges;
@@ -619,7 +655,8 @@ export const addPowerSuit = (
619 655 export const addMechSuit = (
620 656 inventory: TInventoryDatabaseDocument,
621 657 mechsuitName: string,
622 inventoryChanges: IInventoryChanges = {}
658 inventoryChanges: IInventoryChanges = {},
659 features: number | undefined = undefined
623 660 ): IInventoryChanges => {
624 661 const specialItems = getExalted(mechsuitName);
625 662 if (specialItems) {
@@ -627,7 +664,9 @@ export const addMechSuit = (
627 664 addSpecialItem(inventory, specialItem, inventoryChanges);
628 665 }
629 666 }
630 const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
667 const suitIndex =
668 inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) -
669 1;
631 670 inventoryChanges.MechSuits ??= [];
632 671 inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
633 672 return inventoryChanges;
@@ -656,9 +695,17 @@ export const addSpecialItem = (
656 695 export const addSpaceSuit = (
657 696 inventory: TInventoryDatabaseDocument,
658 697 spacesuitName: string,
659 inventoryChanges: IInventoryChanges = {}
698 inventoryChanges: IInventoryChanges = {},
699 features: number | undefined = undefined
660 700 ): IInventoryChanges => {
661 const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
701 const suitIndex =
702 inventory.SpaceSuits.push({
703 ItemType: spacesuitName,
704 Configs: [],
705 UpgradeVer: 101,
706 XP: 0,
707 Features: features
708 }) - 1;
662 709 inventoryChanges.SpaceSuits ??= [];
663 710 inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
664 711 return inventoryChanges;