fix: correctly add kubrow eggs to inventory (#875)
This commit is contained in:
parent
9de87f0959
commit
3a7cb5d9b1
@ -58,7 +58,9 @@ import {
|
||||
equipmentKeys,
|
||||
IKubrowPetDetailsDatabase,
|
||||
ITraits,
|
||||
IKubrowPetDetailsClient
|
||||
IKubrowPetDetailsClient,
|
||||
IKubrowPetEggDatabase,
|
||||
IKubrowPetEggClient
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "../../types/commonTypes";
|
||||
import {
|
||||
@ -378,6 +380,26 @@ StepSequencersSchema.set("toJSON", {
|
||||
}
|
||||
});
|
||||
|
||||
const kubrowPetEggSchema = new Schema<IKubrowPetEggDatabase>(
|
||||
{
|
||||
ItemType: String
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
kubrowPetEggSchema.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_document, obj) {
|
||||
const client = obj as IKubrowPetEggClient;
|
||||
const db = obj as IKubrowPetEggDatabase;
|
||||
|
||||
client.ExpirationDate = { $date: { $numberLong: "2000000000000" } };
|
||||
client.ItemId = toOid(db._id);
|
||||
|
||||
delete obj._id;
|
||||
delete obj.__v;
|
||||
}
|
||||
});
|
||||
|
||||
const affiliationsSchema = new Schema<IAffiliation>(
|
||||
{
|
||||
Initiated: Boolean,
|
||||
@ -910,7 +932,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
//The Mandachord(Octavia) is a step sequencer
|
||||
StepSequencers: [StepSequencersSchema],
|
||||
|
||||
KubrowPetEggs: [Schema.Types.Mixed],
|
||||
KubrowPetEggs: [kubrowPetEggSchema],
|
||||
//Prints Cat(3 Prints)\Kubrow(2 Prints) Pets
|
||||
KubrowPetPrints: [Schema.Types.Mixed],
|
||||
|
||||
|
@ -20,7 +20,9 @@ import {
|
||||
TEquipmentKey,
|
||||
IFusionTreasure,
|
||||
IDailyAffiliations,
|
||||
IInventoryDatabase
|
||||
IInventoryDatabase,
|
||||
IKubrowPetEggDatabase,
|
||||
IKubrowPetEggClient
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
import {
|
||||
@ -46,6 +48,7 @@ import {
|
||||
import { createShip } from "./shipService";
|
||||
import { creditBundles, fusionBundles } from "@/src/services/missionInventoryUpdateService";
|
||||
import { IGiveKeyChainTriggeredItemsRequest } from "@/src/controllers/api/giveKeyChainTriggeredItemsController";
|
||||
import { toOid } from "../helpers/inventoryHelpers";
|
||||
|
||||
export const createInventory = async (
|
||||
accountOwnerId: Types.ObjectId,
|
||||
@ -209,7 +212,20 @@ export const addItem = async (
|
||||
};
|
||||
}
|
||||
if (typeName in ExportResources) {
|
||||
if (ExportResources[typeName].productCategory == "Ships") {
|
||||
if (ExportResources[typeName].productCategory == "MiscItems") {
|
||||
const miscItemChanges = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies IMiscItem
|
||||
];
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
return {
|
||||
InventoryChanges: {
|
||||
MiscItems: miscItemChanges
|
||||
}
|
||||
};
|
||||
} else if (ExportResources[typeName].productCategory == "Ships") {
|
||||
const oid = await createShip(inventory.accountOwnerId, typeName);
|
||||
inventory.Ships.push(oid);
|
||||
return {
|
||||
@ -238,17 +254,24 @@ export const addItem = async (
|
||||
ShipDecorations: changes
|
||||
}
|
||||
};
|
||||
} else {
|
||||
const miscItemChanges = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies IMiscItem
|
||||
];
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
} else if (ExportResources[typeName].productCategory == "KubrowPetEggs") {
|
||||
const changes: IKubrowPetEggClient[] = [];
|
||||
for (let i = 0; i != quantity; ++i) {
|
||||
const egg: IKubrowPetEggDatabase = {
|
||||
ItemType: "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg",
|
||||
_id: new Types.ObjectId()
|
||||
};
|
||||
inventory.KubrowPetEggs ??= [];
|
||||
inventory.KubrowPetEggs.push(egg);
|
||||
changes.push({
|
||||
ItemType: egg.ItemType,
|
||||
ExpirationDate: { $date: { $numberLong: "2000000000000" } },
|
||||
ItemId: toOid(egg._id)
|
||||
});
|
||||
}
|
||||
return {
|
||||
InventoryChanges: {
|
||||
MiscItems: miscItemChanges
|
||||
KubrowPetEggs: changes
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ export interface IInventoryDatabase
|
||||
| "KahlLoadOuts"
|
||||
| "InfestedFoundry"
|
||||
| "DialogueHistory"
|
||||
| "KubrowPetEggs"
|
||||
| TEquipmentKey
|
||||
> {
|
||||
accountOwnerId: Types.ObjectId;
|
||||
@ -54,6 +55,7 @@ export interface IInventoryDatabase
|
||||
KahlLoadOuts: IOperatorConfigDatabase[];
|
||||
InfestedFoundry?: IInfestedFoundryDatabase;
|
||||
DialogueHistory?: IDialogueHistoryDatabase;
|
||||
KubrowPetEggs?: IKubrowPetEggDatabase[];
|
||||
|
||||
Suits: IEquipmentDatabase[];
|
||||
LongGuns: IEquipmentDatabase[];
|
||||
@ -271,7 +273,7 @@ export interface IInventoryClient extends IDailyAffiliations {
|
||||
TauntHistory?: ITaunt[];
|
||||
StoryModeChoice: string;
|
||||
PeriodicMissionCompletions: IPeriodicMissionCompletionDatabase[];
|
||||
KubrowPetEggs: IKubrowPetEgg[];
|
||||
KubrowPetEggs?: IKubrowPetEggClient[];
|
||||
LoreFragmentScans: ILoreFragmentScan[];
|
||||
EquippedEmotes: string[];
|
||||
PendingTrades: IPendingTrade[];
|
||||
@ -613,21 +615,22 @@ export interface IInvasionChainProgress {
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface IKubrowPetEgg {
|
||||
ItemType: KubrowPetEggItemType;
|
||||
ExpirationDate: IMongoDate;
|
||||
export interface IKubrowPetEggClient {
|
||||
ItemType: string;
|
||||
ExpirationDate: IMongoDate; // seems to be set to 7 days ahead @ 0 UTC
|
||||
ItemId: IOid;
|
||||
}
|
||||
|
||||
export enum KubrowPetEggItemType {
|
||||
LotusTypesGameKubrowPetEggsKubrowEgg = "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg"
|
||||
export interface IKubrowPetEggDatabase {
|
||||
ItemType: string;
|
||||
_id: Types.ObjectId;
|
||||
}
|
||||
|
||||
export interface IKubrowPetPrint {
|
||||
ItemType: KubrowPetPrintItemType;
|
||||
Name: string;
|
||||
IsMale: boolean;
|
||||
Size: number;
|
||||
Size: number; // seems to be 0.7 to 1.0
|
||||
DominantTraits: ITraits;
|
||||
RecessiveTraits: ITraits;
|
||||
ItemId: IOid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user