1
0
Fork 0

[haskell] Update models for september 14th changelog

This commit is contained in:
Julien Dessaux 2023-10-15 00:33:59 +02:00
parent 0ecb8e87c0
commit 414aebd697
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 13 additions and 4 deletions

View file

@ -13,9 +13,9 @@ import GHC.Generics
import qualified Data.Text as T
data Route = Route { arrival :: UTCTime
, departure :: RouteEndpoint
, departureTime :: UTCTime
, destination :: RouteEndpoint
, origin :: RouteEndpoint
} deriving (FromJSON, Generic, Show, ToJSON)
data RouteEndpoint = RouteEndpoint { routeEndpointType :: T.Text

View file

@ -15,6 +15,7 @@ import SpaceTraders.Model.Fuel
import SpaceTraders.Model.Nav
data Ship = Ship { cargo :: Cargo
, cooldown :: Cooldown
--, crew :: Crew
--, engine :: Engine
--, frame :: Frame
@ -26,3 +27,8 @@ data Ship = Ship { cargo :: Cargo
--, registration :: Registration
, symbol :: T.Text
} deriving (FromJSON, Generic, Show, ToJSON)
data Cooldown = Cooldown { shipSymbol :: T.Text
, totalSeconds :: Int
, remainingSeconds :: Int
} deriving (FromJSON, Generic, Show, ToJSON)

View file

@ -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 ]