summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2023-10-15 00:33:59 +0200
committerJulien Dessaux2023-10-16 23:33:40 +0200
commit414aebd6976deeb59eae9fd2c3e52ac2347c51df (patch)
tree49a30f3d0a658febf1564240f99eb2c9cbd3777b
parent[haskell] Removed available timestamp from ship's database schema (diff)
downloadspacetraders-414aebd6976deeb59eae9fd2c3e52ac2347c51df.tar.gz
spacetraders-414aebd6976deeb59eae9fd2c3e52ac2347c51df.tar.bz2
spacetraders-414aebd6976deeb59eae9fd2c3e52ac2347c51df.zip
[haskell] Update models for september 14th changelog
-rw-r--r--haskell/src/SpaceTraders/Model/Route.hs2
-rw-r--r--haskell/src/SpaceTraders/Model/Ship.hs6
-rw-r--r--haskell/src/SpaceTraders/Model/Waypoint.hs9
3 files changed, 13 insertions, 4 deletions
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 ]