Compare commits
2 Commits
71e5faf139
...
05782bae69
Author | SHA1 | Date | |
---|---|---|---|
05782bae69 | |||
8429e7ff8f |
@ -47,11 +47,8 @@ namespace character {
|
|||||||
|
|
||||||
class Tools;
|
class Tools;
|
||||||
|
|
||||||
using billyObjects = std::variant<Weapons, Equipments, Tools>;
|
|
||||||
using billyEnums = std::variant<weapons, equipments, tools>;
|
using billyEnums = std::variant<weapons, equipments, tools>;
|
||||||
|
|
||||||
static billyObjects new_object(const billyEnums &inputObject);
|
|
||||||
|
|
||||||
class GenericObject {
|
class GenericObject {
|
||||||
public:
|
public:
|
||||||
virtual ~GenericObject() = default;
|
virtual ~GenericObject() = default;
|
||||||
@ -62,16 +59,22 @@ namespace character {
|
|||||||
|
|
||||||
[[nodiscard]] virtual std::uint32_t add_damage() const noexcept = 0;
|
[[nodiscard]] virtual std::uint32_t add_damage() const noexcept = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual std::uint32_t add_materiel(const characteristic::characType inType) 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 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 {
|
class Weapons final : virtual public GenericObject {
|
||||||
public:
|
public:
|
||||||
const weapons type{ weapons::Sword };
|
const weapons type{ weapons::Sword };
|
||||||
|
|
||||||
friend billyObjects new_object(const billyEnums &inputObject);
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
||||||
|
|
||||||
Weapons() = delete;
|
Weapons() = delete;
|
||||||
|
|
||||||
@ -83,9 +86,11 @@ namespace character {
|
|||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
[[nodiscard]] std::int32_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:
|
private:
|
||||||
explicit Weapons(const weapons type) : type(type) {}
|
explicit Weapons(const weapons type) : type(type) {}
|
||||||
@ -95,7 +100,7 @@ namespace character {
|
|||||||
public:
|
public:
|
||||||
const equipments type{ equipments::Chainmail };
|
const equipments type{ equipments::Chainmail };
|
||||||
|
|
||||||
friend billyObjects new_object(const billyEnums &inputObject);
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
||||||
|
|
||||||
Equipments() = delete;
|
Equipments() = delete;
|
||||||
|
|
||||||
@ -107,9 +112,11 @@ namespace character {
|
|||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
[[nodiscard]] std::int32_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:
|
private:
|
||||||
explicit Equipments(const equipments type) : type(type) {}
|
explicit Equipments(const equipments type) : type(type) {}
|
||||||
@ -119,7 +126,7 @@ namespace character {
|
|||||||
public:
|
public:
|
||||||
const tools type{ tools::Fourche };
|
const tools type{ tools::Fourche };
|
||||||
|
|
||||||
friend billyObjects new_object(const billyEnums &inputObject);
|
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
|
||||||
|
|
||||||
Tools() = delete;
|
Tools() = delete;
|
||||||
|
|
||||||
@ -131,9 +138,11 @@ namespace character {
|
|||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t add_materiel(const characteristic::characType inType) const noexcept final;
|
[[nodiscard]] std::int32_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:
|
private:
|
||||||
explicit Tools(const tools type) : type(type) {}
|
explicit Tools(const tools type) : type(type) {}
|
||||||
|
@ -30,7 +30,7 @@ namespace character {
|
|||||||
|
|
||||||
std::uint32_t Weapons::add_damage() const noexcept { return type == weapons::Morgenstern ? 1 : 0; }
|
std::uint32_t Weapons::add_damage() const noexcept { return type == weapons::Morgenstern ? 1 : 0; }
|
||||||
|
|
||||||
std::uint32_t Weapons::add_materiel(const characteristic::characType inType) const noexcept {
|
std::int32_t Weapons::add_materiel(const characteristic::characType inType) const noexcept {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case weapons::Sword:
|
case weapons::Sword:
|
||||||
if (inType == characType::Habilete) {
|
if (inType == characType::Habilete) {
|
||||||
@ -93,12 +93,14 @@ namespace character {
|
|||||||
|
|
||||||
std::uint32_t Equipments::add_damage() const noexcept { return 0; }
|
std::uint32_t Equipments::add_damage() const noexcept { return 0; }
|
||||||
|
|
||||||
std::uint32_t Equipments::add_materiel(const characteristic::characType inType) const noexcept {
|
std::int32_t Equipments::add_materiel(const characteristic::characType inType) const noexcept {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case equipments::Chainmail:
|
case equipments::Chainmail:
|
||||||
return inType == characType::Habilete ||
|
if (inType == characType::Habilete ||
|
||||||
inType == characType::Adresse ||
|
inType == characType::Adresse) {
|
||||||
inType == characType::Endurance ? 1 : 0;
|
return -1;
|
||||||
|
}
|
||||||
|
return inType == characType::Endurance ? 1 : 0;
|
||||||
case equipments::CookingPot:
|
case equipments::CookingPot:
|
||||||
return inType == characType::Endurance ? 2 : 0;
|
return inType == characType::Endurance ? 2 : 0;
|
||||||
case equipments::PamphletTourist:
|
case equipments::PamphletTourist:
|
||||||
@ -127,7 +129,7 @@ namespace character {
|
|||||||
|
|
||||||
std::uint32_t Tools::add_damage() const noexcept { return 0; }
|
std::uint32_t Tools::add_damage() const noexcept { return 0; }
|
||||||
|
|
||||||
std::uint32_t Tools::add_materiel(const characteristic::characType inType) const noexcept {
|
std::int32_t Tools::add_materiel(const characteristic::characType inType) const noexcept {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case tools::Fourche:
|
case tools::Fourche:
|
||||||
switch (inType) {
|
switch (inType) {
|
||||||
@ -160,11 +162,11 @@ namespace character {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
billyObjects new_object(const billyEnums &inputObject) {
|
billyObjects new_object(const billyEnums &inputObject) noexcept {
|
||||||
return std::visit(overloaded{
|
return std::visit(overloaded{
|
||||||
[](const weapons input) { return billyObjects{ Weapons{ input }}; },
|
[](const weapons input) { return billyObjects{ new Weapons{ input }}; },
|
||||||
[](const equipments input) { return billyObjects{ Equipments{ input }}; },
|
[](const equipments input) { return billyObjects{ new Equipments{ input }}; },
|
||||||
[](const tools input) { return billyObjects{ Tools{ input }}; }
|
[](const tools input) { return billyObjects{ new Tools{ input }}; }
|
||||||
}, inputObject);
|
}, inputObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user