BillySheet/include/generic_object.hpp

146 lines
3.9 KiB
C++
Raw Permalink Normal View History

//
// 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>
// helper type for the visitor
template<typename... Ts>
struct overloaded : Ts ... { using Ts::operator()...; };
template<typename... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
namespace character {
2024-10-30 19:07:23 +01:00
namespace characteristic {
enum class characType : std::uint8_t;
}
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 19:07:23 +01:00
[[nodiscard]] virtual std::int32_t add_materiel(const characteristic::characType &inType) const noexcept = 0;
[[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-30 10:55:52 +01:00
using billyObjects = std::unique_ptr<GenericObject>;
class Weapons final : virtual public GenericObject {
public:
const weapons type{ weapons::Sword };
2024-10-30 16:43:07 +01:00
explicit Weapons(const weapons type) : type(type) {}
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 19:07:23 +01:00
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final;
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; }
};
class Equipments final : virtual public GenericObject {
public:
const equipments type{ equipments::Chainmail };
2024-10-30 16:43:07 +01:00
explicit Equipments(const equipments type) : type(type) {}
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 19:07:23 +01:00
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final;
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; }
};
class Tools final : virtual public GenericObject {
public:
const tools type{ tools::Fourche };
2024-10-30 16:43:07 +01:00
explicit Tools(const tools type) : type(type) {}
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 19:07:23 +01:00
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final;
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; }
};
} // character
#endif //BILLYSHEET_GENERIC_OBJECT_HPP