Compare commits
	
		
			7 Commits
		
	
	
		
			4b46938dab
			...
			dfd1fb834b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| dfd1fb834b | |||
| 2c43d897c0 | |||
| 217eb1f61b | |||
| 5e1ff64cca | |||
| 9c232bfc1f | |||
| 9e73fc7fb1 | |||
| 03b8b610db | 
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -23,7 +23,7 @@
 | 
			
		||||
        "ncp": "^2.0.0",
 | 
			
		||||
        "typescript": "^5.5",
 | 
			
		||||
        "undici": "^7.10.0",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.81",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.82",
 | 
			
		||||
        "warframe-riven-info": "^0.1.2",
 | 
			
		||||
        "winston": "^3.17.0",
 | 
			
		||||
        "winston-daily-rotate-file": "^5.0.0",
 | 
			
		||||
@ -5507,9 +5507,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-public-export-plus": {
 | 
			
		||||
      "version": "0.5.81",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.81.tgz",
 | 
			
		||||
      "integrity": "sha512-kh3e21XThVDSwdC3TJsMsXZnlZ4B/21HdeJkKcjuTygpCd842EPEKS3lRZl3mpXFOmdha744vAW1XEyHfiLofg=="
 | 
			
		||||
      "version": "0.5.82",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.82.tgz",
 | 
			
		||||
      "integrity": "sha512-hZa9KpMDA2wy0Hn03y9Nfyzbjxer1I6Rvb52b363uzrqS0cvDO56rhiDo71JbraeV34qF6yo+Vca1zwFmw2srA=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-riven-info": {
 | 
			
		||||
      "version": "0.1.2",
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,7 @@
 | 
			
		||||
    "ncp": "^2.0.0",
 | 
			
		||||
    "typescript": "^5.5",
 | 
			
		||||
    "undici": "^7.10.0",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.81",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.82",
 | 
			
		||||
    "warframe-riven-info": "^0.1.2",
 | 
			
		||||
    "winston": "^3.17.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0",
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getInventory, updateEntratiVault } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
@ -11,26 +11,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
			
		||||
        "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
 | 
			
		||||
    );
 | 
			
		||||
    const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
 | 
			
		||||
    if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
 | 
			
		||||
        const EPOCH = 1734307200 * 1000; // Mondays, amirite?
 | 
			
		||||
        const day = Math.trunc((Date.now() - EPOCH) / 86400000);
 | 
			
		||||
        const week = Math.trunc(day / 7);
 | 
			
		||||
        const weekStart = EPOCH + week * 604800000;
 | 
			
		||||
        const weekEnd = weekStart + 604800000;
 | 
			
		||||
        inventory.EntratiVaultCountLastPeriod = 0;
 | 
			
		||||
        inventory.EntratiVaultCountResetDate = new Date(weekEnd);
 | 
			
		||||
        if (inventory.EntratiLabConquestUnlocked) {
 | 
			
		||||
            inventory.EntratiLabConquestUnlocked = 0;
 | 
			
		||||
            inventory.EntratiLabConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EntratiLabConquestActiveFrameVariants = [];
 | 
			
		||||
        }
 | 
			
		||||
        if (inventory.EchoesHexConquestUnlocked) {
 | 
			
		||||
            inventory.EchoesHexConquestUnlocked = 0;
 | 
			
		||||
            inventory.EchoesHexConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EchoesHexConquestActiveFrameVariants = [];
 | 
			
		||||
            inventory.EchoesHexConquestActiveStickers = [];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    updateEntratiVault(inventory);
 | 
			
		||||
    if (body.BuyMode) {
 | 
			
		||||
        inventory.EntratiVaultCountLastPeriod! += 2;
 | 
			
		||||
        if (body.IsEchoesDeepArchemedea) {
 | 
			
		||||
@ -51,7 +32,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
 | 
			
		||||
        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate!),
 | 
			
		||||
        EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
 | 
			
		||||
        EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
 | 
			
		||||
        EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import { version_compare } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { fromDbOid, version_compare } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import {
 | 
			
		||||
    antivirusMods,
 | 
			
		||||
    decodeNemesisGuess,
 | 
			
		||||
@ -130,7 +130,9 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
            if (result1 == GUESS_CORRECT || result2 == GUESS_CORRECT || result3 == GUESS_CORRECT) {
 | 
			
		||||
                let antivirusGain = 5;
 | 
			
		||||
                const loadout = (await Loadout.findById(inventory.LoadOutPresets, "DATAKNIFE"))!;
 | 
			
		||||
                const dataknifeLoadout = loadout.DATAKNIFE.id(inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE].$oid);
 | 
			
		||||
                const dataknifeLoadout = loadout.DATAKNIFE.id(
 | 
			
		||||
                    fromDbOid(inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE])
 | 
			
		||||
                );
 | 
			
		||||
                const dataknifeConfigIndex = dataknifeLoadout?.s?.mod ?? 0;
 | 
			
		||||
                const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
 | 
			
		||||
                for (const upgrade of body.knife!.AttachedUpgrades) {
 | 
			
		||||
@ -219,7 +221,7 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
                    // Subtract a charge from all requiem mods installed on parazon
 | 
			
		||||
                    const loadout = (await Loadout.findById(inventory.LoadOutPresets, "DATAKNIFE"))!;
 | 
			
		||||
                    const dataknifeLoadout = loadout.DATAKNIFE.id(
 | 
			
		||||
                        inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE].$oid
 | 
			
		||||
                        fromDbOid(inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE])
 | 
			
		||||
                    );
 | 
			
		||||
                    const dataknifeConfigIndex = dataknifeLoadout?.s?.mod ?? 0;
 | 
			
		||||
                    const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
 | 
			
		||||
 | 
			
		||||
@ -20,8 +20,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
			
		||||
        const tomorrowAt0Utc = config.noKimCooldowns
 | 
			
		||||
            ? Date.now()
 | 
			
		||||
            : (Math.trunc(Date.now() / 86400_000) + 1) * 86400_000;
 | 
			
		||||
        inventory.DialogueHistory ??= {};
 | 
			
		||||
        inventory.DialogueHistory.Dialogues ??= [];
 | 
			
		||||
        const dialogue = getDialogue(inventory, request.DialogueName);
 | 
			
		||||
        dialogue.Rank = request.Rank;
 | 
			
		||||
        dialogue.Chemistry += request.Chemistry;
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,7 @@ export const completeAllMissionsController: RequestHandler = async (req, res) =>
 | 
			
		||||
        await handleStoreItemAcquisition(reward.StoreItem, inventory, reward.ItemCount, undefined, true);
 | 
			
		||||
    }
 | 
			
		||||
    addString(inventory.NodeIntrosCompleted, "TeshinHardModeUnlocked");
 | 
			
		||||
    addString(inventory.NodeIntrosCompleted, "CetusSyndicate_IntroJob");
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.end();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { fromDbOid, toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Guild, GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
 | 
			
		||||
import { Inventory, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
			
		||||
@ -13,7 +13,8 @@ import {
 | 
			
		||||
    IDailyAffiliations,
 | 
			
		||||
    IMission,
 | 
			
		||||
    IPlayerSkills,
 | 
			
		||||
    ITypeXPItem
 | 
			
		||||
    ITypeXPItem,
 | 
			
		||||
    LoadoutIndex
 | 
			
		||||
} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { catBreadHash, getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
@ -298,30 +299,32 @@ const populateLoadout = async (
 | 
			
		||||
): Promise<void> => {
 | 
			
		||||
    if (inventory.CurrentLoadOutIds.length) {
 | 
			
		||||
        const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
 | 
			
		||||
        result.LoadOutPreset = loadout.NORMAL.id(inventory.CurrentLoadOutIds[0].$oid)!.toJSON<ILoadoutConfigClient>();
 | 
			
		||||
        result.LoadOutPreset = loadout.NORMAL.id(
 | 
			
		||||
            fromDbOid(inventory.CurrentLoadOutIds[LoadoutIndex.NORMAL])
 | 
			
		||||
        )!.toJSON<ILoadoutConfigClient>();
 | 
			
		||||
        result.LoadOutPreset.ItemId = undefined;
 | 
			
		||||
        const skins = new Set<string>();
 | 
			
		||||
        if (result.LoadOutPreset.s) {
 | 
			
		||||
        if (result.LoadOutPreset.s?.ItemId) {
 | 
			
		||||
            result.LoadOutInventory.Suits = [
 | 
			
		||||
                inventory.Suits.id(result.LoadOutPreset.s.ItemId.$oid)!.toJSON<IEquipmentClient>()
 | 
			
		||||
                inventory.Suits.id(fromDbOid(result.LoadOutPreset.s.ItemId))!.toJSON<IEquipmentClient>()
 | 
			
		||||
            ];
 | 
			
		||||
            resolveAndCollectSkins(inventory, skins, result.LoadOutInventory.Suits[0]);
 | 
			
		||||
        }
 | 
			
		||||
        if (result.LoadOutPreset.p) {
 | 
			
		||||
        if (result.LoadOutPreset.p?.ItemId) {
 | 
			
		||||
            result.LoadOutInventory.Pistols = [
 | 
			
		||||
                inventory.Pistols.id(result.LoadOutPreset.p.ItemId.$oid)!.toJSON<IEquipmentClient>()
 | 
			
		||||
                inventory.Pistols.id(fromDbOid(result.LoadOutPreset.p.ItemId))!.toJSON<IEquipmentClient>()
 | 
			
		||||
            ];
 | 
			
		||||
            resolveAndCollectSkins(inventory, skins, result.LoadOutInventory.Pistols[0]);
 | 
			
		||||
        }
 | 
			
		||||
        if (result.LoadOutPreset.l) {
 | 
			
		||||
        if (result.LoadOutPreset.l?.ItemId) {
 | 
			
		||||
            result.LoadOutInventory.LongGuns = [
 | 
			
		||||
                inventory.LongGuns.id(result.LoadOutPreset.l.ItemId.$oid)!.toJSON<IEquipmentClient>()
 | 
			
		||||
                inventory.LongGuns.id(fromDbOid(result.LoadOutPreset.l.ItemId))!.toJSON<IEquipmentClient>()
 | 
			
		||||
            ];
 | 
			
		||||
            resolveAndCollectSkins(inventory, skins, result.LoadOutInventory.LongGuns[0]);
 | 
			
		||||
        }
 | 
			
		||||
        if (result.LoadOutPreset.m) {
 | 
			
		||||
        if (result.LoadOutPreset.m?.ItemId) {
 | 
			
		||||
            result.LoadOutInventory.Melee = [
 | 
			
		||||
                inventory.Melee.id(result.LoadOutPreset.m.ItemId.$oid)!.toJSON<IEquipmentClient>()
 | 
			
		||||
                inventory.Melee.id(fromDbOid(result.LoadOutPreset.m.ItemId))!.toJSON<IEquipmentClient>()
 | 
			
		||||
            ];
 | 
			
		||||
            resolveAndCollectSkins(inventory, skins, result.LoadOutInventory.Melee[0]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,11 @@ export const fromOid = (oid: IOidWithLegacySupport): string => {
 | 
			
		||||
    return (oid.$oid ?? oid.$id)!;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// For oids that may have been stored incorrectly
 | 
			
		||||
export const fromDbOid = (x: Types.ObjectId | IOid): Types.ObjectId => {
 | 
			
		||||
    return "$oid" in x ? new Types.ObjectId(x.$oid) : x;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const toMongoDate = (date: Date): IMongoDate => {
 | 
			
		||||
    return { $date: { $numberLong: date.getTime().toString() } };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -100,8 +100,8 @@ import {
 | 
			
		||||
    IOperatorConfigDatabase,
 | 
			
		||||
    IPolarity
 | 
			
		||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { EquipmentSelectionSchema, oidSchema } from "@/src/models/inventoryModels/loadoutModel";
 | 
			
		||||
import { fromDbOid, toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { EquipmentSelectionSchema } from "@/src/models/inventoryModels/loadoutModel";
 | 
			
		||||
import { ICountedStoreItem } from "warframe-public-export-plus";
 | 
			
		||||
import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
 | 
			
		||||
import {
 | 
			
		||||
@ -109,8 +109,8 @@ import {
 | 
			
		||||
    ICrewShipMemberClient,
 | 
			
		||||
    ICrewShipMemberDatabase,
 | 
			
		||||
    ICrewShipMembersDatabase,
 | 
			
		||||
    ICrewShipWeapon,
 | 
			
		||||
    ICrewShipWeaponEmplacements,
 | 
			
		||||
    ICrewShipWeaponDatabase,
 | 
			
		||||
    ICrewShipWeaponEmplacementsDatabase,
 | 
			
		||||
    IEquipmentClient,
 | 
			
		||||
    IEquipmentDatabase,
 | 
			
		||||
    IKubrowPetDetailsClient,
 | 
			
		||||
@ -847,7 +847,6 @@ const endlessXpProgressSchema = new Schema<IEndlessXpProgressDatabase>(
 | 
			
		||||
    },
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
endlessXpProgressSchema.set("toJSON", {
 | 
			
		||||
    transform(_doc, ret: Record<string, any>) {
 | 
			
		||||
        const db = ret as IEndlessXpProgressDatabase;
 | 
			
		||||
@ -861,7 +860,8 @@ endlessXpProgressSchema.set("toJSON", {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
const crewShipWeaponEmplacementsSchema = new Schema<ICrewShipWeaponEmplacements>(
 | 
			
		||||
 | 
			
		||||
const crewShipWeaponEmplacementsSchema = new Schema<ICrewShipWeaponEmplacementsDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
        PRIMARY_A: EquipmentSelectionSchema,
 | 
			
		||||
        PRIMARY_B: EquipmentSelectionSchema,
 | 
			
		||||
@ -871,7 +871,7 @@ const crewShipWeaponEmplacementsSchema = new Schema<ICrewShipWeaponEmplacements>
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
 | 
			
		||||
const crewShipWeaponSchema = new Schema<ICrewShipWeaponDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
        PILOT: crewShipWeaponEmplacementsSchema,
 | 
			
		||||
        PORT_GUNS: crewShipWeaponEmplacementsSchema,
 | 
			
		||||
@ -1748,7 +1748,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
        HasContributedToDojo: Boolean,
 | 
			
		||||
        HWIDProtectEnabled: Boolean,
 | 
			
		||||
        LoadOutPresets: { type: Schema.Types.ObjectId, ref: "Loadout" },
 | 
			
		||||
        CurrentLoadOutIds: [oidSchema],
 | 
			
		||||
        CurrentLoadOutIds: [Schema.Types.Mixed], // should be Types.ObjectId[] but might be IOid[] because of old commits
 | 
			
		||||
        RandomUpgradesIdentified: Number,
 | 
			
		||||
        BountyScore: Number,
 | 
			
		||||
        //ChallengeInstanceStates: [Schema.Types.Mixed],
 | 
			
		||||
@ -1808,12 +1808,15 @@ inventorySchema.set("toJSON", {
 | 
			
		||||
        const inventoryDatabase = returnedObject as Partial<IInventoryDatabase>;
 | 
			
		||||
        const inventoryResponse = returnedObject as IInventoryClient;
 | 
			
		||||
 | 
			
		||||
        if (inventoryDatabase.TrainingDate) {
 | 
			
		||||
            inventoryResponse.TrainingDate = toMongoDate(inventoryDatabase.TrainingDate);
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryDatabase.Created) {
 | 
			
		||||
            inventoryResponse.Created = toMongoDate(inventoryDatabase.Created);
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryDatabase.CurrentLoadOutIds) {
 | 
			
		||||
            inventoryResponse.CurrentLoadOutIds = inventoryDatabase.CurrentLoadOutIds.map(x => toOid(fromDbOid(x)));
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryDatabase.TrainingDate) {
 | 
			
		||||
            inventoryResponse.TrainingDate = toMongoDate(inventoryDatabase.TrainingDate);
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryDatabase.GuildId) {
 | 
			
		||||
            inventoryResponse.GuildId = toOid(inventoryDatabase.GuildId);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1,21 +1,13 @@
 | 
			
		||||
import { fromDbOid, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { IEquipmentSelection } from "@/src/types/equipmentTypes";
 | 
			
		||||
import { IEquipmentSelectionClient, IEquipmentSelectionDatabase } from "@/src/types/equipmentTypes";
 | 
			
		||||
import { ILoadoutConfigDatabase, ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
 | 
			
		||||
import { Document, Model, Schema, Types, model } from "mongoose";
 | 
			
		||||
 | 
			
		||||
export const oidSchema = new Schema<IOid>(
 | 
			
		||||
    {
 | 
			
		||||
        $oid: String
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        _id: false
 | 
			
		||||
    }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
//create a mongoose schema based on interface M
 | 
			
		||||
export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
 | 
			
		||||
export const EquipmentSelectionSchema = new Schema<IEquipmentSelectionDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
        ItemId: oidSchema,
 | 
			
		||||
        ItemId: Schema.Types.Mixed, // should be Types.ObjectId but might be IOid because of old commits
 | 
			
		||||
        mod: Number,
 | 
			
		||||
        cus: Number,
 | 
			
		||||
        hide: Boolean
 | 
			
		||||
@ -24,6 +16,17 @@ export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
 | 
			
		||||
        _id: false
 | 
			
		||||
    }
 | 
			
		||||
);
 | 
			
		||||
EquipmentSelectionSchema.set("toJSON", {
 | 
			
		||||
    virtuals: true,
 | 
			
		||||
    transform(_doc, ret: Record<string, any>) {
 | 
			
		||||
        const db = ret as IEquipmentSelectionDatabase;
 | 
			
		||||
        const client = ret as IEquipmentSelectionClient;
 | 
			
		||||
 | 
			
		||||
        if (db.ItemId) {
 | 
			
		||||
            client.ItemId = toOid(fromDbOid(db.ItemId));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const loadoutConfigSchema = new Schema<ILoadoutConfigDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -39,8 +39,14 @@ import {
 | 
			
		||||
    ICrewShipMemberDatabase,
 | 
			
		||||
    ICrewShipMembersClient,
 | 
			
		||||
    ICrewShipMembersDatabase,
 | 
			
		||||
    ICrewShipWeaponClient,
 | 
			
		||||
    ICrewShipWeaponDatabase,
 | 
			
		||||
    ICrewShipWeaponEmplacementsClient,
 | 
			
		||||
    ICrewShipWeaponEmplacementsDatabase,
 | 
			
		||||
    IEquipmentClient,
 | 
			
		||||
    IEquipmentDatabase,
 | 
			
		||||
    IEquipmentSelectionClient,
 | 
			
		||||
    IEquipmentSelectionDatabase,
 | 
			
		||||
    IKubrowPetDetailsClient,
 | 
			
		||||
    IKubrowPetDetailsDatabase
 | 
			
		||||
} from "@/src/types/equipmentTypes";
 | 
			
		||||
@ -84,7 +90,8 @@ const convertEquipment = (client: IEquipmentClient): IEquipmentDatabase => {
 | 
			
		||||
        Expiry: convertOptionalDate(client.Expiry),
 | 
			
		||||
        UpgradesExpiry: convertOptionalDate(client.UpgradesExpiry),
 | 
			
		||||
        UmbraDate: convertOptionalDate(client.UmbraDate),
 | 
			
		||||
        CrewMembers: client.CrewMembers ? convertCrewShipMembers(client.CrewMembers) : undefined,
 | 
			
		||||
        Weapon: client.Weapon ? importCrewShipWeapon(client.Weapon) : undefined,
 | 
			
		||||
        CrewMembers: client.CrewMembers ? importCrewShipMembers(client.CrewMembers) : undefined,
 | 
			
		||||
        Details: client.Details ? convertKubrowDetails(client.Details) : undefined,
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
			
		||||
        Configs: client.Configs
 | 
			
		||||
@ -133,14 +140,43 @@ const replaceSlots = (db: ISlots, client: ISlots): void => {
 | 
			
		||||
    db.Slots = client.Slots;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const importCrewMemberId = (crewMemberId: ICrewShipMemberClient): ICrewShipMemberDatabase => {
 | 
			
		||||
const convertEquipmentSelection = (es: IEquipmentSelectionClient): IEquipmentSelectionDatabase => {
 | 
			
		||||
    const { ItemId, ...rest } = es;
 | 
			
		||||
    return {
 | 
			
		||||
        ...rest,
 | 
			
		||||
        ItemId: ItemId ? new Types.ObjectId(ItemId.$oid) : undefined
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const convertCrewShipWeaponEmplacements = (
 | 
			
		||||
    obj: ICrewShipWeaponEmplacementsClient
 | 
			
		||||
): ICrewShipWeaponEmplacementsDatabase => {
 | 
			
		||||
    return {
 | 
			
		||||
        PRIMARY_A: obj.PRIMARY_A ? convertEquipmentSelection(obj.PRIMARY_A) : undefined,
 | 
			
		||||
        PRIMARY_B: obj.PRIMARY_B ? convertEquipmentSelection(obj.PRIMARY_B) : undefined,
 | 
			
		||||
        SECONDARY_A: obj.SECONDARY_A ? convertEquipmentSelection(obj.SECONDARY_A) : undefined,
 | 
			
		||||
        SECONDARY_B: obj.SECONDARY_B ? convertEquipmentSelection(obj.SECONDARY_B) : undefined
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const importCrewShipWeapon = (weapon: ICrewShipWeaponClient): ICrewShipWeaponDatabase => {
 | 
			
		||||
    return {
 | 
			
		||||
        PILOT: weapon.PILOT ? convertCrewShipWeaponEmplacements(weapon.PILOT) : undefined,
 | 
			
		||||
        PORT_GUNS: weapon.PORT_GUNS ? convertCrewShipWeaponEmplacements(weapon.PORT_GUNS) : undefined,
 | 
			
		||||
        STARBOARD_GUNS: weapon.STARBOARD_GUNS ? convertCrewShipWeaponEmplacements(weapon.STARBOARD_GUNS) : undefined,
 | 
			
		||||
        ARTILLERY: weapon.ARTILLERY ? convertCrewShipWeaponEmplacements(weapon.ARTILLERY) : undefined,
 | 
			
		||||
        SCANNER: weapon.SCANNER ? convertCrewShipWeaponEmplacements(weapon.SCANNER) : undefined
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const importCrewMemberId = (crewMemberId: ICrewShipMemberClient): ICrewShipMemberDatabase => {
 | 
			
		||||
    if (crewMemberId.ItemId) {
 | 
			
		||||
        return { ItemId: new Types.ObjectId(crewMemberId.ItemId.$oid) };
 | 
			
		||||
    }
 | 
			
		||||
    return { NemesisFingerprint: BigInt(crewMemberId.NemesisFingerprint ?? 0) };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const convertCrewShipMembers = (client: ICrewShipMembersClient): ICrewShipMembersDatabase => {
 | 
			
		||||
export const importCrewShipMembers = (client: ICrewShipMembersClient): ICrewShipMembersDatabase => {
 | 
			
		||||
    return {
 | 
			
		||||
        SLOT_A: client.SLOT_A ? importCrewMemberId(client.SLOT_A) : undefined,
 | 
			
		||||
        SLOT_B: client.SLOT_B ? importCrewMemberId(client.SLOT_B) : undefined,
 | 
			
		||||
@ -429,34 +465,40 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const convertLoadOutConfig = (client: ILoadoutConfigClient): ILoadoutConfigDatabase => {
 | 
			
		||||
export const importLoadOutConfig = (client: ILoadoutConfigClient): ILoadoutConfigDatabase => {
 | 
			
		||||
    const { ItemId, ...rest } = client;
 | 
			
		||||
    return {
 | 
			
		||||
        ...rest,
 | 
			
		||||
        _id: new Types.ObjectId(ItemId.$oid)
 | 
			
		||||
        _id: new Types.ObjectId(ItemId.$oid),
 | 
			
		||||
        s: client.s ? convertEquipmentSelection(client.s) : undefined,
 | 
			
		||||
        p: client.p ? convertEquipmentSelection(client.p) : undefined,
 | 
			
		||||
        l: client.l ? convertEquipmentSelection(client.l) : undefined,
 | 
			
		||||
        m: client.m ? convertEquipmentSelection(client.m) : undefined,
 | 
			
		||||
        h: client.h ? convertEquipmentSelection(client.h) : undefined,
 | 
			
		||||
        a: client.a ? convertEquipmentSelection(client.a) : undefined
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const importLoadOutPresets = (db: ILoadoutDatabase, client: ILoadOutPresets): void => {
 | 
			
		||||
    db.NORMAL = client.NORMAL.map(convertLoadOutConfig);
 | 
			
		||||
    db.SENTINEL = client.SENTINEL.map(convertLoadOutConfig);
 | 
			
		||||
    db.ARCHWING = client.ARCHWING.map(convertLoadOutConfig);
 | 
			
		||||
    db.NORMAL_PVP = client.NORMAL_PVP.map(convertLoadOutConfig);
 | 
			
		||||
    db.LUNARO = client.LUNARO.map(convertLoadOutConfig);
 | 
			
		||||
    db.OPERATOR = client.OPERATOR.map(convertLoadOutConfig);
 | 
			
		||||
    db.GEAR = client.GEAR?.map(convertLoadOutConfig);
 | 
			
		||||
    db.KDRIVE = client.KDRIVE.map(convertLoadOutConfig);
 | 
			
		||||
    db.DATAKNIFE = client.DATAKNIFE.map(convertLoadOutConfig);
 | 
			
		||||
    db.MECH = client.MECH.map(convertLoadOutConfig);
 | 
			
		||||
    db.OPERATOR_ADULT = client.OPERATOR_ADULT.map(convertLoadOutConfig);
 | 
			
		||||
    db.DRIFTER = client.DRIFTER.map(convertLoadOutConfig);
 | 
			
		||||
    db.NORMAL = client.NORMAL.map(importLoadOutConfig);
 | 
			
		||||
    db.SENTINEL = client.SENTINEL.map(importLoadOutConfig);
 | 
			
		||||
    db.ARCHWING = client.ARCHWING.map(importLoadOutConfig);
 | 
			
		||||
    db.NORMAL_PVP = client.NORMAL_PVP.map(importLoadOutConfig);
 | 
			
		||||
    db.LUNARO = client.LUNARO.map(importLoadOutConfig);
 | 
			
		||||
    db.OPERATOR = client.OPERATOR.map(importLoadOutConfig);
 | 
			
		||||
    db.GEAR = client.GEAR?.map(importLoadOutConfig);
 | 
			
		||||
    db.KDRIVE = client.KDRIVE.map(importLoadOutConfig);
 | 
			
		||||
    db.DATAKNIFE = client.DATAKNIFE.map(importLoadOutConfig);
 | 
			
		||||
    db.MECH = client.MECH.map(importLoadOutConfig);
 | 
			
		||||
    db.OPERATOR_ADULT = client.OPERATOR_ADULT.map(importLoadOutConfig);
 | 
			
		||||
    db.DRIFTER = client.DRIFTER.map(importLoadOutConfig);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const convertCustomizationInfo = (client: ICustomizationInfoClient): ICustomizationInfoDatabase => {
 | 
			
		||||
    return {
 | 
			
		||||
        ...client,
 | 
			
		||||
        LoadOutPreset: client.LoadOutPreset ? convertLoadOutConfig(client.LoadOutPreset) : undefined,
 | 
			
		||||
        VehiclePreset: client.VehiclePreset ? convertLoadOutConfig(client.VehiclePreset) : undefined
 | 
			
		||||
        LoadOutPreset: client.LoadOutPreset ? importLoadOutConfig(client.LoadOutPreset) : undefined,
 | 
			
		||||
        VehiclePreset: client.VehiclePreset ? importLoadOutConfig(client.VehiclePreset) : undefined
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -481,7 +523,7 @@ const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
 | 
			
		||||
        ...client,
 | 
			
		||||
        ShipInterior: {
 | 
			
		||||
            ...client.ShipInterior,
 | 
			
		||||
            Colors: Array.isArray(client.ShipInterior.Colors) ? {} : client.ShipInterior.Colors
 | 
			
		||||
            Colors: typeof client.ShipInterior == "object" ? client.ShipInterior.Colors : undefined
 | 
			
		||||
        },
 | 
			
		||||
        Rooms: client.Rooms.map(convertRoom),
 | 
			
		||||
        FavouriteLoadoutId: client.FavouriteLoadoutId ? new Types.ObjectId(client.FavouriteLoadoutId.$oid) : undefined
 | 
			
		||||
 | 
			
		||||
@ -63,6 +63,7 @@ import {
 | 
			
		||||
import { createShip } from "@/src/services/shipService";
 | 
			
		||||
import {
 | 
			
		||||
    catbrowDetails,
 | 
			
		||||
    fromDbOid,
 | 
			
		||||
    fromMongoDate,
 | 
			
		||||
    fromOid,
 | 
			
		||||
    kubrowDetails,
 | 
			
		||||
@ -2232,6 +2233,8 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => {
 | 
			
		||||
    inventory.CurrentLoadOutIds = inventory.CurrentLoadOutIds.map(fromDbOid);
 | 
			
		||||
 | 
			
		||||
    let index = inventory.MiscItems.findIndex(x => x.ItemType == "");
 | 
			
		||||
    if (index != -1) {
 | 
			
		||||
        inventory.MiscItems.splice(index, 1);
 | 
			
		||||
@ -2286,11 +2289,13 @@ export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void =>
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
 | 
			
		||||
    let dialogue = inventory.DialogueHistory!.Dialogues!.find(x => x.DialogueName == dialogueName);
 | 
			
		||||
    inventory.DialogueHistory ??= {};
 | 
			
		||||
    inventory.DialogueHistory.Dialogues ??= [];
 | 
			
		||||
    let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == dialogueName);
 | 
			
		||||
    if (!dialogue) {
 | 
			
		||||
        dialogue =
 | 
			
		||||
            inventory.DialogueHistory!.Dialogues![
 | 
			
		||||
                inventory.DialogueHistory!.Dialogues!.push({
 | 
			
		||||
            inventory.DialogueHistory.Dialogues[
 | 
			
		||||
                inventory.DialogueHistory.Dialogues.push({
 | 
			
		||||
                    Rank: 0,
 | 
			
		||||
                    Chemistry: 0,
 | 
			
		||||
                    AvailableDate: new Date(0),
 | 
			
		||||
@ -2449,3 +2454,26 @@ export const giveNemesisPetRecipe = (
 | 
			
		||||
export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
 | 
			
		||||
    return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const updateEntratiVault = (inventory: TInventoryDatabaseDocument): void => {
 | 
			
		||||
    if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
 | 
			
		||||
        const EPOCH = 1734307200 * 1000; // Mondays, amirite?
 | 
			
		||||
        const day = Math.trunc((Date.now() - EPOCH) / 86400000);
 | 
			
		||||
        const week = Math.trunc(day / 7);
 | 
			
		||||
        const weekStart = EPOCH + week * 604800000;
 | 
			
		||||
        const weekEnd = weekStart + 604800000;
 | 
			
		||||
        inventory.EntratiVaultCountLastPeriod = 0;
 | 
			
		||||
        inventory.EntratiVaultCountResetDate = new Date(weekEnd);
 | 
			
		||||
        if (inventory.EntratiLabConquestUnlocked) {
 | 
			
		||||
            inventory.EntratiLabConquestUnlocked = 0;
 | 
			
		||||
            inventory.EntratiLabConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EntratiLabConquestActiveFrameVariants = [];
 | 
			
		||||
        }
 | 
			
		||||
        if (inventory.EchoesHexConquestUnlocked) {
 | 
			
		||||
            inventory.EchoesHexConquestUnlocked = 0;
 | 
			
		||||
            inventory.EchoesHexConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EchoesHexConquestActiveFrameVariants = [];
 | 
			
		||||
            inventory.EchoesHexConquestActiveStickers = [];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,7 @@ import {
 | 
			
		||||
    giveNemesisPetRecipe,
 | 
			
		||||
    giveNemesisWeaponRecipe,
 | 
			
		||||
    updateCurrency,
 | 
			
		||||
    updateEntratiVault,
 | 
			
		||||
    updateSyndicate
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { updateQuestKey } from "@/src/services/questService";
 | 
			
		||||
@ -64,7 +65,6 @@ import {
 | 
			
		||||
    getNemesisPasscode
 | 
			
		||||
} from "@/src/helpers/nemesisHelpers";
 | 
			
		||||
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
			
		||||
import { ILoadoutConfigDatabase } from "@/src/types/saveLoadoutTypes";
 | 
			
		||||
import {
 | 
			
		||||
    getLiteSortie,
 | 
			
		||||
    getSortie,
 | 
			
		||||
@ -83,6 +83,7 @@ import { ITypeCount } from "@/src/types/commonTypes";
 | 
			
		||||
import { IEquipmentClient } from "@/src/types/equipmentTypes";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { handleGuildGoalProgress } from "@/src/services/guildService";
 | 
			
		||||
import { importLoadOutConfig } from "@/src/services/importService";
 | 
			
		||||
 | 
			
		||||
const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
 | 
			
		||||
    // Disruption missions just tell us (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2599)
 | 
			
		||||
@ -601,11 +602,7 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
                    const loadout = await Loadout.findOne({ loadoutOwnerId: inventory.accountOwnerId });
 | 
			
		||||
                    if (loadout) {
 | 
			
		||||
                        for (const [loadoutId, loadoutConfig] of Object.entries(value.LoadOuts.NORMAL)) {
 | 
			
		||||
                            const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
			
		||||
                            const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
			
		||||
                                _id: new Types.ObjectId(ItemId.$oid),
 | 
			
		||||
                                ...loadoutConfigItemIdRemoved
 | 
			
		||||
                            };
 | 
			
		||||
                            const loadoutConfigDatabase = importLoadOutConfig(loadoutConfig);
 | 
			
		||||
                            const dbConfig = loadout.NORMAL.id(loadoutId);
 | 
			
		||||
                            if (dbConfig) {
 | 
			
		||||
                                dbConfig.overwrite(loadoutConfigDatabase);
 | 
			
		||||
@ -1084,6 +1081,22 @@ const droptableAliases: Record<string, string> = {
 | 
			
		||||
        "/Lotus/Types/DropTables/WF1999DropTables/LasrianTankHardModeDropTable"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const isEligibleForCreditReward = (rewardInfo: IRewardInfo, missions: IMission, node: IRegion): boolean => {
 | 
			
		||||
    // (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
 | 
			
		||||
    if (getRotations(rewardInfo).length == 0) {
 | 
			
		||||
        return missions.Tag == "SolNode720"; // Netracells don't use rewardQualifications but probably should give credits anyway
 | 
			
		||||
    }
 | 
			
		||||
    // The rest here might not be needed anymore, but just to be sure we don't give undue credits...
 | 
			
		||||
    return (
 | 
			
		||||
        node.missionIndex != 23 && // junction
 | 
			
		||||
        node.missionIndex != 28 && // open world
 | 
			
		||||
        missions.Tag != "SolNode761" && // the index
 | 
			
		||||
        missions.Tag != "SolNode762" && // the index
 | 
			
		||||
        missions.Tag != "SolNode763" && // the index
 | 
			
		||||
        missions.Tag != "CrewBattleNode556" // free flight
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//TODO: return type of partial missioninventoryupdate response
 | 
			
		||||
export const addMissionRewards = async (
 | 
			
		||||
    account: TAccountDocument,
 | 
			
		||||
@ -1176,15 +1189,7 @@ export const addMissionRewards = async (
 | 
			
		||||
        const node = ExportRegions[missions.Tag];
 | 
			
		||||
 | 
			
		||||
        //node based credit rewards for mission completion
 | 
			
		||||
        if (
 | 
			
		||||
            node.missionIndex != 23 && // junction
 | 
			
		||||
            node.missionIndex != 28 && // open world
 | 
			
		||||
            missions.Tag != "SolNode761" && // the index
 | 
			
		||||
            missions.Tag != "SolNode762" && // the index
 | 
			
		||||
            missions.Tag != "SolNode763" && // the index
 | 
			
		||||
            missions.Tag != "CrewBattleNode556" && // free flight
 | 
			
		||||
            getRotations(rewardInfo).length > 0 // (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
 | 
			
		||||
        ) {
 | 
			
		||||
        if (isEligibleForCreditReward(rewardInfo, missions, node)) {
 | 
			
		||||
            const levelCreditReward = getLevelCreditRewards(node);
 | 
			
		||||
            missionCompletionCredits += levelCreditReward;
 | 
			
		||||
            logger.debug(`levelCreditReward ${levelCreditReward}`);
 | 
			
		||||
@ -1214,6 +1219,12 @@ export const addMissionRewards = async (
 | 
			
		||||
                }
 | 
			
		||||
            ]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Consume netracells search pulse. Moved here to only cover successful completions. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
 | 
			
		||||
        if (missions.Tag == "SolNode720") {
 | 
			
		||||
            updateEntratiVault(inventory);
 | 
			
		||||
            inventory.EntratiVaultCountLastPeriod! += 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (rewardInfo.useVaultManifest) {
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,6 @@ import {
 | 
			
		||||
    IItemEntry,
 | 
			
		||||
    ILoadoutClient,
 | 
			
		||||
    ILoadoutEntry,
 | 
			
		||||
    ILoadoutConfigDatabase,
 | 
			
		||||
    IOperatorConfigEntry,
 | 
			
		||||
    ISaveLoadoutRequestNoUpgradeVer
 | 
			
		||||
} from "@/src/types/saveLoadoutTypes";
 | 
			
		||||
@ -14,7 +13,7 @@ import { isEmptyObject } from "@/src/helpers/general";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { equipmentKeys, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IItemConfig } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { importCrewMemberId } from "@/src/services/importService";
 | 
			
		||||
import { importCrewShipMembers, importCrewShipWeapon, importLoadOutConfig } from "@/src/services/importService";
 | 
			
		||||
 | 
			
		||||
//TODO: setup default items on account creation or like originally in giveStartingItems.php
 | 
			
		||||
 | 
			
		||||
@ -88,20 +87,17 @@ export const handleInventoryItemConfigChange = async (
 | 
			
		||||
 | 
			
		||||
                        const oldLoadoutConfig = loadout[loadoutSlot].id(loadoutId);
 | 
			
		||||
 | 
			
		||||
                        const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
			
		||||
                        const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
			
		||||
                            _id: new Types.ObjectId(ItemId.$oid),
 | 
			
		||||
                            ...loadoutConfigItemIdRemoved
 | 
			
		||||
                        };
 | 
			
		||||
                        const loadoutConfigDatabase = importLoadOutConfig(loadoutConfig);
 | 
			
		||||
 | 
			
		||||
                        // if no config with this id exists, create a new one
 | 
			
		||||
                        if (!oldLoadoutConfig) {
 | 
			
		||||
                            //save the new object id and assign it for every ffff return at the end
 | 
			
		||||
                            if (ItemId.$oid === "ffffffffffffffffffffffff") {
 | 
			
		||||
                            if (loadoutConfigDatabase._id.toString() === "ffffffffffffffffffffffff") {
 | 
			
		||||
                                if (!newLoadoutId) {
 | 
			
		||||
                                    newLoadoutId = new Types.ObjectId();
 | 
			
		||||
                                }
 | 
			
		||||
                                loadout[loadoutSlot].push({ _id: newLoadoutId, ...loadoutConfigItemIdRemoved });
 | 
			
		||||
                                loadoutConfigDatabase._id = newLoadoutId;
 | 
			
		||||
                                loadout[loadoutSlot].push(loadoutConfigDatabase);
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
@ -218,15 +214,11 @@ export const handleInventoryItemConfigChange = async (
 | 
			
		||||
                        if ("Customization" in itemConfigEntries) {
 | 
			
		||||
                            inventoryItem.Customization = itemConfigEntries.Customization;
 | 
			
		||||
                        }
 | 
			
		||||
                        if ("Weapon" in itemConfigEntries) {
 | 
			
		||||
                            inventoryItem.Weapon = itemConfigEntries.Weapon;
 | 
			
		||||
                        if (itemConfigEntries.Weapon) {
 | 
			
		||||
                            inventoryItem.Weapon = importCrewShipWeapon(itemConfigEntries.Weapon);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (itemConfigEntries.CrewMembers) {
 | 
			
		||||
                            inventoryItem.CrewMembers = {
 | 
			
		||||
                                SLOT_A: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_A ?? {}),
 | 
			
		||||
                                SLOT_B: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_B ?? {}),
 | 
			
		||||
                                SLOT_C: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_C ?? {})
 | 
			
		||||
                            };
 | 
			
		||||
                            inventoryItem.CrewMembers = importCrewShipMembers(itemConfigEntries.CrewMembers);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
@ -7,14 +7,18 @@ import {
 | 
			
		||||
    IPolarity
 | 
			
		||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
 | 
			
		||||
export interface IEquipmentSelection {
 | 
			
		||||
    ItemId: IOid;
 | 
			
		||||
export interface IEquipmentSelectionClient {
 | 
			
		||||
    ItemId?: IOid;
 | 
			
		||||
    mod?: number;
 | 
			
		||||
    cus?: number;
 | 
			
		||||
    ItemType?: string;
 | 
			
		||||
    hide?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IEquipmentSelectionDatabase extends Omit<IEquipmentSelectionClient, "ItemId"> {
 | 
			
		||||
    ItemId?: Types.ObjectId | IOid; // should be Types.ObjectId but might be IOid because of old commits
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum EquipmentFeatures {
 | 
			
		||||
    DOUBLE_CAPACITY = 1,
 | 
			
		||||
    UTILITY_SLOT = 2,
 | 
			
		||||
@ -51,7 +55,7 @@ export interface IEquipmentDatabase {
 | 
			
		||||
    UpgradesExpiry?: Date;
 | 
			
		||||
    UmbraDate?: Date; // related to scrapped "echoes of umbra" feature
 | 
			
		||||
    ArchonCrystalUpgrades?: IArchonCrystalUpgrade[];
 | 
			
		||||
    Weapon?: ICrewShipWeapon;
 | 
			
		||||
    Weapon?: ICrewShipWeaponDatabase;
 | 
			
		||||
    Customization?: ICrewShipCustomization;
 | 
			
		||||
    RailjackImage?: IFlavourItem;
 | 
			
		||||
    CrewMembers?: ICrewShipMembersDatabase;
 | 
			
		||||
@ -64,13 +68,14 @@ export interface IEquipmentDatabase {
 | 
			
		||||
export interface IEquipmentClient
 | 
			
		||||
    extends Omit<
 | 
			
		||||
        IEquipmentDatabase,
 | 
			
		||||
        "_id" | "InfestationDate" | "Expiry" | "UpgradesExpiry" | "UmbraDate" | "CrewMembers" | "Details"
 | 
			
		||||
        "_id" | "InfestationDate" | "Expiry" | "UpgradesExpiry" | "UmbraDate" | "Weapon" | "CrewMembers" | "Details"
 | 
			
		||||
    > {
 | 
			
		||||
    ItemId: IOidWithLegacySupport;
 | 
			
		||||
    InfestationDate?: IMongoDate;
 | 
			
		||||
    Expiry?: IMongoDate;
 | 
			
		||||
    UpgradesExpiry?: IMongoDate;
 | 
			
		||||
    UmbraDate?: IMongoDate;
 | 
			
		||||
    Weapon?: ICrewShipWeaponClient;
 | 
			
		||||
    CrewMembers?: ICrewShipMembersClient;
 | 
			
		||||
    Details?: IKubrowPetDetailsClient;
 | 
			
		||||
}
 | 
			
		||||
@ -117,19 +122,34 @@ export enum Status {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// inventory.CrewShips[0].Weapon
 | 
			
		||||
export interface ICrewShipWeapon {
 | 
			
		||||
    PILOT?: ICrewShipWeaponEmplacements;
 | 
			
		||||
    PORT_GUNS?: ICrewShipWeaponEmplacements;
 | 
			
		||||
    STARBOARD_GUNS?: ICrewShipWeaponEmplacements;
 | 
			
		||||
    ARTILLERY?: ICrewShipWeaponEmplacements;
 | 
			
		||||
    SCANNER?: ICrewShipWeaponEmplacements;
 | 
			
		||||
export interface ICrewShipWeaponClient {
 | 
			
		||||
    PILOT?: ICrewShipWeaponEmplacementsClient;
 | 
			
		||||
    PORT_GUNS?: ICrewShipWeaponEmplacementsClient;
 | 
			
		||||
    STARBOARD_GUNS?: ICrewShipWeaponEmplacementsClient;
 | 
			
		||||
    ARTILLERY?: ICrewShipWeaponEmplacementsClient;
 | 
			
		||||
    SCANNER?: ICrewShipWeaponEmplacementsClient;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ICrewShipWeaponEmplacements {
 | 
			
		||||
    PRIMARY_A?: IEquipmentSelection;
 | 
			
		||||
    PRIMARY_B?: IEquipmentSelection;
 | 
			
		||||
    SECONDARY_A?: IEquipmentSelection;
 | 
			
		||||
    SECONDARY_B?: IEquipmentSelection;
 | 
			
		||||
export interface ICrewShipWeaponDatabase {
 | 
			
		||||
    PILOT?: ICrewShipWeaponEmplacementsDatabase;
 | 
			
		||||
    PORT_GUNS?: ICrewShipWeaponEmplacementsDatabase;
 | 
			
		||||
    STARBOARD_GUNS?: ICrewShipWeaponEmplacementsDatabase;
 | 
			
		||||
    ARTILLERY?: ICrewShipWeaponEmplacementsDatabase;
 | 
			
		||||
    SCANNER?: ICrewShipWeaponEmplacementsDatabase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ICrewShipWeaponEmplacementsClient {
 | 
			
		||||
    PRIMARY_A?: IEquipmentSelectionClient;
 | 
			
		||||
    PRIMARY_B?: IEquipmentSelectionClient;
 | 
			
		||||
    SECONDARY_A?: IEquipmentSelectionClient;
 | 
			
		||||
    SECONDARY_B?: IEquipmentSelectionClient;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ICrewShipWeaponEmplacementsDatabase {
 | 
			
		||||
    PRIMARY_A?: IEquipmentSelectionDatabase;
 | 
			
		||||
    PRIMARY_B?: IEquipmentSelectionDatabase;
 | 
			
		||||
    SECONDARY_A?: IEquipmentSelectionDatabase;
 | 
			
		||||
    SECONDARY_B?: IEquipmentSelectionDatabase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ICrewShipMembersClient {
 | 
			
		||||
 | 
			
		||||
@ -68,12 +68,14 @@ export interface IInventoryDatabase
 | 
			
		||||
            | "LastInventorySync"
 | 
			
		||||
            | "EndlessXP"
 | 
			
		||||
            | "PersonalGoalProgress"
 | 
			
		||||
            | "CurrentLoadOutIds"
 | 
			
		||||
            | TEquipmentKey
 | 
			
		||||
        >,
 | 
			
		||||
        InventoryDatabaseEquipment,
 | 
			
		||||
        IAccountCheats {
 | 
			
		||||
    accountOwnerId: Types.ObjectId;
 | 
			
		||||
    Created: Date;
 | 
			
		||||
    CurrentLoadOutIds: Types.ObjectId[] | IOid[]; // should be Types.ObjectId[] but might be IOid[] because of old commits
 | 
			
		||||
    TrainingDate: Date;
 | 
			
		||||
    LoadOutPresets: Types.ObjectId; // LoadOutPresets changed from ILoadOutPresets to Types.ObjectId for population
 | 
			
		||||
    //Mailbox?: IMailboxDatabase;
 | 
			
		||||
@ -254,7 +256,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
			
		||||
    ActiveQuest: string;
 | 
			
		||||
    FlavourItems: IFlavourItem[];
 | 
			
		||||
    LoadOutPresets: ILoadOutPresets;
 | 
			
		||||
    CurrentLoadOutIds: IOid[]; // we store it in the database using this representation as well :/
 | 
			
		||||
    CurrentLoadOutIds: IOid[];
 | 
			
		||||
    Missions: IMission[];
 | 
			
		||||
    RandomUpgradesIdentified?: number;
 | 
			
		||||
    LastRegionPlayed: TSolarMapRegion;
 | 
			
		||||
 | 
			
		||||
@ -16,8 +16,8 @@ export type TBootLocation = "LISET" | "DRIFTER_CAMP" | "APARTMENT" | "SHOP";
 | 
			
		||||
export interface IOrbiterClient {
 | 
			
		||||
    Features: string[];
 | 
			
		||||
    ShipId: IOid;
 | 
			
		||||
    ShipInterior: IShipCustomization;
 | 
			
		||||
    Rooms: IRoomClient[];
 | 
			
		||||
    ShipInterior?: IShipCustomization;
 | 
			
		||||
    VignetteFish?: string[];
 | 
			
		||||
    FavouriteLoadoutId?: IOid;
 | 
			
		||||
    Wallpaper?: string;
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,12 @@ import {
 | 
			
		||||
    IOperatorConfigClient
 | 
			
		||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
import { ICrewShipMembersClient, ICrewShipWeapon, IEquipmentSelection } from "@/src/types/equipmentTypes";
 | 
			
		||||
import {
 | 
			
		||||
    ICrewShipMembersClient,
 | 
			
		||||
    ICrewShipWeaponClient,
 | 
			
		||||
    IEquipmentSelectionClient,
 | 
			
		||||
    IEquipmentSelectionDatabase
 | 
			
		||||
} from "@/src/types/equipmentTypes";
 | 
			
		||||
 | 
			
		||||
export interface ISaveLoadoutRequest {
 | 
			
		||||
    LoadOuts: ILoadoutClient;
 | 
			
		||||
@ -53,10 +58,12 @@ export interface IOperatorConfigEntry {
 | 
			
		||||
    [configId: string]: IOperatorConfigClient;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// client
 | 
			
		||||
export interface IItemEntry {
 | 
			
		||||
    [itemId: string]: IConfigEntry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// client
 | 
			
		||||
export type IConfigEntry = {
 | 
			
		||||
    [configId in "0" | "1" | "2" | "3" | "4" | "5"]: IItemConfig;
 | 
			
		||||
} & {
 | 
			
		||||
@ -66,7 +73,7 @@ export type IConfigEntry = {
 | 
			
		||||
    ItemName?: string;
 | 
			
		||||
    RailjackImage?: IFlavourItem;
 | 
			
		||||
    Customization?: ICrewShipCustomization;
 | 
			
		||||
    Weapon?: ICrewShipWeapon;
 | 
			
		||||
    Weapon?: ICrewShipWeaponClient;
 | 
			
		||||
    CrewMembers?: ICrewShipMembersClient;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -108,10 +115,6 @@ export interface ILoadoutEntry {
 | 
			
		||||
    [key: string]: ILoadoutConfigClient;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ILoadoutConfigDatabase extends Omit<ILoadoutConfigClient, "ItemId"> {
 | 
			
		||||
    _id: Types.ObjectId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum FocusSchool {
 | 
			
		||||
    Attack = "AP_ATTACK",
 | 
			
		||||
    Defense = "AP_DEFENSE",
 | 
			
		||||
@ -125,12 +128,23 @@ export interface ILoadoutConfigClient {
 | 
			
		||||
    PresetIcon?: string;
 | 
			
		||||
    Favorite?: boolean;
 | 
			
		||||
    n?: string; // Loadout name
 | 
			
		||||
    s?: IEquipmentSelection; // Suit
 | 
			
		||||
    p?: IEquipmentSelection; // Secondary weapon
 | 
			
		||||
    l?: IEquipmentSelection; // Primary weapon
 | 
			
		||||
    m?: IEquipmentSelection; // Melee weapon
 | 
			
		||||
    h?: IEquipmentSelection; // Gravimag weapon
 | 
			
		||||
    a?: IEquipmentSelection; // Necromech exalted weapon
 | 
			
		||||
    s?: IEquipmentSelectionClient; // Suit
 | 
			
		||||
    p?: IEquipmentSelectionClient; // Secondary weapon
 | 
			
		||||
    l?: IEquipmentSelectionClient; // Primary weapon
 | 
			
		||||
    m?: IEquipmentSelectionClient; // Melee weapon
 | 
			
		||||
    h?: IEquipmentSelectionClient; // Gravimag weapon
 | 
			
		||||
    a?: IEquipmentSelectionClient; // Necromech exalted weapon
 | 
			
		||||
    ItemId: IOid;
 | 
			
		||||
    Remove?: boolean; // when client wants to remove a config, it only includes ItemId & Remove.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ILoadoutConfigDatabase
 | 
			
		||||
    extends Omit<ILoadoutConfigClient, "ItemId" | "s" | "p" | "l" | "m" | "h" | "a"> {
 | 
			
		||||
    _id: Types.ObjectId;
 | 
			
		||||
    s?: IEquipmentSelectionDatabase;
 | 
			
		||||
    p?: IEquipmentSelectionDatabase;
 | 
			
		||||
    l?: IEquipmentSelectionDatabase;
 | 
			
		||||
    m?: IEquipmentSelectionDatabase;
 | 
			
		||||
    h?: IEquipmentSelectionDatabase;
 | 
			
		||||
    a?: IEquipmentSelectionDatabase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -266,7 +266,7 @@ dict = {
 | 
			
		||||
    worldState_eightClaw: `Octava Garra`,
 | 
			
		||||
    worldState_eightClawProgressOverride: `Progreso de Octava Garra`,
 | 
			
		||||
    worldState_thermiaFractures: `Fracturas Thermia`,
 | 
			
		||||
    worldState_thermiaFracturesProgressOverride: `[UNTRANSLATED] Thermia Fractures Progress`,
 | 
			
		||||
    worldState_thermiaFracturesProgressOverride: `Progreso de Fracturas Thermia`,
 | 
			
		||||
    worldState_from_year: `de |VAL|`,
 | 
			
		||||
    worldState_pre_year: `antes de |VAL|`,
 | 
			
		||||
    worldState_week: `Semana |VAL|`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user