BillySheet/include/billy_objects.hpp
2024-12-01 12:48:12 +01:00

79 lines
2.3 KiB
C++

//
// Created by postaron on 20/02/24.
//
#ifndef BILLYSHEET_BILLY_OBJECTS_HPP
#define BILLYSHEET_BILLY_OBJECTS_HPP
#include <cstdint>
#include <array>
#include <functional>
#include <variant>
#include <string_view>
#include <unordered_map>
#include <nlohmann/json_fwd.hpp>
#include "generic_object.hpp"
namespace character {
class CharacterSheet;
namespace characteristic {
class Characteristic;
}
class BillyObjects final {
public:
using json = nlohmann::json;
using container = std::unordered_map<billyEnums, billyObjects>;
static constexpr std::array<billyEnums, 12> all_objects{
weapons::Sword,
weapons::Lance,
weapons::Morgenstern,
weapons::Bow,
equipments::Chainmail,
equipments::CookingPot,
equipments::PamphletTourist,
equipments::MedicKit,
tools::Fourche,
tools::Dagger,
tools::RockClimbingKit,
tools::SackOfGrain,
};
static constexpr std::string_view json_key{ "billy_objects" };
static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
static void to_json(json &j, const container &billy);
static void from_json(const json &j, container &billy);
[[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
void erase_object(CharacterSheet &sheet, const billyEnums objToErase) noexcept;
[[nodiscard]] const std::plus<std::uint32_t> &get_plus_operation() const { return plus; }
[[nodiscard]] const std::minus<std::uint32_t> &get_minus_operation() const { return minus; }
static void check_dagger_conditions(CharacterSheet &sheet);
private:
std::plus<std::uint32_t> plus;
std::minus<std::uint32_t> minus;
static void change_carac(const billyObjects &arg,
CharacterSheet &sheet,
characteristic::Characteristic &localHabilete,
characteristic::Characteristic &localAdresse,
characteristic::Characteristic &localEndurance,
characteristic::Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
};
}
#endif //BILLYSHEET_BILLY_OBJECTS_HPP