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