Correct code, I suppose. It compiles.
This commit is contained in:
parent
965d0c1a35
commit
40f692ea5e
2 changed files with 69 additions and 282 deletions
|
@ -10,46 +10,21 @@
|
|||
#include <functional>
|
||||
#include <variant>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <ankerl/svector.h>
|
||||
#include "characteristic/characteristic.hpp"
|
||||
#include "generic_object.hpp"
|
||||
|
||||
// helper type for the visitor
|
||||
template<typename... Ts>
|
||||
struct overloaded : Ts ... { using Ts::operator()...; };
|
||||
template<typename... Ts>
|
||||
overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
namespace character {
|
||||
class CharacterSheet;
|
||||
|
||||
enum class weapons : std::uint8_t {
|
||||
Sword = 0,
|
||||
Lance = 1,
|
||||
Morgenstern = 2,
|
||||
Bow = 3
|
||||
};
|
||||
|
||||
enum class equipments : std::uint8_t {
|
||||
Chainmail = 4,
|
||||
CookingPot = 5,
|
||||
PamphletTourist = 6,
|
||||
MedicKit = 7
|
||||
};
|
||||
|
||||
enum class tools : std::uint8_t {
|
||||
Fourche = 8,
|
||||
Dagger = 9,
|
||||
RockClimbingKit = 10,
|
||||
SackOfGrain = 11
|
||||
};
|
||||
|
||||
class BillyObjects final {
|
||||
public:
|
||||
static constexpr std::size_t max_num_obj{ 3 };
|
||||
using billyObject = std::variant<weapons, equipments, tools>;
|
||||
using container = ankerl::svector<billyObject, max_num_obj>;
|
||||
using container = std::unordered_map<billyEnums, billyObjects>;
|
||||
|
||||
static constexpr std::array<BillyObjects::billyObject, 12> all_objects{
|
||||
static constexpr std::array<billyEnums, 12> all_objects{
|
||||
weapons::Sword,
|
||||
weapons::Lance,
|
||||
weapons::Morgenstern,
|
||||
|
@ -66,22 +41,7 @@ namespace character {
|
|||
|
||||
static constexpr std::string_view json_key{ "billy_objects" };
|
||||
|
||||
static constexpr std::string_view sword{ "Sword" };
|
||||
static constexpr std::string_view lance{ "Lance" };
|
||||
static constexpr std::string_view morgenstern{ "Morgenstern" };
|
||||
static constexpr std::string_view bow{ "Bow" };
|
||||
|
||||
static constexpr std::string_view chainmail{ "Chainmail" };
|
||||
static constexpr std::string_view cooking_pot{ "Cooking pot" };
|
||||
static constexpr std::string_view pamphlet_tourist{ "Touristic pamphlet" };
|
||||
static constexpr std::string_view medic_kit{ "Medic kit" };
|
||||
|
||||
static constexpr std::string_view fourche{ "Fourche" };
|
||||
static constexpr std::string_view dagger{ "Dagger" };
|
||||
static constexpr std::string_view rock_climbing_kit{ "Rock climbing kit" };
|
||||
static constexpr std::string_view sack_of_grain{ "Sack of grain" };
|
||||
|
||||
static std::string_view billy_object_to_string(const billyObject &object) noexcept;
|
||||
static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
|
||||
|
||||
static void to_json(json &j, const BillyObjects::container &billy);
|
||||
|
||||
|
@ -91,47 +51,30 @@ namespace character {
|
|||
|
||||
~BillyObjects() noexcept = default;
|
||||
|
||||
[[nodiscard]] bool push_object(const billyObject &object, CharacterSheet &sheet) noexcept;
|
||||
[[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
|
||||
|
||||
void pop_object(CharacterSheet &sheet) noexcept;
|
||||
|
||||
[[nodiscard]] static ankerl::svector<bool, 3> check_conformity(const CharacterSheet &sheet) noexcept;
|
||||
void erase_object(CharacterSheet &sheet, const billyEnums objToErase) noexcept;
|
||||
|
||||
[[nodiscard]] const std::plus<std::uint32_t> &get_plus_operation() const { return plus; }
|
||||
|
||||
[[nodiscard]] const std::minus<std::uint32_t> &get_minus_operation() const { return minus; }
|
||||
|
||||
private:
|
||||
std::plus<std::uint32_t> plus;
|
||||
std::minus<std::uint32_t> minus;
|
||||
|
||||
static void change_carac_weapon(const weapons &arg,
|
||||
CharacterSheet &sheet,
|
||||
characteristic::Characteristic &localHabilete,
|
||||
characteristic::Characteristic &localAdresse,
|
||||
characteristic::Characteristic &localEndurance,
|
||||
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept;
|
||||
|
||||
static void change_carac_equipment(const equipments &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)> &primary,
|
||||
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &complement) noexcept;
|
||||
|
||||
static void change_carac_tools(const tools &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;
|
||||
|
||||
static void check_dagger_conditions(const CharacterSheet &sheet,
|
||||
characteristic::Characteristic &localHabilete,
|
||||
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation);
|
||||
|
||||
private:
|
||||
std::plus<std::uint32_t> plus;
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue