From 414aebd6976deeb59eae9fd2c3e52ac2347c51df Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 15 Oct 2023 00:33:59 +0200 Subject: [haskell] Update models for september 14th changelog --- haskell/src/SpaceTraders/Model/Route.hs | 2 +- haskell/src/SpaceTraders/Model/Ship.hs | 6 ++++++ haskell/src/SpaceTraders/Model/Waypoint.hs | 9 ++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'haskell') diff --git a/haskell/src/SpaceTraders/Model/Route.hs b/haskell/src/SpaceTraders/Model/Route.hs index 670c953..1a62169 100644 --- a/haskell/src/SpaceTraders/Model/Route.hs +++ b/haskell/src/SpaceTraders/Model/Route.hs @@ -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 diff --git a/haskell/src/SpaceTraders/Model/Ship.hs b/haskell/src/SpaceTraders/Model/Ship.hs index 4228dca..2ec54f1 100644 --- a/haskell/src/SpaceTraders/Model/Ship.hs +++ b/haskell/src/SpaceTraders/Model/Ship.hs @@ -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) 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 ] -- cgit v1.2.3