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