diff options
Diffstat (limited to 'haskell/src/SpaceTraders/Model/Waypoint.hs')
-rw-r--r-- | haskell/src/SpaceTraders/Model/Waypoint.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/haskell/src/SpaceTraders/Model/Waypoint.hs b/haskell/src/SpaceTraders/Model/Waypoint.hs index b32af75..d80dc7a 100644 --- a/haskell/src/SpaceTraders/Model/Waypoint.hs +++ b/haskell/src/SpaceTraders/Model/Waypoint.hs @@ -10,19 +10,22 @@ import Data.Aeson import qualified Data.Text as T import GHC.Generics -data Waypoint = Waypoint { symbol :: T.Text +data Waypoint = Waypoint { orbits :: Maybe T.Text + , symbol :: T.Text , waypointType :: T.Text , x :: Int , y :: Int } deriving (Generic, Show) instance FromJSON Waypoint where parseJSON = withObject "Waypoint" $ \o -> - Waypoint <$> o .: "symbol" + Waypoint <$> o .:? "orbits" + <*> o .: "symbol" <*> o .: "type" <*> o .: "x" <*> o .: "y" instance ToJSON Waypoint where - toJSON (Waypoint o s t xx yy) = object [ "symbol" .= s + toJSON (Waypoint o s t xx yy) = object [ "orbits" .= o + , "symbol" .= s , "type" .= t , "x" .= xx , "y" .= yy ] |