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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

feat: conclave challenges reward (#3253)

Atleast on U40.0.5.1 client process rewards at it own, so we just write result of that in database Re #1192 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3253 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>

134e7bbc
AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
提交于

代码差异

4 个文件 +74 -8
Modified src/models/inventoryModels/inventoryModel.ts +32 -2
@@ -96,7 +96,10 @@ import type {
96 96 IDescentLevelReward,
97 97 IDescentCategoryRewardClient,
98 98 IDescentCategoryRewardDatabase,
99 IFocusLoadoutDatabase
99 IFocusLoadoutDatabase,
100 IChallengeInstanceStateDatabase,
101 IChallengeInstanceStateClient,
102 IParam
100 103 } from "../../types/inventoryTypes/inventoryTypes.ts";
101 104 import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts";
102 105 import type { IOid, ITypeCount } from "../../types/commonTypes.ts";
@@ -1507,6 +1510,33 @@ const nokkoColonySchema = new Schema<INokkoColony>(
1507 1510 { _id: false }
1508 1511 );
1509 1512
1513 const challengeInstanceStateParamSchema = new Schema<IParam>(
1514 {
1515 n: String,
1516 v: String
1517 },
1518 { _id: false }
1519 );
1520
1521 const challengeInstanceStateSchema = new Schema<IChallengeInstanceStateDatabase>({
1522 Progress: Number,
1523 params: [challengeInstanceStateParamSchema],
1524 IsRewardCollected: Boolean
1525 });
1526
1527 challengeInstanceStateSchema.set("toJSON", {
1528 virtuals: true,
1529 transform(_doc, obj: Record<string, any>) {
1530 const db = obj as IChallengeInstanceStateDatabase;
1531 const client = obj as IChallengeInstanceStateClient;
1532
1533 client.id = toOid(db._id);
1534
1535 delete obj._id;
1536 delete obj.__v;
1537 }
1538 });
1539
1510 1540 const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1511 1541 {
1512 1542 accountOwnerId: Schema.Types.ObjectId,
@@ -1896,7 +1926,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1896 1926 CurrentLoadOutIds: [Schema.Types.Mixed], // should be Types.ObjectId[] but might be IOid[] because of old commits
1897 1927 RandomUpgradesIdentified: Number,
1898 1928 BountyScore: Number,
1899 //ChallengeInstanceStates: [Schema.Types.Mixed],
1929 ChallengeInstanceStates: { type: [challengeInstanceStateSchema], default: undefined },
1900 1930 RecentVendorPurchases: { type: [recentVendorPurchaseSchema], default: undefined },
1901 1931 //Robotics: [Schema.Types.Mixed],
1902 1932 CollectibleSeries: { type: [collectibleEntrySchema], default: undefined },
Modified src/services/missionInventoryUpdateService.ts +23 -2
@@ -85,7 +85,7 @@ import {
85 85 import { config } from "./configService.ts";
86 86 import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json" with { type: "json" };
87 87 import type { IGoal, ISyndicateJob, ISyndicateMissionInfo } from "../types/worldStateTypes.ts";
88 import { fromOid, version_compare } from "../helpers/inventoryHelpers.ts";
88 import { fromOid, toObjectId, toOid2, version_compare } from "../helpers/inventoryHelpers.ts";
89 89 import type { TAccountDocument } from "./loginService.ts";
90 90 import type { ITypeCount } from "../types/commonTypes.ts";
91 91 import type { IEquipmentClient } from "../types/equipmentTypes.ts";
@@ -1194,7 +1194,8 @@ export const addMissionRewards = async (
1194 1194 AffiliationChanges: AffiliationMods,
1195 1195 InvasionProgress: invasionProgress,
1196 1196 EndOfMatchUpload: endOfMatchUpload,
1197 GoalTag: goalTag
1197 GoalTag: goalTag,
1198 ChallengeInstanceStates: challengeInstanceStates
1198 1199 }: IMissionInventoryUpdateRequest,
1199 1200 firstCompletion: boolean
1200 1201 ): Promise<AddMissionRewardsReturnType> => {
@@ -1693,6 +1694,26 @@ export const addMissionRewards = async (
1693 1694 }
1694 1695 }
1695 1696
1697 if (challengeInstanceStates) {
1698 inventory.ChallengeInstanceStates ??= [];
1699 for (const challenge of challengeInstanceStates) {
1700 const inventoryState = inventory.ChallengeInstanceStates.find(
1701 c => toOid2(c._id, account.BuildLabel) == challenge.id
1702 );
1703 if (inventoryState) {
1704 inventoryState.Progress = challenge.Progress;
1705 inventoryState.IsRewardCollected = challenge.IsRewardCollected;
1706 } else {
1707 inventory.ChallengeInstanceStates.push({
1708 params: challenge.params,
1709 Progress: challenge.Progress,
1710 IsRewardCollected: challenge.IsRewardCollected,
1711 _id: toObjectId(fromOid(challenge.id))
1712 });
1713 }
1714 }
1715 }
1716
1696 1717 return {
1697 1718 inventoryChanges,
1698 1719 MissionRewards,
Modified src/types/inventoryTypes/inventoryTypes.ts +9 -3
@@ -137,6 +137,7 @@ export interface IInventoryDatabase
137 137 | "PersonalGoalProgress"
138 138 | "CurrentLoadOutIds"
139 139 | "FocusLoadouts"
140 | "ChallengeInstanceStates"
140 141 | TEquipmentKey
141 142 >,
142 143 InventoryDatabaseEquipment,
@@ -184,6 +185,7 @@ export interface IInventoryDatabase
184 185 PersonalGoalProgress?: IGoalProgressDatabase[];
185 186 MissionRelicRewards?: ITypeCount[];
186 187 FocusLoadouts?: IFocusLoadoutDatabase[];
188 ChallengeInstanceStates?: IChallengeInstanceStateDatabase[];
187 189 }
188 190
189 191 export interface IQuestKeyDatabase {
@@ -413,7 +415,7 @@ export interface IInventoryClient
413 415 ThemeBackground: string;
414 416 ThemeSounds: string;
415 417 BountyScore?: number;
416 //ChallengeInstanceStates: IChallengeInstanceState[];
418 ChallengeInstanceStates?: IChallengeInstanceStateClient[];
417 419 LoginMilestoneRewards: string[];
418 420 RecentVendorPurchases?: IRecentVendorPurchaseClient[];
419 421 NodeIntrosCompleted: string[];
@@ -518,11 +520,15 @@ export interface IBooster {
518 520 UsesRemaining?: number;
519 521 }
520 522
521 export interface IChallengeInstanceState {
522 id: IOid;
523 export interface IChallengeInstanceStateDatabase {
523 524 Progress: number;
524 525 params: IParam[];
525 526 IsRewardCollected: boolean;
527 _id: Types.ObjectId;
528 }
529
530 export interface IChallengeInstanceStateClient extends Omit<IChallengeInstanceStateDatabase, "_id"> {
531 id: IOidWithLegacySupport;
526 532 }
527 533
528 534 export interface IParam {
Modified src/types/requestTypes.ts +10 -1
@@ -22,7 +22,8 @@ import type {
22 22 IWeaponSkinClient,
23 23 IKubrowPetEggClient,
24 24 INemesisClient,
25 IUpgradeClient
25 IUpgradeClient,
26 IChallengeInstanceStateClient
26 27 } from "./inventoryTypes/inventoryTypes.ts";
27 28 import type { IGroup } from "./loginTypes.ts";
28 29 import type { ILoadOutPresets } from "./saveLoadoutTypes.ts";
@@ -171,6 +172,7 @@ export type IMissionInventoryUpdateRequest = {
171 172 Warframes: string[];
172 173 Weapons: string[];
173 174 };
175 ChallengeInstanceStates?: IChallengeInstanceStateClient[];
174 176 } & {
175 177 [K in TEquipmentKey]?: IEquipmentClient[];
176 178 };
@@ -225,6 +227,13 @@ export interface IRewardInfo extends IBountyRewardInfo {
225 227 ConquestHardModeActive?: number;
226 228 EncounterEnemyLevel?: number;
227 229 missionType?: TMissionType;
230 PvpGame?: boolean;
231 PvpWinner?: boolean;
232 PvpVariantPrize?: boolean;
233 PvpChallengeHadAffector?: boolean;
234 PVPChallengeInstancesCompleted?: {
235 ChallengeInstanceIDs: IOidWithLegacySupport[];
236 };
228 237 }
229 238
230 239 export type IMissionStatus = "GS_SUCCESS" | "GS_FAILURE" | "GS_DUMPED" | "GS_QUIT" | "GS_INTERRUPTED";