diff --git a/include/billy_objects.hpp b/include/billy_objects.hpp index 6759631..7b4b95b 100644 --- a/include/billy_objects.hpp +++ b/include/billy_objects.hpp @@ -66,7 +66,13 @@ namespace character { void push_object(const billyObject &object, CharacterSheet &sheet) noexcept; - void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept; + void pop_object(CharacterSheet &sheet) noexcept; + + [[nodiscard]] std::pair get_objects() const noexcept { + return { objects, end_object }; + } + +// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept; private: container objects; diff --git a/src/billy_objects.cpp b/src/billy_objects.cpp index 0610c12..dd69c23 100644 --- a/src/billy_objects.cpp +++ b/src/billy_objects.cpp @@ -48,6 +48,46 @@ namespace character { } } + void BillyObjects::pop_object(CharacterSheet &sheet) noexcept { + if (end_object > 0) { + const auto &obj = objects.at(end_object - 1); + --end_object; + + auto &local_habilete = static_cast(sheet.habilete); + auto &local_adresse = static_cast(sheet.adresse); + auto &local_endurance = static_cast(sheet.endurance); + auto &local_chance = static_cast(sheet.chance); + + std::visit(overloaded{ + [&](const weapons &arg) { + --sheet.nb_weapons; + change_carac_weapon(arg, sheet, local_habilete, local_adresse, local_endurance, minus); + }, + [&](const equipments &arg) { + --sheet.nb_equipments; + change_carac_equipment(arg, + sheet, + local_habilete, + local_adresse, + local_endurance, + local_chance, + minus, + plus); + }, + [&](const tools &arg) { + --sheet.nb_tools; + change_carac_tools(arg, + sheet, + local_habilete, + local_adresse, + local_endurance, + local_chance, + minus); + } + }, obj); + } + } + void BillyObjects::change_carac_tools(const tools &arg, CharacterSheet &sheet, Characteristic &localHabilete,