Use msg-val everywhere and fix some definitions' argument lists.
[mudsync.git] / worlds / bricabrac.scm
1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
3 ;;;
4 ;;; This file is part of Mudsync.
5 ;;;
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ;;; General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync.  If not, see <http://www.gnu.org/licenses/>.
18
19 ;;; Hotel Bricabrac
20
21 (use-modules (mudsync)
22              (mudsync parser)
23              (8sync systems actors)
24              (8sync agenda)
25              (oop goops)
26              (ice-9 control)
27              (ice-9 format)
28              (ice-9 match)
29              (rx irregex))
30
31
32 \f
33 ;;; Utilities, useful or otherwise
34 ;;; ==============================
35
36 (set! *random-state* (random-state-from-platform))
37
38 (define (random-choice lst)
39   (list-ref lst (random (length lst))))
40
41 ;; list of lists, lol.
42 (define-syntax-rule (lol (list-contents ...) ...)
43   (list (list list-contents ...) ...))
44
45 \f
46 ;;; Some simple object types.
47 ;;; =========================
48
49 (define readable-commands
50   (list
51    (direct-command "read" 'cmd-read)))
52
53 (define readable-commands*
54   (append readable-commands
55           thing-commands))
56
57 (define readable-actions
58   (build-actions
59    (cmd-read (wrap-apply readable-cmd-read))))
60
61 (define readable-actions*
62   (append readable-actions
63           thing-actions*))
64
65 (define-class <readable> (<thing>)
66   (read-text #:init-value "All it says is: \"Blah blah blah.\""
67              #:init-keyword #:read-text)
68   (commands
69    #:init-value readable-commands*)
70   (message-handler
71    #:init-value
72    (simple-dispatcher readable-actions*)))
73
74 (define (readable-cmd-read actor message)
75   (<- actor (message-from message) 'tell
76       #:text (string-append (slot-ref actor 'read-text) "\n")))
77
78
79 \f
80 ;;; Lobby
81 ;;; -----
82
83 (define (npc-chat-randomly actor message . _)
84   (define text-to-send
85     (format #f "~a says: \"~a\"\n"
86             (slot-ref actor 'name)
87             (random-choice (slot-ref actor 'catchphrases))))
88   (<- actor (message-from message) 'tell
89       #:text text-to-send))
90
91 (define chat-commands
92   (list
93    (direct-command "chat" 'cmd-chat)
94    (direct-command "talk" 'cmd-chat)))
95 (define chat-actions
96   (build-actions
97    (cmd-chat (wrap-apply npc-chat-randomly))))
98
99 (define hotel-owner-grumps
100   '("Eight sinks!  Eight sinks!  And I couldn't unwind them..."
101     "Don't mind the mess.  I built this place on a dare, you
102 know?"
103     "(*tearfully*) Here, take this parenthesis.  May it serve
104 you well."
105     "I gotta get back to the goblin farm soon..."
106     "Oh, but I was going to make a mansion... a great,
107 beautiful mansion!  Full of ghosts!  Now all I have is this cruddy
108 mo... hotel.  Oh... If only I had more time!"
109     "I told them to paint more of the walls purple.
110 Why didn't they listen?"
111     "Listen to that overhead muzak.  Whoever made that doesn't
112 know how to compose very well!  Have you heard of the bands 'fmt'
113 or 'skribe'?  Now *that's* composition!"))
114
115 (define-class <chatty-npc> (<gameobj>)
116   (catchphrases #:init-value '("Blarga blarga blarga!")
117                 #:init-keyword #:catchphrases)
118   (commands
119    #:init-value chat-commands)
120   (message-handler
121    #:init-value
122    (simple-dispatcher (append gameobj-actions chat-actions))))
123
124 (define random-bricabrac
125   '("a creepy porcelain doll"
126     "assorted 1950s robots"
127     "an exquisite tea set"
128     "an antique mustard pot"
129     "the pickled head of Elvis"
130     "the pickled circuitboard of EVLIS"
131     "a scroll of teletype paper holding the software Four Freedoms"
132     "a telephone shaped like an orange cartoon cat"))
133
134 (define-class <sign-in-form> (<gameobj>)
135   (commands
136    #:init-value
137    (list
138     (prep-direct-command "sign" 'cmd-sign-form
139                              '("as"))))
140   (message-handler
141    #:init-value
142    (simple-dispatcher
143     (append
144      (build-actions
145       (cmd-sign-form (wrap-apply sign-cmd-sign-in)))
146      gameobj-actions))))
147
148
149 (define name-sre
150   (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
151
152 (define forbidden-words
153   (append article preposition
154           '("and" "or" "but" "admin")))
155
156 (define (valid-name? name)
157   (and (irregex-match name-sre name)
158        (not (member name forbidden-words))))
159
160 (define* (sign-cmd-sign-in actor message
161                            #:key direct-obj indir-obj preposition)
162   (define old-name
163     (msg-val (<-wait actor (message-from message) 'get-name)))
164   (define name indir-obj)
165   (if (valid-name? indir-obj)
166       (begin
167         (<-wait actor (message-from message) 'set-name! name)
168         (<- actor (slot-ref actor 'loc) 'tell-room
169             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
170                            old-name old-name name)))
171       (<- actor (message-from message) 'tell
172           #:text "Sorry, that's not a valid name.
173 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
174 character.\n")))
175
176
177 (define summoning-bell-commands
178   (list
179    (direct-command "ring" 'cmd-ring)))
180 (define summoning-bell-commands*
181   (append summoning-bell-commands
182           thing-commands*))
183
184 (define summoning-bell-actions
185   (build-actions
186    (cmd-ring (wrap-apply summoning-bell-cmd-ring))))
187 (define summoning-bell-actions*
188   (append summoning-bell-actions
189           thing-actions*))
190
191 (define-class <summoning-bell> (<thing>)
192   (summons #:init-keyword #:summons)
193
194   (commands
195    #:init-value summoning-bell-commands*)
196   (message-handler
197    #:init-value
198    (simple-dispatcher summoning-bell-actions*)))
199
200 (define* (summoning-bell-cmd-ring bell message . _)
201   ;; Call back to actor who invoked this message handler
202   ;; and find out their name.  We'll call *their* get-name message
203   ;; handler... meanwhile, this procedure suspends until we get
204   ;; their response.
205   (define who-rang
206     (msg-val (<-wait bell (message-from message) 'get-name)))
207
208   ;; Now we'll invoke the "tell" message handler on the player
209   ;; who rang us, displaying this text on their screen.
210   ;; This one just uses <- instead of <-wait, since we don't
211   ;; care when it's delivered; we're not following up on it.
212   (<- bell (message-from message) 'tell
213       #:text "*ring ring!*  You ring the bell!\n")
214   ;; We also want everyone else in the room to "hear" the bell,
215   ;; but they get a different message since they aren't the ones
216   ;; ringing it.  Notice here's where we make use of the invoker's
217   ;; name as extracted and assigned to the who-rang variable.
218   ;; Notice how we send this message to our "location", which
219   ;; forwards it to the rest of the occupants in the room.
220   (<- bell (gameobj-loc bell) 'tell-room
221       #:text
222       (format #f "*ring ring!*  ~a rings the bell!\n"
223               who-rang)
224       #:exclude (message-from message))
225   ;; Now we perform the primary task of the bell, which is to summon
226   ;; the "clerk" character to the room.  (This is configurable,
227   ;; so we dynamically look up their address.)
228   (<- bell (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
229       #:who-summoned (message-from message)))
230
231
232 (define prefect-quotes
233   '("I'm a frood who really knows where my towel is!"
234     "On no account allow a Vogon to read poetry at you."
235     "Time is an illusion, lunchtime doubly so!"
236     "How can you have money if none of you produces anything?"
237     "On no account allow Arthur to request tea on this ship."))
238
239 (define lobby
240   (lol
241    ('room:lobby
242     <room> #f
243     #:name "Hotel Lobby"
244     #:desc
245     "  You're in some sort of hotel lobby.  You see a large sign hanging
246 over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
247 that says \"ring for service\".  Terrible music plays from a speaker
248 somewhere overhead.
249   The room is lined with various curio cabinets, filled with all sorts
250 of kitschy junk.  It looks like whoever decorated this place had great
251 ambitions, but actually assembled it all in a hurry and used whatever
252 kind of objects they found lying around.
253   There's a door to the north leading to some kind of hallway."
254     #:exits
255     (list (make <exit>
256             #:name "north"
257             #:to 'room:grand-hallway)))
258    ;; NPC: hotel owner
259    ('npc:lobby:hotel-owner
260     <chatty-npc> 'room:lobby
261     #:name "a frumpy fellow"
262     #:desc "  Whoever this is, they looks totally exhausted.  They're
263 collapsed into the only comfortable looking chair in the room and you
264 don't get the sense that they're likely to move any time soon.
265   You notice they're wearing a sticker badly adhesed to their clothing
266 which says \"Hotel Proprietor\", but they look so disorganized that you
267 think that can't possibly be true... can it?
268   Despite their exhaustion, you sense they'd be happy to chat with you,
269 though the conversation may be a bit one sided."
270     #:goes-by '("frumpy fellow" "fellow"
271                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
272                 "hotel proprietor" "proprietor")
273     #:catchphrases hotel-owner-grumps)
274    ;; Object: Sign
275    ('thing:lobby:sign
276     <readable> 'room:lobby
277     #:name "the Hotel Bricabrac sign"
278     #:desc "  It strikes you that there's something funny going on with this sign.
279 Sure enough, if you look at it hard enough, you can tell that someone
280 hastily painted over an existing sign and changed the \"M\" to an \"H\".
281 Classy!"
282     #:read-text "  All it says is \"Hotel Bricabrac\" in smudged, hasty text."
283     #:goes-by '("sign"
284                 "bricabrac sign"
285                 "hotel sign"
286                 "hotel bricabrac sign"
287                 "lobby sign"))
288
289    ('thing:lobby:bell
290     <summoning-bell> 'room:lobby
291     #:name "a shiny brass bell"
292     #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
293     #:desc "  A shiny brass bell.  Inscribed on its wooden base is the text
294 \"ring me for service\".  You probably could \"ring the bell\" if you 
295 wanted to."
296     #:summons 'npc:break-room:desk-clerk)
297
298    ;; Object: curio cabinets
299    ('thing:lobby:cabinet
300     <gameobj> 'room:lobby
301     #:name "a curio cabinet"
302     #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
303     #:desc (lambda _
304              (format #f "  The curio cabinet is full of all sorts of oddities!
305 Something catches your eye!
306 Ooh, ~a!" (random-choice random-bricabrac))))
307    ('thing:lobby:sign-in-form
308     <sign-in-form> 'room:lobby
309     #:name "sign-in form"
310     #:goes-by '("sign-in form" "form" "signin form")
311     #:desc "It looks like you could sign this form and set your name.")
312    ;; Object: desk
313    ;;  - Object: bell
314    ;;  - Object: sign in form
315    ;;  - Object: pamphlet
316    ;; Object: <invisible bell>: reprimands that you want to ring the
317    ;;   bell on the desk
318    )
319   )
320
321
322 \f
323 ;;; Grand hallway
324 ;;; -------------
325
326 (define grand-hallway
327   (lol
328    ('room:grand-hallway
329     <room> #f
330     #:name "Grand Hallway"
331     #:desc "  A majestic red carpet runs down the center of the room.
332 Busts of serious looking people line the walls, but there's no
333 clear indication that they have any logical relation to this place.
334   In the center is a large statue of a bearded man.  You wonder what
335 that's all about?
336   To the south is the lobby.  A door to the east is labeled \"smoking
337 room\", while a door to the west is labeled \"playroom\"."
338     #:exits
339     (list (make <exit>
340             #:name "south"
341             #:to 'room:lobby)
342           (make <exit>
343             #:name "west"
344             #:to 'room:playroom)
345           (make <exit>
346             #:name "east"
347             #:to 'room:smoking-parlor)))
348    ('thing:ignucius-statue
349     <gameobj> 'room:grand-hallway
350     #:name "a statue"
351     #:desc "  The statue is of a serious-looking bearded man with long, flowing hair.
352 The inscription says \"St. Ignucius\".
353   It has a large physical halo.  Removing it is tempting, but it looks pretty
354 well fastened."
355     #:goes-by '("statue" "st ignucius" "st. ignucius"))))
356
357 \f
358 ;;; Playroom
359 ;;; --------
360
361 (define playroom
362   (lol
363    ('room:playroom
364     <room> #f
365     #:name "The Playroom"
366     #:desc "  There are toys scattered everywhere here.  It's really unclear
367 if this room is intended for children or child-like adults."
368     #:exits
369     (list (make <exit>
370             #:name "east"
371             #:to 'room:grand-hallway)))
372    ('thing:playroom:cubey
373     <thing> 'room:playroom
374     #:name "cubey"
375     #:takeable #t
376     #:desc "  It's a little foam cube with googly eyes on it.  So cute!")
377    ('thing:cuddles-plushie
378     <thing> 'room:playroom
379     #:name "a cuddles plushie"
380     #:goes-by '("plushie" "cuddles plushie" "cuddles")
381     #:takeable #t
382     #:desc "  A warm and fuzzy cuddles plushie!  It's a cuddlefish!")))
383
384
385 \f
386 ;;; Writing room
387 ;;; ------------
388
389 \f
390 ;;; Armory???
391 ;;; ---------
392
393 ;; ... full of NURPH weapons?
394
395 \f
396 ;;; Smoking parlor
397 ;;; --------------
398
399 (define-class <furniture> (<gameobj>)
400   (sit-phrase #:init-keyword #:sit-phrase)
401   (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
402   (sit-name #:init-keyword #:sit-name)
403
404   (commands
405    #:init-value
406    (list
407     (direct-command "sit" 'cmd-sit-furniture)))
408   (message-handler
409    #:init-value
410    (simple-dispatcher
411     (append
412      (build-actions
413       (cmd-sit-furniture (wrap-apply furniture-cmd-sit)))
414      gameobj-actions))))
415
416 (define* (furniture-cmd-sit actor message #:key direct-obj)
417   (define player-name
418     (msg-val (<-wait actor (message-from message) 'get-name)))
419   (<- actor (message-from message) 'tell
420       #:text (format #f "You ~a ~a.\n"
421                      (slot-ref actor 'sit-phrase)
422                      (slot-ref actor 'sit-name)))
423   (<- actor (slot-ref actor 'loc) 'tell-room
424       #:text (format #f "~a ~a on ~a.\n"
425                      player-name
426                      (slot-ref actor 'sit-phrase-third-person)
427                      (slot-ref actor 'sit-name))
428       #:exclude (message-from message)))
429
430
431 (define smoking-parlor
432   (lol
433    ('room:smoking-parlor
434     <room> #f
435     #:name "Smoking Parlor"
436     #:desc "  This room looks quite posh.  There are huge comfy seats you can sit in
437 if you like.
438   Strangely, you see a large sign saying \"No Smoking\".  The owners must
439 have installed this place and then changed their mind later.
440   There's a door to the west leading back to the grand hallway, and
441 a nondescript steel door to the south, leading apparently outside."
442     #:exits
443     (list (make <exit>
444             #:name "west"
445             #:to 'room:grand-hallway)
446           (make <exit>
447             #:name "south"
448             #:to 'room:break-room)))
449    ('thing:smoking-room:chair
450     <furniture> 'room:smoking-parlor
451     #:name "a comfy leather chair"
452     #:desc "  That leather chair looks really comfy!"
453     #:goes-by '("leather chair" "comfy leather chair" "chair")
454     #:sit-phrase "sink into"
455     #:sit-phrase-third-person "sinks into"
456     #:sit-name "the comfy leather chair")
457    ('thing:smoking-room:sofa
458     <furniture> 'room:smoking-parlor
459     #:name "a plush leather sofa"
460     #:desc "  That leather chair looks really comfy!"
461     #:goes-by '("leather sofa" "plush leather sofa" "sofa"
462                 "leather couch" "plush leather couch" "couch")
463     #:sit-phrase "sprawl out on"
464     #:sit-phrase-third-person "sprawls out on into"
465     #:sit-name "the plush leather couch")
466    ('thing:smoking-room:bar-stool
467     <furniture> 'room:smoking-parlor
468     #:name "a bar stool"
469     #:desc "  Conveniently located near the bar!  Not the most comfortable
470 seat in the room, though."
471     #:goes-by '("stool" "bar stool" "seat")
472     #:sit-phrase "hop on"
473     #:sit-phrase-third-person "hops onto"
474     #:sit-name "the bar stool")
475    ('npc:ford-prefect
476     <chatty-npc> 'room:smoking-parlor
477     #:name "Ford Prefect"
478     #:desc "Just some guy, you know?"
479     #:goes-by '("Ford Prefect" "ford prefect"
480                 "frood" "prefect" "ford")
481     #:catchphrases prefect-quotes)
482
483    ;; TODO: Cigar dispenser
484
485    ))
486
487 \f
488
489 ;;; Breakroom
490 ;;; ---------
491
492 (define clerk-commands
493   (list
494    (direct-command "talk" 'cmd-chat)
495    (direct-command "chat" 'cmd-chat)
496    (direct-command "ask" 'cmd-ask-incomplete)
497    (prep-direct-command "ask" 'cmd-ask-about)
498    (direct-command "dismiss" 'cmd-dismiss)))
499 (define clerk-commands*
500   (append clerk-commands thing-commands*))
501
502 (define clerk-actions
503   (build-actions
504    (init (wrap-apply clerk-act-init))
505    (cmd-chat (wrap-apply clerk-cmd-chat))
506    (cmd-ask-incomplete (wrap-apply clerk-cmd-ask-incomplete))
507    (cmd-ask-about (wrap-apply clerk-cmd-ask))
508    (cmd-dismiss (wrap-apply clerk-cmd-dismiss))
509    (update-loop (wrap-apply clerk-act-update-loop))
510    (be-summoned (wrap-apply clerk-act-be-summoned))))
511 (define clerk-actions* (append clerk-actions
512                                thing-actions*))
513
514 (define-class <desk-clerk> (<thing>)
515   ;; The desk clerk has three states:
516   ;;  - on-duty: Arrived, and waiting for instructions (and losing patience
517   ;;    gradually)
518   ;;  - slacking: In the break room, probably smoking a cigarette
519   ;;    or checking text messages
520   (state #:init-value 'slacking)
521   (commands #:init-value clerk-commands*)
522   (patience #:init-value 0)
523   (message-handler
524    #:init-value
525    (simple-dispatcher clerk-actions*)))
526
527 (define (clerk-act-init clerk message)
528   ;; call the gameobj main init method
529   (gameobj-act-init clerk message)
530   ;; start our main loop
531   (<- clerk (actor-id clerk) 'update-loop))
532
533 (define clerk-help-topics
534   '(("changing name" .
535      "Changing your name is easy!  We have a clipboard here at the desk
536 where you can make yourself known to other participants in the hotel
537 if you sign it.  Try 'sign form as <your-name>', replacing
538 <your-name>, obviously!")
539     ("common commands" .
540      "Here are some useful commands you might like to try: chat,
541 go, take, drop, say...")
542     ("hotel" .
543      "We hope you enjoy your stay at Hotel Bricabrac.  As you may see,
544 our hotel emphasizes interesting experiences over rest and lodging.
545 The origins of the hotel are... unclear... and it has recently come
546 under new... 'management'.  But at Hotel Bricabrac we believe these
547 aspects make the hotel into a fun and unique experience!  Please,
548 feel free to walk around and explore.")))
549
550
551 (define clerk-knows-about
552   "'changing name', 'common commands', and 'about the hotel'")
553
554 (define clerk-general-helpful-line
555   (string-append
556    "The clerk says, \"If you need help with anything, feel free to ask me about it.
557 For example, 'ask clerk about changing name'. You can ask me about the following:
558 " clerk-knows-about ".\"\n"))
559
560 (define clerk-slacking-complaints
561   '("The pay here is absolutely lousy."
562     "The owner here has no idea what they're doing."
563     "Some times you just gotta step away, you know?"
564     "You as exhausted as I am?"
565     "Yeah well, this is just temporary.  I'm studying to be a high
566 energy particle physicist.  But ya gotta pay the bills, especially
567 with tuition at where it is..."))
568
569 (define* (clerk-cmd-chat clerk message #:key direct-obj)
570   (match (slot-ref clerk 'state)
571     ('on-duty
572      (<- clerk (message-from message) 'tell
573          #:text clerk-general-helpful-line))
574     ('slacking
575      (<- clerk (message-from message) 'tell
576          #:text
577          (string-append
578           "The clerk says, \""
579           (random-choice clerk-slacking-complaints)
580           "\"\n")))))
581
582 (define (clerk-cmd-ask-incomplete clerk message)
583   (<- clerk (message-from message) 'tell
584       #:text "The clerk says, \"Ask about what?\"\n"))
585
586 (define clerk-doesnt-know-text
587   "The clerk apologizes and says she doesn't know about that topic.\n")
588
589 (define (clerk-cmd-ask clerk message indir-obj)
590   (match (slot-ref clerk 'state)
591     ('on-duty
592      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
593        ((_ . info)
594            (<- clerk (message-from message) 'tell
595                #:text
596                (string-append "The clerk clears her throat and says:\n  \""
597                               info
598                               "\"\n")))
599        (#f
600         (<- clerk (message-from message) 'tell
601             #:text clerk-doesnt-know-text))))
602     ('slacking
603      (<- clerk (message-from message) 'tell
604          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
605
606 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
607   (match (slot-ref clerk 'state)
608     ('on-duty
609      (<- clerk who-summoned 'tell
610          #:text
611          "The clerk tells you as politely as she can that she's already here,
612 so there's no need to ring the bell.\n"))
613     ('slacking
614      (<- clerk (gameobj-loc clerk) 'tell-room
615          #:text
616          "The clerk's ears perk up, she stamps out a cigarette, and she
617 runs out of the room!\n")
618      (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
619      (slot-set! clerk 'patience 8)
620      (slot-set! clerk 'state 'on-duty)
621      (<- clerk (gameobj-loc clerk) 'tell-room
622          #:text
623          (string-append
624           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
625 badge that says \"Desk Clerk\".
626   \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
627 We look forward to your stay.  If you'd like help getting acclimated,
628 feel free to ask me.  For example, 'ask clerk about changing name'.
629 You can ask me about the following:
630 " clerk-knows-about ".\"\n")))))
631
632 (define* (clerk-cmd-dismiss clerk message . _)
633   (define player-name
634     (msg-val (<-wait clerk (message-from message) 'get-name)))
635   (match (slot-ref clerk 'state)
636     ('on-duty
637      (<- clerk (gameobj-loc clerk) 'tell-room
638          #:text
639          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
640 The clerk leaves the room in a hurry.\n"
641                  player-name)
642          #:exclude (actor-id clerk))
643      (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
644      (slot-set! clerk 'state 'slacking)
645      (<- clerk (gameobj-loc clerk) 'tell-room
646          #:text clerk-return-to-slacking-text
647          #:exclude (actor-id clerk)))
648     ('slacking
649      (<- clerk (message-from message) 'tell
650          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
651
652 (define clerk-slacking-texts
653   '("The clerk takes a long drag on her cigarette.\n"
654     "The clerk scrolls through text messages on her phone.\n"
655     "The clerk coughs a few times.\n"
656     "The clerk checks her watch and justifies a few more minutes outside.\n"
657     "The clerk fumbles around for a lighter.\n"
658     "The clerk sighs deeply and exhaustedly.\n"
659     "The clerk fumbles around for a cigarette.\n"))
660
661 (define clerk-working-impatience-texts
662   '("The clerk struggles to retain an interested and polite smile.\n"
663     "The clerk checks the time on her phone.\n"
664     "The clerk taps her foot.\n"
665     "The clerk takes a deep breath.\n"
666     "The clerk yawns.\n"
667     "The clerk drums her nails on the counter.\n"
668     "The clerk clicks around on the desk computer.\n"))
669
670 (define clerk-slack-excuse-text
671   "The desk clerk excuses herself, claiming she has important things to
672 attend to.\n")
673
674 (define clerk-return-to-slacking-text
675   "The desk clerk enters and slams the door behind her.\n")
676
677 (define (clerk-act-update-loop clerk message)
678   (define (tell-room text)
679     (<- clerk (gameobj-loc clerk) 'tell-room
680         #:text text
681         #:exclude (actor-id clerk)))
682   (define (loop-if-not-destructed)
683     (if (not (slot-ref clerk 'destructed))
684         (<- clerk (actor-id clerk) 'update-loop)))
685   (match (slot-ref clerk 'state)
686     ('slacking
687      (tell-room (random-choice clerk-slacking-texts))
688      (8sleep (+ (random 10) 10))
689      (loop-if-not-destructed))
690     ('on-duty
691      (if (> (slot-ref clerk 'patience) 0)
692          ;; Keep working but lose patience gradually
693          (begin
694            (tell-room (random-choice clerk-working-impatience-texts))
695            (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
696                                          (+ (random 2) 1)))
697            (8sleep (+ (random 25) 20))
698            (loop-if-not-destructed))
699          ;; Back to slacking
700          (begin
701            (tell-room clerk-slack-excuse-text)
702            ;; back bto the break room
703            (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'room:break-room)))
704            (tell-room clerk-return-to-slacking-text)
705            ;; annnnnd back to slacking
706            (slot-set! clerk 'state 'slacking)
707            (8sleep (+ (random 30) 15))
708            (loop-if-not-destructed))))))
709
710
711 (define break-room
712   (lol
713    ('room:break-room
714     <room> #f
715     #:name "Employee Break Room"
716     #:desc "  This is less a room and more of an outdoor wire cage.  You get
717 a bit of a view of the brick exterior of the building, and a crisp wind blows,
718 whistling, through the openings of the fenced area.  Partly smoked cigarettes
719 and various other debris cover the floor.
720   Through the wires you can see... well... hm.  It looks oddly like
721 the scenery tapers off nothingness.  But that can't be right, can it?"
722     #:exits
723     (list (make <exit>
724             #:name "north"
725             #:to 'room:smoking-parlor))
726     )
727    ('npc:break-room:desk-clerk
728     <desk-clerk> 'room:break-room
729     #:name "the hotel desk clerk"
730     #:desc "  The hotel clerk is wearing a neatly pressed uniform bearing the
731 hotel insignia.  She looks like she'd much rather be somewhere else."
732     #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))))
733
734
735 \f
736 ;;; Ennpie's Sea Lounge
737 ;;; -------------------
738
739 \f
740 ;;; Computer room
741 ;;; -------------
742
743 \f
744 ;;; Game
745 ;;; ----
746
747 (define game-spec
748   (append lobby grand-hallway smoking-parlor
749           playroom break-room))
750
751 ;; TODO: Provide command line args
752 (define (run-game . args)
753   (run-demo game-spec 'room:lobby #:repl-server #t))
754