Add InventorySlot enum

This commit is contained in:
Sainan 2024-06-15 01:19:21 +02:00
parent 0570b94533
commit f9afdc7a2b
3 changed files with 16 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { updateCurrency } from "@/src/services/inventoryService"; import { updateCurrency } from "@/src/services/inventoryService";
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { updateSlots } from "@/src/services/inventoryService"; import { updateSlots } from "@/src/services/inventoryService";
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
/* /*
loadout slots are additionally purchased slots only loadout slots are additionally purchased slots only
@ -27,7 +28,7 @@ export const inventorySlotsController: RequestHandler = async (req, res) => {
//TODO: check which slot was purchased because pvpBonus is also possible //TODO: check which slot was purchased because pvpBonus is also possible
const currencyChanges = await updateCurrency(20, true, accountId); const currencyChanges = await updateCurrency(20, true, accountId);
await updateSlots(accountId, "PveBonusLoadoutBin", 1, 1); await updateSlots(accountId, InventorySlot.PVE_LOADOUTS, 1, 1);
//console.log({ InventoryChanges: currencyChanges }, " added loadout changes:"); //console.log({ InventoryChanges: currencyChanges }, " added loadout changes:");

View File

@ -14,7 +14,8 @@ import {
IMission, IMission,
IRawUpgrade, IRawUpgrade,
ISeasonChallengeHistory, ISeasonChallengeHistory,
ITypeCount ITypeCount,
InventorySlot
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; import { IGenericUpdate } from "../types/genericUpdate";
import { import {
@ -74,7 +75,7 @@ export const addItem = async (
case "Powersuits": case "Powersuits":
if (typeName.includes("EntratiMech")) { if (typeName.includes("EntratiMech")) {
const mechSuit = await addMechSuit(typeName, accountId); const mechSuit = await addMechSuit(typeName, accountId);
await updateSlots(accountId, "MechBin", 0, 1); await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1);
logger.debug("mech suit", mechSuit); logger.debug("mech suit", mechSuit);
return { return {
InventoryChanges: { InventoryChanges: {
@ -88,7 +89,7 @@ export const addItem = async (
}; };
} }
const suit = await addPowerSuit(typeName, accountId); const suit = await addPowerSuit(typeName, accountId);
await updateSlots(accountId, "SuitBin", 0, 1); await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
return { return {
InventoryChanges: { InventoryChanges: {
SuitBin: { SuitBin: {
@ -102,7 +103,7 @@ export const addItem = async (
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);
await updateSlots(accountId, "WeaponBin", 0, 1); await updateSlots(accountId, InventorySlot.WEAPONS, 0, 1);
return { return {
InventoryChanges: { InventoryChanges: {
WeaponBin: { count: 1, platinum: 0, Slots: -1 }, WeaponBin: { count: 1, platinum: 0, Slots: -1 },
@ -127,7 +128,7 @@ export const addItem = async (
case "Sentinels": case "Sentinels":
// TOOD: Sentinels should also grant their DefaultUpgrades & SentinelWeapon. // TOOD: Sentinels should also grant their DefaultUpgrades & SentinelWeapon.
const sentinel = await addSentinel(typeName, accountId); const sentinel = await addSentinel(typeName, accountId);
await updateSlots(accountId, "SentinelBin", 0, 1); await updateSlots(accountId, InventorySlot.SENTINELS, 0, 1);
return { return {
InventoryChanges: { InventoryChanges: {
SentinelBin: { count: 1, platinum: 0, Slots: -1 }, SentinelBin: { count: 1, platinum: 0, Slots: -1 },

View File

@ -419,6 +419,14 @@ export interface ICrewShipHarnessConfig {
Upgrades?: string[]; Upgrades?: string[];
} }
export enum InventorySlot {
SUITS = "SuitBin",
WEAPONS = "WeaponBin",
MECHSUITS = "MechBin",
PVE_LOADOUTS = "PveBonusLoadoutBin",
SENTINELS = "SentinelBin"
}
export interface ISlots { export interface ISlots {
Extra: number; // can be undefined, but not if used via mongoose Extra: number; // can be undefined, but not if used via mongoose
Slots: number; Slots: number;