Compare commits
	
		
			2 commits
		
	
	
		
			
				7a5d36f6ea
			
			...
			
				877e7ad2fa
			
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
							
							
	
	
		
			
		
	
	877e7ad2fa | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	77e5a18784 | 
						
						
							
					 2 changed files with 7 additions and 9 deletions
				
			
		| 
						 | 
					@ -46,13 +46,9 @@ namespace character {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
 | 
					        static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void to_json(json &j, const BillyObjects::container &billy);
 | 
					        static void to_json(json &j, const container &billy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void from_json(const json &j, BillyObjects::container &billy);
 | 
					        static void from_json(const json &j, container &billy);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        BillyObjects() noexcept = default;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ~BillyObjects() noexcept = default;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
 | 
					        [[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
#include "character_sheet.hpp"
 | 
					#include "character_sheet.hpp"
 | 
				
			||||||
#include <nlohmann/json.hpp>
 | 
					#include <nlohmann/json.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::uint32_t constexpr const_hash(const char *input) {
 | 
					constexpr std::uint32_t const_hash(const char *input) {
 | 
				
			||||||
    return *input ? static_cast<unsigned int>(*input) + 33 * const_hash(input + 1) : 5381;
 | 
					    return *input ? static_cast<unsigned int>(*input) + 33 * const_hash(input + 1) : 5381;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,7 +104,7 @@ namespace character {
 | 
				
			||||||
        return object->to_string();
 | 
					        return object->to_string();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void BillyObjects::from_json(const json &j, BillyObjects::container &billy) {
 | 
					    void BillyObjects::from_json(const json &j, container &billy) {
 | 
				
			||||||
        for (const auto &element: j) {
 | 
					        for (const auto &element: j) {
 | 
				
			||||||
            const std::uint32_t key = element[0].get<std::uint32_t>();
 | 
					            const std::uint32_t key = element[0].get<std::uint32_t>();
 | 
				
			||||||
            const std::uint8_t value = element[1].get<std::uint8_t>();
 | 
					            const std::uint8_t value = element[1].get<std::uint8_t>();
 | 
				
			||||||
| 
						 | 
					@ -119,11 +119,13 @@ namespace character {
 | 
				
			||||||
                case toolsHash:
 | 
					                case toolsHash:
 | 
				
			||||||
                    billy.emplace(static_cast<tools>(value), std::make_unique<Tools>(static_cast<tools>(value)));
 | 
					                    billy.emplace(static_cast<tools>(value), std::make_unique<Tools>(static_cast<tools>(value)));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    throw std::logic_error("Wrong hash for from_json in BillyObjects::from_json");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void BillyObjects::to_json(json &j, const BillyObjects::container &billy) {
 | 
					    void BillyObjects::to_json(json &j, const container &billy) {
 | 
				
			||||||
        for (const auto &[object_type, _]: billy) {
 | 
					        for (const auto &[object_type, _]: billy) {
 | 
				
			||||||
            std::visit(overloaded{
 | 
					            std::visit(overloaded{
 | 
				
			||||||
                    [&j](const weapons weapon) {
 | 
					                    [&j](const weapons weapon) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue