BillySheet/include/billy_objects.hpp

110 lines
3.9 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>
#include "characteristic/characteristic.hpp"
// helper type for the visitor
template<typename... Ts>
struct overloaded : Ts ... { using Ts::operator()...; };
template<typename... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
namespace character {
class CharacterSheet;
enum class weapons : std::uint8_t {
Sword = 0,
Lance = 1,
Morgenstern = 2,
Bow = 3
};
enum class equipments : std::uint8_t {
Chainmail = 0,
CookingPot = 1,
PamphletTourist = 2,
MedicKit = 3,
};
enum class tools : std::uint8_t {
Fourche = 0,
Dagger = 1,
RockClimbingKit = 2,
SackOfGrain = 3
};
class BillyObjects final {
public:
using billyObject = std::variant<weapons, equipments, tools>;
using container = std::array<billyObject, 3>;
static constexpr std::string_view sword{ "Sword" };
static constexpr std::string_view lance{ "Lance" };
static constexpr std::string_view morgenstern{ "Morgenstern" };
static constexpr std::string_view bow{ "Bow" };
static constexpr std::string_view chainmail{ "Chainmail" };
static constexpr std::string_view cooking_pot{ "Cooking pot" };
static constexpr std::string_view pamphlet_tourist{ "Touristic pamphlet" };
static constexpr std::string_view medic_kit{ "Medic kit" };
static constexpr std::string_view fourche{ "Fourche" };
static constexpr std::string_view dagger{ "Dagger" };
static constexpr std::string_view rock_climbing_kit{ "Rock climbing kit" };
static constexpr std::string_view sack_of_grain{ "Sack of grain" };
static std::string_view billy_object_to_string(const billyObject &object) noexcept;
void push_object(const billyObject &object, CharacterSheet &sheet) noexcept;
2024-02-26 23:53:18 +01:00
void pop_object(CharacterSheet &sheet) noexcept;
[[nodiscard]] std::pair<const container &, std::int8_t> get_objects() const noexcept {
return { objects, end_object };
}
// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
private:
container objects;
std::plus<std::uint32_t> plus;
std::minus<std::uint32_t> minus;
std::uint8_t end_object{ 0 };
static void change_carac_weapon(const weapons &arg,
2024-02-29 12:04:09 +01:00
CharacterSheet &sheet,
characteristic::Characteristic &localHabilete,
characteristic::Characteristic &localAdresse,
characteristic::Characteristic &localEndurance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
static void change_carac_equipment(const equipments &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)> &primary,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &complement) noexcept;
static void change_carac_tools(const tools &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