From c69352277774f8cfc5019f12fb6691ff2400f8b7 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 5 Nov 2022 15:02:51 +0100 Subject: Add random state per execution and try it with some game mechanics --- depre/main.scm | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'depre') diff --git a/depre/main.scm b/depre/main.scm index a35411c..964fca3 100644 --- a/depre/main.scm +++ b/depre/main.scm @@ -2,6 +2,9 @@ (define-module (depre main) #:use-module (ice-9 textual-ports)) +;; Random seed +(set! *random-state* (random-state-from-platform)) + ;; Code makes heavy use of functional code and parameters for state. (define max-100 (lambda (x) (if (> x 100) 100 x))) (define %depression (make-parameter 50 max-100)) @@ -112,29 +115,52 @@ `(lambda () ((hash-ref %states ,name)))) (register-state - 'beginning - (state "This is the game beginning, as a test" - (list (cons "Return to start" + 'morning-1 + (state "It's early in the morning. You have time to do whatever you want right now. What do you want to do?" + (list + (cons "Work." + (rest)) + (cons "Relax." + (rest))))) + +(register-state + 'morning-2 + (state "It's late in the morning. You still have some time before having lunch. What do you want to do?" + (list (cons "nope" (rest))))) + +(register-state + 'wake-up + (state "Good morning. It's time to wake up, what do you want to do?" + (list (cons "Wake up and start your day." (f-or-tired (combine - (answer "Alright, you can do that.") - (rest) - (to-state 'start)) + (answer "You just woke up, had your shower, had some breakfast and now you are ready for anything.") + (cheer-up) + (tire) + (to-state 'morning-1)) (combine - (answer "You are too tired for that") + (answer "You are too tired for waking up now. You stay at bed instead and your day starts in mid morning.") (depress) - (to-state 'start))))))) + (rest) + (to-state 'morning-2)))) + + (cons "Stay in bed" + (combine + (answer "You rest for a little bit more, but you feel bad because you have a hard time waking up like a normal person") + (depress) + (rest) + (to-state 'morning-2)))))) (register-state 'start (state "Hi, game starts" - (list (cons "Start game" - (combine - (answer "Let's start, then. You are getting tired.") - (tire) - (to-state 'beginning))) - (cons "Quit game" - (answer "Good bye!"))) + (list + (cons "Start game" + (combine + (answer "Let's start, then. Press [ENTER] to continue.") + (to-state 'wake-up))) + (cons "Quit game" + (answer "Good bye!"))) #:hide-status)) ((to-state 'start)) -- cgit v1.2.3