{- This module is part of Antisplice. Copyleft (c) 2014 Marvin Cohrs All wrongs reversed. Sharing is an act of love, not crime. Please share Antisplice with everyone you like. Antisplice is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Antisplice is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Antisplice. If not, see . -} module Game.Antisplice.SingleUser where import Text.Chatty.Printer import Text.Chatty.Finalizer import Text.Chatty.Interactor import Text.Chatty.Expansion import Text.Chatty.Expansion.Vars import Text.Chatty.Expansion.History import Text.Chatty.Extended.Printer import Text.Chatty.Extended.ANSI import Text.Chatty.Channel.Printer import Game.Antisplice.Monad.Dungeon import Game.Antisplice.Monad.Vocab import Data.Chatty.Fail import Data.Chatty.Counter import Data.Chatty.Atoms import Data.Chatty.None import Game.Antisplice.Errors import Game.Antisplice.Monad import Game.Antisplice.Rooms import Game.Antisplice.Lang import Game.Antisplice.Terminal.Repl import Text.Printf import System.IO import Control.Monad import Control.Monad.IO.Class singleUser :: DungeonT (FailT SplErr (VocabT (AtomStoreT (CounterT (AnsiPrinterT (JoinerT (HistoryT (ExpanderT (NullExpanderT (HandleCloserT IO)))))))))) () -> IO () singleUser init = void $ withLazyIO $ withExpansion $ localEnvironment $ flip runHistoryT [] $ runJoinerT $ flip runAnsiPrinterT [] $ withCounter $ flip runAtomStoreT none $ flip runVocabT defVocab $ do mputv "prompt" $ Literal "$user #{health}H#?{ #{otitle} #{ohealth}H}> " r <- runFailT $ flip runDungeonT none $ do init reenterCurrentRoom roomTriggerOnAnnounceOf =<< getRoomState roomTriggerOnLookOf =<< getRoomState mputv "prompt" . Literal =<< expand "$prompt> " repl case r :: Either SplErr ((),DungeonState) of Left QuitError -> mprintLn "Bye bye!" Left e -> mprintLn $ printf "Error occured: %s\n" $ show e Right x -> noneM