feat: syndicate initiation #638
8
package-lock.json
generated
8
package-lock.json
generated
@ -12,7 +12,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.14",
|
"warframe-public-export-plus": "^0.5.15",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
@ -3877,9 +3877,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/warframe-public-export-plus": {
|
"node_modules/warframe-public-export-plus": {
|
||||||
"version": "0.5.14",
|
"version": "0.5.15",
|
||||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.14.tgz",
|
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.15.tgz",
|
||||||
"integrity": "sha512-G6Jrs1PoETheYQjN2Mm6qVZeiIS5h2U8e+nHC3fPDVhLz3gZkbZShDOTCJ3JNAlP1NFrFYoBqUc6gMmN0Z9Acg=="
|
"integrity": "sha512-xsMgj1+lB2VPDCLuU88YsbwQiGQT5cNgjgNTk1iKx2ZpX31fu19tflTWrTHEJbSnqxuh/8h2LP5ZpBZV0a9fCg=="
|
||||||
},
|
},
|
||||||
"node_modules/warframe-riven-info": {
|
"node_modules/warframe-riven-info": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.14",
|
"warframe-public-export-plus": "^0.5.15",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
|
@ -40,9 +40,11 @@ import {
|
|||||||
ExportRecipes,
|
ExportRecipes,
|
||||||
ExportResources,
|
ExportResources,
|
||||||
ExportSentinels,
|
ExportSentinels,
|
||||||
|
ExportSyndicates,
|
||||||
ExportUpgrades
|
ExportUpgrades
|
||||||
} from "warframe-public-export-plus";
|
} from "warframe-public-export-plus";
|
||||||
import { createShip } from "./shipService";
|
import { createShip } from "./shipService";
|
||||||
|
import { handleStoreItemAcquisition } from "./purchaseService";
|
||||||
|
|
||||||
export const createInventory = async (
|
export const createInventory = async (
|
||||||
accountOwnerId: Types.ObjectId,
|
accountOwnerId: Types.ObjectId,
|
||||||
@ -553,11 +555,24 @@ export const syndicateSacrifice = async (
|
|||||||
accountId: string
|
accountId: string
|
||||||
): Promise<ISyndicateSacrificeResponse> => {
|
): Promise<ISyndicateSacrificeResponse> => {
|
||||||
const inventory = await getInventory(accountId);
|
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 = {
|
const res: ISyndicateSacrificeResponse = {
|
||||||
AffiliationTag: data.AffiliationTag,
|
AffiliationTag: data.AffiliationTag,
|
||||||
InventoryChanges: [],
|
InventoryChanges: {},
|
||||||
Level: data.SacrificeLevel,
|
Level: data.SacrificeLevel,
|
||||||
LevelIncrease: level <= 0 ? 1 : level,
|
LevelIncrease: level <= 0 ? 1 : level,
|
||||||
NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
|
NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
|
||||||
@ -567,6 +582,10 @@ export const syndicateSacrifice = async (
|
|||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
|
||||||
|
if (reward) {
|
||||||
|
res.InventoryChanges = (await handleStoreItemAcquisition(reward, accountId)).InventoryChanges;
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
|
|||||||
const purchaseResponse = await handleStoreItemAcquisition(
|
const purchaseResponse = await handleStoreItemAcquisition(
|
||||||
purchaseRequest.PurchaseParams.StoreItem,
|
purchaseRequest.PurchaseParams.StoreItem,
|
||||||
accountId,
|
accountId,
|
||||||
purchaseRequest.PurchaseParams.Quantity,
|
purchaseRequest.PurchaseParams.Quantity
|
||||||
"COMMON"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!purchaseResponse) throw new Error("purchase response was undefined");
|
if (!purchaseResponse) throw new Error("purchase response was undefined");
|
||||||
@ -160,11 +159,11 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
|
|||||||
return purchaseResponse;
|
return purchaseResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStoreItemAcquisition = async (
|
export const handleStoreItemAcquisition = async (
|
||||||
storeItemName: string,
|
storeItemName: string,
|
||||||
accountId: string,
|
accountId: string,
|
||||||
quantity: number,
|
quantity: number = 1,
|
||||||
durability: TRarity,
|
durability: TRarity = "COMMON",
|
||||||
ignorePurchaseQuantity: boolean = false
|
ignorePurchaseQuantity: boolean = false
|
||||||
): Promise<IPurchaseResponse> => {
|
): Promise<IPurchaseResponse> => {
|
||||||
let purchaseResponse = {
|
let purchaseResponse = {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { IInventoryChanges } from "./purchaseTypes";
|
||||||
|
|
||||||
export interface ISyndicateSacrifice {
|
export interface ISyndicateSacrifice {
|
||||||
AffiliationTag: string;
|
AffiliationTag: string;
|
||||||
SacrificeLevel: number;
|
SacrificeLevel: number;
|
||||||
@ -8,6 +10,6 @@ export interface ISyndicateSacrificeResponse {
|
|||||||
AffiliationTag: string;
|
AffiliationTag: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
LevelIncrease: number;
|
LevelIncrease: number;
|
||||||
InventoryChanges: any[];
|
InventoryChanges: IInventoryChanges;
|
||||||
NewEpisodeReward: boolean;
|
NewEpisodeReward: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user