This commit is contained in:
Pcornat 2026-01-22 20:20:21 +01:00
commit b050a7634d
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
8 changed files with 113 additions and 104 deletions

View file

@ -66,12 +66,12 @@ namespace character {
std::minus<std::uint32_t> minus;
static void change_carac(const billyObjects &arg,
CharacterSheet &sheet,
characteristic::Characteristic &localHabilete,
characteristic::Characteristic &localAdresse,
characteristic::Characteristic &localEndurance,
characteristic::Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
CharacterSheet &sheet,
characteristic::Characteristic &localHabilete,
characteristic::Characteristic &localAdresse,
characteristic::Characteristic &localEndurance,
characteristic::Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
};
}

View file

@ -7,15 +7,14 @@
namespace character {
enum class classe : std::uint8_t {
Guerrier = 0,
Prudent = 1,
Paysan = 2,
Guerrier = 0,
Prudent = 1,
Paysan = 2,
Debrouillard = 3,
};
class CharacterSheet final {
private:
friend BillyObjects;
std::string caractere{};
@ -33,8 +32,8 @@ namespace character {
BillyObjects::container objects;
std::unordered_set<billyEnums> available_objects{
BillyObjects::all_objects.cbegin(),
BillyObjects::all_objects.cend()
BillyObjects::all_objects.cbegin(),
BillyObjects::all_objects.cend()
};
std::uint32_t health_point{ 0 };
@ -54,6 +53,7 @@ namespace character {
std::uint32_t nb_equipments{ 0 };
std::uint32_t nb_tools{ 0 };
public:
CharacterSheet() = default;
@ -146,4 +146,4 @@ namespace character {
}
#endif //BILLYSHEET_CHARACTER_SHEET_HPP
#endif //BILLYSHEET_CHARACTER_SHEET_HPP

View file

@ -1,6 +1,7 @@
#ifndef BILLYSHEET_CHARACTERISTIC_HPP
#define BILLYSHEET_CHARACTERISTIC_HPP
#include <algorithm>
#include <cstdint>
#include <nlohmann/json.hpp>
@ -12,10 +13,10 @@ namespace character {
namespace character::characteristic {
enum class characType : std::uint8_t {
Adresse = 0,
Adresse = 0,
Endurance = 1,
Chance = 2,
Habilete = 3
Chance = 2,
Habilete = 3
};
class Characteristic {
@ -46,14 +47,14 @@ namespace character::characteristic {
Characteristic() noexcept = default;
Characteristic(const characType inType,
const std::uint32_t carac,
const std::uint32_t materiel,
const std::uint32_t additional) :
base(get_base(inType)),
carac(carac),
materiel(materiel),
additional(additional),
type(inType) { (void) get_total(); }
const std::uint32_t carac,
const std::uint32_t materiel,
const std::uint32_t additional) :
base(get_base(inType)),
carac(carac),
materiel(materiel),
additional(additional),
type(inType) { (void) get_total(); }
explicit Characteristic(const characType inType) : Characteristic(inType, 0, 0, 0) {}
@ -82,9 +83,7 @@ namespace character::characteristic {
[[nodiscard]] std::size_t get_total() const noexcept {
if (total == defaultValue::max()) {
total = static_cast<std::int32_t>(base + carac + materiel + additional);
if (total < 0) {
total = 0;
}
total = std::max(total, 0);
}
return total;
}
@ -110,4 +109,4 @@ namespace character::characteristic {
}
#endif //BILLYSHEET_CHARACTERISTIC_HPP
#endif //BILLYSHEET_CHARACTERISTIC_HPP

View file

@ -12,7 +12,10 @@
// helper type for the visitor
template<typename... Ts>
struct overloaded : Ts ... { using Ts::operator()...; };
struct overloaded : Ts... {
using Ts::operator()...;
};
template<typename... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
@ -24,24 +27,24 @@ namespace character {
using namespace std::string_literals;
enum class weapons : std::uint8_t {
Sword = 0,
Lance = 1,
Sword = 0,
Lance = 1,
Morgenstern = 2,
Bow = 3
Bow = 3
};
enum class equipments : std::uint8_t {
Chainmail = 4,
CookingPot = 5,
Chainmail = 4,
CookingPot = 5,
PamphletTourist = 6,
MedicKit = 7
MedicKit = 7
};
enum class tools : std::uint8_t {
Fourche = 8,
Dagger = 9,
Fourche = 8,
Dagger = 9,
RockClimbingKit = 10,
SackOfGrain = 11
SackOfGrain = 11
};
class Weapons;
@ -139,7 +142,6 @@ namespace character {
[[nodiscard]] billyEnums get_type() const noexcept final { return type; }
};
} // character
#endif //BILLYSHEET_GENERIC_OBJECT_HPP
#endif //BILLYSHEET_GENERIC_OBJECT_HPP