summaryrefslogtreecommitdiff
path: root/haskell/app/Main.hs
blob: a8c1d291dea6632e5820cc1384247cc8b73bdddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Main (main) where

import           SpaceTraders
import           SpaceTraders.APIClient.Agent
import           SpaceTraders.APIClient.Contracts
import           SpaceTraders.APIClient.Ships
import           SpaceTraders.Automation.Init
import           SpaceTraders.Database.Ships

main :: IO ()
main = do
  env <- initST
  runSpaceTradersT main' env
  deinitST env
  where
    main' :: SpaceTradersT ()
    main' = do
      -- refresh our core objects
      (Right _) <- myAgent
      (Right _) <- myContracts
      (Right _) <- myShips
      -- Testing
      ships <- getShips
      let cmdShip = head ships
      t <- refuel cmdShip
      liftIO . print $ case t of
        (Right r) -> "response: " ++ show r
        (Left e)  -> "error: " ++ show e
      return ()