|
@@ -132,7 +132,7 @@ toggleFlag c = c
|
|
|
|
|
|
loop::Int -> Int -> Int -> Grid -> IO ()
|
|
|
loop i j n b@(Grid xs)
|
|
|
- | won n b = putStrLn " Victory !"
|
|
|
+ | won b n = putStrLn "Victory !"
|
|
|
| otherwise = do
|
|
|
putStrLn $ show $ Grid $ applyij ( const Selected ) i j xs
|
|
|
c <- getChar
|
|
@@ -141,8 +141,8 @@ loop i j n b@(Grid xs)
|
|
|
'k' -> loop (min (i + 1) ((length xs) - 1)) j n b -- move caret down
|
|
|
'j' -> loop i (max (j - 1) 0) n b -- move caret left
|
|
|
'l' -> loop i (min (j + 1) ((length (xs!!0)) - 1)) n b -- move caret right
|
|
|
- 'f' -> Grid $ applyij toggleFlag i j b -- toggle flag
|
|
|
- 'u' -> Grid $ applyij uncover i j b -- uncover tile
|
|
|
+ 'f' -> loop i j n (Grid $ applyij toggleFlag i j xs) -- toggle flag
|
|
|
+ 'u' -> loop i j n (uncover (i, j) b) -- uncover tile
|
|
|
otherwise -> loop i j n b -- do nothing
|
|
|
|
|
|
|