feat: purchase modular weapon from daily special #1217

Merged
Sainan merged 5 commits from modular-weapon-purchase into main 2025-03-17 05:10:45 -07:00
2 changed files with 10 additions and 4 deletions
Showing only changes of commit 22be3cc707 - Show all commits

View File

@ -28,13 +28,15 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
const category = modularWeaponTypes[data.WeaponType]; const category = modularWeaponTypes[data.WeaponType];
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(data.Parts)); const defaultUpgrades = getDefaultUpgrades(data.Parts);
const configs = applyDefaultUpgrades(inventory, defaultUpgrades);
// Give weapon
const inventoryChanges: IInventoryChanges = { const inventoryChanges: IInventoryChanges = {
...addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs }), ...addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs }),
...occupySlot(inventory, productCategoryToInventoryBin(category)!, false) ...occupySlot(inventory, productCategoryToInventoryBin(category)!, false)
}; };
if (defaultUpgrades) {
inventoryChanges.RawUpgrades = defaultUpgrades.map(x => ({ ItemType: x.ItemType, ItemCount: 1 }));
}
// Remove credits & parts // Remove credits & parts
const miscItemChanges = []; const miscItemChanges = [];

View File

@ -39,7 +39,8 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
const weaponInfo = getSaleInfos(partTypeToParts, payload.Revision).find(x => x.Name == payload.SaleName)! const weaponInfo = getSaleInfos(partTypeToParts, payload.Revision).find(x => x.Name == payload.SaleName)!
.Weapons[payload.ItemIndex]; .Weapons[payload.ItemIndex];
const category = modularWeaponTypes[weaponInfo.ItemType]; const category = modularWeaponTypes[weaponInfo.ItemType];
const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(weaponInfo.ModularParts)); const defaultUpgrades = getDefaultUpgrades(weaponInfo.ModularParts);
const configs = applyDefaultUpgrades(inventory, defaultUpgrades);
const inventoryChanges: IInventoryChanges = { const inventoryChanges: IInventoryChanges = {
...addEquipment( ...addEquipment(
inventory, inventory,
@ -62,6 +63,9 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
...occupySlot(inventory, productCategoryToInventoryBin(category)!, true), ...occupySlot(inventory, productCategoryToInventoryBin(category)!, true),
...updateCurrency(inventory, weaponInfo.PremiumPrice, true) ...updateCurrency(inventory, weaponInfo.PremiumPrice, true)
}; };
if (defaultUpgrades) {
inventoryChanges.RawUpgrades = defaultUpgrades.map(x => ({ ItemType: x.ItemType, ItemCount: 1 }));
}
await inventory.save(); await inventory.save();
res.json({ res.json({
InventoryChanges: inventoryChanges InventoryChanges: inventoryChanges