2024-02-26 14:27:40 +01:00
|
|
|
//
|
|
|
|
// Created by postaron on 23/02/24.
|
|
|
|
//
|
|
|
|
#include "billy_objects.hpp"
|
|
|
|
#include "characteristic/characteristic.hpp"
|
|
|
|
#include "character_sheet.hpp"
|
|
|
|
|
|
|
|
namespace character {
|
|
|
|
using characteristic::Characteristic;
|
|
|
|
|
2024-02-26 23:51:09 +01:00
|
|
|
void BillyObjects::push_object(const billyObject &object, CharacterSheet &sheet) noexcept {
|
2024-02-29 12:23:30 +01:00
|
|
|
if (objects.size() < 3) {
|
|
|
|
objects.emplace_back(object);
|
2024-02-26 14:27:40 +01:00
|
|
|
|
|
|
|
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;
|
2024-02-26 23:51:09 +01:00
|
|
|
change_carac_weapon(arg, sheet, local_habilete, local_adresse, local_endurance, plus);
|
2024-02-26 14:27:40 +01:00
|
|
|
},
|
|
|
|
[&](const equipments &arg) {
|
|
|
|
++sheet.nb_equipments;
|
|
|
|
change_carac_equipment(arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
sheet,
|
|
|
|
local_habilete,
|
|
|
|
local_adresse,
|
|
|
|
local_endurance,
|
|
|
|
local_chance,
|
|
|
|
plus,
|
|
|
|
minus);
|
2024-02-26 14:27:40 +01:00
|
|
|
},
|
|
|
|
[&](const tools &arg) {
|
|
|
|
++sheet.nb_tools;
|
|
|
|
change_carac_tools(arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
sheet,
|
|
|
|
local_habilete,
|
|
|
|
local_adresse,
|
|
|
|
local_endurance,
|
|
|
|
local_chance,
|
|
|
|
plus);
|
2024-02-26 14:27:40 +01:00
|
|
|
},
|
|
|
|
}, object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 23:53:18 +01:00
|
|
|
void BillyObjects::pop_object(CharacterSheet &sheet) noexcept {
|
2024-02-29 12:23:30 +01:00
|
|
|
if (!objects.empty()) {
|
|
|
|
const billyObject obj = objects.back();
|
|
|
|
objects.pop_back();
|
2024-02-26 23:53:18 +01:00
|
|
|
|
|
|
|
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,
|
2024-02-29 12:04:09 +01:00
|
|
|
sheet,
|
|
|
|
local_habilete,
|
|
|
|
local_adresse,
|
|
|
|
local_endurance,
|
|
|
|
local_chance,
|
|
|
|
minus,
|
|
|
|
plus);
|
2024-02-26 23:53:18 +01:00
|
|
|
},
|
|
|
|
[&](const tools &arg) {
|
|
|
|
--sheet.nb_tools;
|
|
|
|
change_carac_tools(arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
sheet,
|
|
|
|
local_habilete,
|
|
|
|
local_adresse,
|
|
|
|
local_endurance,
|
|
|
|
local_chance,
|
|
|
|
minus);
|
2024-02-26 23:53:18 +01:00
|
|
|
}
|
|
|
|
}, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 14:27:40 +01:00
|
|
|
void BillyObjects::change_carac_tools(const tools &arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
CharacterSheet &sheet,
|
|
|
|
Characteristic &localHabilete,
|
|
|
|
Characteristic &localAdresse,
|
|
|
|
Characteristic &localEndurance,
|
|
|
|
Characteristic &localChance,
|
|
|
|
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept {
|
2024-02-26 14:27:40 +01:00
|
|
|
switch (arg) {
|
|
|
|
case tools::Fourche:
|
|
|
|
localHabilete.materiel = operation(localHabilete.materiel, 1);
|
|
|
|
localEndurance.materiel = operation(localEndurance.materiel, 3);
|
|
|
|
break;
|
|
|
|
case tools::Dagger:
|
|
|
|
break;
|
|
|
|
case tools::RockClimbingKit:
|
|
|
|
localAdresse.materiel = operation(localAdresse.materiel, 1);
|
|
|
|
break;
|
|
|
|
case tools::SackOfGrain:
|
|
|
|
localEndurance.materiel = operation(localEndurance.materiel, 2);
|
|
|
|
localChance.materiel = operation(localChance.materiel, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BillyObjects::change_carac_equipment(const equipments &arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
CharacterSheet &sheet,
|
|
|
|
Characteristic &localHabilete,
|
|
|
|
Characteristic &localAdresse,
|
|
|
|
Characteristic &localEndurance,
|
|
|
|
Characteristic &localChance,
|
|
|
|
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &primary,
|
2024-02-29 12:23:16 +01:00
|
|
|
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &complement) noexcept {
|
2024-02-26 14:27:40 +01:00
|
|
|
switch (arg) {
|
|
|
|
case equipments::Chainmail:
|
|
|
|
localHabilete.materiel = complement(localHabilete.materiel, 1);
|
|
|
|
localAdresse.materiel = complement(localAdresse.materiel, 1);
|
|
|
|
localEndurance.materiel = primary(localEndurance.materiel, 1);
|
|
|
|
sheet.armor = primary(sheet.armor, 2);
|
|
|
|
break;
|
|
|
|
case equipments::CookingPot:
|
|
|
|
localEndurance.materiel = primary(localEndurance.materiel, 2);
|
|
|
|
sheet.armor = primary(sheet.armor, 1);
|
|
|
|
break;
|
|
|
|
case equipments::PamphletTourist:
|
|
|
|
localChance.materiel = primary(localChance.materiel, 4);
|
|
|
|
break;
|
|
|
|
case equipments::MedicKit:
|
|
|
|
localChance.materiel = primary(localChance.materiel, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 23:51:09 +01:00
|
|
|
void BillyObjects::change_carac_weapon(const weapons &arg,
|
2024-02-29 12:04:09 +01:00
|
|
|
CharacterSheet &sheet,
|
|
|
|
Characteristic &localHabilete,
|
|
|
|
Characteristic &localAdresse,
|
|
|
|
Characteristic &localEndurance,
|
2024-02-29 12:23:16 +01:00
|
|
|
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept {
|
2024-02-26 14:27:40 +01:00
|
|
|
switch (arg) {
|
|
|
|
case weapons::Sword:
|
|
|
|
localHabilete.materiel = operation(localHabilete.materiel, 4);
|
|
|
|
break;
|
|
|
|
case weapons::Lance:
|
|
|
|
localHabilete.materiel = operation(localHabilete.materiel, 3);
|
|
|
|
localAdresse.materiel = operation(localAdresse.materiel, 1);
|
|
|
|
break;
|
|
|
|
case weapons::Morgenstern:
|
|
|
|
localHabilete.materiel = operation(localHabilete.materiel, 1);
|
|
|
|
localEndurance.materiel = operation(localEndurance.materiel, 1);
|
|
|
|
sheet.damage = operation(sheet.damage, 1);
|
|
|
|
break;
|
|
|
|
case weapons::Bow:
|
|
|
|
localHabilete.materiel = operation(localHabilete.materiel, 3);
|
|
|
|
localAdresse.materiel = operation(localAdresse.materiel, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string_view BillyObjects::billy_object_to_string(const billyObject &object) noexcept {
|
|
|
|
return std::visit(overloaded{
|
|
|
|
[](const weapons &arg) {
|
|
|
|
switch (arg) {
|
|
|
|
case weapons::Sword:
|
|
|
|
return sword;
|
|
|
|
case weapons::Lance:
|
|
|
|
return lance;
|
|
|
|
case weapons::Morgenstern:
|
|
|
|
return morgenstern;
|
|
|
|
case weapons::Bow:
|
|
|
|
return bow;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[](const equipments &arg) {
|
|
|
|
switch (arg) {
|
|
|
|
case equipments::Chainmail:
|
|
|
|
return chainmail;
|
|
|
|
case equipments::CookingPot:
|
|
|
|
return cooking_pot;
|
|
|
|
case equipments::MedicKit:
|
|
|
|
return medic_kit;
|
2024-02-26 16:47:57 +01:00
|
|
|
case equipments::PamphletTourist:
|
|
|
|
return pamphlet_tourist;
|
2024-02-26 14:27:40 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
[](const tools &arg) {
|
|
|
|
switch (arg) {
|
|
|
|
case tools::Fourche:
|
|
|
|
return fourche;
|
|
|
|
case tools::Dagger:
|
|
|
|
return dagger;
|
|
|
|
case tools::RockClimbingKit:
|
|
|
|
return rock_climbing_kit;
|
|
|
|
case tools::SackOfGrain:
|
|
|
|
return sack_of_grain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, object);
|
|
|
|
}
|
|
|
|
}
|