Now popping objects too.

This commit is contained in:
Pcornat 2024-02-26 23:53:18 +01:00
parent fd230e87e9
commit 9d5971e23a
Signed by: Pcornat
GPG Key ID: E0326CC678A00BDD
2 changed files with 47 additions and 1 deletions

View File

@ -66,7 +66,13 @@ namespace character {
void push_object(const billyObject &object, CharacterSheet &sheet) noexcept; 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<const container &, std::int8_t> get_objects() const noexcept {
return { objects, end_object };
}
// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
private: private:
container objects; container objects;

View File

@ -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<Characteristic &>(sheet.habilete);
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
auto &local_endurance = static_cast<Characteristic &>(sheet.endurance);
auto &local_chance = static_cast<Characteristic &>(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, void BillyObjects::change_carac_tools(const tools &arg,
CharacterSheet &sheet, CharacterSheet &sheet,
Characteristic &localHabilete, Characteristic &localHabilete,