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