[haskell] Update models for september 14th changelog
This commit is contained in:
parent
0ecb8e87c0
commit
414aebd697
3 changed files with 13 additions and 4 deletions
|
@ -13,9 +13,9 @@ import GHC.Generics
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
data Route = Route { arrival :: UTCTime
|
data Route = Route { arrival :: UTCTime
|
||||||
, departure :: RouteEndpoint
|
|
||||||
, departureTime :: UTCTime
|
, departureTime :: UTCTime
|
||||||
, destination :: RouteEndpoint
|
, destination :: RouteEndpoint
|
||||||
|
, origin :: RouteEndpoint
|
||||||
} deriving (FromJSON, Generic, Show, ToJSON)
|
} deriving (FromJSON, Generic, Show, ToJSON)
|
||||||
|
|
||||||
data RouteEndpoint = RouteEndpoint { routeEndpointType :: T.Text
|
data RouteEndpoint = RouteEndpoint { routeEndpointType :: T.Text
|
||||||
|
|
|
@ -15,6 +15,7 @@ import SpaceTraders.Model.Fuel
|
||||||
import SpaceTraders.Model.Nav
|
import SpaceTraders.Model.Nav
|
||||||
|
|
||||||
data Ship = Ship { cargo :: Cargo
|
data Ship = Ship { cargo :: Cargo
|
||||||
|
, cooldown :: Cooldown
|
||||||
--, crew :: Crew
|
--, crew :: Crew
|
||||||
--, engine :: Engine
|
--, engine :: Engine
|
||||||
--, frame :: Frame
|
--, frame :: Frame
|
||||||
|
@ -26,3 +27,8 @@ data Ship = Ship { cargo :: Cargo
|
||||||
--, registration :: Registration
|
--, registration :: Registration
|
||||||
, symbol :: T.Text
|
, symbol :: T.Text
|
||||||
} deriving (FromJSON, Generic, Show, ToJSON)
|
} deriving (FromJSON, Generic, Show, ToJSON)
|
||||||
|
|
||||||
|
data Cooldown = Cooldown { shipSymbol :: T.Text
|
||||||
|
, totalSeconds :: Int
|
||||||
|
, remainingSeconds :: Int
|
||||||
|
} deriving (FromJSON, Generic, Show, ToJSON)
|
||||||
|
|
|
@ -10,19 +10,22 @@ import Data.Aeson
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
|
|
||||||
data Waypoint = Waypoint { symbol :: T.Text
|
data Waypoint = Waypoint { orbits :: Maybe T.Text
|
||||||
|
, symbol :: T.Text
|
||||||
, waypointType :: T.Text
|
, waypointType :: T.Text
|
||||||
, x :: Int
|
, x :: Int
|
||||||
, y :: Int
|
, y :: Int
|
||||||
} deriving (Generic, Show)
|
} deriving (Generic, Show)
|
||||||
instance FromJSON Waypoint where
|
instance FromJSON Waypoint where
|
||||||
parseJSON = withObject "Waypoint" $ \o ->
|
parseJSON = withObject "Waypoint" $ \o ->
|
||||||
Waypoint <$> o .: "symbol"
|
Waypoint <$> o .:? "orbits"
|
||||||
|
<*> o .: "symbol"
|
||||||
<*> o .: "type"
|
<*> o .: "type"
|
||||||
<*> o .: "x"
|
<*> o .: "x"
|
||||||
<*> o .: "y"
|
<*> o .: "y"
|
||||||
instance ToJSON Waypoint where
|
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
|
, "type" .= t
|
||||||
, "x" .= xx
|
, "x" .= xx
|
||||||
, "y" .= yy ]
|
, "y" .= yy ]
|
||||||
|
|
Loading…
Add table
Reference in a new issue