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