blob: 0092ef5cd6dbda4a8b35535725d34cbd39d6e4d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module SpaceTraders.Model.System
( System(..)
) where
import Data.Aeson
import qualified Data.Text as T
import GHC.Generics
import SpaceTraders.Model.Waypoint(Waypoint)
data System = System { sectorSymbol :: T.Text
, symbol :: T.Text
, systemType :: T.Text
, x :: Int
, y :: Int
, waypoints :: [Waypoint]
--, factions :: [Faction]
} deriving (Generic, Show)
instance FromJSON System where
parseJSON = withObject "System" $ \o ->
System <$> o .: "sectorSymbol"
<*> o .: "symbol"
<*> o .: "type"
<*> o .: "x"
<*> o .: "y"
<*> o .: "waypoints"
instance ToJSON System where
toJSON (System ss s t xx yy w) = object [ "sectorSymbol" .= ss
, "symbol" .= s
, "type" .= t
, "x" .= xx
, "y" .= yy
, "waypoints" .= w ]
|