Generic object is good for now
This commit is contained in:
		
					parent
					
						
							
								71e5faf139
							
						
					
				
			
			
				commit
				
					
						8429e7ff8f
					
				
			
		
					 2 changed files with 22 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -47,11 +47,8 @@ namespace character {
 | 
			
		|||
 | 
			
		||||
    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;
 | 
			
		||||
| 
						 | 
				
			
			@ -65,13 +62,19 @@ namespace character {
 | 
			
		|||
        [[nodiscard]] virtual std::uint32_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<GenericObject>;
 | 
			
		||||
 | 
			
		||||
    static billyObjects new_object(const billyEnums &inputObject) noexcept;
 | 
			
		||||
 | 
			
		||||
    class Weapons final : virtual public GenericObject {
 | 
			
		||||
    public:
 | 
			
		||||
        const weapons type{ weapons::Sword };
 | 
			
		||||
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject);
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject) noexcept;
 | 
			
		||||
 | 
			
		||||
        Weapons() = delete;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +88,9 @@ namespace character {
 | 
			
		|||
 | 
			
		||||
        [[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept override;
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] billyEnums get_type() const noexcept final { return type; }
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        explicit Weapons(const weapons type) : type(type) {}
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +100,7 @@ namespace character {
 | 
			
		|||
    public:
 | 
			
		||||
        const equipments type{ equipments::Chainmail };
 | 
			
		||||
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject);
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject) noexcept;
 | 
			
		||||
 | 
			
		||||
        Equipments() = delete;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +114,9 @@ namespace character {
 | 
			
		|||
 | 
			
		||||
        [[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept override;
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] billyEnums get_type() const noexcept final { return type; }
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        explicit Equipments(const equipments type) : type(type) {}
 | 
			
		||||
| 
						 | 
				
			
			@ -119,7 +126,7 @@ namespace character {
 | 
			
		|||
    public:
 | 
			
		||||
        const tools type{ tools::Fourche };
 | 
			
		||||
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject);
 | 
			
		||||
        friend billyObjects new_object(const billyEnums &inputObject) noexcept;
 | 
			
		||||
 | 
			
		||||
        Tools() = delete;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +140,9 @@ namespace character {
 | 
			
		|||
 | 
			
		||||
        [[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept override;
 | 
			
		||||
        [[nodiscard]] std::string_view to_string() const noexcept final;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] billyEnums get_type() const noexcept final { return type; }
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        explicit Tools(const tools type) : type(type) {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue