From 01293baa64fa905c5763020bd6c0b4903d41fc78 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 12 Jun 2021 15:32:53 -0400 Subject: Verified some creature attacks --- src/utils.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index 005e5be..77096e7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -23,6 +24,23 @@ namespace nlohmann { opt = std::shared_ptr(T::create(j)); } }; + + template struct adl_serializer> { + static void to_json(json& j, const std::optional& opt) { + if(opt) { + j = *opt; + } else { + j = nullptr; + } + } + static void from_json(const json& j, std::optional& opt) { + if(j.is_null()) { + opt = std::optional(); + } else { + opt = j.get(); + } + } + }; } namespace utils { -- cgit v1.2.3