Compare commits
2 commits
9ba06c686f
...
db8b482f74
| Author | SHA1 | Date | |
|---|---|---|---|
|
db8b482f74 |
|||
|
5a14994645 |
3 changed files with 15 additions and 4 deletions
|
|
@ -49,6 +49,8 @@ namespace character {
|
|||
|
||||
static std::string_view billy_object_to_string(const billyObjects &object) noexcept;
|
||||
|
||||
static std::string_view billy_object_to_string(const billyEnums &object) noexcept;
|
||||
|
||||
static void to_json(json &j, const container &billy);
|
||||
|
||||
static void from_json(const json &j, container &billy);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace character {
|
|||
public:
|
||||
const weapons type{ weapons::Sword };
|
||||
|
||||
explicit Weapons(const weapons type) : type(type) {}
|
||||
explicit Weapons(const weapons type) noexcept : type(type) {}
|
||||
|
||||
Weapons() = delete;
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ namespace character {
|
|||
public:
|
||||
const equipments type{ equipments::Chainmail };
|
||||
|
||||
explicit Equipments(const equipments type) : type(type) {}
|
||||
explicit Equipments(const equipments type) noexcept : type(type) {}
|
||||
|
||||
Equipments() = delete;
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ namespace character {
|
|||
public:
|
||||
const tools type{ tools::Fourche };
|
||||
|
||||
explicit Tools(const tools type) : type(type) {}
|
||||
explicit Tools(const tools type) noexcept : type(type) {}
|
||||
|
||||
Tools() = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,15 @@ namespace character {
|
|||
return object->to_string();
|
||||
}
|
||||
|
||||
std::string_view BillyObjects::billy_object_to_string(const billyEnums &object) noexcept {
|
||||
return std::visit(overloaded{
|
||||
[](const weapons &obj) { return Weapons{ obj }.to_string(); },
|
||||
[](const equipments &obj) { return Equipments{ obj }.to_string(); },
|
||||
[](const tools &obj) { return Tools{ obj }.to_string(); },
|
||||
},
|
||||
object);
|
||||
}
|
||||
|
||||
void BillyObjects::from_json(const json &j, container &billy) {
|
||||
for (const auto &element: j) {
|
||||
const std::uint32_t key = element[0].get<std::uint32_t>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue