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