fix: occupy a sentinel slot for sentinel weapons
All checks were successful
Build / build (22) (push) Successful in 41s
Build / build (18) (push) Successful in 1m3s
Build / build (20) (push) Successful in 1m3s
Build / build (22) (pull_request) Successful in 59s
Build / build (18) (pull_request) Successful in 44s
Build / build (20) (pull_request) Successful in 1m0s

This commit is contained in:
Sainan 2025-03-11 18:07:37 +01:00
parent 1b54bcd1e0
commit 92f8ab1dcb

View File

@ -518,15 +518,7 @@ export const addItem = async (
switch (typeName.substr(1).split("/")[2]) { switch (typeName.substr(1).split("/")[2]) {
case "Sentinels": { case "Sentinels": {
return { return {
InventoryChanges: { InventoryChanges: addSentinel(inventory, typeName, premiumPurchase)
...addSentinel(
inventory,
typeName,
{},
premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
),
...occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase)
}
}; };
} }
case "Game": { case "Game": {
@ -622,20 +614,24 @@ export const applyDefaultUpgrades = (
}; };
//TODO: maybe genericMethod for all the add methods, they share a lot of logic //TODO: maybe genericMethod for all the add methods, they share a lot of logic
export const addSentinel = ( const addSentinel = (
inventory: TInventoryDatabaseDocument, inventory: TInventoryDatabaseDocument,
sentinelName: string, sentinelName: string,
inventoryChanges: IInventoryChanges = {}, premiumPurchase: boolean,
features: number | undefined = undefined inventoryChanges: IInventoryChanges = {}
): IInventoryChanges => { ): IInventoryChanges => {
// Sentinel itself occupies a slot in the sentinels bin
combineInventoryChanges(inventoryChanges, occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase));
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (ExportSentinels[sentinelName]?.defaultWeapon) { if (ExportSentinels[sentinelName]?.defaultWeapon) {
addSentinelWeapon(inventory, ExportSentinels[sentinelName].defaultWeapon, inventoryChanges); addSentinelWeapon(inventory, ExportSentinels[sentinelName].defaultWeapon, premiumPurchase, inventoryChanges);
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const configs: IItemConfig[] = applyDefaultUpgrades(inventory, ExportSentinels[sentinelName]?.defaultUpgrades); const configs: IItemConfig[] = applyDefaultUpgrades(inventory, ExportSentinels[sentinelName]?.defaultUpgrades);
const features = premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined;
const sentinelIndex = const sentinelIndex =
inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0, Features: features }) - 1; inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0, Features: features }) - 1;
inventoryChanges.Sentinels ??= []; inventoryChanges.Sentinels ??= [];
@ -644,11 +640,15 @@ export const addSentinel = (
return inventoryChanges; return inventoryChanges;
}; };
export const addSentinelWeapon = ( const addSentinelWeapon = (
inventory: TInventoryDatabaseDocument, inventory: TInventoryDatabaseDocument,
typeName: string, typeName: string,
premiumPurchase: boolean,
inventoryChanges: IInventoryChanges inventoryChanges: IInventoryChanges
): void => { ): void => {
// Sentinel weapons also occupy a slot in the sentinels bin
combineInventoryChanges(inventoryChanges, occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase));
const index = inventory.SentinelWeapons.push({ ItemType: typeName, XP: 0 }) - 1; const index = inventory.SentinelWeapons.push({ ItemType: typeName, XP: 0 }) - 1;
inventoryChanges.SentinelWeapons ??= []; inventoryChanges.SentinelWeapons ??= [];
inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON<IEquipmentClient>()); inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON<IEquipmentClient>());