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

@ -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