feat(import): additional fields (#1305)
Reviewed-on: OpenWF/SpaceNinjaServer#1305 Reviewed-by: Sainan <sainan@calamity.inc> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
This commit is contained in:
parent
a77c1906bf
commit
0085c20e11
@ -76,7 +76,6 @@ import {
|
||||
IIncentiveState,
|
||||
ISongChallenge,
|
||||
ILibraryPersonalProgress,
|
||||
ICrewShipWeaponDatabase,
|
||||
IRecentVendorPurchaseDatabase,
|
||||
IVendorPurchaseHistoryEntryDatabase,
|
||||
IVendorPurchaseHistoryEntryClient,
|
||||
@ -1118,25 +1117,6 @@ const alignmentSchema = new Schema<IAlignment>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const crewShipWeaponSchema2 = new Schema<ICrewShipWeaponDatabase>(
|
||||
{
|
||||
ItemType: String
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
|
||||
crewShipWeaponSchema2.virtual("ItemId").get(function () {
|
||||
return { $oid: this._id.toString() } satisfies IOid;
|
||||
});
|
||||
|
||||
crewShipWeaponSchema2.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_document, returnedObject) {
|
||||
delete returnedObject._id;
|
||||
delete returnedObject.__v;
|
||||
}
|
||||
});
|
||||
|
||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
{
|
||||
accountOwnerId: Schema.Types.ObjectId,
|
||||
@ -1259,20 +1239,20 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
|
||||
//Default RailJack
|
||||
CrewShipAmmo: [typeCountSchema],
|
||||
CrewShipWeapons: [crewShipWeaponSchema2],
|
||||
CrewShipWeapons: [EquipmentSchema],
|
||||
CrewShipWeaponSkins: [upgradeSchema],
|
||||
CrewShipSalvagedWeapons: [EquipmentSchema],
|
||||
CrewShipSalvagedWeaponSkins: [upgradeSchema],
|
||||
|
||||
//NPC Crew and weapon
|
||||
//RailJack Crew
|
||||
CrewMembers: [Schema.Types.Mixed],
|
||||
CrewShipSalvagedWeaponSkins: [Schema.Types.Mixed],
|
||||
CrewShipSalvagedWeapons: [Schema.Types.Mixed],
|
||||
|
||||
//Complete Mission\Quests
|
||||
Missions: [missionSchema],
|
||||
QuestKeys: [questKeysSchema],
|
||||
ActiveQuest: { type: String, default: "" },
|
||||
//item like DojoKey or Boss missions key
|
||||
LevelKeys: [Schema.Types.Mixed],
|
||||
LevelKeys: [typeCountSchema],
|
||||
//Active quests
|
||||
Quests: [Schema.Types.Mixed],
|
||||
|
||||
@ -1333,7 +1313,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
SpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
|
||||
|
||||
//New Quest Email
|
||||
EmailItems: [TypeXPItemSchema],
|
||||
EmailItems: [typeCountSchema],
|
||||
|
||||
//Profile->Wishlist
|
||||
Wishlist: [String],
|
||||
@ -1527,8 +1507,8 @@ export type InventoryDocumentProps = {
|
||||
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
||||
QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
|
||||
Drones: Types.DocumentArray<IDroneDatabase>;
|
||||
CrewShipWeapons: Types.DocumentArray<ICrewShipWeaponDatabase>;
|
||||
CrewShipWeaponSkins: Types.DocumentArray<IUpgradeDatabase>;
|
||||
CrewShipSalvagedWeaponsSkins: Types.DocumentArray<IUpgradeDatabase>;
|
||||
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
|
@ -23,6 +23,12 @@ import {
|
||||
IKubrowPetDetailsDatabase,
|
||||
ILoadoutConfigClient,
|
||||
ILoadOutPresets,
|
||||
INemesisClient,
|
||||
INemesisDatabase,
|
||||
IPendingRecipeClient,
|
||||
IPendingRecipeDatabase,
|
||||
IQuestKeyClient,
|
||||
IQuestKeyDatabase,
|
||||
ISlots,
|
||||
IUpgradeClient,
|
||||
IUpgradeDatabase,
|
||||
@ -144,6 +150,27 @@ const convertKubrowDetails = (client: IKubrowPetDetailsClient): IKubrowPetDetail
|
||||
};
|
||||
};
|
||||
|
||||
const convertQuestKey = (client: IQuestKeyClient): IQuestKeyDatabase => {
|
||||
return {
|
||||
...client,
|
||||
CompletionDate: convertOptionalDate(client.CompletionDate)
|
||||
};
|
||||
};
|
||||
|
||||
const convertPendingRecipe = (client: IPendingRecipeClient): IPendingRecipeDatabase => {
|
||||
return {
|
||||
...client,
|
||||
CompletionDate: convertDate(client.CompletionDate)
|
||||
};
|
||||
};
|
||||
|
||||
const convertNemesis = (client: INemesisClient): INemesisDatabase => {
|
||||
return {
|
||||
...client,
|
||||
d: convertDate(client.d)
|
||||
};
|
||||
};
|
||||
|
||||
export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
|
||||
for (const key of equipmentKeys) {
|
||||
if (client[key] !== undefined) {
|
||||
@ -153,10 +180,22 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
|
||||
if (client.WeaponSkins !== undefined) {
|
||||
replaceArray<IWeaponSkinDatabase>(db.WeaponSkins, client.WeaponSkins.map(convertWeaponSkin));
|
||||
}
|
||||
if (client.Upgrades !== undefined) {
|
||||
replaceArray<IUpgradeDatabase>(db.Upgrades, client.Upgrades.map(convertUpgrade));
|
||||
for (const key of ["Upgrades", "CrewShipSalvagedWeaponSkins", "CrewShipWeaponSkins"] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
replaceArray<IUpgradeDatabase>(db[key], client[key].map(convertUpgrade));
|
||||
}
|
||||
}
|
||||
for (const key of ["RawUpgrades", "MiscItems", "Consumables"] as const) {
|
||||
for (const key of [
|
||||
"RawUpgrades",
|
||||
"MiscItems",
|
||||
"Consumables",
|
||||
"Recipes",
|
||||
"LevelKeys",
|
||||
"EmailItems",
|
||||
"ShipDecorations",
|
||||
"CrewShipAmmo",
|
||||
"CrewShipRawSalvage"
|
||||
] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key].splice(0, db[key].length);
|
||||
client[key].forEach(x => {
|
||||
@ -190,8 +229,16 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
|
||||
replaceSlots(db[key], client[key]);
|
||||
}
|
||||
}
|
||||
if (client.UseAdultOperatorLoadout !== undefined) {
|
||||
db.UseAdultOperatorLoadout = client.UseAdultOperatorLoadout;
|
||||
for (const key of [
|
||||
"UseAdultOperatorLoadout",
|
||||
"HasOwnedVoidProjectionsPreviously",
|
||||
"ReceivedStartingGear",
|
||||
"ArchwingEnabled",
|
||||
"PlayedParkourTutorial"
|
||||
] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
for (const key of [
|
||||
"PlayerLevel",
|
||||
@ -199,18 +246,37 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
|
||||
"PremiumCredits",
|
||||
"PremiumCreditsFree",
|
||||
"FusionPoints",
|
||||
"PrimeTokens"
|
||||
"PrimeTokens",
|
||||
"TradesRemaining",
|
||||
"GiftsRemaining",
|
||||
"ChallengesFixVersion"
|
||||
] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
for (const key of ["ThemeStyle", "ThemeBackground", "ThemeSounds", "EquippedInstrument", "FocusAbility"] as const) {
|
||||
for (const key of [
|
||||
"ThemeStyle",
|
||||
"ThemeBackground",
|
||||
"ThemeSounds",
|
||||
"EquippedInstrument",
|
||||
"FocusAbility",
|
||||
"ActiveQuest",
|
||||
"SupportedSyndicate",
|
||||
"ActiveAvatarImageType"
|
||||
] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
for (const key of ["EquippedGear", "EquippedEmotes", "NodeIntrosCompleted"] as const) {
|
||||
for (const key of [
|
||||
"EquippedGear",
|
||||
"EquippedEmotes",
|
||||
"NodeIntrosCompleted",
|
||||
"DeathMarks",
|
||||
"Wishlist",
|
||||
"NemesisAbandonedRewards"
|
||||
] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
@ -242,6 +308,77 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
|
||||
if (client.CustomMarkers !== undefined) {
|
||||
db.CustomMarkers = client.CustomMarkers;
|
||||
}
|
||||
if (client.ChallengeProgress !== undefined) {
|
||||
db.ChallengeProgress = client.ChallengeProgress;
|
||||
}
|
||||
if (client.QuestKeys !== undefined) {
|
||||
replaceArray<IQuestKeyDatabase>(db.QuestKeys, client.QuestKeys.map(convertQuestKey));
|
||||
}
|
||||
if (client.LastRegionPlayed !== undefined) {
|
||||
db.LastRegionPlayed = client.LastRegionPlayed;
|
||||
}
|
||||
if (client.PendingRecipes !== undefined) {
|
||||
replaceArray<IPendingRecipeDatabase>(db.PendingRecipes, client.PendingRecipes.map(convertPendingRecipe));
|
||||
}
|
||||
if (client.TauntHistory !== undefined) {
|
||||
db.TauntHistory = client.TauntHistory;
|
||||
}
|
||||
if (client.LoreFragmentScans !== undefined) {
|
||||
db.LoreFragmentScans = client.LoreFragmentScans;
|
||||
}
|
||||
for (const key of ["PendingSpectreLoadouts", "SpectreLoadouts"] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
if (client.FocusXP !== undefined) {
|
||||
db.FocusXP = client.FocusXP;
|
||||
}
|
||||
for (const key of ["Alignment", "AlignmentReplay"] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
if (client.StepSequencers !== undefined) {
|
||||
db.StepSequencers = client.StepSequencers;
|
||||
}
|
||||
if (client.CompletedJobChains !== undefined) {
|
||||
db.CompletedJobChains = client.CompletedJobChains;
|
||||
}
|
||||
if (client.Nemesis !== undefined) {
|
||||
db.Nemesis = convertNemesis(client.Nemesis);
|
||||
}
|
||||
if (client.PlayerSkills !== undefined) {
|
||||
db.PlayerSkills = client.PlayerSkills;
|
||||
}
|
||||
if (client.LotusCustomization !== undefined) {
|
||||
db.LotusCustomization = client.LotusCustomization;
|
||||
}
|
||||
if (client.CollectibleSeries !== undefined) {
|
||||
db.CollectibleSeries = client.CollectibleSeries;
|
||||
}
|
||||
for (const key of ["LibraryAvailableDailyTaskInfo", "LibraryActiveDailyTaskInfo"] as const) {
|
||||
if (client[key] !== undefined) {
|
||||
db[key] = client[key];
|
||||
}
|
||||
}
|
||||
if (client.EndlessXP !== undefined) {
|
||||
db.EndlessXP = client.EndlessXP;
|
||||
}
|
||||
if (client.SongChallenges !== undefined) {
|
||||
db.SongChallenges = client.SongChallenges;
|
||||
}
|
||||
if (client.Missions !== undefined) {
|
||||
db.Missions = client.Missions;
|
||||
}
|
||||
if (client.FlavourItems !== undefined) {
|
||||
db.FlavourItems.splice(0, db.FlavourItems.length);
|
||||
client.FlavourItems.forEach(x => {
|
||||
db.FlavourItems.push({
|
||||
ItemType: x.ItemType
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const convertLoadOutConfig = (client: ILoadoutConfigClient): ILoadoutConfigDatabase => {
|
||||
|
@ -25,8 +25,7 @@ import {
|
||||
ILibraryDailyTaskInfo,
|
||||
ICalendarProgress,
|
||||
IDroneClient,
|
||||
IUpgradeClient,
|
||||
ICrewShipWeaponClient
|
||||
IUpgradeClient
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate";
|
||||
import { IMissionInventoryUpdateRequest, IUpdateChallengeProgressRequest } from "../types/requestTypes";
|
||||
@ -434,7 +433,7 @@ export const addItem = async (
|
||||
}
|
||||
if (typeName in ExportRailjackWeapons) {
|
||||
return {
|
||||
...addCrewShipWeapon(inventory, typeName),
|
||||
...addEquipment(inventory, ExportRailjackWeapons[typeName].productCategory, typeName),
|
||||
...occupySlot(inventory, InventorySlot.RJ_COMPONENT_AND_ARMAMENTS, premiumPurchase)
|
||||
};
|
||||
}
|
||||
@ -947,20 +946,6 @@ export const addSkin = (
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
const addCrewShipWeapon = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
typeName: string,
|
||||
inventoryChanges: IInventoryChanges = {}
|
||||
): IInventoryChanges => {
|
||||
const index = inventory.CrewShipWeapons.push({ ItemType: typeName, _id: new Types.ObjectId() }) - 1;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
inventoryChanges.CrewShipWeapons ??= [];
|
||||
(inventoryChanges.CrewShipWeapons as ICrewShipWeaponClient[]).push(
|
||||
inventory.CrewShipWeapons[index].toJSON<ICrewShipWeaponClient>()
|
||||
);
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
const addCrewShipWeaponSkin = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
typeName: string,
|
||||
|
@ -30,9 +30,8 @@ export interface IInventoryDatabase
|
||||
| "Ships"
|
||||
| "WeaponSkins"
|
||||
| "Upgrades"
|
||||
| "CrewShipSalvagedWeaponSkins"
|
||||
| "CrewShipWeapons"
|
||||
| "CrewShipWeaponSkins"
|
||||
| "CrewShipSalvagedWeaponSkins"
|
||||
| "AdultOperatorLoadOuts"
|
||||
| "OperatorLoadOuts"
|
||||
| "KahlLoadOuts"
|
||||
@ -60,9 +59,8 @@ export interface IInventoryDatabase
|
||||
Ships: Types.ObjectId[];
|
||||
WeaponSkins: IWeaponSkinDatabase[];
|
||||
Upgrades: IUpgradeDatabase[];
|
||||
CrewShipSalvagedWeaponSkins: IUpgradeDatabase[];
|
||||
CrewShipWeapons: ICrewShipWeaponDatabase[];
|
||||
CrewShipWeaponSkins: IUpgradeDatabase[];
|
||||
CrewShipSalvagedWeaponSkins: IUpgradeDatabase[];
|
||||
AdultOperatorLoadOuts: IOperatorConfigDatabase[];
|
||||
OperatorLoadOuts: IOperatorConfigDatabase[];
|
||||
KahlLoadOuts: IOperatorConfigDatabase[];
|
||||
@ -114,7 +112,9 @@ export const equipmentKeys = [
|
||||
"DataKnives",
|
||||
"MechSuits",
|
||||
"CrewShipHarnesses",
|
||||
"KubrowPets"
|
||||
"KubrowPets",
|
||||
"CrewShipWeapons",
|
||||
"CrewShipSalvagedWeapons"
|
||||
] as const;
|
||||
|
||||
export type TEquipmentKey = (typeof equipmentKeys)[number];
|
||||
@ -299,10 +299,8 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
||||
PersonalTechProjects: IPersonalTechProject[];
|
||||
PlayerSkills: IPlayerSkills;
|
||||
CrewShipAmmo: ITypeCount[];
|
||||
CrewShipSalvagedWeaponSkins: IUpgradeClient[];
|
||||
CrewShipWeapons: ICrewShipWeaponClient[];
|
||||
CrewShipSalvagedWeapons: IEquipmentClient[];
|
||||
CrewShipWeaponSkins: IUpgradeClient[];
|
||||
CrewShipSalvagedWeaponSkins: IUpgradeClient[];
|
||||
TradeBannedUntil?: IMongoDate;
|
||||
PlayedParkourTutorial: boolean;
|
||||
SubscribedToEmailsPersonalized: number;
|
||||
@ -538,17 +536,6 @@ export interface ICrewShipWeapon {
|
||||
PORT_GUNS: ICrewShipPortGuns;
|
||||
}
|
||||
|
||||
// inventory.CrewShipWeapons
|
||||
export interface ICrewShipWeaponClient {
|
||||
ItemType: string;
|
||||
ItemId: IOid;
|
||||
}
|
||||
|
||||
export interface ICrewShipWeaponDatabase {
|
||||
ItemType: string;
|
||||
_id: Types.ObjectId;
|
||||
}
|
||||
|
||||
export interface ICrewShipPilotWeapon {
|
||||
PRIMARY_A: IEquipmentSelection;
|
||||
SECONDARY_A: IEquipmentSelection;
|
||||
|
Loading…
x
Reference in New Issue
Block a user