feat: save InvasionProgress/QualifyingInvasions
All checks were successful
Build / build (push) Successful in 1m27s
Build / build (pull_request) Successful in 52s

This commit is contained in:
Sainan 2025-04-18 06:21:30 +02:00
parent 379f57be2c
commit c693b692da
4 changed files with 62 additions and 4 deletions

View File

@ -88,7 +88,9 @@ import {
IPersonalTechProjectDatabase,
IPersonalTechProjectClient,
ILastSortieRewardDatabase,
ILastSortieRewardClient
ILastSortieRewardClient,
IInvasionProgressDatabase,
IInvasionProgressClient
} from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes";
import {
@ -631,6 +633,27 @@ questKeysSchema.set("toJSON", {
export const fusionTreasuresSchema = new Schema<IFusionTreasure>().add(typeCountSchema).add({ Sockets: Number });
const invasionProgressSchema = new Schema<IInvasionProgressDatabase>(
{
invasionId: Schema.Types.ObjectId,
Delta: Number,
AttackerScore: Number,
DefenderScore: Number
},
{ _id: false }
);
invasionProgressSchema.set("toJSON", {
transform(_doc, obj) {
const db = obj as IInvasionProgressDatabase;
const client = obj as IInvasionProgressClient;
client._id = toOid(db.invasionId);
delete obj.invasionId;
delete obj.__v;
}
});
const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
{
ItemType: String,
@ -1423,7 +1446,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
SentientSpawnChanceBoosters: Schema.Types.Mixed,
QualifyingInvasions: [Schema.Types.Mixed],
QualifyingInvasions: [invasionProgressSchema],
FactionScores: [Number],
// https://warframe.fandom.com/wiki/Specter_(Tenno)

View File

@ -530,6 +530,26 @@ export const addMissionInventoryUpdates = async (
inventoryChanges.RegularCredits -= value;
break;
}
case "InvasionProgress": {
for (const clientProgress of value) {
const dbProgress = inventory.QualifyingInvasions.find(x =>
x.invasionId.equals(clientProgress._id.$oid)
);
if (dbProgress) {
dbProgress.Delta += clientProgress.Delta;
dbProgress.AttackerScore += clientProgress.AttackerScore;
dbProgress.DefenderScore += clientProgress.DefenderScore;
} else {
inventory.QualifyingInvasions.push({
invasionId: new Types.ObjectId(clientProgress._id.$oid),
Delta: clientProgress.Delta,
AttackerScore: clientProgress.AttackerScore,
DefenderScore: clientProgress.DefenderScore
});
}
}
break;
}
default:
// Equipment XP updates
if (equipmentKeys.includes(key as TEquipmentKey)) {

View File

@ -49,6 +49,7 @@ export interface IInventoryDatabase
| "PersonalTechProjects"
| "LastSortieReward"
| "LastLiteSortieReward"
| "QualifyingInvasions"
| TEquipmentKey
>,
InventoryDatabaseEquipment {
@ -83,6 +84,7 @@ export interface IInventoryDatabase
PersonalTechProjects: IPersonalTechProjectDatabase[];
LastSortieReward?: ILastSortieRewardDatabase[];
LastLiteSortieReward?: ILastSortieRewardDatabase[];
QualifyingInvasions: IInvasionProgressDatabase[];
}
export interface IQuestKeyDatabase {
@ -270,7 +272,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
SentientSpawnChanceBoosters: ISentientSpawnChanceBoosters;
SupportedSyndicate?: string;
Affiliations: IAffiliation[];
QualifyingInvasions: any[];
QualifyingInvasions: IInvasionProgressClient[];
FactionScores: number[];
ArchwingEnabled?: boolean;
PendingSpectreLoadouts?: ISpectreLoadout[];
@ -668,6 +670,17 @@ export interface IInvasionChainProgress {
count: number;
}
export interface IInvasionProgressClient {
_id: IOid;
Delta: number;
AttackerScore: number;
DefenderScore: number;
}
export interface IInvasionProgressDatabase extends Omit<IInvasionProgressClient, "_id"> {
invasionId: Types.ObjectId;
}
export interface IKubrowPetEggClient {
ItemType: string;
ExpirationDate: IMongoDate; // seems to be set to 7 days ahead @ 0 UTC

View File

@ -19,7 +19,8 @@ import {
ICollectibleEntry,
IDiscoveredMarker,
ILockedWeaponGroupClient,
ILoadOutPresets
ILoadOutPresets,
IInvasionProgressClient
} from "./inventoryTypes/inventoryTypes";
import { IGroup } from "./loginTypes";
@ -123,6 +124,7 @@ export type IMissionInventoryUpdateRequest = {
};
wagerTier?: number; // the index
creditsFee?: number; // the index
InvasionProgress?: IInvasionProgressClient[];
} & {
[K in TEquipmentKey]?: IEquipmentClient[];
};