// // Created by postaron on 01/09/24. // #ifndef BILLYSHEET_GENERIC_OBJECT_HPP #define BILLYSHEET_GENERIC_OBJECT_HPP #include #include #include #include // helper type for the visitor template struct overloaded : Ts ... { using Ts::operator()...; }; template overloaded(Ts...) -> overloaded; namespace character { 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; 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::int32_t add_materiel(const characteristic::characType &inType) const noexcept = 0; [[nodiscard]] virtual std::string_view to_string() const noexcept = 0; [[nodiscard]] virtual billyEnums get_type() const noexcept = 0; }; using billyObjects = std::unique_ptr; class Weapons final : virtual public GenericObject { public: const weapons type{ weapons::Sword }; 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; [[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final; [[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 }; 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; [[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final; [[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 }; 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; [[nodiscard]] std::int32_t add_materiel(const characteristic::characType &inType) const noexcept final; [[nodiscard]] std::string_view to_string() const noexcept final; [[nodiscard]] billyEnums get_type() const noexcept final { return type; } }; } // character #endif //BILLYSHEET_GENERIC_OBJECT_HPP