diff options
author | Julien Dessaux | 2024-03-23 15:28:28 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | 51705b930f8408c1a3f4706d0b172eb7970f20ba (patch) | |
tree | d262a4617b084e3c03c647eb64c51679016700c0 /haskell/src/SpaceTraders/Model | |
parent | [haskell] only dock or orbit when needed (diff) | |
download | spacetraders-51705b930f8408c1a3f4706d0b172eb7970f20ba.tar.gz spacetraders-51705b930f8408c1a3f4706d0b172eb7970f20ba.tar.bz2 spacetraders-51705b930f8408c1a3f4706d0b172eb7970f20ba.zip |
[haskell] implemented ship refueling
Diffstat (limited to '')
-rw-r--r-- | haskell/src/SpaceTraders/Model/Ship.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/haskell/src/SpaceTraders/Model/Ship.hs b/haskell/src/SpaceTraders/Model/Ship.hs index f42d558..f30679c 100644 --- a/haskell/src/SpaceTraders/Model/Ship.hs +++ b/haskell/src/SpaceTraders/Model/Ship.hs @@ -6,6 +6,7 @@ module SpaceTraders.Model.Ship ( Ship(..) , isDocked , isInOrbit + , overNinetyPercentFuel ) where import Data.Aeson @@ -40,3 +41,10 @@ isDocked ship = status (nav ship) == "DOCKED" isInOrbit :: Ship -> Bool isInOrbit = not . isDocked + +overNinetyPercentFuel :: Ship -> Bool +overNinetyPercentFuel ship = curr * 10 > capa * 9 + where + curr = current f + capa = SpaceTraders.Model.Fuel.capacity f + f = fuel ship |