XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

feat: syndicate initiation (#638)

735f0b88
Sainan <sainan@calamity.inc>
提交于

代码差异

5 个文件 +34 -14
Modified package-lock.json +4 -4
@@ -12,7 +12,7 @@
12 12 "copyfiles": "^2.4.1",
13 13 "express": "^5",
14 14 "mongoose": "^8.9.2",
15 "warframe-public-export-plus": "^0.5.14",
15 "warframe-public-export-plus": "^0.5.15",
16 16 "warframe-riven-info": "^0.1.2",
17 17 "winston": "^3.17.0",
18 18 "winston-daily-rotate-file": "^5.0.0"
@@ -3877,9 +3877,9 @@
3877 3877 }
3878 3878 },
3879 3879 "node_modules/warframe-public-export-plus": {
3880 "version": "0.5.14",
3881 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.14.tgz",
3882 "integrity": "sha512-G6Jrs1PoETheYQjN2Mm6qVZeiIS5h2U8e+nHC3fPDVhLz3gZkbZShDOTCJ3JNAlP1NFrFYoBqUc6gMmN0Z9Acg=="
3880 "version": "0.5.15",
3881 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.15.tgz",
3882 "integrity": "sha512-xsMgj1+lB2VPDCLuU88YsbwQiGQT5cNgjgNTk1iKx2ZpX31fu19tflTWrTHEJbSnqxuh/8h2LP5ZpBZV0a9fCg=="
3883 3883 },
3884 3884 "node_modules/warframe-riven-info": {
3885 3885 "version": "0.1.2",
Modified package.json +1 -1
@@ -16,7 +16,7 @@
16 16 "copyfiles": "^2.4.1",
17 17 "express": "^5",
18 18 "mongoose": "^8.9.2",
19 "warframe-public-export-plus": "^0.5.14",
19 "warframe-public-export-plus": "^0.5.15",
20 20 "warframe-riven-info": "^0.1.2",
21 21 "winston": "^3.17.0",
22 22 "winston-daily-rotate-file": "^5.0.0"
Modified src/services/inventoryService.ts +22 -3
@@ -40,9 +40,11 @@ import {
40 40 ExportRecipes,
41 41 ExportResources,
42 42 ExportSentinels,
43 ExportSyndicates,
43 44 ExportUpgrades
44 45 } from "warframe-public-export-plus";
45 46 import { createShip } from "./shipService";
47 import { handleStoreItemAcquisition } from "./purchaseService";
46 48
47 49 export const createInventory = async (
48 50 accountOwnerId: Types.ObjectId,
@@ -553,11 +555,24 @@ export const syndicateSacrifice = async (
553 555 accountId: string
554 556 ): Promise<ISyndicateSacrificeResponse> => {
555 557 const inventory = await getInventory(accountId);
556 const syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag);
557 const level = data.SacrificeLevel - (syndicate?.Title ?? 0);
558
559 let syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag);
560 if (!syndicate) {
561 syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: data.AffiliationTag, Standing: 0 }) - 1];
562 }
563
564 let reward: string | undefined;
565
566 const manifest = ExportSyndicates[data.AffiliationTag];
567 if (manifest?.initiationReward && data.SacrificeLevel == 0) {
568 reward = manifest.initiationReward;
569 syndicate.Initiated = true;
570 }
571
572 const level = data.SacrificeLevel - (syndicate.Title ?? 0);
558 573 const res: ISyndicateSacrificeResponse = {
559 574 AffiliationTag: data.AffiliationTag,
560 InventoryChanges: [],
575 InventoryChanges: {},
561 576 Level: data.SacrificeLevel,
562 577 LevelIncrease: level <= 0 ? 1 : level,
563 578 NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
@@ -567,6 +582,10 @@ export const syndicateSacrifice = async (
567 582
568 583 await inventory.save();
569 584
585 if (reward) {
586 res.InventoryChanges = (await handleStoreItemAcquisition(reward, accountId)).InventoryChanges;
587 }
588
570 589 return res;
571 590 };
572 591
Modified src/services/purchaseService.ts +4 -5
@@ -56,8 +56,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
56 56 const purchaseResponse = await handleStoreItemAcquisition(
57 57 purchaseRequest.PurchaseParams.StoreItem,
58 58 accountId,
59 purchaseRequest.PurchaseParams.Quantity,
60 "COMMON"
59 purchaseRequest.PurchaseParams.Quantity
61 60 );
62 61
63 62 if (!purchaseResponse) throw new Error("purchase response was undefined");
@@ -160,11 +159,11 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
160 159 return purchaseResponse;
161 160 };
162 161
163 const handleStoreItemAcquisition = async (
162 export const handleStoreItemAcquisition = async (
164 163 storeItemName: string,
165 164 accountId: string,
166 quantity: number,
167 durability: TRarity,
165 quantity: number = 1,
166 durability: TRarity = "COMMON",
168 167 ignorePurchaseQuantity: boolean = false
169 168 ): Promise<IPurchaseResponse> => {
170 169 let purchaseResponse = {
Modified src/types/syndicateTypes.ts +3 -1
@@ -1,3 +1,5 @@
1 import { IInventoryChanges } from "./purchaseTypes";
2
1 3 export interface ISyndicateSacrifice {
2 4 AffiliationTag: string;
3 5 SacrificeLevel: number;
@@ -8,6 +10,6 @@ export interface ISyndicateSacrificeResponse {
8 10 AffiliationTag: string;
9 11 Level: number;
10 12 LevelIncrease: number;
11 InventoryChanges: any[];
13 InventoryChanges: IInventoryChanges;
12 14 NewEpisodeReward: boolean;
13 15 }