fixed infinite recursion on clerk main loop
[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-mhandler (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-mhandler (sign-cmd-sign-in actor message direct-obj indir-obj)
161   (define old-name
162     (message-ref
163      (<-wait actor (message-from message) 'get-name)
164      'val))
165   (define name indir-obj)
166   (if (valid-name? indir-obj)
167       (begin
168         (<-wait actor (message-from message) 'set-name!
169                 #:val name)
170         (<- actor (slot-ref actor 'loc) 'tell-room
171             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
172                            old-name old-name name)))
173       (<- actor (message-from message) 'tell
174           #:text "Sorry, that's not a valid name.
175 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
176 character.\n")))
177
178
179 (define summoning-bell-commands
180   (list
181    (direct-command "ring" 'cmd-ring)))
182 (define summoning-bell-commands*
183   (append summoning-bell-commands
184           thing-commands*))
185
186 (define summoning-bell-actions
187   (build-actions
188    (cmd-ring (wrap-apply summoning-bell-cmd-ring))))
189 (define summoning-bell-actions*
190   (append summoning-bell-actions
191           thing-actions*))
192
193 (define-class <summoning-bell> (<thing>)
194   (summons #:init-keyword #:summons)
195
196   (commands
197    #:init-value summoning-bell-commands*)
198   (message-handler
199    #:init-value
200    (simple-dispatcher summoning-bell-actions*)))
201
202 (define-mhandler (summoning-bell-cmd-ring bell message)
203   (define who-rang
204     (message-ref
205      (<-wait bell (message-from message) 'get-name)
206      'val))
207   (<- bell (message-from message) 'tell
208       #:text "*ring ring!*  You ring the bell!\n")
209   (<- bell (gameobj-loc bell) 'tell-room
210       #:text
211       (format #f "*ring ring!*  ~a rings the bell!\n"
212               who-rang)
213       #:exclude (message-from message))
214
215   (<- bell (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
216       #:who-summoned (message-from message)))
217
218
219 (define prefect-quotes
220   '("I'm a frood who really knows where my towel is!"
221     "On no account allow a Vogon to read poetry at you."
222     "Time is an illusion, lunchtime doubly so!"
223     "How can you have money if none of you produces anything?"
224     "On no account allow Arthur to request tea on this ship."))
225
226 (define lobby
227   (lol
228    ('room:lobby
229     <room> #f
230     #:name "Hotel Lobby"
231     #:desc
232     "  You're in some sort of hotel lobby.  You see a large sign hanging
233 over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
234 that says \"ring for service\".  Terrible music plays from a speaker
235 somewhere overhead.
236   The room is lined with various curio cabinets, filled with all sorts
237 of kitschy junk.  It looks like whoever decorated this place had great
238 ambitions, but actually assembled it all in a hurry and used whatever
239 kind of objects they found lying around.
240   There's a door to the north leading to some kind of hallway."
241     #:exits
242     (list (make <exit>
243             #:name "north"
244             #:to 'room:grand-hallway)))
245    ;; NPC: hotel owner
246    ('npc:lobby:hotel-owner
247     <chatty-npc> 'room:lobby
248     #:name "a frumpy fellow"
249     #:desc "  Whoever this is, they looks totally exhausted.  They're
250 collapsed into the only comfortable looking chair in the room and you
251 don't get the sense that they're likely to move any time soon.
252   You notice they're wearing a sticker badly adhesed to their clothing
253 which says \"Hotel Proprietor\", but they look so disorganized that you
254 think that can't possibly be true... can it?
255   Despite their exhaustion, you sense they'd be happy to chat with you,
256 though the conversation may be a bit one sided."
257     #:goes-by '("frumpy fellow" "fellow"
258                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
259                 "hotel proprietor" "proprietor")
260     #:catchphrases hotel-owner-grumps)
261    ;; Object: Sign
262    ('thing:lobby:sign
263     <readable> 'room:lobby
264     #:name "the Hotel Bricabrac sign"
265     #:desc "  It strikes you that there's something funny going on with this sign.
266 Sure enough, if you look at it hard enough, you can tell that someone
267 hastily painted over an existing sign and changed the \"M\" to an \"H\".
268 Classy!"
269     #:read-text "  All it says is \"Hotel Bricabrac\" in smudged, hasty text."
270     #:goes-by '("sign"
271                 "bricabrac sign"
272                 "hotel sign"
273                 "hotel bricabrac sign"
274                 "lobby sign"))
275
276    ('thing:lobby:bell
277     <summoning-bell> 'room:lobby
278     #:name "a shiny brass bell"
279     #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
280     #:desc "  A shiny brass bell.  Inscribed on its wooden base is the text
281 \"ring me for service\".  You probably could \"ring the bell\" if you 
282 wanted to."
283     #:summons 'npc:break-room:desk-clerk)
284
285    ;; Object: curio cabinets
286    ('thing:lobby:cabinet
287     <gameobj> 'room:lobby
288     #:name "a curio cabinet"
289     #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
290     #:desc (lambda _
291              (format #f "  The curio cabinet is full of all sorts of oddities!
292 Something catches your eye!
293 Ooh, ~a!" (random-choice random-bricabrac))))
294    ('thing:lobby:sign-in-form
295     <sign-in-form> 'room:lobby
296     #:name "sign-in form"
297     #:goes-by '("sign-in form" "form" "signin form")
298     #:desc "It looks like you could sign this form and set your name.")
299    ;; Object: desk
300    ;;  - Object: bell
301    ;;  - Object: sign in form
302    ;;  - Object: pamphlet
303    ;; Object: <invisible bell>: reprimands that you want to ring the
304    ;;   bell on the desk
305    )
306   )
307
308
309 \f
310 ;;; Grand hallway
311 ;;; -------------
312
313 (define grand-hallway
314   (lol
315    ('room:grand-hallway
316     <room> #f
317     #:name "Grand Hallway"
318     #:desc "  A majestic red carpet runs down the center of the room.
319 Busts of serious looking people line the walls, but there's no
320 clear indication that they have any logical relation to this place.
321   In the center is a large statue of a bearded man.  You wonder what
322 that's all about?
323   To the south is the lobby.  A door to the east is labeled \"smoking
324 room\", while a door to the west is labeled \"playroom\"."
325     #:exits
326     (list (make <exit>
327             #:name "south"
328             #:to 'room:lobby)
329           (make <exit>
330             #:name "west"
331             #:to 'room:playroom)
332           (make <exit>
333             #:name "east"
334             #:to 'room:smoking-parlor)))
335    ('thing:ignucius-statue
336     <gameobj> 'room:grand-hallway
337     #:name "a statue"
338     #:desc "  The statue is of a serious-looking bearded man with long, flowing hair.
339 The inscription says \"St. Ignucius\".
340   It has a large physical halo.  Removing it is tempting, but it looks pretty
341 well fastened."
342     #:goes-by '("statue" "st ignucius" "st. ignucius"))))
343
344 \f
345 ;;; Playroom
346 ;;; --------
347
348 (define playroom
349   (lol
350    ('room:playroom
351     <room> #f
352     #:name "The Playroom"
353     #:desc "  There are toys scattered everywhere here.  It's really unclear
354 if this room is intended for children or child-like adults."
355     #:exits
356     (list (make <exit>
357             #:name "east"
358             #:to 'room:grand-hallway)))
359    ('thing:playroom:cubey
360     <thing> 'room:playroom
361     #:name "cubey"
362     #:takeable #t
363     #:desc "  It's a little foam cube with googly eyes on it.  So cute!")
364    ('thing:cuddles-plushie
365     <thing> 'room:playroom
366     #:name "a cuddles plushie"
367     #:goes-by '("plushie" "cuddles plushie" "cuddles")
368     #:takeable #t
369     #:desc "  A warm and fuzzy cuddles plushie!  It's a cuddlefish!")))
370
371
372 \f
373 ;;; Writing room
374 ;;; ------------
375
376 \f
377 ;;; Armory???
378 ;;; ---------
379
380 ;; ... full of NURPH weapons?
381
382 \f
383 ;;; Smoking parlor
384 ;;; --------------
385
386 (define-class <furniture> (<gameobj>)
387   (sit-phrase #:init-keyword #:sit-phrase)
388   (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
389   (sit-name #:init-keyword #:sit-name)
390
391   (commands
392    #:init-value
393    (list
394     (direct-command "sit" 'cmd-sit-furniture)))
395   (message-handler
396    #:init-value
397    (simple-dispatcher
398     (append
399      (build-actions
400       (cmd-sit-furniture (wrap-apply furniture-cmd-sit)))
401      gameobj-actions))))
402
403 (define-mhandler (furniture-cmd-sit actor message direct-obj)
404   (define player-name
405     (message-ref
406      (<-wait actor (message-from message) 'get-name)
407      'val))
408   (<- actor (message-from message) 'tell
409       #:text (format #f "You ~a ~a.\n"
410                      (slot-ref actor 'sit-phrase)
411                      (slot-ref actor 'sit-name)))
412   (<- actor (slot-ref actor 'loc) 'tell-room
413       #:text (format #f "~a ~a on ~a.\n"
414                      player-name
415                      (slot-ref actor 'sit-phrase-third-person)
416                      (slot-ref actor 'sit-name))
417       #:exclude (message-from message)))
418
419
420 (define smoking-parlor
421   (lol
422    ('room:smoking-parlor
423     <room> #f
424     #:name "Smoking Parlor"
425     #:desc "  This room looks quite posh.  There are huge comfy seats you can sit in
426 if you like.
427   Strangely, you see a large sign saying \"No Smoking\".  The owners must
428 have installed this place and then changed their mind later.
429   There's a door to the west leading back to the grand hallway, and
430 a nondescript steel door to the south, leading apparently outside."
431     #:exits
432     (list (make <exit>
433             #:name "west"
434             #:to 'room:grand-hallway)
435           (make <exit>
436             #:name "south"
437             #:to 'room:break-room)))
438    ('thing:smoking-room:chair
439     <furniture> 'room:smoking-parlor
440     #:name "a comfy leather chair"
441     #:desc "  That leather chair looks really comfy!"
442     #:goes-by '("leather chair" "comfy leather chair" "chair")
443     #:sit-phrase "sink into"
444     #:sit-phrase-third-person "sinks into"
445     #:sit-name "the comfy leather chair")
446    ('thing:smoking-room:sofa
447     <furniture> 'room:smoking-parlor
448     #:name "a plush leather sofa"
449     #:desc "  That leather chair looks really comfy!"
450     #:goes-by '("leather sofa" "plush leather sofa" "sofa"
451                 "leather couch" "plush leather couch" "couch")
452     #:sit-phrase "sprawl out on"
453     #:sit-phrase-third-person "sprawls out on into"
454     #:sit-name "the plush leather couch")
455    ('thing:smoking-room:bar-stool
456     <furniture> 'room:smoking-parlor
457     #:name "a bar stool"
458     #:desc "  Conveniently located near the bar!  Not the most comfortable
459 seat in the room, though."
460     #:goes-by '("stool" "bar stool" "seat")
461     #:sit-phrase "hop on"
462     #:sit-phrase-third-person "hops onto"
463     #:sit-name "the bar stool")
464    ('npc:ford-prefect
465     <chatty-npc> 'room:smoking-parlor
466     #:name "Ford Prefect"
467     #:desc "Just some guy, you know?"
468     #:goes-by '("Ford Prefect" "ford prefect"
469                 "frood" "prefect" "ford")
470     #:catchphrases prefect-quotes)
471
472    ;; TODO: Cigar dispenser
473
474    ))
475
476 \f
477
478 ;;; Breakroom
479 ;;; ---------
480
481 (define clerk-commands
482   (list
483    (direct-command "talk" 'cmd-chat)
484    (direct-command "chat" 'cmd-chat)
485    (direct-command "ask" 'cmd-ask-incomplete)
486    (prep-direct-command "ask" 'cmd-ask-about)
487    (direct-command "dismiss" 'cmd-dismiss)))
488 (define clerk-commands*
489   (append clerk-commands thing-commands*))
490
491 (define clerk-actions
492   (build-actions
493    (init (wrap-apply clerk-act-init))
494    (cmd-chat (wrap-apply clerk-cmd-chat))
495    (cmd-ask-incomplete (wrap-apply clerk-cmd-ask-incomplete))
496    (cmd-ask-about (wrap-apply clerk-cmd-ask))
497    (cmd-dismiss (wrap-apply clerk-cmd-dismiss))
498    (update-loop (wrap-apply clerk-act-update-loop))
499    (be-summoned (wrap-apply clerk-act-be-summoned))))
500 (define clerk-actions* (append clerk-actions
501                                thing-actions*))
502
503 (define-class <desk-clerk> (<thing>)
504   ;; The desk clerk has three states:
505   ;;  - on-duty: Arrived, and waiting for instructions (and losing patience
506   ;;    gradually)
507   ;;  - slacking: In the break room, probably smoking a cigarette
508   ;;    or checking text messages
509   (state #:init-value 'slacking)
510   (commands #:init-value clerk-commands*)
511   (patience #:init-value 0)
512   (message-handler
513    #:init-value
514    (simple-dispatcher clerk-actions*)))
515
516 (define-mhandler (clerk-act-init clerk message)
517   ;; call the gameobj main init method
518   (gameobj-act-init clerk message)
519   ;; start our main loop
520   (<- clerk (actor-id clerk) 'update-loop))
521
522 (define clerk-help-topics
523   '(("changing name" .
524      "Changing your name is easy!  We have a clipboard here at the desk
525 where you can make yourself known to other participants in the hotel
526 if you sign it.  Try 'sign form as <your-name>', replacing
527 <your-name>, obviously!")
528     ("common commands" .
529      "Here are some useful commands you might like to try: chat,
530 go, take, drop, say...")
531     ("hotel" .
532      "We hope you enjoy your stay at Hotel Bricabrac.  As you may see,
533 our hotel emphasizes interesting experiences over rest and lodging.
534 The origins of the hotel are... unclear... and it has recently come
535 under new... 'management'.  But at Hotel Bricabrac we believe these
536 aspects make the hotel into a fun and unique experience!  Please,
537 feel free to walk around and explore.")))
538
539
540 (define clerk-knows-about
541   "'changing name', 'common commands', and 'about the hotel'")
542
543 (define clerk-general-helpful-line
544   (string-append
545    "The clerk says, \"If you need help with anything, feel free to ask me about it.
546 For example, 'ask clerk about changing name'. You can ask me about the following:
547 " clerk-knows-about ".\"\n"))
548
549 (define clerk-slacking-complaints
550   '("The pay here is absolutely lousy."
551     "The owner here has no idea what they're doing."
552     "Some times you just gotta step away, you know?"
553     "You as exhausted as I am?"
554     "Yeah well, this is just temporary.  I'm studying to be a high
555 energy particle physicist.  But ya gotta pay the bills, especially
556 with tuition at where it is..."))
557
558 (define-mhandler (clerk-cmd-chat clerk message)
559   (match (slot-ref clerk 'state)
560     ('on-duty
561      (<- clerk (message-from message) 'tell
562          #:text clerk-general-helpful-line))
563     ('slacking
564      (<- clerk (message-from message) 'tell
565          #:text
566          (string-append
567           "The clerk says, \""
568           (random-choice clerk-slacking-complaints)
569           "\"\n")))))
570
571 (define-mhandler (clerk-cmd-ask-incomplete clerk message)
572   (<- clerk (message-from message) 'tell
573       #:text "The clerk says, \"Ask about what?\"\n"))
574
575 (define clerk-doesnt-know-text
576   "The clerk apologizes and says she doesn't know about that topic.\n")
577
578 (define-mhandler (clerk-cmd-ask clerk message indir-obj)
579   (match (slot-ref clerk 'state)
580     ('on-duty
581      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
582        ((_ . info)
583            (<- clerk (message-from message) 'tell
584                #:text
585                (string-append "The clerk clears her throat and says:\n  \""
586                               info
587                               "\"\n")))
588        (#f
589         (<- clerk (message-from message) 'tell
590             #:text clerk-doesnt-know-text))))
591     ('slacking
592      (<- clerk (message-from message) 'tell
593          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
594
595 (define-mhandler (clerk-act-be-summoned clerk message who-summoned)
596   (match (slot-ref clerk 'state)
597     ('on-duty
598      (<- clerk who-summoned 'tell
599          #:text
600          "The clerk tells you as politely as she can that she's already here,
601 so there's no need to ring the bell.\n"))
602     ('slacking
603      (<- clerk (gameobj-loc clerk) 'tell-room
604          #:text
605          "The clerk's ears perk up, she stamps out a cigarette, and she
606 runs out of the room!\n")
607      (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
608      (slot-set! clerk 'patience 8)
609      (slot-set! clerk 'state 'on-duty)
610      (<- clerk (gameobj-loc clerk) 'tell-room
611          #:text
612          (string-append
613           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
614 badge that says \"Desk Clerk\".
615   \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
616 We look forward to your stay.  If you'd like help getting acclimated,
617 feel free to ask me.  For example, 'ask clerk about changing name'.
618 You can ask me about the following:
619 " clerk-knows-about ".\"\n")))))
620
621 (define-mhandler (clerk-cmd-dismiss clerk message)
622   (define player-name
623     (message-ref
624      (<-wait clerk (message-from message) 'get-name)
625      'val))
626   (match (slot-ref clerk 'state)
627     ('on-duty
628      (<- clerk (gameobj-loc clerk) 'tell-room
629          #:text
630          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
631 The clerk leaves the room in a hurry.\n"
632                  player-name)
633          #:exclude (actor-id clerk))
634      (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
635      (slot-set! clerk 'state 'slacking)
636      (<- clerk (gameobj-loc clerk) 'tell-room
637          #:text clerk-return-to-slacking-text
638          #:exclude (actor-id clerk)))
639     ('slacking
640      (<- clerk (message-from message) 'tell
641          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
642
643 (define clerk-slacking-texts
644   '("The clerk takes a long drag on her cigarette.\n"
645     "The clerk scrolls through text messages on her phone.\n"
646     "The clerk coughs a few times.\n"
647     "The clerk checks her watch and justifies a few more minutes outside.\n"
648     "The clerk fumbles around for a lighter.\n"
649     "The clerk sighs deeply and exhaustedly.\n"
650     "The clerk fumbles around for a cigarette.\n"))
651
652 (define clerk-working-impatience-texts
653   '("The clerk struggles to retain an interested and polite smile.\n"
654     "The clerk checks the time on her phone.\n"
655     "The clerk taps her foot.\n"
656     "The clerk takes a deep breath.\n"
657     "The clerk yawns.\n"
658     "The clerk drums her nails on the counter.\n"
659     "The clerk clicks around on the desk computer.\n"))
660
661 (define clerk-slack-excuse-text
662   "The desk clerk excuses herself, claiming she has important things to
663 attend to.\n")
664
665 (define clerk-return-to-slacking-text
666   "The desk clerk enters and slams the door behind her.\n")
667
668 (define-mhandler (clerk-act-update-loop clerk message)
669   (define (tell-room text)
670     (<- clerk (gameobj-loc clerk) 'tell-room
671         #:text text
672         #:exclude (actor-id clerk)))
673   (define (loop-if-not-destructed)
674     (if (not (slot-ref clerk 'destructed))
675         (<- clerk (actor-id clerk) 'update-loop)))
676   (match (slot-ref clerk 'state)
677     ('slacking
678      (tell-room (random-choice clerk-slacking-texts))
679      (8sleep (+ (random 10) 10))
680      (loop-if-not-destructed))
681     ('on-duty
682      (if (> (slot-ref clerk 'patience) 0)
683          ;; Keep working but lose patience gradually
684          (begin
685            (tell-room (random-choice clerk-working-impatience-texts))
686            (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
687                                          (+ (random 2) 1)))
688            (8sleep (+ (random 25) 20))
689            (loop-if-not-destructed))
690          ;; Back to slacking
691          (begin
692            (tell-room clerk-slack-excuse-text)
693            ;; back bto the break room
694            (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'room:break-room)))
695            (tell-room clerk-return-to-slacking-text)
696            ;; annnnnd back to slacking
697            (slot-set! clerk 'state 'slacking)
698            (8sleep (+ (random 30) 15))
699            (loop-if-not-destructed))))))
700
701
702 (define break-room
703   (lol
704    ('room:break-room
705     <room> #f
706     #:name "Employee Break Room"
707     #:desc "  This is less a room and more of an outdoor wire cage.  You get
708 a bit of a view of the brick exterior of the building, and a crisp wind blows,
709 whistling, through the openings of the fenced area.  Partly smoked cigarettes
710 and various other debris cover the floor.
711   Through the wires you can see... well... hm.  It looks oddly like
712 the scenery tapers off nothingness.  But that can't be right, can it?"
713     #:exits
714     (list (make <exit>
715             #:name "north"
716             #:to 'room:smoking-parlor))
717     )
718    ('npc:break-room:desk-clerk
719     <desk-clerk> 'room:break-room
720     #:name "the hotel desk clerk"
721     #:desc "  The hotel clerk is wearing a neatly pressed uniform bearing the
722 hotel insignia.  She looks like she'd much rather be somewhere else."
723     #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))))
724
725
726 \f
727 ;;; Ennpie's Sea Lounge
728 ;;; -------------------
729
730 \f
731 ;;; Computer room
732 ;;; -------------
733
734 \f
735 ;;; Game
736 ;;; ----
737
738 (define game-spec
739   (append lobby grand-hallway smoking-parlor
740           playroom break-room))
741
742 ;; TODO: Provide command line args
743 (define (run-game . args)
744   (run-demo game-spec 'room:lobby #:repl-server #t))
745