Feature: adding matériel to Billy.

No conformity is done when adding things (dagger or bow for example)
This commit is contained in:
Pcornat 2024-09-02 12:46:04 +02:00
commit 75f8db9f5a
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
6 changed files with 124 additions and 37 deletions

View file

@ -5,7 +5,9 @@
#include "characteristic/endurance.hpp"
#include "characteristic/chance.hpp"
#include "characteristic/habilete.hpp"
#include "billy_objects.hpp"
#include <random>
#include <unordered_set>
namespace gui {
class Gui;
@ -23,7 +25,7 @@ namespace character {
private:
friend gui::Gui;
friend class BillyObjects;
friend BillyObjects;
std::mt19937_64 engine{ std::random_device{ "rdseed" }() };
@ -39,6 +41,13 @@ namespace character {
characteristic::Habilete habilete;
BillyObjects::container objects;
std::unordered_set<BillyObjects::billyObject> available_objects{
BillyObjects::all_objects.cbegin(),
BillyObjects::all_objects.cend()
};
std::uint32_t health_point{ 0 };
std::uint32_t armor{ 0 };
@ -79,6 +88,8 @@ namespace character {
[[nodiscard]] const characteristic::Habilete &get_habilete() const { return habilete; }
[[nodiscard]] const BillyObjects::container &get_objects() const { return objects; }
[[nodiscard]] classe get_current_class() const {
if (nb_weapons >= 2) {
return classe::Guerrier;
@ -121,6 +132,7 @@ namespace character {
j.at("nb_weapons").get_to(billy.nb_weapons);
j.at("nb_equipments").get_to(billy.nb_equipments);
j.at("nb_tools").get_to(billy.nb_tools);
BillyObjects::from_json(j.at(BillyObjects::json_key), billy.objects);
}
};
@ -139,6 +151,8 @@ namespace character {
j["nb_weapons"] = billy.get_nb_weapons();
j["nb_equipments"] = billy.get_nb_equipments();
j["nb_tools"] = billy.get_nb_tools();
j.emplace(std::pair{ BillyObjects::json_key, json::array() });
BillyObjects::to_json(j.at(BillyObjects::json_key), billy.get_objects());
}
}