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: receiving descendia rewards (#3172)

Re #3129 For some reason completed floors doesn't appers on client Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3172 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>

95ef43f1
AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
提交于

代码差异

5 个文件 +50 -14
Modified src/controllers/api/descentRewardsController.ts +3 -3
@@ -25,7 +25,7 @@ export const descentRewardsController: RequestHandler = async (req, res) => {
25 25 entry = {
26 26 Category: payload.Category,
27 27 Expiry: new Date(0),
28 FloorsClaimed: 0,
28 FloorClaimed: 0,
29 29 PendingRewards: [],
30 30 Seed: 0,
31 31 SelectedUpgrades: []
@@ -38,7 +38,7 @@ export const descentRewardsController: RequestHandler = async (req, res) => {
38 38
39 39 if (entry.Expiry.getTime() != weekEnd) {
40 40 entry.Expiry = new Date(weekEnd);
41 entry.FloorsClaimed = 0;
41 entry.FloorClaimed = 0;
42 42 entry.PendingRewards = [
43 43 {
44 44 FloorCheckpoint: 2,
@@ -103,7 +103,7 @@ export const descentRewardsController: RequestHandler = async (req, res) => {
103 103 await inventory.save();
104 104 res.json({
105 105 Expiry: { $date: { $numberLong: weekEnd.toString() } },
106 FloorClaimed: entry.FloorsClaimed,
106 FloorClaimed: entry.FloorClaimed,
107 107 PendingRewards: entry.PendingRewards,
108 108 Seed: entry.Seed,
109 109 SelectedUpgrades: entry.SelectedUpgrades
Modified src/models/inventoryModels/inventoryModel.ts +1 -1
@@ -892,7 +892,7 @@ const descentCategoryRewardSchema = new Schema<IDescentCategoryRewardDatabase>(
892 892 {
893 893 Category: { type: String, required: true },
894 894 Expiry: Date,
895 FloorsClaimed: { type: Number, default: 0 },
895 FloorClaimed: { type: Number, default: 0 },
896 896 PendingRewards: { type: [descentLevelRewardSchema], default: [] },
897 897 Seed: Number,
898 898 SelectedUpgrades: { type: [String], default: [] }
Modified src/services/missionInventoryUpdateService.ts +30 -0
@@ -1574,6 +1574,36 @@ export const addMissionRewards = async (
1574 1574 }
1575 1575 }
1576 1576
1577 if (rewardInfo.missionType == "MT_DESCENT") {
1578 if (account.BuildLabel) {
1579 if (version_compare(account.BuildLabel, gameToBuildVersion["41.0.0"]) < 0) {
1580 throw new Error(
1581 `account logged into ${account.BuildLabel} (< 41.0.0) but now completes >= 41.0.0 misssion ?!`
1582 );
1583 }
1584
1585 const isSteelPath = missions?.Tier;
1586 inventory.DescentRewards ??= [];
1587 const entry = inventory.DescentRewards.find(
1588 x => x.Category == (isSteelPath ? "DM_COH_HARD" : "DM_COH_NORMAL")
1589 );
1590 if (!entry) {
1591 throw new Error(`Missing DescentRewards entry`);
1592 }
1593 logger.debug(`completed ${rewardInfo.CheckpointCounter} ${entry.Category} floor`);
1594 if (rewardInfo.CheckpointCounter && rewardInfo.CheckpointCounter > entry.FloorClaimed) {
1595 entry.FloorClaimed = rewardInfo.CheckpointCounter;
1596 const reward = entry.PendingRewards.find(x => x.FloorCheckpoint == rewardInfo.CheckpointCounter);
1597 if (reward) {
1598 logger.debug(`giving ${entry.Category} floor ${rewardInfo.CheckpointCounter} reward`, {
1599 reward: reward.Rewards
1600 });
1601 MissionRewards.push(...reward.Rewards);
1602 }
1603 }
1604 }
1605 }
1606
1577 1607 if (rewardInfo.challengeMissionId) {
1578 1608 const [syndicateTag, tierStr, chemistryBuddyStr] = rewardInfo.challengeMissionId.split("_");
1579 1609 const tier = Number(tierStr);
Modified src/types/inventoryTypes/inventoryTypes.ts +1 -1
@@ -1141,7 +1141,7 @@ export type TDescentCategory = "DM_COH_NORMAL" | "DM_COH_HARD";
1141 1141 export interface IDescentCategoryRewardClient {
1142 1142 Category: TDescentCategory;
1143 1143 Expiry: IMongoDate;
1144 FloorsClaimed: number;
1144 FloorClaimed: number;
1145 1145 PendingRewards: IDescentLevelReward[];
1146 1146 Seed: number;
1147 1147 SelectedUpgrades: string[];
Modified src/types/requestTypes.ts +15 -9
@@ -27,6 +27,7 @@ import type {
27 27 import type { IGroup } from "./loginTypes.ts";
28 28 import type { ILoadOutPresets } from "./saveLoadoutTypes.ts";
29 29 import type { IEquipmentClient } from "./equipmentTypes.ts";
30 import type { TMissionType } from "warframe-public-export-plus";
30 31
31 32 export interface IAffiliationChange {
32 33 Tag: string;
@@ -173,7 +174,19 @@ export type IMissionInventoryUpdateRequest = {
173 174 [K in TEquipmentKey]?: IEquipmentClient[];
174 175 };
175 176
176 export interface IRewardInfo {
177 export interface IBountyRewardInfo {
178 node: string;
179 EOM_AFK?: number;
180 JobTier?: number;
181 jobId?: string;
182 JobStage?: number;
183 Q?: boolean; // likely indicates that the bonus objective for this stage was completed
184 CheckpointCounter?: number; // starts at 1, is incremented with each job stage upload, and does not reset when starting a new job
185 challengeMissionId?: string;
186 GoalProgressAmount?: number;
187 }
188
189 export interface IRewardInfo extends IBountyRewardInfo {
177 190 node: string;
178 191 goalId?: string;
179 192 goalManifest?: string;
@@ -209,14 +222,7 @@ export interface IRewardInfo {
209 222 ConquestPersonalModifiersActive?: number;
210 223 ConquestStickersActive?: number;
211 224 ConquestHardModeActive?: number;
212 // for bounties, only EOM_AFK and node are given from above, plus:
213 JobTier?: number;
214 jobId?: string;
215 JobStage?: number;
216 Q?: boolean; // likely indicates that the bonus objective for this stage was completed
217 CheckpointCounter?: number; // starts at 1, is incremented with each job stage upload, and does not reset when starting a new job
218 challengeMissionId?: string;
219 GoalProgressAmount?: number;
225 missionType?: TMissionType;
220 226 }
221 227
222 228 export type IMissionStatus = "GS_SUCCESS" | "GS_FAILURE" | "GS_DUMPED" | "GS_QUIT" | "GS_INTERRUPTED";