diff options
author | Julien Dessaux | 2024-03-22 16:29:09 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | dde6abef3926021d09b46732c924af94771ae5a9 (patch) | |
tree | 26da842876fef6b77c5187eb0efb3dab889e40f4 /haskell/src/SpaceTraders/Model | |
parent | [haskell] refactoring (diff) | |
download | spacetraders-dde6abef3926021d09b46732c924af94771ae5a9.tar.gz spacetraders-dde6abef3926021d09b46732c924af94771ae5a9.tar.bz2 spacetraders-dde6abef3926021d09b46732c924af94771ae5a9.zip |
[haskell] only dock or orbit when needed
Diffstat (limited to 'haskell/src/SpaceTraders/Model')
-rw-r--r-- | haskell/src/SpaceTraders/Model/Ship.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/haskell/src/SpaceTraders/Model/Ship.hs b/haskell/src/SpaceTraders/Model/Ship.hs index 522276c..f42d558 100644 --- a/haskell/src/SpaceTraders/Model/Ship.hs +++ b/haskell/src/SpaceTraders/Model/Ship.hs @@ -1,8 +1,11 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE OverloadedStrings #-} module SpaceTraders.Model.Ship ( Ship(..) + , isDocked + , isInOrbit ) where import Data.Aeson @@ -31,3 +34,9 @@ data Cooldown = Cooldown { shipSymbol :: T.Text , totalSeconds :: Int , remainingSeconds :: Int } deriving (FromJSON, Generic, Show, ToJSON) + +isDocked :: Ship -> Bool +isDocked ship = status (nav ship) == "DOCKED" + +isInOrbit :: Ship -> Bool +isInOrbit = not . isDocked |