-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameEngine.hs
48 lines (41 loc) · 1.35 KB
/
GameEngine.hs
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
36
37
38
39
40
41
42
43
44
45
46
module GameEngine (gameLoop) where
import Data.Char
import Data.List
import System.IO
import Interface
import BinarySearchTree
import WordsTupleSetup
manResistence = 6
teste::Int->Int
teste te = te+1
gameLoop :: (String,String,BSTree content) -> Int -> IO ()
gameLoop (hs,cr,(Node leaf left right)) i| i > manResistence = do
putStrLn "\n"
Interface.drawHangman i
putStrLn "\n Voce Perdeu =("
if left == Null || right == Null
then do putStrLn "O jogo acabou voce acertou x palavras"
else do
let gameCurrentLevel = BinarySearchTree.getCurrentNode left
let word = fst leaf
gameLoop ("",word,left) 0
| all (`elem` hs) (map toLower cr) = do
putStrLn "\n "
Interface.printWord hs cr
putStrLn "\nParabens voce ganhou"
if left == Null || right == Null
then putStrLn "O jogo acabou voce acertou x palavras"
else do
let gameCurrentLevel = BinarySearchTree.getCurrentNode right
let word = fst gameCurrentLevel
gameLoop ("",word,right) 0
gameLoop (hs,cr,(Node leaf left right)) i = do
putStrLn "\n "
Interface.drawHangman i
Interface.printWord hs cr
putStrLn "\n "
h <- getChar >>= (return.toLower)
if (h `elem` (map toLower cr)) then
gameLoop ((h:hs),cr,(Node leaf left right)) i
else do
gameLoop (hs,cr,(Node leaf left right)) (i+1)