BillySheet/include/billy_objects.hpp

82 lines
2.6 KiB
C++
Raw Normal View History

//
// 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>
2024-10-30 17:04:21 +01:00
#include <unordered_map>
2024-02-29 12:23:30 +01:00
#include <ankerl/svector.h>
#include "characteristic/characteristic.hpp"
2024-10-30 17:04:21 +01:00
#include "generic_object.hpp"
namespace character {
class CharacterSheet;
class BillyObjects final {
public:
2024-03-04 17:24:17 +01:00
static constexpr std::size_t max_num_obj{ 3 };
2024-10-30 17:04:21 +01:00
using container = std::unordered_map<billyEnums, billyObjects>;
2024-10-30 17:04:21 +01:00
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,
};
2024-03-04 17:25:11 +01:00
static constexpr std::string_view json_key{ "billy_objects" };
2024-10-30 17:04:21 +01:00
static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
2024-03-04 17:25:11 +01:00
static void to_json(json &j, const BillyObjects::container &billy);
static void from_json(const json &j, BillyObjects::container &billy);
BillyObjects() noexcept = default;
~BillyObjects() noexcept = default;
2024-10-30 17:04:21 +01:00
[[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
2024-02-26 23:53:18 +01:00
2024-10-30 17:04:21 +01:00
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; }
2024-10-30 17:04:21 +01:00
static void check_dagger_conditions(const CharacterSheet &sheet,
characteristic::Characteristic &localHabilete,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation);
private:
std::plus<std::uint32_t> plus;
2024-10-30 17:04:21 +01:00
std::minus<std::uint32_t> minus;
2024-10-30 17:04:21 +01:00
static void change_carac(const billyObjects &arg,
2024-02-29 12:04:09 +01:00
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