返回提交历史
Modified
src/services/inventoryService.ts
+12
-22
Modified
src/types/purchaseTypes.ts
+4
-1
XFEstudio/SpaceNinjaServer
chore: properly type equipment in IInventoryChanges (#973)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/973 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
ac6ac191
代码差异
2 个文件
+16
-23
@@ -234,7 +234,7 @@ export const addItem = async (
234
234
InventoryChanges: {
235
235
Ships: [
236
236
{
237
ItemId: { $oid: oid },
237
ItemId: { $oid: oid.toString() },
238
238
ItemType: typeName
239
239
}
240
240
]
@@ -499,7 +499,7 @@ export const addItem = async (
499
499
const horseIndex = inventory.Horses.push({ ItemType: typeName });
500
500
return {
501
501
InventoryChanges: {
502
Horses: inventory.Horses[horseIndex - 1].toJSON()
502
Horses: [inventory.Horses[horseIndex - 1].toJSON<IEquipmentClient>()]
503
503
}
504
504
};
505
505
}
@@ -572,9 +572,7 @@ export const addSentinel = (
572
572
addMods(inventory, modsToGive);
573
573
const sentinelIndex = inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0 }) - 1;
574
574
inventoryChanges.Sentinels ??= [];
575
(inventoryChanges.Sentinels as IEquipmentClient[]).push(
576
inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>()
577
);
575
inventoryChanges.Sentinels.push(inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>());
578
576
579
577
return inventoryChanges;
580
578
};
@@ -586,9 +584,7 @@ export const addSentinelWeapon = (
586
584
): void => {
587
585
const index = inventory.SentinelWeapons.push({ ItemType: typeName, XP: 0 }) - 1;
588
586
inventoryChanges.SentinelWeapons ??= [];
589
(inventoryChanges.SentinelWeapons as IEquipmentClient[]).push(
590
inventory.SentinelWeapons[index].toJSON<IEquipmentClient>()
591
);
587
inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON<IEquipmentClient>());
592
588
};
593
589
594
590
export const addPowerSuit = (
@@ -604,7 +600,7 @@ export const addPowerSuit = (
604
600
}
605
601
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
606
602
inventoryChanges.Suits ??= [];
607
(inventoryChanges.Suits as IEquipmentClient[]).push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
603
inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
608
604
return inventoryChanges;
609
605
};
610
606
@@ -621,7 +617,7 @@ export const addMechSuit = (
621
617
}
622
618
const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
623
619
inventoryChanges.MechSuits ??= [];
624
(inventoryChanges.MechSuits as IEquipmentClient[]).push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
620
inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
625
621
return inventoryChanges;
626
622
};
627
623
@@ -642,9 +638,7 @@ export const addSpecialItem = (
642
638
XP: 0
643
639
}) - 1;
644
640
inventoryChanges.SpecialItems ??= [];
645
(inventoryChanges.SpecialItems as IEquipmentClient[]).push(
646
inventory.SpecialItems[specialItemIndex].toJSON<IEquipmentClient>()
647
);
641
inventoryChanges.SpecialItems.push(inventory.SpecialItems[specialItemIndex].toJSON<IEquipmentClient>());
648
642
};
649
643
650
644
export const addSpaceSuit = (
@@ -654,9 +648,7 @@ export const addSpaceSuit = (
654
648
): IInventoryChanges => {
655
649
const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
656
650
inventoryChanges.SpaceSuits ??= [];
657
(inventoryChanges.SpaceSuits as IEquipmentClient[]).push(
658
inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>()
659
);
651
inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
660
652
return inventoryChanges;
661
653
};
662
654
@@ -798,7 +790,7 @@ export const addEquipment = (
798
790
}) - 1;
799
791
800
792
inventoryChanges[category] ??= [];
801
(inventoryChanges[category] as IEquipmentClient[]).push(inventory[category][index].toJSON<IEquipmentClient>());
793
inventoryChanges[category].push(inventory[category][index].toJSON<IEquipmentClient>());
802
794
return inventoryChanges;
803
795
};
804
796
@@ -838,7 +830,7 @@ const addCrewShip = (
838
830
}
839
831
const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
840
832
inventoryChanges.CrewShips ??= [];
841
(inventoryChanges.CrewShips as IEquipmentClient[]).push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
833
inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
842
834
return inventoryChanges;
843
835
};
844
836
@@ -852,9 +844,7 @@ const addCrewShipHarness = (
852
844
}
853
845
const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
854
846
inventoryChanges.CrewShipHarnesses ??= [];
855
(inventoryChanges.CrewShipHarnesses as IEquipmentClient[]).push(
856
inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>()
857
);
847
inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
858
848
return inventoryChanges;
859
849
};
860
850
@@ -868,7 +858,7 @@ const addMotorcycle = (
868
858
}
869
859
const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
870
860
inventoryChanges.Motorcycles ??= [];
871
(inventoryChanges.Motorcycles as IEquipmentClient[]).push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
861
inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
872
862
return inventoryChanges;
873
863
};
874
864
@@ -1,4 +1,5 @@
1
import { IInfestedFoundryClient } from "./inventoryTypes/inventoryTypes";
1
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
2
import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
2
3
3
4
export interface IPurchaseRequest {
4
5
PurchaseParams: IPurchaseParams;
@@ -29,6 +30,8 @@ export interface ICurrencyChanges {
29
30
30
31
export type IInventoryChanges = {
31
32
[_ in SlotNames]?: IBinChanges;
33
} & {
34
[_ in TEquipmentKey]?: IEquipmentClient[];
32
35
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
33
36
string,
34
37
IBinChanges | number | object[] | IInfestedFoundryClient