summaryrefslogtreecommitdiff
path: root/haskell/app/Main.hs
blob: a7774e51ac7944daf294ba3195beb605c9e9c33c (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
30
31
32
33
34
35
{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Control.Exception
import System.Environment
import System.Posix.Process

import SpaceTraders
import SpaceTraders.Automation.Init
import SpaceTraders.APIClient.Errors
import SpaceTraders.APIClient.Ships
import SpaceTraders.APIClient.Systems
import SpaceTraders.Database.Agents
import SpaceTraders.Database.Contracts
import SpaceTraders.Database.Ships

main :: IO ()
main = do
  env <- initST
  runSpaceTradersT getAgent env >>= print
  s <- runSpaceTradersT initSystems env
  case s of
    Left (APIResetHappened _) -> do
      p <- getExecutablePath
      a <- getArgs
      e <- getEnvironment
      executeFile p False a (Just e)
    Left e -> throwIO e
    Right s' -> print $ length s'
  runSpaceTradersT getContracts env >>= print
  ss <- runSpaceTradersT getShips env
  runSpaceTradersT (dock $ head ss) env >>= print
  runSpaceTradersT (orbit $ head ss) env >>= print
  deinitST env