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