2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00
pulsar/ObservatoryFramework/Files/Converters/MissionEffectConverter.cs
2024-04-13 18:10:46 +10:00

37 lines
1.0 KiB
C#

using System.Text.Json;
using System.Text.Json.Serialization;
using Observatory.Framework.Files.ParameterTypes;
namespace Observatory.Framework.Files.Converters;
public class MissionEffectConverter : JsonConverter<MissionEffect>
{
public override MissionEffect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var effect = reader.GetString();
//TODO: Find out all possible values
switch (effect)
{
case "+":
effect = "Low";
break;
case "++":
effect = "Med";
break;
case "+++":
case "++++":
case "+++++":
effect = "High";
break;
}
var missionEffect = (MissionEffect)Enum.Parse(typeof(MissionEffect), effect, true);
return missionEffect;
}
public override void Write(Utf8JsonWriter writer, MissionEffect value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}