| 113 | } |
| 114 | |
| 115 | EphemeralStatusEffect jsonToEphemeralStatusEffect(Json const& config) { |
| 116 | if (config.isType(Json::Type::String)) { |
| 117 | return EphemeralStatusEffect{UniqueStatusEffect(config.toString()), {}}; |
| 118 | } else if (config.isType(Json::Type::Object)) { |
| 119 | String effectName = config.getString("effect"); |
| 120 | Maybe<float> duration = config.optFloat("duration"); |
| 121 | return EphemeralStatusEffect{UniqueStatusEffect(effectName), duration}; |
| 122 | } else { |
| 123 | throw JsonException("Json is wrong type for ephemeral stat effect config"); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | Json jsonFromEphemeralStatusEffect(EphemeralStatusEffect const& effect) { |
| 128 | return JsonObject{{"effect", effect.uniqueEffect}, {"duration", jsonFromMaybe(effect.duration)}}; |
no test coverage detected