diff options
author | Julien Dessaux | 2024-03-22 01:13:34 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | 7e27a0a7eada373780a9757fd89f70d4d911d69a (patch) | |
tree | 8b660bde99d5f9b4ae4f9e9caea4b51f19931dbe /haskell/src/SpaceTraders/Model | |
parent | [node] begin the great typescript rewrite (diff) | |
download | spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.tar.gz spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.tar.bz2 spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.zip |
[haskell] refactoring
Diffstat (limited to 'haskell/src/SpaceTraders/Model')
-rw-r--r-- | haskell/src/SpaceTraders/Model/Agent.hs | 17 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Cargo.hs | 13 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Fuel.hs | 13 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Inventory.hs | 15 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Nav.hs | 19 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Ship.hs | 27 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/System.hs | 21 | ||||
-rw-r--r-- | haskell/src/SpaceTraders/Model/Waypoint.hs | 17 |
8 files changed, 67 insertions, 75 deletions
diff --git a/haskell/src/SpaceTraders/Model/Agent.hs b/haskell/src/SpaceTraders/Model/Agent.hs index 01c08a0..a03d47f 100644 --- a/haskell/src/SpaceTraders/Model/Agent.hs +++ b/haskell/src/SpaceTraders/Model/Agent.hs @@ -1,19 +1,18 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Agent ( Agent(..) ) where -import Data.Aeson -import GHC.Generics -import qualified Data.Text as T +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics -data Agent = Agent { accountId :: T.Text - , credits :: Integer +data Agent = Agent { accountId :: T.Text + , credits :: Integer --, faction :: Faction - , headquarters :: T.Text + , headquarters :: T.Text , startingFaction :: T.Text - , symbol :: T.Text + , symbol :: T.Text } deriving (Eq, FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/Cargo.hs b/haskell/src/SpaceTraders/Model/Cargo.hs index 126fc63..232627c 100644 --- a/haskell/src/SpaceTraders/Model/Cargo.hs +++ b/haskell/src/SpaceTraders/Model/Cargo.hs @@ -1,17 +1,16 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Cargo ( Cargo(..) ) where -import Data.Aeson -import GHC.Generics +import Data.Aeson +import GHC.Generics -import SpaceTraders.Model.Inventory(Inventory) +import SpaceTraders.Model.Inventory (Inventory) -data Cargo = Cargo { capacity :: Int +data Cargo = Cargo { capacity :: Int , inventory :: [Inventory] - , units :: Int + , units :: Int } deriving (FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/Fuel.hs b/haskell/src/SpaceTraders/Model/Fuel.hs index ca17ebb..99c4709 100644 --- a/haskell/src/SpaceTraders/Model/Fuel.hs +++ b/haskell/src/SpaceTraders/Model/Fuel.hs @@ -1,21 +1,20 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Fuel ( Consumed(..) , Fuel(..) ) where -import Data.Aeson -import Data.Time -import GHC.Generics +import Data.Aeson +import Data.Time +import GHC.Generics -data Consumed = Consumed { amount :: Int +data Consumed = Consumed { amount :: Int , timestamp :: UTCTime } deriving (FromJSON, Generic, Show, ToJSON) data Fuel = Fuel { capacity :: Int , consumed :: Consumed - , current :: Int + , current :: Int } deriving (FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/Inventory.hs b/haskell/src/SpaceTraders/Model/Inventory.hs index db74ddb..4faea52 100644 --- a/haskell/src/SpaceTraders/Model/Inventory.hs +++ b/haskell/src/SpaceTraders/Model/Inventory.hs @@ -1,17 +1,16 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Inventory ( Inventory(..) ) where -import Data.Aeson -import GHC.Generics -import qualified Data.Text as T +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics data Inventory = Inventory { description :: T.Text - , name :: T.Text - , symbol :: T.Text - , units :: Int + , name :: T.Text + , symbol :: T.Text + , units :: Int } deriving (FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/Nav.hs b/haskell/src/SpaceTraders/Model/Nav.hs index 1c23ca1..8550836 100644 --- a/haskell/src/SpaceTraders/Model/Nav.hs +++ b/haskell/src/SpaceTraders/Model/Nav.hs @@ -1,20 +1,19 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Nav ( Nav(..) ) where -import Data.Aeson -import GHC.Generics -import qualified Data.Text as T +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics -import SpaceTraders.Model.Route +import SpaceTraders.Model.Route -data Nav = Nav { flightMode :: T.Text - , route :: Route - , status :: T.Text - , systemSymbol :: T.Text +data Nav = Nav { flightMode :: T.Text + , route :: Route + , status :: T.Text + , systemSymbol :: T.Text , waypointSymbol :: T.Text } deriving (FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/Ship.hs b/haskell/src/SpaceTraders/Model/Ship.hs index 2ec54f1..522276c 100644 --- a/haskell/src/SpaceTraders/Model/Ship.hs +++ b/haskell/src/SpaceTraders/Model/Ship.hs @@ -1,34 +1,33 @@ {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} module SpaceTraders.Model.Ship ( Ship(..) ) where -import Data.Aeson -import GHC.Generics -import qualified Data.Text as T +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics -import SpaceTraders.Model.Cargo -import SpaceTraders.Model.Fuel -import SpaceTraders.Model.Nav +import SpaceTraders.Model.Cargo +import SpaceTraders.Model.Fuel +import SpaceTraders.Model.Nav -data Ship = Ship { cargo :: Cargo +data Ship = Ship { cargo :: Cargo , cooldown :: Cooldown --, crew :: Crew --, engine :: Engine --, frame :: Frame - , fuel :: Fuel + , fuel :: Fuel --, modules :: [Module] --, mounts :: [Mount] - , nav :: Nav + , nav :: Nav --, reactor :: Reactor --, registration :: Registration - , symbol :: T.Text + , symbol :: T.Text } deriving (FromJSON, Generic, Show, ToJSON) -data Cooldown = Cooldown { shipSymbol :: T.Text - , totalSeconds :: Int +data Cooldown = Cooldown { shipSymbol :: T.Text + , totalSeconds :: Int , remainingSeconds :: Int } deriving (FromJSON, Generic, Show, ToJSON) diff --git a/haskell/src/SpaceTraders/Model/System.hs b/haskell/src/SpaceTraders/Model/System.hs index 0092ef5..a673b56 100644 --- a/haskell/src/SpaceTraders/Model/System.hs +++ b/haskell/src/SpaceTraders/Model/System.hs @@ -1,23 +1,22 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} module SpaceTraders.Model.System ( System(..) ) where -import Data.Aeson -import qualified Data.Text as T -import GHC.Generics +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics -import SpaceTraders.Model.Waypoint(Waypoint) +import SpaceTraders.Model.Waypoint (Waypoint) data System = System { sectorSymbol :: T.Text - , symbol :: T.Text - , systemType :: T.Text - , x :: Int - , y :: Int - , waypoints :: [Waypoint] + , symbol :: T.Text + , systemType :: T.Text + , x :: Int + , y :: Int + , waypoints :: [Waypoint] --, factions :: [Faction] } deriving (Generic, Show) instance FromJSON System where diff --git a/haskell/src/SpaceTraders/Model/Waypoint.hs b/haskell/src/SpaceTraders/Model/Waypoint.hs index d80dc7a..9f0776c 100644 --- a/haskell/src/SpaceTraders/Model/Waypoint.hs +++ b/haskell/src/SpaceTraders/Model/Waypoint.hs @@ -1,20 +1,19 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} module SpaceTraders.Model.Waypoint ( Waypoint(..) ) where -import Data.Aeson -import qualified Data.Text as T -import GHC.Generics +import Data.Aeson +import qualified Data.Text as T +import GHC.Generics -data Waypoint = Waypoint { orbits :: Maybe T.Text - , symbol :: T.Text +data Waypoint = Waypoint { orbits :: Maybe T.Text + , symbol :: T.Text , waypointType :: T.Text - , x :: Int - , y :: Int + , x :: Int + , y :: Int } deriving (Generic, Show) instance FromJSON Waypoint where parseJSON = withObject "Waypoint" $ \o -> |