feat: handle purchasing of archwing, archgun, & archmelee

This commit is contained in:
Sainan 2024-06-19 02:08:33 +02:00
parent f1237d562d
commit 4ba718f27a
3 changed files with 83 additions and 49 deletions

View File

@ -197,29 +197,32 @@ ArchonCrystalUpgradeSchema.set("toJSON", {
} }
}); });
const EquipmentSchema = new Schema<IEquipmentDatabase>({ const EquipmentSchema = new Schema<IEquipmentDatabase>(
ItemType: String, {
Configs: [ItemConfigSchema], ItemType: String,
UpgradeVer: Number, Configs: [ItemConfigSchema],
XP: Number, UpgradeVer: Number,
Features: Number, XP: Number,
Polarized: Number, Features: Number,
Polarity: [polaritySchema], Polarized: Number,
FocusLens: String, Polarity: [polaritySchema],
ModSlotPurchases: Number, FocusLens: String,
CustomizationSlotPurchases: Number, ModSlotPurchases: Number,
UpgradeType: String, CustomizationSlotPurchases: Number,
UpgradeFingerprint: String, UpgradeType: String,
ItemName: String, UpgradeFingerprint: String,
InfestationDate: Date, ItemName: String,
InfestationDays: Number, InfestationDate: Date,
InfestationType: String, InfestationDays: Number,
ModularParts: [String], InfestationType: String,
UnlockLevel: Number, ModularParts: { type: [String], default: undefined },
Expiry: Date, UnlockLevel: Number,
SkillTree: String, Expiry: Date,
ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined } SkillTree: String,
}); ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined }
},
{ id: false }
);
EquipmentSchema.virtual("ItemId").get(function () { EquipmentSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() } satisfies IOid; return { $oid: this._id.toString() } satisfies IOid;
@ -955,6 +958,9 @@ type InventoryDocumentProps = {
Sentinels: Types.DocumentArray<IEquipmentDatabase>; Sentinels: Types.DocumentArray<IEquipmentDatabase>;
Horses: Types.DocumentArray<IEquipmentDatabase>; Horses: Types.DocumentArray<IEquipmentDatabase>;
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>; PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
SpaceSuits: Types.DocumentArray<IEquipmentDatabase>;
SpaceGuns: Types.DocumentArray<IEquipmentDatabase>;
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
}; };
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types

View File

@ -92,33 +92,51 @@ export const addItem = async (
// Path-based duck typing // Path-based duck typing
switch (typeName.substr(1).split("/")[1]) { switch (typeName.substr(1).split("/")[1]) {
case "Powersuits": case "Powersuits":
if (typeName.includes("EntratiMech")) { switch (typeName.substr(1).split("/")[2]) {
const mechSuit = await addMechSuit(typeName, accountId); default: {
await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1); const suit = await addPowerSuit(typeName, accountId);
logger.debug("mech suit", mechSuit); await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
return { return {
InventoryChanges: { InventoryChanges: {
MechBin: { SuitBin: {
count: 1, count: 1,
platinum: 0, platinum: 0,
Slots: -1 Slots: -1
}, },
MechSuits: [mechSuit] Suits: [suit]
} }
}; };
}
const suit = await addPowerSuit(typeName, accountId);
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
return {
InventoryChanges: {
SuitBin: {
count: 1,
platinum: 0,
Slots: -1
},
Suits: [suit]
} }
}; case "Archwing": {
const spaceSuit = await addSpaceSuit(typeName, accountId);
await updateSlots(accountId, InventorySlot.SPACESUITS, 0, 1);
return {
InventoryChanges: {
SpaceSuitBin: {
count: 1,
platinum: 0,
Slots: -1
},
SpaceSuits: [spaceSuit]
}
};
}
case "EntratiMech": {
const mechSuit = await addMechSuit(typeName, accountId);
await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1);
return {
InventoryChanges: {
MechBin: {
count: 1,
platinum: 0,
Slots: -1
},
MechSuits: [mechSuit]
}
};
}
}
break;
case "Weapons": case "Weapons":
const weaponType = getWeaponType(typeName); const weaponType = getWeaponType(typeName);
const weapon = await addWeapon(weaponType, typeName, accountId); const weapon = await addWeapon(weaponType, typeName, accountId);
@ -277,6 +295,13 @@ export const addSpecialItem = async (itemName: string, accountId: string) => {
return changedInventory.SpecialItems[specialItemIndex - 1].toJSON(); return changedInventory.SpecialItems[specialItemIndex - 1].toJSON();
}; };
export const addSpaceSuit = async (spacesuitName: string, accountId: string) => {
const inventory = await getInventory(accountId);
const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save();
return changedInventory.SpaceSuits[suitIndex - 1].toJSON();
};
export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => { export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => {
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
@ -397,6 +422,8 @@ export const addWeapon = async (
case "Pistols": case "Pistols":
case "Melee": case "Melee":
case "OperatorAmps": case "OperatorAmps":
case "SpaceGuns":
case "SpaceMelee":
weaponIndex = inventory[weaponType].push({ weaponIndex = inventory[weaponType].push({
ItemType: weaponName, ItemType: weaponName,
Configs: [], Configs: [],

View File

@ -358,6 +358,7 @@ export interface ICombat {
export enum InventorySlot { export enum InventorySlot {
SUITS = "SuitBin", SUITS = "SuitBin",
WEAPONS = "WeaponBin", WEAPONS = "WeaponBin",
SPACESUITS = "SpaceSuitBin",
MECHSUITS = "MechBin", MECHSUITS = "MechBin",
PVE_LOADOUTS = "PveBonusLoadoutBin", PVE_LOADOUTS = "PveBonusLoadoutBin",
SENTINELS = "SentinelBin" SENTINELS = "SentinelBin"