forked from OpenWF/SpaceNinjaServer
feat: handle purchasing of archwing, archgun, & archmelee (#326)
This commit is contained in:
parent
f1237d562d
commit
1fe8351dca
@ -197,29 +197,32 @@ ArchonCrystalUpgradeSchema.set("toJSON", {
|
||||
}
|
||||
});
|
||||
|
||||
const EquipmentSchema = new Schema<IEquipmentDatabase>({
|
||||
ItemType: String,
|
||||
Configs: [ItemConfigSchema],
|
||||
UpgradeVer: Number,
|
||||
XP: Number,
|
||||
Features: Number,
|
||||
Polarized: Number,
|
||||
Polarity: [polaritySchema],
|
||||
FocusLens: String,
|
||||
ModSlotPurchases: Number,
|
||||
CustomizationSlotPurchases: Number,
|
||||
UpgradeType: String,
|
||||
UpgradeFingerprint: String,
|
||||
ItemName: String,
|
||||
InfestationDate: Date,
|
||||
InfestationDays: Number,
|
||||
InfestationType: String,
|
||||
ModularParts: [String],
|
||||
UnlockLevel: Number,
|
||||
Expiry: Date,
|
||||
SkillTree: String,
|
||||
ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined }
|
||||
});
|
||||
const EquipmentSchema = new Schema<IEquipmentDatabase>(
|
||||
{
|
||||
ItemType: String,
|
||||
Configs: [ItemConfigSchema],
|
||||
UpgradeVer: Number,
|
||||
XP: Number,
|
||||
Features: Number,
|
||||
Polarized: Number,
|
||||
Polarity: [polaritySchema],
|
||||
FocusLens: String,
|
||||
ModSlotPurchases: Number,
|
||||
CustomizationSlotPurchases: Number,
|
||||
UpgradeType: String,
|
||||
UpgradeFingerprint: String,
|
||||
ItemName: String,
|
||||
InfestationDate: Date,
|
||||
InfestationDays: Number,
|
||||
InfestationType: String,
|
||||
ModularParts: { type: [String], default: undefined },
|
||||
UnlockLevel: Number,
|
||||
Expiry: Date,
|
||||
SkillTree: String,
|
||||
ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined }
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
|
||||
EquipmentSchema.virtual("ItemId").get(function () {
|
||||
return { $oid: this._id.toString() } satisfies IOid;
|
||||
@ -955,6 +958,10 @@ type InventoryDocumentProps = {
|
||||
Sentinels: Types.DocumentArray<IEquipmentDatabase>;
|
||||
Horses: Types.DocumentArray<IEquipmentDatabase>;
|
||||
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
|
||||
|
@ -92,33 +92,51 @@ export const addItem = async (
|
||||
// Path-based duck typing
|
||||
switch (typeName.substr(1).split("/")[1]) {
|
||||
case "Powersuits":
|
||||
if (typeName.includes("EntratiMech")) {
|
||||
const mechSuit = await addMechSuit(typeName, accountId);
|
||||
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);
|
||||
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
|
||||
return {
|
||||
InventoryChanges: {
|
||||
SuitBin: {
|
||||
count: 1,
|
||||
platinum: 0,
|
||||
Slots: -1
|
||||
},
|
||||
Suits: [suit]
|
||||
switch (typeName.substr(1).split("/")[2]) {
|
||||
default: {
|
||||
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":
|
||||
const weaponType = getWeaponType(typeName);
|
||||
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();
|
||||
};
|
||||
|
||||
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) => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
@ -391,22 +416,12 @@ export const addWeapon = async (
|
||||
): Promise<IEquipmentClient> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
let weaponIndex;
|
||||
switch (weaponType) {
|
||||
case "LongGuns":
|
||||
case "Pistols":
|
||||
case "Melee":
|
||||
case "OperatorAmps":
|
||||
weaponIndex = inventory[weaponType].push({
|
||||
ItemType: weaponName,
|
||||
Configs: [],
|
||||
XP: 0,
|
||||
ModularParts: modularParts
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Error("unknown weapon type: " + weaponType);
|
||||
}
|
||||
const weaponIndex = inventory[weaponType].push({
|
||||
ItemType: weaponName,
|
||||
Configs: [],
|
||||
XP: 0,
|
||||
ModularParts: modularParts
|
||||
});
|
||||
|
||||
const changedInventory = await inventory.save();
|
||||
return changedInventory[weaponType][weaponIndex - 1].toJSON();
|
||||
|
@ -358,6 +358,7 @@ export interface ICombat {
|
||||
export enum InventorySlot {
|
||||
SUITS = "SuitBin",
|
||||
WEAPONS = "WeaponBin",
|
||||
SPACESUITS = "SpaceSuitBin",
|
||||
MECHSUITS = "MechBin",
|
||||
PVE_LOADOUTS = "PveBonusLoadoutBin",
|
||||
SENTINELS = "SentinelBin"
|
||||
|
Loading…
x
Reference in New Issue
Block a user