145 lines
3.9 KiB
C++
145 lines
3.9 KiB
C++
//
|
|
// Created by postaron on 01/09/24.
|
|
//
|
|
|
|
#ifndef BILLYSHEET_GENERIC_OBJECT_HPP
|
|
#define BILLYSHEET_GENERIC_OBJECT_HPP
|
|
|
|
#include <cstdint>
|
|
#include <variant>
|
|
#include <string>
|
|
#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 {
|
|
using namespace std::string_literals;
|
|
|
|
enum class weapons : std::uint8_t {
|
|
Sword = 0,
|
|
Lance = 1,
|
|
Morgenstern = 2,
|
|
Bow = 3
|
|
};
|
|
|
|
enum class equipments : std::uint8_t {
|
|
Chainmail = 4,
|
|
CookingPot = 5,
|
|
PamphletTourist = 6,
|
|
MedicKit = 7
|
|
};
|
|
|
|
enum class tools : std::uint8_t {
|
|
Fourche = 8,
|
|
Dagger = 9,
|
|
RockClimbingKit = 10,
|
|
SackOfGrain = 11
|
|
};
|
|
|
|
class Weapons;
|
|
|
|
class Equipments;
|
|
|
|
class Tools;
|
|
|
|
using billyObjects = std::variant<Weapons, Equipments, Tools>;
|
|
using billyEnums = std::variant<weapons, equipments, tools>;
|
|
|
|
static billyObjects new_object(const billyEnums &inputObject);
|
|
|
|
class GenericObject {
|
|
public:
|
|
virtual ~GenericObject() = default;
|
|
|
|
[[nodiscard]] virtual std::uint32_t add_armor() const noexcept = 0;
|
|
|
|
[[nodiscard]] virtual std::uint32_t add_critique() const noexcept = 0;
|
|
|
|
[[nodiscard]] virtual std::uint32_t add_damage() const noexcept = 0;
|
|
|
|
[[nodiscard]] virtual std::uint32_t add_materiel(const characteristic::characType inType) const noexcept = 0;
|
|
|
|
[[nodiscard]] virtual std::string_view to_string() const noexcept = 0;
|
|
};
|
|
|
|
class Weapons final : virtual public GenericObject {
|
|
public:
|
|
const weapons type{ weapons::Sword };
|
|
|
|
friend billyObjects new_object(const billyEnums &inputObject);
|
|
|
|
Weapons() = delete;
|
|
|
|
~Weapons() final = default;
|
|
|
|
[[nodiscard]] std::uint32_t add_armor() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_critique() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept override;
|
|
|
|
private:
|
|
explicit Weapons(const weapons type) : type(type) {}
|
|
};
|
|
|
|
class Equipments final : virtual public GenericObject {
|
|
public:
|
|
const equipments type{ equipments::Chainmail };
|
|
|
|
friend billyObjects new_object(const billyEnums &inputObject);
|
|
|
|
Equipments() = delete;
|
|
|
|
~Equipments() final = default;
|
|
|
|
[[nodiscard]] std::uint32_t add_armor() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_critique() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept override;
|
|
|
|
private:
|
|
explicit Equipments(const equipments type) : type(type) {}
|
|
};
|
|
|
|
class Tools final : virtual public GenericObject {
|
|
public:
|
|
const tools type{ tools::Fourche };
|
|
|
|
friend billyObjects new_object(const billyEnums &inputObject);
|
|
|
|
Tools() = delete;
|
|
|
|
~Tools() final = default;
|
|
|
|
[[nodiscard]] std::uint32_t add_armor() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_critique() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
|
|
|
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept override;
|
|
|
|
private:
|
|
explicit Tools(const tools type) : type(type) {}
|
|
};
|
|
|
|
} // character
|
|
|
|
#endif //BILLYSHEET_GENERIC_OBJECT_HPP
|