summaryrefslogtreecommitdiff
path: root/fp2/week1/camil
diff options
context:
space:
mode:
authorCamil Staps2015-04-19 14:17:40 +0200
committerCamil Staps2015-04-19 14:17:40 +0200
commitfbd9180da9e4dd644faa002adecba594079da100 (patch)
tree21ba315ac620cfe11ab6af8e7f3cb64be25ecce7 /fp2/week1/camil
parentAdded mistakes left counter; now all that is left to do is an ASCII art gallow (diff)
Added gallow
Diffstat (limited to 'fp2/week1/camil')
-rw-r--r--fp2/week1/camil/Galgje.icl21
-rw-r--r--fp2/week1/camil/round-0.txt7
-rw-r--r--fp2/week1/camil/round-1.txt7
-rw-r--r--fp2/week1/camil/round-2.txt7
-rw-r--r--fp2/week1/camil/round-3.txt7
-rw-r--r--fp2/week1/camil/round-4.txt7
-rw-r--r--fp2/week1/camil/round-5.txt7
-rw-r--r--fp2/week1/camil/round-lost.txt7
8 files changed, 62 insertions, 8 deletions
diff --git a/fp2/week1/camil/Galgje.icl b/fp2/week1/camil/Galgje.icl
index f8dd8f3..4225929 100644
--- a/fp2/week1/camil/Galgje.icl
+++ b/fp2/week1/camil/Galgje.icl
@@ -26,17 +26,20 @@ randomWord env
| otherwise = (Just (skip_nl ((shuffle (fromJust ss) seed)!!0)), env)
// word, guesses, mistakes left, stdio -> (win, new guesses, stdio)
-play :: String [Char] Int *File -> (Bool, [Char], *File)
-play w g n io
+play :: String [Char] Int *File *env -> (Bool, [Char], *File, *env) | FileSystem env
+play w g n io world
# io = io <<< stripUnknown w g <<< '\n'
-| stripUnknown w g == w = (True, g, io)
+| stripUnknown w g == w = (True, g, io, world)
+# (round,world) = readFile ("round-" +++ (toString n) +++ ".txt") world
+| round == Nothing = abort "Couldn't get gallow"
+# io = io <<< (fromJust round)
# io = io <<< "Guess (" <<< toString n <<< "): "
# (ok,g`,io) = freadc io
# (_,io) = freadline io // to read until the next \n
| not ok = abort "Couldn't get guessed letter"
-| isMemberString w g` = play w [g`:g] n io
-| n == 0 = (False, [g`:g], io)
-| otherwise = play w [g`:g] (n-1) io
+| isMemberString w g` = play w [g`:g] n io world
+| n == 0 = (False, [g`:g], io, world)
+| otherwise = play w [g`:g] (n-1) io world
Start :: *World -> *World
Start world
@@ -44,8 +47,10 @@ Start world
| word == Nothing = abort "Couldn't get random word"
# word = fromJust word
# (io,world) = stdio world
-# (win,g,io) = play word [] 5 io
-# io = if win (io <<< "You win!\n") (io <<< "You lose!\n")
+# (win,g,io,world) = play word [] 5 io world
+# (lost,world) = readFile "round-lost.txt" world
+| lost == Nothing = abort "Couldn't get gallow"
+# io = if win (io <<< "You win!\n") (io <<< "You lose!\n" <<< fromJust lost)
# (ok,world) = fclose io world
| not ok = abort "Couldn't close stdio"
| otherwise = world
diff --git a/fp2/week1/camil/round-0.txt b/fp2/week1/camil/round-0.txt
new file mode 100644
index 0000000..7236e17
--- /dev/null
+++ b/fp2/week1/camil/round-0.txt
@@ -0,0 +1,7 @@
+ ------
+ | \ |
+ o \|
+ /O\ |
+ |
+ |
+________
diff --git a/fp2/week1/camil/round-1.txt b/fp2/week1/camil/round-1.txt
new file mode 100644
index 0000000..8694aad
--- /dev/null
+++ b/fp2/week1/camil/round-1.txt
@@ -0,0 +1,7 @@
+ ------
+ | \ |
+ o \|
+ |
+ |
+ |
+________
diff --git a/fp2/week1/camil/round-2.txt b/fp2/week1/camil/round-2.txt
new file mode 100644
index 0000000..d46d77c
--- /dev/null
+++ b/fp2/week1/camil/round-2.txt
@@ -0,0 +1,7 @@
+ ------
+ | \ |
+ \|
+ |
+ |
+ |
+________
diff --git a/fp2/week1/camil/round-3.txt b/fp2/week1/camil/round-3.txt
new file mode 100644
index 0000000..9bdd2ba
--- /dev/null
+++ b/fp2/week1/camil/round-3.txt
@@ -0,0 +1,7 @@
+ ------
+ \ |
+ \|
+ |
+ |
+ |
+________
diff --git a/fp2/week1/camil/round-4.txt b/fp2/week1/camil/round-4.txt
new file mode 100644
index 0000000..41ca216
--- /dev/null
+++ b/fp2/week1/camil/round-4.txt
@@ -0,0 +1,7 @@
+
+ |
+ |
+ |
+ |
+ |
+________
diff --git a/fp2/week1/camil/round-5.txt b/fp2/week1/camil/round-5.txt
new file mode 100644
index 0000000..f29c0dd
--- /dev/null
+++ b/fp2/week1/camil/round-5.txt
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+________
diff --git a/fp2/week1/camil/round-lost.txt b/fp2/week1/camil/round-lost.txt
new file mode 100644
index 0000000..7ec2fa7
--- /dev/null
+++ b/fp2/week1/camil/round-lost.txt
@@ -0,0 +1,7 @@
+ ------
+ | \ |
+ o \|
+ /O\ |
+ / \ |
+ |
+________