feat: syndicate initiation

This commit is contained in:
Sainan 2024-12-24 00:22:48 +01:00
parent 8ad979ab11
commit b8e1ae1b2b
5 changed files with 34 additions and 14 deletions

8
package-lock.json generated
View File

@ -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",

View File

@ -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"

View File

@ -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<ISyndicateSacrificeResponse> => {
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;
};

View File

@ -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<IPurchaseResponse> => {
let purchaseResponse = {

View File

@ -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;
}