feat: handle purchasing of archwing, archgun, & archmelee (#326)
This commit is contained in:
parent
f1237d562d
commit
1fe8351dca
@ -197,7 +197,8 @@ ArchonCrystalUpgradeSchema.set("toJSON", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const EquipmentSchema = new Schema<IEquipmentDatabase>({
|
const EquipmentSchema = new Schema<IEquipmentDatabase>(
|
||||||
|
{
|
||||||
ItemType: String,
|
ItemType: String,
|
||||||
Configs: [ItemConfigSchema],
|
Configs: [ItemConfigSchema],
|
||||||
UpgradeVer: Number,
|
UpgradeVer: Number,
|
||||||
@ -214,12 +215,14 @@ const EquipmentSchema = new Schema<IEquipmentDatabase>({
|
|||||||
InfestationDate: Date,
|
InfestationDate: Date,
|
||||||
InfestationDays: Number,
|
InfestationDays: Number,
|
||||||
InfestationType: String,
|
InfestationType: String,
|
||||||
ModularParts: [String],
|
ModularParts: { type: [String], default: undefined },
|
||||||
UnlockLevel: Number,
|
UnlockLevel: Number,
|
||||||
Expiry: Date,
|
Expiry: Date,
|
||||||
SkillTree: String,
|
SkillTree: String,
|
||||||
ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined }
|
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,10 @@ 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>;
|
||||||
|
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
@ -92,21 +92,8 @@ 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);
|
|
||||||
logger.debug("mech suit", mechSuit);
|
|
||||||
return {
|
|
||||||
InventoryChanges: {
|
|
||||||
MechBin: {
|
|
||||||
count: 1,
|
|
||||||
platinum: 0,
|
|
||||||
Slots: -1
|
|
||||||
},
|
|
||||||
MechSuits: [mechSuit]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const suit = await addPowerSuit(typeName, accountId);
|
const suit = await addPowerSuit(typeName, accountId);
|
||||||
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
|
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
|
||||||
return {
|
return {
|
||||||
@ -119,6 +106,37 @@ export const addItem = async (
|
|||||||
Suits: [suit]
|
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);
|
||||||
|
|
||||||
@ -391,22 +416,12 @@ export const addWeapon = async (
|
|||||||
): Promise<IEquipmentClient> => {
|
): Promise<IEquipmentClient> => {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
|
|
||||||
let weaponIndex;
|
const weaponIndex = inventory[weaponType].push({
|
||||||
switch (weaponType) {
|
|
||||||
case "LongGuns":
|
|
||||||
case "Pistols":
|
|
||||||
case "Melee":
|
|
||||||
case "OperatorAmps":
|
|
||||||
weaponIndex = inventory[weaponType].push({
|
|
||||||
ItemType: weaponName,
|
ItemType: weaponName,
|
||||||
Configs: [],
|
Configs: [],
|
||||||
XP: 0,
|
XP: 0,
|
||||||
ModularParts: modularParts
|
ModularParts: modularParts
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("unknown weapon type: " + weaponType);
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedInventory = await inventory.save();
|
const changedInventory = await inventory.save();
|
||||||
return changedInventory[weaponType][weaponIndex - 1].toJSON();
|
return changedInventory[weaponType][weaponIndex - 1].toJSON();
|
||||||
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user