Lighter library with a rework on characteristics.
This commit is contained in:
		
					parent
					
						
							
								f412b1b997
							
						
					
				
			
			
				commit
				
					
						7e613ca2a0
					
				
			
		
					 10 changed files with 404 additions and 142 deletions
				
			
		| 
						 | 
				
			
			@ -1,30 +0,0 @@
 | 
			
		|||
#ifndef BILLYSHEET_ADRESSE_HPP
 | 
			
		||||
#define BILLYSHEET_ADRESSE_HPP
 | 
			
		||||
 | 
			
		||||
#include "characteristic.hpp"
 | 
			
		||||
#include <nlohmann/json.hpp>
 | 
			
		||||
 | 
			
		||||
using json = nlohmann::json;
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
    class Adresse final : public Characteristic {
 | 
			
		||||
    public:
 | 
			
		||||
        Adresse() noexcept: Characteristic(1, 0, 0, 0) {}
 | 
			
		||||
 | 
			
		||||
        Adresse(const std::uint32_t carac, const std::uint32_t materiel, const std::uint32_t additional) :
 | 
			
		||||
                Characteristic(1, carac, materiel, additional) {}
 | 
			
		||||
 | 
			
		||||
        ~Adresse() noexcept final = default;
 | 
			
		||||
 | 
			
		||||
        friend void from_json(const json &j, Adresse &adresse) {
 | 
			
		||||
            nlohmann::from_json(j, static_cast<Characteristic &>(adresse));
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static void to_json(json &j, const Adresse &adresse) {
 | 
			
		||||
        to_json(j, static_cast<Characteristic>(adresse));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //BILLYSHEET_ADRESSE_HPP
 | 
			
		||||
| 
						 | 
				
			
			@ -1,27 +0,0 @@
 | 
			
		|||
#ifndef BILLYSHEET_CHANCE_HPP
 | 
			
		||||
#define BILLYSHEET_CHANCE_HPP
 | 
			
		||||
 | 
			
		||||
#include "characteristic.hpp"
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
    class Chance final : public Characteristic {
 | 
			
		||||
    public:
 | 
			
		||||
        Chance() noexcept: Characteristic(3, 0, 0, 0) {}
 | 
			
		||||
 | 
			
		||||
        Chance(const std::uint32_t carac, const std::uint32_t materiel, const std::uint32_t additional) :
 | 
			
		||||
                Characteristic(3, carac, materiel, additional) {}
 | 
			
		||||
 | 
			
		||||
        ~Chance() noexcept final = default;
 | 
			
		||||
 | 
			
		||||
        friend void from_json(const json &j, Chance &chance) {
 | 
			
		||||
            nlohmann::from_json(j, static_cast<Characteristic &>(chance));
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static void to_json(json &j, const Chance &chance) {
 | 
			
		||||
        to_json(j, static_cast<Characteristic>(chance));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //BILLYSHEET_CHANCE_HPP
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +11,13 @@ namespace character {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
    enum class characType : std::uint8_t {
 | 
			
		||||
        Adresse = 0,
 | 
			
		||||
        Endurance = 1,
 | 
			
		||||
        Chance = 2,
 | 
			
		||||
        Habilete = 3
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    class Characteristic {
 | 
			
		||||
    protected:
 | 
			
		||||
        friend character::BillyObjects;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,19 +28,40 @@ namespace character::characteristic {
 | 
			
		|||
        std::uint32_t materiel{ 0 };
 | 
			
		||||
        std::uint32_t additional{ 0 };
 | 
			
		||||
 | 
			
		||||
        static std::uint32_t get_base(const characType inType) noexcept {
 | 
			
		||||
            switch (inType) {
 | 
			
		||||
                case characType::Adresse:
 | 
			
		||||
                    return 1;
 | 
			
		||||
                case characType::Chance:
 | 
			
		||||
                    return 3;
 | 
			
		||||
                case characType::Endurance:
 | 
			
		||||
                case characType::Habilete:
 | 
			
		||||
                    return 2;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
        const characType type{ characType::Adresse };
 | 
			
		||||
 | 
			
		||||
        Characteristic() noexcept = default;
 | 
			
		||||
 | 
			
		||||
        Characteristic(const std::uint32_t base,
 | 
			
		||||
        Characteristic(const characType inType,
 | 
			
		||||
                const std::uint32_t carac,
 | 
			
		||||
                const std::uint32_t materiel,
 | 
			
		||||
                const std::uint32_t additional) noexcept:
 | 
			
		||||
                base(base), carac(carac), materiel(materiel), additional(additional) { (void) get_total(); }
 | 
			
		||||
                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) {}
 | 
			
		||||
 | 
			
		||||
        Characteristic(const Characteristic &charac) noexcept = default;
 | 
			
		||||
 | 
			
		||||
        Characteristic &operator=(const Characteristic &charac) noexcept {
 | 
			
		||||
            const_cast<std::uint32_t &>(base) = charac.base;
 | 
			
		||||
            const_cast<characType &>(type) = charac.type;
 | 
			
		||||
            carac = charac.carac;
 | 
			
		||||
            materiel = charac.materiel;
 | 
			
		||||
            additional = charac.additional;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,15 +91,17 @@ namespace character::characteristic {
 | 
			
		|||
 | 
			
		||||
        friend void from_json(const json &j, Characteristic &charac) {
 | 
			
		||||
            const_cast<std::uint32_t &>(charac.base) = j.at("base").get<std::uint32_t>();
 | 
			
		||||
            const_cast<characType &>(charac.type) = static_cast<characType>(j.at("type").get<std::uint8_t>());
 | 
			
		||||
            charac.carac = j.at("carac").get<std::uint32_t>();
 | 
			
		||||
            charac.materiel = j.at("materiel").get<std::uint32_t>();
 | 
			
		||||
            charac.additional = j.at("additional").get<std::uint32_t>();
 | 
			
		||||
            charac.total = j.at("total").get<std::uint32_t>();
 | 
			
		||||
            charac.total = j.at("total").get<std::int32_t>();
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static void to_json(json &j, const Characteristic &charac) {
 | 
			
		||||
        j["base"] = charac.get_base();
 | 
			
		||||
        j["type"] = charac.type;
 | 
			
		||||
        j["carac"] = charac.get_carac();
 | 
			
		||||
        j["materiel"] = charac.get_materiel();
 | 
			
		||||
        j["additional"] = charac.get_additional();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,32 +0,0 @@
 | 
			
		|||
#ifndef BILLYSHEET_ENDURANCE_HPP
 | 
			
		||||
#define BILLYSHEET_ENDURANCE_HPP
 | 
			
		||||
 | 
			
		||||
#include "characteristic.hpp"
 | 
			
		||||
#include <nlohmann/json.hpp>
 | 
			
		||||
 | 
			
		||||
using json = nlohmann::json;
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
    class Endurance final : public Characteristic {
 | 
			
		||||
    public:
 | 
			
		||||
        Endurance() noexcept: Characteristic(2, 0, 0, 0) {};
 | 
			
		||||
 | 
			
		||||
        Endurance(const std::uint32_t carac, const std::uint32_t materiel, const std::uint32_t additional) noexcept:
 | 
			
		||||
                Characteristic(2, carac, materiel, additional) {}
 | 
			
		||||
 | 
			
		||||
        ~Endurance() noexcept final = default;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] std::uint32_t get_max_lp() const noexcept;
 | 
			
		||||
 | 
			
		||||
        friend void from_json(const json &j, Endurance &endurance) {
 | 
			
		||||
            nlohmann::from_json(j, static_cast<Characteristic &>(endurance));
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static void to_json(json &j, const Endurance &endurance) {
 | 
			
		||||
        to_json(j, static_cast<Characteristic>(endurance));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //BILLYSHEET_ENDURANCE_HPP
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
#ifndef BILLYSHEET_HABILETE_HPP
 | 
			
		||||
#define BILLYSHEET_HABILETE_HPP
 | 
			
		||||
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include "characteristic.hpp"
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
    class Habilete final : public Characteristic {
 | 
			
		||||
    public:
 | 
			
		||||
        Habilete() noexcept: Characteristic(2, 0, 0, 0) {};
 | 
			
		||||
 | 
			
		||||
        Habilete(const uint32_t carac, const uint32_t materiel, const uint32_t additional) noexcept:
 | 
			
		||||
                Characteristic(2, carac, materiel, additional) {}
 | 
			
		||||
 | 
			
		||||
        ~Habilete() noexcept final = default;
 | 
			
		||||
 | 
			
		||||
        friend void from_json(const json &j, Habilete &habilete) {
 | 
			
		||||
            nlohmann::from_json(j, static_cast<Characteristic &>(habilete));
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static void to_json(json &j, const Habilete &habilete) {
 | 
			
		||||
        to_json(j, static_cast<Characteristic>(habilete));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //BILLYSHEET_HABILETE_HPP
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue