From efca5ca06d1bf2ede55397e2a4576985089996c2 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 12 Feb 2022 19:15:42 +0100 Subject: [PATCH] Include string value effect parameters --- BuildAbilities.cpp | 7 ++++++- BuildItems.cpp | 5 +++++ BuildMoves.cpp | 12 +++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/BuildAbilities.cpp b/BuildAbilities.cpp index d4483fa..0f45887 100644 --- a/BuildAbilities.cpp +++ b/BuildAbilities.cpp @@ -1,6 +1,6 @@ #include "BuildAbilities.hpp" -#include "json.hpp" #include +#include "json.hpp" using json = nlohmann::json; @@ -51,6 +51,11 @@ CreatureLib::Library::TalentLibrary* BuildAbilities::Build(const std::string& pa case json::value_t::number_float: realParameters.Append(new CreatureLib::Library::EffectParameter(p.get())); break; + case json::value_t ::string: { + auto s = p.get(); + realParameters.Append(new CreatureLib::Library::EffectParameter(ArbUt::StringView(s.c_str(), s.length()))); + break; + } default: continue; } } diff --git a/BuildItems.cpp b/BuildItems.cpp index 4d96dd8..6be500f 100644 --- a/BuildItems.cpp +++ b/BuildItems.cpp @@ -83,6 +83,11 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) { case json::value_t::number_float: parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); break; + case json::value_t ::string: { + auto s = p.get(); + parameters.Append(new CreatureLib::Library::EffectParameter(ArbUt::StringView(s.c_str(), s.length()))); + break; + } default: continue; } } diff --git a/BuildMoves.cpp b/BuildMoves.cpp index f6cba28..d3a2528 100644 --- a/BuildMoves.cpp +++ b/BuildMoves.cpp @@ -5,11 +5,11 @@ using json = nlohmann::json; #define GET(o, objectKey, key) \ - auto& _##objectKey = o[#objectKey]; \ + auto& _##objectKey = o[#objectKey]; \ if (_##objectKey.is_null()) { \ auto errorKeyFunc = [=]() { return key; }; \ - std::cout << "Failed to retrieve key '" << #objectKey << "' for object with key '" << errorKeyFunc() \ - << path << "'\n"; \ + std::cout << "Failed to retrieve key '" << #objectKey << "' for object with key '" << errorKeyFunc() << path \ + << "'\n"; \ return nullptr; \ } @@ -89,6 +89,12 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path, case json::value_t::number_float: parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); break; + case json::value_t ::string: { + auto s = p.get(); + parameters.Append(new CreatureLib::Library::EffectParameter( + ArbUt::StringView(s.c_str(), s.length()))); + break; + } default: continue; } }