Compare commits
No commits in common. "79d575da10adeadc8e71b2154205cce5dd3a8785" and "86a0f20bca199efa1f6f48b92b2fa65b22380486" have entirely different histories.
79d575da10
...
86a0f20bca
3 changed files with 36 additions and 60 deletions
|
|
@ -55,22 +55,8 @@ namespace character {
|
||||||
|
|
||||||
static void from_json(const json &j, container &billy);
|
static void from_json(const json &j, container &billy);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief It inserts the object inside the sheet.
|
|
||||||
*
|
|
||||||
* This method changes values inside the sheet according to the book's rules.
|
|
||||||
* \param sheet sheet to insert object into
|
|
||||||
* \param objType the object to insert
|
|
||||||
* \return true: object inserted, false otherwise
|
|
||||||
*/
|
|
||||||
[[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
|
[[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* \param sheet sheet to erase object from
|
|
||||||
* \param objToErase the object to erase
|
|
||||||
* \return true: object erased, false otherwise
|
|
||||||
*/
|
|
||||||
[[nodiscard]] bool erase_object(CharacterSheet &sheet, const billyEnums objToErase) noexcept;
|
[[nodiscard]] bool erase_object(CharacterSheet &sheet, const billyEnums objToErase) noexcept;
|
||||||
|
|
||||||
[[nodiscard]] static bool is_full(const CharacterSheet &sheet) noexcept;
|
[[nodiscard]] static bool is_full(const CharacterSheet &sheet) noexcept;
|
||||||
|
|
@ -86,15 +72,13 @@ namespace character {
|
||||||
|
|
||||||
std::minus<std::uint32_t> minus;
|
std::minus<std::uint32_t> minus;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* \param arg object used to change values
|
|
||||||
* \param sheet sheet to change
|
|
||||||
* \param operation Operation to apply to change values
|
|
||||||
*/
|
|
||||||
static void change_carac(const billyObjects &arg,
|
static void change_carac(const billyObjects &arg,
|
||||||
CharacterSheet &sheet,
|
CharacterSheet &sheet,
|
||||||
const std::function<uint32_t(uint32_t, uint32_t)> &operation) noexcept;
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ namespace character {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace character::characteristic {
|
namespace character::characteristic {
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Different characteristic type
|
|
||||||
*/
|
|
||||||
enum class characType : std::uint8_t {
|
enum class characType : std::uint8_t {
|
||||||
Adresse = 0,
|
Adresse = 0,
|
||||||
Endurance = 1,
|
Endurance = 1,
|
||||||
|
|
@ -23,35 +19,17 @@ namespace character::characteristic {
|
||||||
Habilete = 3
|
Habilete = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief This class represents a characteristic for Billy (one of characType)
|
|
||||||
*/
|
|
||||||
class Characteristic {
|
class Characteristic {
|
||||||
protected:
|
protected:
|
||||||
friend BillyObjects;
|
friend character::BillyObjects;
|
||||||
using defaultValue = std::numeric_limits<std::int32_t>;
|
using defaultValue = std::numeric_limits<std::int32_t>;
|
||||||
|
|
||||||
//! Total point for this charac
|
|
||||||
mutable std::int32_t total{ defaultValue::max() };
|
mutable std::int32_t total{ defaultValue::max() };
|
||||||
|
|
||||||
//! Base value
|
|
||||||
const std::uint32_t base{ 0 };
|
const std::uint32_t base{ 0 };
|
||||||
|
|
||||||
//! Value depending of the characType for this characteristic.
|
|
||||||
std::uint32_t carac{ 0 };
|
std::uint32_t carac{ 0 };
|
||||||
|
|
||||||
//! Value changed from a billyObjects (billyEnums) possessed
|
|
||||||
std::uint32_t materiel{ 0 };
|
std::uint32_t materiel{ 0 };
|
||||||
|
|
||||||
//! Additional value when creating the character
|
|
||||||
std::uint32_t additional{ 0 };
|
std::uint32_t additional{ 0 };
|
||||||
|
|
||||||
/*!
|
static std::uint32_t get_base(const characType inType) noexcept {
|
||||||
* \brief Get base value depending of the characType
|
|
||||||
* \param inType Characteristic type used to get base number
|
|
||||||
* \return Base value depending of the characType
|
|
||||||
*/
|
|
||||||
static constexpr std::uint32_t get_base(const characType inType) noexcept {
|
|
||||||
switch (inType) {
|
switch (inType) {
|
||||||
case characType::Adresse:
|
case characType::Adresse:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -66,21 +44,21 @@ namespace character::characteristic {
|
||||||
public:
|
public:
|
||||||
const characType type{ characType::Adresse };
|
const characType type{ characType::Adresse };
|
||||||
|
|
||||||
constexpr Characteristic() noexcept = default;
|
Characteristic() noexcept = default;
|
||||||
|
|
||||||
constexpr Characteristic(const characType inType,
|
Characteristic(const characType inType,
|
||||||
const std::uint32_t carac,
|
const std::uint32_t carac,
|
||||||
const std::uint32_t materiel,
|
const std::uint32_t materiel,
|
||||||
const std::uint32_t additional) :
|
const std::uint32_t additional) :
|
||||||
base(get_base(inType)),
|
base(get_base(inType)),
|
||||||
carac(carac),
|
carac(carac),
|
||||||
materiel(materiel),
|
materiel(materiel),
|
||||||
additional(additional),
|
additional(additional),
|
||||||
type(inType) { (void) get_total(); }
|
type(inType) { (void) get_total(); }
|
||||||
|
|
||||||
constexpr explicit Characteristic(const characType inType) : Characteristic(inType, 0, 0, 0) {}
|
explicit Characteristic(const characType inType) : Characteristic(inType, 0, 0, 0) {}
|
||||||
|
|
||||||
constexpr Characteristic(const Characteristic &charac) noexcept = default;
|
Characteristic(const Characteristic &charac) noexcept = default;
|
||||||
|
|
||||||
Characteristic &operator=(const Characteristic &charac) noexcept {
|
Characteristic &operator=(const Characteristic &charac) noexcept {
|
||||||
const_cast<std::uint32_t &>(base) = charac.base;
|
const_cast<std::uint32_t &>(base) = charac.base;
|
||||||
|
|
@ -131,4 +109,4 @@ namespace character::characteristic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //BILLYSHEET_CHARACTERISTIC_HPP
|
#endif //BILLYSHEET_CHARACTERISTIC_HPP
|
||||||
|
|
@ -40,13 +40,18 @@ namespace character {
|
||||||
const auto &object = sheet.objects[objType];
|
const auto &object = sheet.objects[objType];
|
||||||
sheet.available_objects.erase(objType);
|
sheet.available_objects.erase(objType);
|
||||||
|
|
||||||
|
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||||
|
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||||
|
auto &local_endurance = static_cast<Characteristic &>(sheet.endurance);
|
||||||
|
auto &local_chance = static_cast<Characteristic &>(sheet.chance);
|
||||||
|
|
||||||
std::visit(overloaded{
|
std::visit(overloaded{
|
||||||
[&](const weapons &) { ++sheet.nb_weapons; },
|
[&](const weapons &) { ++sheet.nb_weapons; },
|
||||||
[&](const equipments &) { ++sheet.nb_equipments; },
|
[&](const equipments &) { ++sheet.nb_equipments; },
|
||||||
[&](const tools &) { ++sheet.nb_tools; },
|
[&](const tools &) { ++sheet.nb_tools; },
|
||||||
},
|
},
|
||||||
objType);
|
objType);
|
||||||
change_carac(object, sheet, plus);
|
change_carac(object, sheet, local_habilete, local_adresse, local_endurance, local_chance, plus);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -58,13 +63,18 @@ namespace character {
|
||||||
sheet.objects.erase(objToErase);
|
sheet.objects.erase(objToErase);
|
||||||
sheet.available_objects.insert(objToErase);
|
sheet.available_objects.insert(objToErase);
|
||||||
|
|
||||||
|
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||||
|
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||||
|
auto &local_endurance = static_cast<Characteristic &>(sheet.endurance);
|
||||||
|
auto &local_chance = static_cast<Characteristic &>(sheet.chance);
|
||||||
|
|
||||||
std::visit(overloaded{
|
std::visit(overloaded{
|
||||||
[&](const weapons &) { --sheet.nb_weapons; },
|
[&](const weapons &) { --sheet.nb_weapons; },
|
||||||
[&](const equipments &) { --sheet.nb_equipments; },
|
[&](const equipments &) { --sheet.nb_equipments; },
|
||||||
[&](const tools &) { --sheet.nb_tools; }
|
[&](const tools &) { --sheet.nb_tools; }
|
||||||
},
|
},
|
||||||
objToErase);
|
objToErase);
|
||||||
change_carac(obj, sheet, minus);
|
change_carac(obj, sheet, local_habilete, local_adresse, local_endurance, local_chance, minus);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -76,12 +86,16 @@ namespace character {
|
||||||
|
|
||||||
void BillyObjects::change_carac(const billyObjects &arg,
|
void BillyObjects::change_carac(const billyObjects &arg,
|
||||||
CharacterSheet &sheet,
|
CharacterSheet &sheet,
|
||||||
const std::function<uint32_t(uint32_t, uint32_t)> &operation)
|
Characteristic &localHabilete,
|
||||||
|
Characteristic &localAdresse,
|
||||||
|
Characteristic &localEndurance,
|
||||||
|
Characteristic &localChance,
|
||||||
|
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation)
|
||||||
noexcept {
|
noexcept {
|
||||||
sheet.habilete.materiel = operation(sheet.habilete.materiel, arg->add_materiel(sheet.habilete.type));
|
localHabilete.materiel = operation(localHabilete.materiel, arg->add_materiel(localHabilete.type));
|
||||||
sheet.adresse.materiel = operation(sheet.adresse.materiel, arg->add_materiel(sheet.adresse.type));
|
localAdresse.materiel = operation(localAdresse.materiel, arg->add_materiel(localAdresse.type));
|
||||||
sheet.endurance.materiel = operation(sheet.endurance.materiel, arg->add_materiel(sheet.endurance.type));
|
localEndurance.materiel = operation(localEndurance.materiel, arg->add_materiel(localEndurance.type));
|
||||||
sheet.chance.materiel = operation(sheet.chance.materiel, arg->add_materiel(sheet.chance.type));
|
localChance.materiel = operation(localChance.materiel, arg->add_materiel(localChance.type));
|
||||||
sheet.armor = operation(sheet.armor, arg->add_armor());
|
sheet.armor = operation(sheet.armor, arg->add_armor());
|
||||||
sheet.damage = operation(sheet.armor, arg->add_damage());
|
sheet.damage = operation(sheet.armor, arg->add_damage());
|
||||||
sheet.critique = operation(sheet.critique, arg->add_critique());
|
sheet.critique = operation(sheet.critique, arg->add_critique());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue