Nimbin[12]?SDL & Graphics / mapcreator / src/inventory/item.hpp

mapcreator git · master

SDL3 2.5D game and engine using assets, with map editor

sdl3 c++ game engine map-editor cmake · first commit 2025-10-31 · last commit 2026-09-07 (1 month ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-spieleentwicklung/map_creator

C++ 99.3%
git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gz
src/inventory/item.hpp 1.7 KB · 92 lines raw
#pragma once

#include "objects/object.hpp"
#include "building/building_data.hpp"
#include "resource/resource.hpp"

class Inventory;
class Messages;


enum class EquipmentSlot {
    HEAD,
    CAPE,
    CHEST,
    HAND_LEFT,
    HAND_RIGHT,
    LEGS,
    NONE,
    LAST
};


// also add Item::stats if adding to ItemType!
enum class ItemType : uint32_t {
    NONE,
    HAND,
    BUILDING_TOOL,
    SWORD_WOOD,
    SWORD_STONE,
    WOODAXE_STONE,
    BONE_BREASTPLATE,
    PICKAXE_STONE,
    CULTIVATOR,
    LAST
};

struct ItemStats {
    ItemType type;
    std::string title;
    std::initializer_list<BuildingCost> cost;

    int base_damage;
    int base_armor;
    int base_health;

    float base_speed;

    int dmg_per_level;
    int armor_per_level;
    int health_per_level;

    int max_level;

    float crafting_duration;

    EquipmentSlot equipement_slot;

    size_t research_level;
    BuildingType research_station;
};

struct ItemCrafting {
    ItemType type = ItemType::NONE;
    ItemStats stats = {};
    float duration = 0;
    float duration_max = 0;
    bool is_crafting = false;
};



namespace Item {
    extern ItemCrafting crafting_item;

    extern std::vector<ItemStats> stats;

    const ItemStats& get(ItemType t);

    bool is_Weapon(ItemType&);

    int get_Damage(ItemType t, int lvl);

    int get_Health(ItemType t, int lvl);

    std::vector<ItemType>
    get_ResearchedItems(const std::vector<bool>& researched);

    bool craft_ItemStart(Inventory*, ItemType item, ItemCrafting& = Item::crafting_item);
    bool craft_Item(Inventory*, ItemCrafting&, Messages*);
    void craft_Stop(ItemCrafting& = Item::crafting_item);
    std::string to_String(ItemType);
}