feat: save InvasionProgress/QualifyingInvasions (#1719)

Reviewed-on: OpenWF/SpaceNinjaServer#1719
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-04-18 11:27:29 -07:00 committed by Sainan
parent cdead6fdf8
commit 8b0ba0b84a
4 changed files with 62 additions and 4 deletions

View File

@ -92,7 +92,9 @@ import {
ICrewMemberSkillEfficiency,
ICrewMemberDatabase,
ICrewMemberClient,
ISortieRewardAttenuation
ISortieRewardAttenuation,
IInvasionProgressDatabase,
IInvasionProgressClient
} from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes";
import {
@ -684,6 +686,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,
@ -1482,7 +1505,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

@ -532,6 +532,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

@ -50,6 +50,7 @@ export interface IInventoryDatabase
| "LastSortieReward"
| "LastLiteSortieReward"
| "CrewMembers"
| "QualifyingInvasions"
| TEquipmentKey
>,
InventoryDatabaseEquipment {
@ -85,6 +86,7 @@ export interface IInventoryDatabase
LastSortieReward?: ILastSortieRewardDatabase[];
LastLiteSortieReward?: ILastSortieRewardDatabase[];
CrewMembers: ICrewMemberDatabase[];
QualifyingInvasions: IInvasionProgressDatabase[];
}
export interface IQuestKeyDatabase {
@ -272,7 +274,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
SentientSpawnChanceBoosters: ISentientSpawnChanceBoosters;
SupportedSyndicate?: string;
Affiliations: IAffiliation[];
QualifyingInvasions: any[];
QualifyingInvasions: IInvasionProgressClient[];
FactionScores: number[];
ArchwingEnabled?: boolean;
PendingSpectreLoadouts?: ISpectreLoadout[];
@ -676,6 +678,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[];
};