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