BillySheet/include/character_sheet.hpp

118 lines
3.6 KiB
C++
Raw Normal View History

#ifndef BILLYSHEET_CHARACTER_SHEET_HPP
#define BILLYSHEET_CHARACTER_SHEET_HPP
#include "characteristic/adresse.hpp"
#include "characteristic/endurance.hpp"
#include "characteristic/chance.hpp"
#include "characteristic/habilete.hpp"
#include <random>
2022-01-17 19:57:00 +01:00
namespace gui {
2024-01-28 20:31:50 +01:00
class Gui;
2022-01-17 19:57:00 +01:00
}
namespace character {
2024-01-28 20:31:50 +01:00
enum class classe : std::uint8_t {
Guerrier = 0,
Prudent = 1,
Paysan = 2,
Debrouillard = 3,
};
2022-01-25 19:53:58 +01:00
2024-01-28 20:31:50 +01:00
class CharacterSheet final {
private:
friend gui::Gui;
2022-01-25 19:53:58 +01:00
2024-01-28 20:31:50 +01:00
friend class Controller;
2024-01-28 20:31:50 +01:00
std::mt19937_64 engine{ std::random_device{ "rdseed" }() };
2024-01-28 20:31:50 +01:00
std::string caractere{};
2024-01-28 20:31:50 +01:00
characteristic::Adresse adresse;
2024-01-28 20:31:50 +01:00
characteristic::Endurance endurance;
2024-01-28 20:31:50 +01:00
characteristic::Chance chance;
2024-01-28 20:31:50 +01:00
characteristic::Habilete habilete;
2024-01-28 20:31:50 +01:00
classe current_class{ classe::Guerrier };
2022-01-25 19:53:58 +01:00
2024-01-28 20:31:50 +01:00
std::uint32_t health_point{ 0 };
2024-01-28 20:31:50 +01:00
std::uint32_t armor{ 0 };
2024-01-28 20:31:50 +01:00
std::uint32_t damage{ 0 };
2024-01-28 20:31:50 +01:00
std::uint32_t glory{ 0 };
2024-01-28 20:31:50 +01:00
std::uint32_t money{ 0 };
public:
CharacterSheet() = default;
2024-01-28 20:31:50 +01:00
CharacterSheet(const CharacterSheet &sheet) noexcept = default;
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
CharacterSheet(CharacterSheet &&sheet) noexcept = default;
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
CharacterSheet &operator=(const CharacterSheet &characterSheet) noexcept = default;
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
CharacterSheet &operator=(CharacterSheet &&characterSheet) noexcept = default;
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
~CharacterSheet() noexcept = default;
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] const std::string &get_caractere() const { return caractere; }
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] const characteristic::Adresse &get_adresse() const { return adresse; }
2022-01-25 19:53:58 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] const characteristic::Endurance &get_endurance() const { return endurance; }
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] const characteristic::Chance &get_chance() const { return chance; }
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] const characteristic::Habilete &get_habilete() const { return habilete; }
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] classe get_current_class() const { return current_class; }
2022-01-14 22:59:16 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] std::uint32_t get_health_point() const { return health_point; }
2022-01-14 23:15:23 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] std::uint32_t get_armor() const { return armor; }
2022-01-14 23:09:20 +01:00
2024-01-28 20:31:50 +01:00
[[nodiscard]] std::uint32_t get_damage() const { return damage; }
[[nodiscard]] std::uint32_t get_glory() const { return glory; }
[[nodiscard]] std::uint32_t get_money() const { return money; }
friend void from_json(const json &j, CharacterSheet &billy) {
j.at("caractere").get_to(billy.caractere);
j.at("adresse").get_to(billy.adresse);
j.at("endurance").get_to(billy.endurance);
j.at("chance").get_to(billy.chance);
j.at("habilete").get_to(billy.habilete);
j.at("classe").get_to(billy.current_class);
j.at("health_point").get_to(billy.health_point);
j.at("armor").get_to(billy.armor);
j.at("damage").get_to(billy.damage);
j.at("glory").get_to(billy.glory);
j.at("money").get_to(billy.money);
}
};
static void to_json(json &j, const CharacterSheet &billy) {
j["caractere"] = billy.get_caractere();
j["adresse"] = billy.get_adresse();
j["endurance"] = billy.get_endurance();
j["chance"] = billy.get_chance();
j["habilete"] = billy.get_habilete();
j["classe"] = billy.get_current_class();
j["health_point"] = billy.get_health_point();
j["armor"] = billy.get_armor();
j["damage"] = billy.get_damage();
j["glory"] = billy.get_glory();
j["money"] = billy.get_money();
}
}
#endif //BILLYSHEET_CHARACTER_SHEET_HPP