forked from OpenWF/SpaceNinjaServer
feat: syndicate initiation (#638)
This commit is contained in:
parent
8fe9b89143
commit
735f0b885d
8
package-lock.json
generated
8
package-lock.json
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user