Kelsidavis-WoWee/include/game/inventory.hpp
Kelsi 62b7622f75 feat: parse and display StartQuest field from item query response
Items that begin a quest (like quest starter drop items) now show
"Begins a Quest" in the tooltip.

All three expansion parsers (WotLK/TBC/Classic) now read the
PageText/LanguageID/PageMaterial/StartQuest fields after Description.
startQuestId is propagated through all 5 inventory rebuild paths and
stored in ItemDef.
2026-03-10 17:05:04 -07:00

143 lines
4.4 KiB
C++

#pragma once
#include <cstdint>
#include <string>
#include <array>
#include <vector>
namespace wowee {
namespace game {
enum class ItemQuality : uint8_t {
POOR = 0, // Grey
COMMON = 1, // White
UNCOMMON = 2, // Green
RARE = 3, // Blue
EPIC = 4, // Purple
LEGENDARY = 5, // Orange
};
enum class EquipSlot : uint8_t {
HEAD = 0, NECK, SHOULDERS, SHIRT, CHEST,
WAIST, LEGS, FEET, WRISTS, HANDS,
RING1, RING2, TRINKET1, TRINKET2,
BACK, MAIN_HAND, OFF_HAND, RANGED, TABARD,
BAG1, BAG2, BAG3, BAG4,
NUM_SLOTS // = 23
};
struct ItemDef {
uint32_t itemId = 0;
std::string name;
std::string subclassName; // "Sword", "Mace", "Shield", etc.
ItemQuality quality = ItemQuality::COMMON;
uint8_t inventoryType = 0;
uint32_t stackCount = 1;
uint32_t maxStack = 1;
uint32_t bagSlots = 0;
float damageMin = 0.0f;
float damageMax = 0.0f;
uint32_t delayMs = 0;
// Stats
int32_t armor = 0;
int32_t stamina = 0;
int32_t strength = 0;
int32_t agility = 0;
int32_t intellect = 0;
int32_t spirit = 0;
uint32_t displayInfoId = 0;
uint32_t sellPrice = 0;
uint32_t curDurability = 0;
uint32_t maxDurability = 0;
uint32_t itemLevel = 0;
uint32_t requiredLevel = 0;
uint32_t bindType = 0; // 0=none, 1=BoP, 2=BoE, 3=BoU, 4=BoQ
std::string description; // Flavor/lore text shown in tooltip (italic yellow)
// Generic stat pairs for non-primary stats (hit, crit, haste, AP, SP, etc.)
struct ExtraStat { uint32_t statType = 0; int32_t statValue = 0; };
std::vector<ExtraStat> extraStats;
uint32_t startQuestId = 0; // Non-zero: item begins a quest
};
struct ItemSlot {
ItemDef item;
bool empty() const { return item.itemId == 0; }
};
class Inventory {
public:
static constexpr int BACKPACK_SLOTS = 16;
static constexpr int NUM_EQUIP_SLOTS = 23;
static constexpr int NUM_BAG_SLOTS = 4;
static constexpr int MAX_BAG_SIZE = 36;
static constexpr int BANK_SLOTS = 28;
static constexpr int BANK_BAG_SLOTS = 7;
Inventory();
// Backpack
const ItemSlot& getBackpackSlot(int index) const;
bool setBackpackSlot(int index, const ItemDef& item);
bool clearBackpackSlot(int index);
int getBackpackSize() const { return BACKPACK_SLOTS; }
// Equipment
const ItemSlot& getEquipSlot(EquipSlot slot) const;
bool setEquipSlot(EquipSlot slot, const ItemDef& item);
bool clearEquipSlot(EquipSlot slot);
// Extra bags
int getBagSize(int bagIndex) const;
void setBagSize(int bagIndex, int size);
const ItemSlot& getBagSlot(int bagIndex, int slotIndex) const;
bool setBagSlot(int bagIndex, int slotIndex, const ItemDef& item);
bool clearBagSlot(int bagIndex, int slotIndex);
// Bank slots (28 main + 7 bank bags)
const ItemSlot& getBankSlot(int index) const;
bool setBankSlot(int index, const ItemDef& item);
bool clearBankSlot(int index);
const ItemSlot& getBankBagSlot(int bagIndex, int slotIndex) const;
bool setBankBagSlot(int bagIndex, int slotIndex, const ItemDef& item);
bool clearBankBagSlot(int bagIndex, int slotIndex);
int getBankBagSize(int bagIndex) const;
void setBankBagSize(int bagIndex, int size);
const ItemSlot& getBankBagItem(int bagIndex) const;
void setBankBagItem(int bagIndex, const ItemDef& item);
uint8_t getPurchasedBankBagSlots() const { return purchasedBankBagSlots_; }
void setPurchasedBankBagSlots(uint8_t count) { purchasedBankBagSlots_ = count; }
// Swap two bag slots (equip items + contents)
void swapBagContents(int bagA, int bagB);
// Utility
int findFreeBackpackSlot() const;
bool addItem(const ItemDef& item);
// Test data
void populateTestItems();
private:
std::array<ItemSlot, BACKPACK_SLOTS> backpack{};
std::array<ItemSlot, NUM_EQUIP_SLOTS> equipment{};
struct BagData {
int size = 0;
ItemSlot bagItem; // The bag item itself (for icon/name/tooltip)
std::array<ItemSlot, MAX_BAG_SIZE> slots{};
};
std::array<BagData, NUM_BAG_SLOTS> bags{};
// Bank
std::array<ItemSlot, BANK_SLOTS> bankSlots_{};
std::array<BagData, BANK_BAG_SLOTS> bankBags_{};
uint8_t purchasedBankBagSlots_ = 0;
};
const char* getQualityName(ItemQuality quality);
const char* getEquipSlotName(EquipSlot slot);
} // namespace game
} // namespace wowee