Reformat
This commit is contained in:
parent
b3c59ffe0d
commit
b050a7634d
8 changed files with 113 additions and 104 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue