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

SDL_Game_CPP git · main

SDL game in C++

sdl game c++ · first commit 2026-03-24 · last commit 2026-03-24 (8 months ago) · synced 1 hour ago · upstream: codeberg.org/Studying_at_HsNR/SDL_Game_CPP

C++ 99.3%
git clone https://git.christianimmanuel.de/sdl-graphics/SDL_Game_CPP.gitwget https://git.christianimmanuel.de/sdl-graphics/SDL_Game_CPP/archive/SDL_Game_CPP.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);
}