diff options
author | Julien Dessaux | 2023-07-20 00:24:31 +0200 |
---|---|---|
committer | Julien Dessaux | 2023-07-20 00:24:31 +0200 |
commit | 24f6c8eb90555b81a96b142fec8057b05d334035 (patch) | |
tree | d85d9f71cb9dc6472d6cb4e95a0d2ca256308ce8 /haskell/app | |
parent | [haskell] Fixed models' serialization (diff) | |
download | spacetraders-24f6c8eb90555b81a96b142fec8057b05d334035.tar.gz spacetraders-24f6c8eb90555b81a96b142fec8057b05d334035.tar.bz2 spacetraders-24f6c8eb90555b81a96b142fec8057b05d334035.zip |
[haskell] Finalized the agent initialization, refresh and reset
Diffstat (limited to '')
-rw-r--r-- | haskell/app/Main.hs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/haskell/app/Main.hs b/haskell/app/Main.hs index 1b2ccec..85b07da 100644 --- a/haskell/app/Main.hs +++ b/haskell/app/Main.hs @@ -8,29 +8,25 @@ import System.Posix.Process import SpaceTraders import SpaceTraders.Automation.Init -import SpaceTraders.APIClient.Agent(myAgent) -import SpaceTraders.APIClient.Client -import SpaceTraders.APIClient.Ships +import SpaceTraders.APIClient.Errors import SpaceTraders.APIClient.Systems +import SpaceTraders.Database.Agents +import SpaceTraders.Database.Contracts +import SpaceTraders.Database.Ships main :: IO () main = do env <- initST - ma <- runSpaceTradersT myAgent env - case ma of - Left (APIResetHappened _) -> do - p <- getExecutablePath - a <- getArgs - e <- getEnvironment - executeFile p False a (Just e) - Left e -> throwIO e - Right ma' -> print ma' - s <- runSpaceTradersT listSystems env + 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' - ships <- runSpaceTradersT listShips env - case ships of - Left e -> throwIO e - Right s' -> print $ s' + runSpaceTradersT getContracts env >>= print + runSpaceTradersT getShips env >>= print deinitST env |