Compare commits
	
		
			No commits in common. "7a5d36f6ead66e695e3efd0c9d4a480ff6d2b13c" and "92575d7d085d36517f45da81a915da5130b42fd4" have entirely different histories.
		
	
	
		
			
				7a5d36f6ea
			
			...
			
				92575d7d08
			
		
	
		
					 7 changed files with 82 additions and 114 deletions
				
			
		| 
						 | 
					@ -2,13 +2,11 @@ cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
project(UnitTest CXX)
 | 
					project(UnitTest CXX)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include(CTest)
 | 
					 | 
				
			||||||
include(../external/catch2/extras/Catch.cmake)
 | 
					include(../external/catch2/extras/Catch.cmake)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(UnitTest
 | 
					add_executable(UnitTest adummy.cpp
 | 
				
			||||||
        characteristics_tests.cpp
 | 
					        characteristics_tests.cpp
 | 
				
			||||||
        billy_objects_tests.cpp
 | 
					        billy_objects_tests.cpp
 | 
				
			||||||
        sheet_tests.cpp
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set_target_properties(Catch2 UnitTest PROPERTIES
 | 
					set_target_properties(Catch2 UnitTest PROPERTIES
 | 
				
			||||||
| 
						 | 
					@ -16,7 +14,7 @@ set_target_properties(Catch2 UnitTest PROPERTIES
 | 
				
			||||||
        CXX_STANDARD_REQUIRED ON
 | 
					        CXX_STANDARD_REQUIRED ON
 | 
				
			||||||
        CXX_EXTENSIONS OFF
 | 
					        CXX_EXTENSIONS OFF
 | 
				
			||||||
        INTERPROCEDURAL_OPTIMIZATION_RELEASE ON
 | 
					        INTERPROCEDURAL_OPTIMIZATION_RELEASE ON
 | 
				
			||||||
        #        UNITY_BUILD ON
 | 
					        UNITY_BUILD ON
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
 | 
					target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
 | 
				
			||||||
target_compile_definitions(UnitTest PRIVATE ${DEF_COMP})
 | 
					target_compile_definitions(UnitTest PRIVATE ${DEF_COMP})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								Unit testing/adummy.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Unit testing/adummy.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					#define CATCH_CONFIG_MAIN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <catch2/catch_all.hpp>
 | 
				
			||||||
| 
						 | 
					@ -20,14 +20,12 @@ namespace character::test {
 | 
				
			||||||
    void from_json(const json &j, DummyObject &dummy) {
 | 
					    void from_json(const json &j, DummyObject &dummy) {
 | 
				
			||||||
        BillyObjects::from_json(j, dummy.objects);
 | 
					        BillyObjects::from_json(j, dummy.objects);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    static std::unique_ptr<GenericObject> get_obj(const billyEnums &object) noexcept {
 | 
					    static std::unique_ptr<GenericObject> get_obj(const billyEnums &object) noexcept {
 | 
				
			||||||
        return std::visit(overloaded{
 | 
					        return std::visit(overloaded{
 | 
				
			||||||
                [](const weapons &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Weapons>(arg)); },
 | 
					                [](const weapons &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Weapons>(arg)); },
 | 
				
			||||||
                [](const equipments &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Equipments>(arg)); },
 | 
					                [](const equipments &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Equipments>(arg)); },
 | 
				
			||||||
                [](const tools &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Tools>(arg)); },
 | 
					                [](const tools &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Tools>(arg)); },
 | 
				
			||||||
            },
 | 
					        }, object);
 | 
				
			||||||
            object);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +39,9 @@ TEST_CASE("[C] Serialize empty BillyObjects", "[serialize][0]") {
 | 
				
			||||||
    serializer.clear();
 | 
					    serializer.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    REQUIRE_NOTHROW(tester.empty() == true);
 | 
					    REQUIRE_NOTHROW(tester.empty() == true);
 | 
				
			||||||
    REQUIRE(tester.empty()); {
 | 
					    REQUIRE(tester.empty());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        std::ofstream file{ "billy_objects_empty.json" };
 | 
					        std::ofstream file{ "billy_objects_empty.json" };
 | 
				
			||||||
        file << tester << std::flush;
 | 
					        file << tester << std::flush;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,8 @@ TEST_CASE("[C] Serialize empty BillyObjects", "[serialize][0]") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_CASE("[C] Serialize full BillyObjects", "[serialize][1]") {
 | 
					TEST_CASE("[C] Serialize full BillyObjects", "[serialize][1]") {
 | 
				
			||||||
    BillyObjects gestionnaire{};
 | 
					    BillyObjects gestionnaire{};
 | 
				
			||||||
    test::DummyObject dummy_object; {
 | 
					    test::DummyObject dummy_object;
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        CharacterSheet sheet;
 | 
					        CharacterSheet sheet;
 | 
				
			||||||
        REQUIRE(gestionnaire.insert_object(sheet, weapons::Sword));
 | 
					        REQUIRE(gestionnaire.insert_object(sheet, weapons::Sword));
 | 
				
			||||||
        REQUIRE(gestionnaire.insert_object(sheet, tools::Fourche));
 | 
					        REQUIRE(gestionnaire.insert_object(sheet, tools::Fourche));
 | 
				
			||||||
| 
						 | 
					@ -64,7 +65,9 @@ TEST_CASE("[C] Serialize full BillyObjects", "[serialize][1]") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto &tester = serializer.at("sheet").at(BillyObjects::json_key);
 | 
					    const auto &tester = serializer.at("sheet").at(BillyObjects::json_key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    REQUIRE_FALSE(tester.empty()); {
 | 
					    REQUIRE_FALSE(tester.empty());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        std::ofstream file{ "billy_objects_full.json" };
 | 
					        std::ofstream file{ "billy_objects_full.json" };
 | 
				
			||||||
        file << tester << std::flush;
 | 
					        file << tester << std::flush;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -85,6 +88,7 @@ TEST_CASE("[D] Deserialize empty BillyObjects", "[deserialize][0]") {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_CASE("[D] Deserialize full BillyObjects", "[deserialize][1]") {
 | 
					TEST_CASE("[D] Deserialize full BillyObjects", "[deserialize][1]") {
 | 
				
			||||||
 | 
					//    BillyObjects gestionnaire{};
 | 
				
			||||||
    test::DummyObject dummy_object;
 | 
					    test::DummyObject dummy_object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto deserializer = []() -> json {
 | 
					    const auto deserializer = []() -> json {
 | 
				
			||||||
| 
						 | 
					@ -108,18 +112,18 @@ TEST_CASE("[D] Deserialize full BillyObjects", "[deserialize][1]") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_CASE("[D] Pushing popping BillyObjects", "[pushpop][0]") {
 | 
					TEST_CASE("[D] Pushing popping BillyObjects", "[pushpop][0]") {
 | 
				
			||||||
    constexpr std::array<billyEnums, 12> all_objects{
 | 
					    constexpr std::array<billyEnums, 12> all_objects{
 | 
				
			||||||
        weapons::Sword,
 | 
					            weapons::Sword,
 | 
				
			||||||
        weapons::Lance,
 | 
					            weapons::Lance,
 | 
				
			||||||
        weapons::Morgenstern,
 | 
					            weapons::Morgenstern,
 | 
				
			||||||
        weapons::Bow,
 | 
					            weapons::Bow,
 | 
				
			||||||
        equipments::Chainmail,
 | 
					            equipments::Chainmail,
 | 
				
			||||||
        equipments::CookingPot,
 | 
					            equipments::CookingPot,
 | 
				
			||||||
        equipments::PamphletTourist,
 | 
					            equipments::PamphletTourist,
 | 
				
			||||||
        equipments::MedicKit,
 | 
					            equipments::MedicKit,
 | 
				
			||||||
        tools::Fourche,
 | 
					            tools::Fourche,
 | 
				
			||||||
        tools::Dagger,
 | 
					            tools::Dagger,
 | 
				
			||||||
        tools::RockClimbingKit,
 | 
					            tools::RockClimbingKit,
 | 
				
			||||||
        tools::SackOfGrain,
 | 
					            tools::SackOfGrain,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    BillyObjects gestionnaire{};
 | 
					    BillyObjects gestionnaire{};
 | 
				
			||||||
| 
						 | 
					@ -156,9 +160,9 @@ TEST_CASE("[D] Printing Billy's objects", "[printing]") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_CASE("[Z] Cleaning after all tests", "[cleaning]") {
 | 
					TEST_CASE("[Z] Cleaning after all tests", "[cleaning]") {
 | 
				
			||||||
    namespace fs = std::filesystem;
 | 
					    namespace fs = std::filesystem;
 | 
				
			||||||
    const auto pwd = is_directory(fs::current_path())
 | 
					    const auto pwd = is_directory(fs::current_path()) ?
 | 
				
			||||||
                         ? fs::directory_iterator(fs::current_path())
 | 
					                     fs::directory_iterator(fs::current_path()) :
 | 
				
			||||||
                         : fs::directory_iterator(fs::current_path().root_directory());
 | 
					                     fs::directory_iterator(fs::current_path().root_directory());
 | 
				
			||||||
    for (const auto &entry: pwd) {
 | 
					    for (const auto &entry: pwd) {
 | 
				
			||||||
        if (entry.is_regular_file() && entry.path().extension() == ".json") {
 | 
					        if (entry.is_regular_file() && entry.path().extension() == ".json") {
 | 
				
			||||||
            fs::remove(entry);
 | 
					            fs::remove(entry);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,31 +0,0 @@
 | 
				
			||||||
#include <catch2/catch_all.hpp>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					 | 
				
			||||||
#include <character_sheet.hpp>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace character;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TEST_CASE("[E] Serialize sheet", "[serialize][0]") {
 | 
					 | 
				
			||||||
    CharacterSheet sheet;
 | 
					 | 
				
			||||||
    BillyObjects gestion{};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    REQUIRE(gestion.insert_object(sheet, weapons::Sword));
 | 
					 | 
				
			||||||
    REQUIRE(gestion.insert_object(sheet, weapons::Lance));
 | 
					 | 
				
			||||||
    REQUIRE(gestion.insert_object(sheet, tools::Dagger));
 | 
					 | 
				
			||||||
    BillyObjects::check_dagger_conditions(sheet);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    BillyObjects::json serializer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    REQUIRE_NOTHROW(serializer["character_sheet"] = sheet); {
 | 
					 | 
				
			||||||
        std::ofstream file{ "character_sheet.json" };
 | 
					 | 
				
			||||||
        file << serializer << std::flush;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TEST_CASE("[F] Deserialize sheet", "[deserialize][0]") {
 | 
					 | 
				
			||||||
    const auto deserializer = []() {
 | 
					 | 
				
			||||||
        std::ifstream file{ "character_sheet.json" };
 | 
					 | 
				
			||||||
        return json::parse(file);
 | 
					 | 
				
			||||||
    }();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const auto sheet = deserializer.at("character_sheet").get<CharacterSheet>();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace character {
 | 
					namespace character {
 | 
				
			||||||
    class CharacterSheet;
 | 
					    class CharacterSheet;
 | 
				
			||||||
 | 
					    namespace characteristic{
 | 
				
			||||||
    namespace characteristic {
 | 
					 | 
				
			||||||
        class Characteristic;
 | 
					        class Characteristic;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,18 +27,18 @@ namespace character {
 | 
				
			||||||
        using container = std::unordered_map<billyEnums, billyObjects>;
 | 
					        using container = std::unordered_map<billyEnums, billyObjects>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static constexpr std::array<billyEnums, 12> all_objects{
 | 
					        static constexpr std::array<billyEnums, 12> all_objects{
 | 
				
			||||||
            weapons::Sword,
 | 
					                weapons::Sword,
 | 
				
			||||||
            weapons::Lance,
 | 
					                weapons::Lance,
 | 
				
			||||||
            weapons::Morgenstern,
 | 
					                weapons::Morgenstern,
 | 
				
			||||||
            weapons::Bow,
 | 
					                weapons::Bow,
 | 
				
			||||||
            equipments::Chainmail,
 | 
					                equipments::Chainmail,
 | 
				
			||||||
            equipments::CookingPot,
 | 
					                equipments::CookingPot,
 | 
				
			||||||
            equipments::PamphletTourist,
 | 
					                equipments::PamphletTourist,
 | 
				
			||||||
            equipments::MedicKit,
 | 
					                equipments::MedicKit,
 | 
				
			||||||
            tools::Fourche,
 | 
					                tools::Fourche,
 | 
				
			||||||
            tools::Dagger,
 | 
					                tools::Dagger,
 | 
				
			||||||
            tools::RockClimbingKit,
 | 
					                tools::RockClimbingKit,
 | 
				
			||||||
            tools::SackOfGrain,
 | 
					                tools::SackOfGrain,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static constexpr std::string_view json_key{ "billy_objects" };
 | 
					        static constexpr std::string_view json_key{ "billy_objects" };
 | 
				
			||||||
| 
						 | 
					@ -62,7 +61,9 @@ namespace character {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [[nodiscard]] const std::minus<std::uint32_t> &get_minus_operation() const { return minus; }
 | 
					        [[nodiscard]] const std::minus<std::uint32_t> &get_minus_operation() const { return minus; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void check_dagger_conditions(CharacterSheet &sheet);
 | 
					        static void check_dagger_conditions(const CharacterSheet &sheet,
 | 
				
			||||||
 | 
					                characteristic::Characteristic &localHabilete,
 | 
				
			||||||
 | 
					                const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
        std::plus<std::uint32_t> plus;
 | 
					        std::plus<std::uint32_t> plus;
 | 
				
			||||||
| 
						 | 
					@ -70,12 +71,12 @@ namespace character {
 | 
				
			||||||
        std::minus<std::uint32_t> minus;
 | 
					        std::minus<std::uint32_t> minus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void change_carac(const billyObjects &arg,
 | 
					        static void change_carac(const billyObjects &arg,
 | 
				
			||||||
            CharacterSheet &sheet,
 | 
					                CharacterSheet &sheet,
 | 
				
			||||||
            characteristic::Characteristic &localHabilete,
 | 
					                characteristic::Characteristic &localHabilete,
 | 
				
			||||||
            characteristic::Characteristic &localAdresse,
 | 
					                characteristic::Characteristic &localAdresse,
 | 
				
			||||||
            characteristic::Characteristic &localEndurance,
 | 
					                characteristic::Characteristic &localEndurance,
 | 
				
			||||||
            characteristic::Characteristic &localChance,
 | 
					                characteristic::Characteristic &localChance,
 | 
				
			||||||
            const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
 | 
					                const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,17 +17,11 @@ namespace character {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool BillyObjects::insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept {
 | 
					    bool BillyObjects::insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept {
 | 
				
			||||||
        if (sheet.objects.size() < 3) {
 | 
					        if (sheet.objects.size() < 3) {
 | 
				
			||||||
            sheet.objects.emplace(objType,
 | 
					            sheet.objects.emplace(objType, std::visit(overloaded{
 | 
				
			||||||
                std::visit(overloaded{
 | 
					                    [](const weapons &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Weapons>(arg)); },
 | 
				
			||||||
                        [](const weapons &arg) {
 | 
					                    [](const equipments &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Equipments>(arg)); },
 | 
				
			||||||
                            return std::unique_ptr<GenericObject>(std::make_unique<Weapons>(arg));
 | 
					                    [](const tools &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Tools>(arg)); },
 | 
				
			||||||
                        },
 | 
					            }, objType));
 | 
				
			||||||
                        [](const equipments &arg) {
 | 
					 | 
				
			||||||
                            return std::unique_ptr<GenericObject>(std::make_unique<Equipments>(arg));
 | 
					 | 
				
			||||||
                        },
 | 
					 | 
				
			||||||
                        [](const tools &arg) { return std::unique_ptr<GenericObject>(std::make_unique<Tools>(arg)); },
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    objType));
 | 
					 | 
				
			||||||
            const auto &object = sheet.objects[objType];
 | 
					            const auto &object = sheet.objects[objType];
 | 
				
			||||||
            sheet.available_objects.erase(objType);
 | 
					            sheet.available_objects.erase(objType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,8 +34,7 @@ namespace character {
 | 
				
			||||||
                    [&](const weapons &arg) { ++sheet.nb_weapons; },
 | 
					                    [&](const weapons &arg) { ++sheet.nb_weapons; },
 | 
				
			||||||
                    [&](const equipments &arg) { ++sheet.nb_equipments; },
 | 
					                    [&](const equipments &arg) { ++sheet.nb_equipments; },
 | 
				
			||||||
                    [&](const tools &arg) { ++sheet.nb_tools; },
 | 
					                    [&](const tools &arg) { ++sheet.nb_tools; },
 | 
				
			||||||
                },
 | 
					            }, objType);
 | 
				
			||||||
                objType);
 | 
					 | 
				
			||||||
            change_carac(object, sheet, local_habilete, local_adresse, local_endurance, local_chance, plus);
 | 
					            change_carac(object, sheet, local_habilete, local_adresse, local_endurance, local_chance, plus);
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -63,19 +56,18 @@ namespace character {
 | 
				
			||||||
                    [&](const weapons &arg) { --sheet.nb_weapons; },
 | 
					                    [&](const weapons &arg) { --sheet.nb_weapons; },
 | 
				
			||||||
                    [&](const equipments &arg) { --sheet.nb_equipments; },
 | 
					                    [&](const equipments &arg) { --sheet.nb_equipments; },
 | 
				
			||||||
                    [&](const tools &arg) { --sheet.nb_tools; }
 | 
					                    [&](const tools &arg) { --sheet.nb_tools; }
 | 
				
			||||||
                },
 | 
					            }, objToErase);
 | 
				
			||||||
                objToErase);
 | 
					 | 
				
			||||||
            change_carac(obj, sheet, local_habilete, local_adresse, local_endurance, local_chance, minus);
 | 
					            change_carac(obj, sheet, local_habilete, local_adresse, local_endurance, local_chance, minus);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void BillyObjects::change_carac(const billyObjects &arg,
 | 
					    void BillyObjects::change_carac(const billyObjects &arg,
 | 
				
			||||||
        CharacterSheet &sheet,
 | 
					            CharacterSheet &sheet,
 | 
				
			||||||
        Characteristic &localHabilete,
 | 
					            Characteristic &localHabilete,
 | 
				
			||||||
        Characteristic &localAdresse,
 | 
					            Characteristic &localAdresse,
 | 
				
			||||||
        Characteristic &localEndurance,
 | 
					            Characteristic &localEndurance,
 | 
				
			||||||
        Characteristic &localChance,
 | 
					            Characteristic &localChance,
 | 
				
			||||||
        const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept {
 | 
					            const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept {
 | 
				
			||||||
        localHabilete.materiel = operation(localHabilete.materiel, arg->add_materiel(localHabilete.type));
 | 
					        localHabilete.materiel = operation(localHabilete.materiel, arg->add_materiel(localHabilete.type));
 | 
				
			||||||
        localAdresse.materiel = operation(localAdresse.materiel, arg->add_materiel(localAdresse.type));
 | 
					        localAdresse.materiel = operation(localAdresse.materiel, arg->add_materiel(localAdresse.type));
 | 
				
			||||||
        localEndurance.materiel = operation(localEndurance.materiel, arg->add_materiel(localEndurance.type));
 | 
					        localEndurance.materiel = operation(localEndurance.materiel, arg->add_materiel(localEndurance.type));
 | 
				
			||||||
| 
						 | 
					@ -85,17 +77,19 @@ namespace character {
 | 
				
			||||||
        sheet.critique = operation(sheet.critique, arg->add_critique());
 | 
					        sheet.critique = operation(sheet.critique, arg->add_critique());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void BillyObjects::check_dagger_conditions(CharacterSheet &sheet) {
 | 
					    void BillyObjects::check_dagger_conditions(const CharacterSheet &sheet,
 | 
				
			||||||
        if (const auto it_dagger = sheet.get_objects().find(tools::Dagger); it_dagger != sheet.get_objects().cend()) {
 | 
					            Characteristic &localHabilete,
 | 
				
			||||||
            const std::size_t count_weapons = std::count_if(sheet.get_objects().cbegin(),
 | 
					            const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) {
 | 
				
			||||||
                sheet.get_objects().cend(),
 | 
					        if (const auto it_dagger = sheet.objects.find(tools::Dagger); it_dagger != sheet.objects.cend()) {
 | 
				
			||||||
                [](container::const_reference node) {
 | 
					            const std::size_t count_weapons = std::count_if(sheet.objects.cbegin(),
 | 
				
			||||||
                    return std::get_if<weapons>(&node.first) != nullptr;
 | 
					                    sheet.objects.cend(),
 | 
				
			||||||
                }
 | 
					                    [](container::const_reference node) {
 | 
				
			||||||
            );
 | 
					                        return std::get_if<weapons>(&node.first) != nullptr;
 | 
				
			||||||
            if (const bool is_there_bow = sheet.get_objects().find(weapons::Bow) != sheet.get_objects().cend();
 | 
					                    });
 | 
				
			||||||
                count_weapons > 1 || is_there_bow) {
 | 
					            const bool is_there_bow = sheet.objects.find(weapons::Bow) != sheet.objects.cend();
 | 
				
			||||||
                sheet.habilete.materiel -= it_dagger->second->add_materiel(sheet.get_habilete().type);
 | 
					            if (count_weapons > 1 || is_there_bow) {
 | 
				
			||||||
 | 
					                localHabilete.materiel = operation(localHabilete.materiel,
 | 
				
			||||||
 | 
					                        -it_dagger->second->add_materiel(localHabilete.type));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -114,7 +108,7 @@ namespace character {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case equipmentHash:
 | 
					                case equipmentHash:
 | 
				
			||||||
                    billy.emplace(static_cast<equipments>(value),
 | 
					                    billy.emplace(static_cast<equipments>(value),
 | 
				
			||||||
                        std::make_unique<Equipments>(static_cast<equipments>(value)));
 | 
					                            std::make_unique<Equipments>(static_cast<equipments>(value)));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case toolsHash:
 | 
					                case toolsHash:
 | 
				
			||||||
                    billy.emplace(static_cast<tools>(value), std::make_unique<Tools>(static_cast<tools>(value)));
 | 
					                    billy.emplace(static_cast<tools>(value), std::make_unique<Tools>(static_cast<tools>(value)));
 | 
				
			||||||
| 
						 | 
					@ -135,8 +129,7 @@ namespace character {
 | 
				
			||||||
                    [&j](const tools tool) {
 | 
					                    [&j](const tools tool) {
 | 
				
			||||||
                        j.emplace_back(std::pair{ toolsHash, static_cast<std::uint8_t>(tool) });
 | 
					                        j.emplace_back(std::pair{ toolsHash, static_cast<std::uint8_t>(tool) });
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                },
 | 
					            }, object_type);
 | 
				
			||||||
                object_type);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue