Skip to content

Commit

Permalink
- Инициальная структура программы для руководства.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jun 4, 2011
1 parent c2b20d6 commit 4e13bf8
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions QuestMain.hs
@@ -1,44 +1,6 @@
module Main where

import Types
import Locations
import System.IO (hFlush, stdout)
import Control.Monad.State (liftIO)

directionsToString :: [Direction] -> String
directionsToString (dir:dirs) = show dir ++ case null(dirs) of
True -> []
False -> ", " ++ directionsToString dirs
directionsToString [] = []

describeDirections :: Location -> String
describeDirections loc = "You can go " ++ directionsToString ( getLocationDirections loc)

describeActions :: Location -> String
describeActions _ = "You can do something."

describeGameSituation :: Location -> String
describeGameSituation loc = do
describeDirections loc
describeActions loc


getAction = do
putStr "> "
hFlush stdout
line <- getLine
return (line)

run :: Location -> IO ()
run oldLoc = do
putStrLn . describeLocation $ oldLoc
putStrLn . describeDirections $ oldLoc
putStrLn . describeActions $ Room
x <- getAction
case x of
"Quit" -> return ()
"q" -> return ()
otherwise -> run . getLocation $ (oldLoc, x)

main :: IO ()
main = run Room
describeLocation :: String -> String
describeLocation locName = case locName of
"Home" -> "You are standing in the middle room at the wooden table."
"Friend's home" -> "You are standing in the front of the night garden behind the small wooden fence."
otherwise -> "Unknown location."

0 comments on commit 4e13bf8

Please sign in to comment.