Compare commits

..

No commits in common. "05782bae6928a4bc02f5bb70bfad4ec947ef0cf4" and "71e5faf13960534b8ea9f2f94f7741616a65cb89" have entirely different histories.

2 changed files with 23 additions and 34 deletions

View file

@ -47,8 +47,11 @@ 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;
@ -59,22 +62,16 @@ namespace character {
[[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::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) noexcept;
friend billyObjects new_object(const billyEnums &inputObject);
Weapons() = delete;
@ -86,11 +83,9 @@ namespace character {
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
[[nodiscard]] std::uint32_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; }
[[nodiscard]] std::string_view to_string() const noexcept override;
private:
explicit Weapons(const weapons type) : type(type) {}
@ -100,7 +95,7 @@ namespace character {
public:
const equipments type{ equipments::Chainmail };
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
friend billyObjects new_object(const billyEnums &inputObject);
Equipments() = delete;
@ -112,11 +107,9 @@ namespace character {
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
[[nodiscard]] std::uint32_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; }
[[nodiscard]] std::string_view to_string() const noexcept override;
private:
explicit Equipments(const equipments type) : type(type) {}
@ -126,7 +119,7 @@ namespace character {
public:
const tools type{ tools::Fourche };
friend billyObjects new_object(const billyEnums &inputObject) noexcept;
friend billyObjects new_object(const billyEnums &inputObject);
Tools() = delete;
@ -138,11 +131,9 @@ namespace character {
[[nodiscard]] std::uint32_t add_damage() const noexcept final;
[[nodiscard]] std::int32_t add_materiel(const characteristic::characType inType) const noexcept final;
[[nodiscard]] std::uint32_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; }
[[nodiscard]] std::string_view to_string() const noexcept override;
private:
explicit Tools(const tools type) : type(type) {}

View file

@ -30,7 +30,7 @@ namespace character {
std::uint32_t Weapons::add_damage() const noexcept { return type == weapons::Morgenstern ? 1 : 0; }
std::int32_t Weapons::add_materiel(const characteristic::characType inType) const noexcept {
std::uint32_t Weapons::add_materiel(const characteristic::characType inType) const noexcept {
switch (type) {
case weapons::Sword:
if (inType == characType::Habilete) {
@ -93,14 +93,12 @@ namespace character {
std::uint32_t Equipments::add_damage() const noexcept { return 0; }
std::int32_t Equipments::add_materiel(const characteristic::characType inType) const noexcept {
std::uint32_t Equipments::add_materiel(const characteristic::characType inType) const noexcept {
switch (type) {
case equipments::Chainmail:
if (inType == characType::Habilete ||
inType == characType::Adresse) {
return -1;
}
return inType == characType::Endurance ? 1 : 0;
return inType == characType::Habilete ||
inType == characType::Adresse ||
inType == characType::Endurance ? 1 : 0;
case equipments::CookingPot:
return inType == characType::Endurance ? 2 : 0;
case equipments::PamphletTourist:
@ -129,7 +127,7 @@ namespace character {
std::uint32_t Tools::add_damage() const noexcept { return 0; }
std::int32_t Tools::add_materiel(const characteristic::characType inType) const noexcept {
std::uint32_t Tools::add_materiel(const characteristic::characType inType) const noexcept {
switch (type) {
case tools::Fourche:
switch (inType) {
@ -162,11 +160,11 @@ namespace character {
}
}
billyObjects new_object(const billyEnums &inputObject) noexcept {
billyObjects new_object(const billyEnums &inputObject) {
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 }}; }
[](const weapons input) { return billyObjects{ Weapons{ input }}; },
[](const equipments input) { return billyObjects{ Equipments{ input }}; },
[](const tools input) { return billyObjects{ Tools{ input }}; }
}, inputObject);
}
}