diff --git a/package-lock.json b/package-lock.json index 824848de..6c646266 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.14", + "warframe-public-export-plus": "^0.5.15", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -3877,9 +3877,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.14", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.14.tgz", - "integrity": "sha512-G6Jrs1PoETheYQjN2Mm6qVZeiIS5h2U8e+nHC3fPDVhLz3gZkbZShDOTCJ3JNAlP1NFrFYoBqUc6gMmN0Z9Acg==" + "version": "0.5.15", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.15.tgz", + "integrity": "sha512-xsMgj1+lB2VPDCLuU88YsbwQiGQT5cNgjgNTk1iKx2ZpX31fu19tflTWrTHEJbSnqxuh/8h2LP5ZpBZV0a9fCg==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index 4ad256c5..6f962ace 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.14", + "warframe-public-export-plus": "^0.5.15", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 8b8f5167..34e621b5 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -40,9 +40,11 @@ import { ExportRecipes, ExportResources, ExportSentinels, + ExportSyndicates, ExportUpgrades } from "warframe-public-export-plus"; import { createShip } from "./shipService"; +import { handleStoreItemAcquisition } from "./purchaseService"; export const createInventory = async ( accountOwnerId: Types.ObjectId, @@ -553,11 +555,24 @@ export const syndicateSacrifice = async ( accountId: string ): Promise => { const inventory = await getInventory(accountId); - const syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag); - const level = data.SacrificeLevel - (syndicate?.Title ?? 0); + + let syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag); + if (!syndicate) { + syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: data.AffiliationTag, Standing: 0 }) - 1]; + } + + let reward: string | undefined; + + const manifest = ExportSyndicates[data.AffiliationTag]; + if (manifest?.initiationReward && data.SacrificeLevel == 0) { + reward = manifest.initiationReward; + syndicate.Initiated = true; + } + + const level = data.SacrificeLevel - (syndicate.Title ?? 0); const res: ISyndicateSacrificeResponse = { AffiliationTag: data.AffiliationTag, - InventoryChanges: [], + InventoryChanges: {}, Level: data.SacrificeLevel, LevelIncrease: level <= 0 ? 1 : level, NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate" @@ -567,6 +582,10 @@ export const syndicateSacrifice = async ( await inventory.save(); + if (reward) { + res.InventoryChanges = (await handleStoreItemAcquisition(reward, accountId)).InventoryChanges; + } + return res; }; diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index e0104ca2..fe7da772 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -56,8 +56,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI const purchaseResponse = await handleStoreItemAcquisition( purchaseRequest.PurchaseParams.StoreItem, accountId, - purchaseRequest.PurchaseParams.Quantity, - "COMMON" + purchaseRequest.PurchaseParams.Quantity ); if (!purchaseResponse) throw new Error("purchase response was undefined"); @@ -160,11 +159,11 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI return purchaseResponse; }; -const handleStoreItemAcquisition = async ( +export const handleStoreItemAcquisition = async ( storeItemName: string, accountId: string, - quantity: number, - durability: TRarity, + quantity: number = 1, + durability: TRarity = "COMMON", ignorePurchaseQuantity: boolean = false ): Promise => { let purchaseResponse = { diff --git a/src/types/syndicateTypes.ts b/src/types/syndicateTypes.ts index fae4e446..741f3760 100644 --- a/src/types/syndicateTypes.ts +++ b/src/types/syndicateTypes.ts @@ -1,3 +1,5 @@ +import { IInventoryChanges } from "./purchaseTypes"; + export interface ISyndicateSacrifice { AffiliationTag: string; SacrificeLevel: number; @@ -8,6 +10,6 @@ export interface ISyndicateSacrificeResponse { AffiliationTag: string; Level: number; LevelIncrease: number; - InventoryChanges: any[]; + InventoryChanges: IInventoryChanges; NewEpisodeReward: boolean; }