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