summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2022-11-05 12:04:37 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2022-11-05 12:04:37 +0100
commit26b43e773b10d3b8dfe86cc73bc7c065b1c6a5e0 (patch)
tree1e2a942072e93c92e7ba052c35a923f0768018d8
parent395b51b37fb8c226384b09793be16304a8f94dd8 (diff)
Add state alteration functions
-rw-r--r--depre/main.scm20
1 files changed, 19 insertions, 1 deletions
diff --git a/depre/main.scm b/depre/main.scm
index 525f685..a35411c 100644
--- a/depre/main.scm
+++ b/depre/main.scm
@@ -38,6 +38,21 @@
(lambda ()
(if (< (random 100) (%depression)) (f) (depressed))))
+
+;; State alteration functions for easy access
+(define (tire)
+ (lambda () (%tiredness (+ (%tiredness) 5))))
+
+(define (rest)
+ (lambda () (%tiredness (- (%tiredness) 5))))
+
+(define (depress)
+ (lambda () (%depression (+ (%depression) 5))))
+
+(define (cheer-up)
+ (lambda () (%depression (- (%depression) 5))))
+
+
;; Simple I/O
(define (answer message)
(lambda ()
@@ -103,9 +118,11 @@
(f-or-tired
(combine
(answer "Alright, you can do that.")
+ (rest)
(to-state 'start))
(combine
(answer "You are too tired for that")
+ (depress)
(to-state 'start)))))))
(register-state
@@ -113,7 +130,8 @@
(state "Hi, game starts"
(list (cons "Start game"
(combine
- (answer "Let's start, then.")
+ (answer "Let's start, then. You are getting tired.")
+ (tire)
(to-state 'beginning)))
(cons "Quit game"
(answer "Good bye!")))