// // Created by postaron on 01/09/24. // #include "generic_object.hpp" namespace character { using characteristic::characType; static constexpr std::string_view jsonKey{ "billy_objects" }; static constexpr std::string_view sword{ "Sword" }; static constexpr std::string_view lance{ "Lance" }; static constexpr std::string_view morgenstern{ "Morgenstern" }; static constexpr std::string_view bow{ "Bow" }; static constexpr std::string_view chainmail{ "Chainmail" }; static constexpr std::string_view cookingPot{ "Cooking pot" }; static constexpr std::string_view pamphletTourist{ "Touristic pamphlet" }; static constexpr std::string_view medicKit{ "Medic kit" }; static constexpr std::string_view fourche{ "Fourche" }; static constexpr std::string_view dagger{ "Dagger" }; static constexpr std::string_view rockClimbingKit{ "Rock climbing kit" }; static constexpr std::string_view sackOfGrain{ "Sack of grain" }; std::uint32_t Weapons::add_armor() const noexcept { return 0; } std::uint32_t Weapons::add_critique() const noexcept { return 0; } 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 { switch (type) { case weapons::Sword: if (inType == characType::Habilete) { return 4; } else { return 0; } case weapons::Lance: switch (inType) { case characType::Adresse: return 1; case characType::Habilete: return 3; default: return 0; } case weapons::Morgenstern: if (inType == characType::Endurance || inType == characType::Habilete) { return 1; } else { return 0; } case weapons::Bow: switch (inType) { case characType::Habilete: return 3; case characType::Adresse: return 1; default: return 0; } } } std::string_view Weapons::to_string() const noexcept { switch (type) { case weapons::Sword: return sword; case weapons::Lance: return lance; case weapons::Morgenstern: return morgenstern; case weapons::Bow: return bow; } } std::uint32_t Equipments::add_armor() const noexcept { switch (type) { case equipments::Chainmail: return 2; case equipments::CookingPot: return 1; default: return 0; } } std::uint32_t Equipments::add_critique() const noexcept { return 0; } std::uint32_t Equipments::add_damage() const noexcept { return 0; } std::int32_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; case equipments::CookingPot: return inType == characType::Endurance ? 2 : 0; case equipments::PamphletTourist: return inType == characType::Chance ? 4 : 0; case equipments::MedicKit: return inType == characType::Chance ? 1 : 0; } } std::string_view Equipments::to_string() const noexcept { switch (type) { case equipments::Chainmail: return chainmail; case equipments::CookingPot: return cookingPot; case equipments::PamphletTourist: return pamphletTourist; case equipments::MedicKit: return medicKit; } } std::uint32_t Tools::add_armor() const noexcept { return 0; } std::uint32_t Tools::add_critique() const noexcept { return type == tools::Dagger ? 6 : 0; } std::uint32_t Tools::add_damage() const noexcept { return 0; } std::int32_t Tools::add_materiel(const characteristic::characType inType) const noexcept { switch (type) { case tools::Fourche: switch (inType) { case characType::Habilete: return 1; case characType::Endurance: return 3; default: return 0; } case tools::Dagger: return 0; case tools::RockClimbingKit: return inType == characType::Adresse ? 1 : 0; case tools::SackOfGrain: return inType == characType::Endurance || inType == characType::Chance ? 2 : 0; } } std::string_view Tools::to_string() const noexcept { switch (type) { case tools::Fourche: return fourche; case tools::Dagger: return dagger; case tools::RockClimbingKit: return rockClimbingKit; case tools::SackOfGrain: 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); } }