Creating easily objects
This commit is contained in:
parent
f7862f09f9
commit
0b2467475a
@ -68,13 +68,11 @@ namespace character {
|
||||
|
||||
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) noexcept;
|
||||
explicit Weapons(const weapons type) : type(type) {}
|
||||
|
||||
Weapons() = delete;
|
||||
|
||||
@ -91,16 +89,13 @@ namespace character {
|
||||
[[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) {}
|
||||
};
|
||||
|
||||
class Equipments final : virtual public GenericObject {
|
||||
public:
|
||||
const equipments type{ equipments::Chainmail };
|
||||
|
||||
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
||||
explicit Equipments(const equipments type) : type(type) {}
|
||||
|
||||
Equipments() = delete;
|
||||
|
||||
@ -117,16 +112,13 @@ namespace character {
|
||||
[[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) {}
|
||||
};
|
||||
|
||||
class Tools final : virtual public GenericObject {
|
||||
public:
|
||||
const tools type{ tools::Fourche };
|
||||
|
||||
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
||||
explicit Tools(const tools type) : type(type) {}
|
||||
|
||||
Tools() = delete;
|
||||
|
||||
@ -143,9 +135,6 @@ namespace character {
|
||||
[[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) {}
|
||||
};
|
||||
|
||||
} // character
|
||||
|
@ -165,12 +165,4 @@ namespace character {
|
||||
return sackOfGrain;
|
||||
}
|
||||
}
|
||||
|
||||
billyObjects new_object(const billyEnums &inputObject) noexcept {
|
||||
return std::visit(overloaded{
|
||||
[](const weapons input) { return billyObjects{ new Weapons{ input }}; },
|
||||
[](const equipments input) { return billyObjects{ new Equipments{ input }}; },
|
||||
[](const tools input) { return billyObjects{ new Tools{ input }}; }
|
||||
}, inputObject);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user