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: claimJunctionChallengeReward (#2289)

Closes #2285 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2289 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

c9edef39
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

6 个文件 +51 -9
Modified package-lock.json +4 -4
@@ -22,7 +22,7 @@
22 22 "ncp": "^2.0.0",
23 23 "typescript": "^5.5",
24 24 "undici": "^7.10.0",
25 "warframe-public-export-plus": "^0.5.70",
25 "warframe-public-export-plus": "^0.5.71",
26 26 "warframe-riven-info": "^0.1.2",
27 27 "winston": "^3.17.0",
28 28 "winston-daily-rotate-file": "^5.0.0",
@@ -3388,9 +3388,9 @@
3388 3388 }
3389 3389 },
3390 3390 "node_modules/warframe-public-export-plus": {
3391 "version": "0.5.70",
3392 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.70.tgz",
3393 "integrity": "sha512-d5dQ/a0rakQnW9tl1HitST8439jDvEgMhkkntQIw7HmdM7s7mvIxvaYSl5wjlYawpUVfGyvGBdZVoAJ7kkQRWw=="
3391 "version": "0.5.71",
3392 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.71.tgz",
3393 "integrity": "sha512-TCS2wPRsBzuURJlIMDhygAHaLsKVZ7dGuC73WZ/iMyn3gKVwA98nnaIj24D+UceWS08fwq4ilWAfUzHJd6X29A=="
3394 3394 },
3395 3395 "node_modules/warframe-riven-info": {
3396 3396 "version": "0.1.2",
Modified package.json +1 -1
@@ -36,7 +36,7 @@
36 36 "ncp": "^2.0.0",
37 37 "typescript": "^5.5",
38 38 "undici": "^7.10.0",
39 "warframe-public-export-plus": "^0.5.70",
39 "warframe-public-export-plus": "^0.5.71",
40 40 "warframe-riven-info": "^0.1.2",
41 41 "winston": "^3.17.0",
42 42 "winston-daily-rotate-file": "^5.0.0",
Added src/controllers/api/claimJunctionChallengeRewardController.ts +35 -0
@@ -0,0 +1,35 @@
1 import { getJSONfromString } from "@/src/helpers/stringHelpers";
2 import { combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
3 import { getAccountIdForRequest } from "@/src/services/loginService";
4 import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
5 import { RequestHandler } from "express";
6 import { ExportChallenges } from "warframe-public-export-plus";
7
8 export const claimJunctionChallengeRewardController: RequestHandler = async (req, res) => {
9 const accountId = await getAccountIdForRequest(req);
10 const inventory = await getInventory(accountId);
11 const data = getJSONfromString<IClaimJunctionChallengeRewardRequest>(String(req.body));
12 const challengeProgress = inventory.ChallengeProgress.find(x => x.Name == data.Challenge)!;
13 if (challengeProgress.ReceivedJunctionReward) {
14 throw new Error(`attempt to double-claim junction reward`);
15 }
16 challengeProgress.ReceivedJunctionReward = true;
17 inventory.ClaimedJunctionChallengeRewards ??= [];
18 inventory.ClaimedJunctionChallengeRewards.push(data.Challenge);
19 const challengeMeta = Object.entries(ExportChallenges).find(arr => arr[0].endsWith("/" + data.Challenge))![1];
20 const inventoryChanges = {};
21 for (const reward of challengeMeta.countedRewards!) {
22 combineInventoryChanges(
23 inventoryChanges,
24 (await handleStoreItemAcquisition(reward.StoreItem, inventory, reward.ItemCount)).InventoryChanges
25 );
26 }
27 await inventory.save();
28 res.json({
29 inventoryChanges: inventoryChanges // Yeah, it's "inventoryChanges" in the response here.
30 });
31 };
32
33 interface IClaimJunctionChallengeRewardRequest {
34 Challenge: string;
35 }
Modified src/models/inventoryModels/inventoryModel.ts +6 -3
@@ -483,8 +483,9 @@ personalGoalProgressSchema.set("toJSON", {
483 483 const challengeProgressSchema = new Schema<IChallengeProgress>(
484 484 {
485 485 Progress: Number,
486 Name: String,
487 Completed: [String]
486 Completed: { type: [String], default: undefined },
487 ReceivedJunctionReward: Boolean,
488 Name: { type: String, required: true }
488 489 },
489 490 { _id: false }
490 491 );
@@ -1777,7 +1778,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1777 1778 BrandedSuits: { type: [Schema.Types.ObjectId], default: undefined },
1778 1779 LockedWeaponGroup: { type: lockedWeaponGroupSchema, default: undefined },
1779 1780
1780 HubNpcCustomizations: { type: [hubNpcCustomizationSchema], default: undefined }
1781 HubNpcCustomizations: { type: [hubNpcCustomizationSchema], default: undefined },
1782
1783 ClaimedJunctionChallengeRewards: { type: [String], default: undefined }
1781 1784 },
1782 1785 { timestamps: { createdAt: "Created", updatedAt: false } }
1783 1786 );
Modified src/routes/api.ts +2 -0
@@ -19,6 +19,7 @@ import { changeDojoRootController } from "@/src/controllers/api/changeDojoRootCo
19 19 import { changeGuildRankController } from "@/src/controllers/api/changeGuildRankController";
20 20 import { checkDailyMissionBonusController } from "@/src/controllers/api/checkDailyMissionBonusController";
21 21 import { claimCompletedRecipeController } from "@/src/controllers/api/claimCompletedRecipeController";
22 import { claimJunctionChallengeRewardController } from "@/src/controllers/api/claimJunctionChallengeRewardController";
22 23 import { claimLibraryDailyTaskRewardController } from "@/src/controllers/api/claimLibraryDailyTaskRewardController";
23 24 import { clearDialogueHistoryController } from "@/src/controllers/api/clearDialogueHistoryController";
24 25 import { clearNewEpisodeRewardController } from "@/src/controllers/api/clearNewEpisodeRewardController";
@@ -237,6 +238,7 @@ apiRouter.post("/artifacts.php", artifactsController);
237 238 apiRouter.post("/artifactTransmutation.php", artifactTransmutationController);
238 239 apiRouter.post("/changeDojoRoot.php", changeDojoRootController);
239 240 apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
241 apiRouter.post("/claimJunctionChallengeReward.php", claimJunctionChallengeRewardController);
240 242 apiRouter.post("/clearDialogueHistory.php", clearDialogueHistoryController);
241 243 apiRouter.post("/clearNewEpisodeReward.php", clearNewEpisodeRewardController);
242 244 apiRouter.post("/commitStoryModeDecision.php", (_req, res) => { res.end(); }); // U14 (maybe wanna actually unlock the ship features?)
Modified src/types/inventoryTypes/inventoryTypes.ts +3 -1
@@ -380,6 +380,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
380 380 LockedWeaponGroup?: ILockedWeaponGroupClient;
381 381 HubNpcCustomizations?: IHubNpcCustomization[];
382 382 Ship?: IOrbiter; // U22 and below, response only
383 ClaimedJunctionChallengeRewards?: string[]; // U39
383 384 }
384 385
385 386 export interface IAffiliation {
@@ -448,8 +449,9 @@ export interface IVendorPurchaseHistoryEntryDatabase {
448 449
449 450 export interface IChallengeProgress {
450 451 Progress: number;
451 Name: string;
452 452 Completed?: string[];
453 ReceivedJunctionReward?: boolean; // U39
454 Name: string;
453 455 }
454 456
455 457 export interface ICollectibleEntry {