From 11f2ffe64ddc57fea20677671eb6a55232c1fe7f Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sun, 20 Apr 2025 07:53:45 -0700 Subject: [PATCH] feat(import): accolades (#1750) So one is able to import e.g. `{"Staff":true}` to set that field to true without going into Compass. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1750 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/models/inventoryModels/inventoryModel.ts | 20 +++++++++++++++++++- src/services/importService.ts | 17 +++++++++++++++-- src/types/inventoryTypes/inventoryTypes.ts | 8 +++++--- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index db77926e..029bf6c0 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -94,7 +94,8 @@ import { ICrewMemberClient, ISortieRewardAttenuation, IInvasionProgressDatabase, - IInvasionProgressClient + IInvasionProgressClient, + IAccolades } from "../../types/inventoryTypes/inventoryTypes"; import { IOid } from "../../types/commonTypes"; import { @@ -1059,6 +1060,13 @@ pendingRecipeSchema.set("toJSON", { } }); +const accoladesSchema = new Schema( + { + Heirloom: Boolean + }, + { _id: false } +); + const infestedFoundrySchema = new Schema( { Name: String, @@ -1466,6 +1474,16 @@ const inventorySchema = new Schema( //Mastery Rank next availability TrainingDate: { type: Date, default: new Date(0) }, + //Accolades + Staff: Boolean, + Founder: Number, + Guide: Number, + Moderator: Boolean, + Partner: Boolean, + Accolades: accoladesSchema, + //Not an accolade but unlocks an extra chat + Counselor: Boolean, + //you saw last played Region when you opened the star map LastRegionPlayed: String, diff --git a/src/services/importService.ts b/src/services/importService.ts index 0f5dd28d..ea03047b 100644 --- a/src/services/importService.ts +++ b/src/services/importService.ts @@ -230,17 +230,23 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< replaceSlots(db[key], client[key]); } } + // boolean for (const key of [ "UseAdultOperatorLoadout", "HasOwnedVoidProjectionsPreviously", "ReceivedStartingGear", "ArchwingEnabled", - "PlayedParkourTutorial" + "PlayedParkourTutorial", + "Staff", + "Moderator", + "Partner", + "Counselor" ] as const) { if (client[key] !== undefined) { db[key] = client[key]; } } + // number for (const key of [ "PlayerLevel", "RegularCredits", @@ -250,12 +256,15 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< "PrimeTokens", "TradesRemaining", "GiftsRemaining", - "ChallengesFixVersion" + "ChallengesFixVersion", + "Founder", + "Guide" ] as const) { if (client[key] !== undefined) { db[key] = client[key]; } } + // string for (const key of [ "ThemeStyle", "ThemeBackground", @@ -270,6 +279,7 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< db[key] = client[key]; } } + // string[] for (const key of [ "EquippedGear", "EquippedEmotes", @@ -380,6 +390,9 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< }); }); } + if (client.Accolades !== undefined) { + db.Accolades = client.Accolades; + } }; const convertLoadOutConfig = (client: ILoadoutConfigClient): ILoadoutConfigDatabase => { diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index d5f6344a..b4dbc57c 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -250,9 +250,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu Guide?: number; Moderator?: boolean; Partner?: boolean; - Accolades?: { - Heirloom?: boolean; - }; + Accolades?: IAccolades; Counselor?: boolean; Upgrades: IUpgradeClient[]; EquippedGear: string[]; @@ -914,6 +912,10 @@ export interface IPendingRecipeClient CompletionDate: IMongoDate; } +export interface IAccolades { + Heirloom?: boolean; +} + export interface IPendingTrade { State: number; SelfReady: boolean;