2024-10-29 23:23:56 +01:00
|
|
|
//
|
|
|
|
// 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 billyEnums = std::variant<weapons, equipments, tools>;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-10-30 12:17:14 +01:00
|
|
|
[[nodiscard]] virtual std::int32_t add_materiel(const characteristic::characType inType) const noexcept = 0;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
[[nodiscard]] virtual std::string_view to_string() const noexcept = 0;
|
2024-10-30 10:55:52 +01:00
|
|
|
|
|
|
|
[[nodiscard]] virtual billyEnums get_type() const noexcept = 0;
|
2024-10-29 23:23:56 +01:00
|
|
|
};
|
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
using billyObjects = std::unique_ptr<GenericObject>;
|
|
|
|
|
|
|
|
static billyObjects new_object(const billyEnums &inputObject) noexcept;
|
|
|
|
|
2024-10-29 23:23:56 +01:00
|
|
|
class Weapons final : virtual public GenericObject {
|
|
|
|
public:
|
|
|
|
const weapons type{ weapons::Sword };
|
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-10-30 12:17:14 +01:00
|
|
|
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept final;
|
|
|
|
|
|
|
|
[[nodiscard]] billyEnums get_type() const noexcept final { return type; }
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Weapons(const weapons type) : type(type) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Equipments final : virtual public GenericObject {
|
|
|
|
public:
|
|
|
|
const equipments type{ equipments::Chainmail };
|
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-10-30 12:17:14 +01:00
|
|
|
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept final;
|
|
|
|
|
|
|
|
[[nodiscard]] billyEnums get_type() const noexcept final { return type; }
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Equipments(const equipments type) : type(type) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Tools final : virtual public GenericObject {
|
|
|
|
public:
|
|
|
|
const tools type{ tools::Fourche };
|
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-10-30 12:17:14 +01:00
|
|
|
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
2024-10-29 23:23:56 +01:00
|
|
|
|
2024-10-30 10:55:52 +01:00
|
|
|
[[nodiscard]] std::string_view to_string() const noexcept final;
|
|
|
|
|
|
|
|
[[nodiscard]] billyEnums get_type() const noexcept final { return type; }
|
2024-10-29 23:23:56 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Tools(const tools type) : type(type) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // character
|
|
|
|
|
|
|
|
#endif //BILLYSHEET_GENERIC_OBJECT_HPP
|