most of the async museum
[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 container)
23              (8sync)
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 (slot-ref actor 'read-text)))
62
63
64 ;; This one allows you to take from items that are proxied by it
65 (define-actor <proxy-items> (<gameobj>)
66   ((cmd-take-from take-from-proxy))
67   (proxy-items #:init-keyword #:proxy-items))
68
69 (define* (take-from-proxy gameobj message
70                           #:key direct-obj indir-obj preposition
71                           (player (message-from message)))
72   (call/ec
73    (lambda (escape)
74      (for-each
75       (lambda (obj-sym)
76         (define obj-id (dyn-ref gameobj obj-sym))
77         (define goes-by
78           (mbody-val (<-wait obj-id 'goes-by)))
79         (when (ci-member direct-obj goes-by)
80           (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
81           (escape #f)))
82       (slot-ref gameobj 'proxy-items))
83
84      (<- player 'tell
85         #:text `("You don't see any such " ,direct-obj " to take "
86                  ,preposition " " ,(slot-ref gameobj 'name) ".")))))
87
88
89 \f
90 ;;; Lobby
91 ;;; -----
92
93 (define (npc-chat-randomly actor message . _)
94   (define text-to-send
95     (format #f "~a says: \"~a\"\n"
96             (slot-ref actor 'name)
97             (random-choice (slot-ref actor 'catchphrases))))
98   (<- (message-from message) 'tell
99       #:text text-to-send))
100
101 (define hotel-owner-grumps
102   '("Eight sinks!  Eight sinks!  And I couldn't unwind them..."
103     "Don't mind the mess.  I built this place on a dare, you
104 know?"
105     "(*tearfully*) Here, take this parenthesis.  May it serve
106 you well."
107     "I gotta get back to the goblin farm soon..."
108     "Oh, but I was going to make a mansion... a great,
109 beautiful mansion!  Full of ghosts!  Now all I have is this cruddy
110 mo... hotel.  Oh... If only I had more time!"
111     "I told them to paint more of the walls purple.
112 Why didn't they listen?"
113     "Listen to that overhead muzak.  Whoever made that doesn't
114 know how to compose very well!  Have you heard of the bands 'fmt'
115 or 'skribe'?  Now *that's* composition!"))
116
117 (define-class <chatty-npc> (<gameobj>)
118   (catchphrases #:init-value '("Blarga blarga blarga!")
119                 #:init-keyword #:catchphrases)
120   (commands
121    #:allocation #:each-subclass
122    #:init-thunk (build-commands
123                  (("chat" "talk") ((direct-command cmd-chat)))))
124   (actions #:allocation #:each-subclass
125            #:init-thunk
126            (build-actions
127             (cmd-chat npc-chat-randomly))))
128
129 (define-class <sign-in-form> (<gameobj>)
130   (commands
131    #:allocation #:each-subclass
132    #:init-thunk (build-commands
133                  ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
134
135   (actions #:allocation #:each-subclass
136            #:init-thunk (build-actions
137                          (cmd-sign-form sign-cmd-sign-in))))
138
139
140 (define name-sre
141   (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
142
143 (define forbidden-words
144   (append article preposition
145           '("and" "or" "but" "admin")))
146
147 (define (valid-name? name)
148   (and (irregex-match name-sre name)
149        (not (member name forbidden-words))))
150
151 (define* (sign-cmd-sign-in actor message
152                            #:key direct-obj indir-obj preposition)
153   (define old-name
154     (mbody-val (<-wait (message-from message) 'get-name)))
155   (define name indir-obj)
156   (if (valid-name? indir-obj)
157       (begin
158         (<-wait (message-from message) 'set-name! name)
159         (<- (slot-ref actor 'loc) 'tell-room
160             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
161                            old-name old-name name)))
162       (<- (message-from message) 'tell
163           #:text "Sorry, that's not a valid name.
164 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
165 character.\n")))
166
167
168 (define-class <summoning-bell> (<gameobj>)
169   (summons #:init-keyword #:summons)
170
171   (commands
172    #:allocation #:each-subclass
173    #:init-thunk (build-commands
174                  ("ring" ((direct-command cmd-ring)))))
175   (actions #:allocation #:each-subclass
176            #:init-thunk (build-actions
177                          (cmd-ring summoning-bell-cmd-ring))))
178
179 (define* (summoning-bell-cmd-ring bell message . _)
180   ;; Call back to actor who invoked this message handler
181   ;; and find out their name.  We'll call *their* get-name message
182   ;; handler... meanwhile, this procedure suspends until we get
183   ;; their response.
184   (define who-rang
185     (mbody-val (<-wait (message-from message) 'get-name)))
186
187   ;; Now we'll invoke the "tell" message handler on the player
188   ;; who rang us, displaying this text on their screen.
189   ;; This one just uses <- instead of <-wait, since we don't
190   ;; care when it's delivered; we're not following up on it.
191   (<- (message-from message) 'tell
192       #:text "*ring ring!*  You ring the bell!\n")
193   ;; We also want everyone else in the room to "hear" the bell,
194   ;; but they get a different message since they aren't the ones
195   ;; ringing it.  Notice here's where we make use of the invoker's
196   ;; name as extracted and assigned to the who-rang variable.
197   ;; Notice how we send this message to our "location", which
198   ;; forwards it to the rest of the occupants in the room.
199   (<- (gameobj-loc bell) 'tell-room
200       #:text
201       (format #f "*ring ring!*  ~a rings the bell!\n"
202               who-rang)
203       #:exclude (message-from message))
204   ;; Now we perform the primary task of the bell, which is to summon
205   ;; the "clerk" character to the room.  (This is configurable,
206   ;; so we dynamically look up their address.)
207   (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
208       #:who-summoned (message-from message)))
209
210
211 (define prefect-quotes
212   '("I'm a frood who really knows where my towel is!"
213     "On no account allow a Vogon to read poetry at you."
214     "Time is an illusion, lunchtime doubly so!"
215     "How can you have money if none of you produces anything?"
216     "On no account allow Arthur to request tea on this ship."))
217
218 (define-class <cabinet-item> (<gameobj>)
219   (take-me? #:init-value
220             (lambda _
221               (values #f #:why-not
222                       `("Hm, well... the cabinet is locked and the properitor "
223                         "is right over there.")))))
224
225 (define lobby
226   (lol
227    ('lobby
228     <room> #f
229     #:name "Hotel Lobby"
230     #:desc
231     '((p "You're in some sort of hotel lobby.  You see a large sign hanging "
232          "over the desk that says \"Hotel Bricabrac\".  On the desk is a bell "
233          "that says \"'ring bell' for service\".  Terrible music plays from a speaker "
234          "somewhere overhead.  "
235          "The room is lined with various curio cabinets, filled with all sorts "
236          "of kitschy junk.  It looks like whoever decorated this place had great "
237          "ambitions, but actually assembled it all in a hurry and used whatever "
238          "kind of objects they found lying around.")
239       (p "There's a door to the north leading to some kind of hallway."))
240     #:exits
241     (list (make <exit>
242             #:name "north"
243             #:to 'grand-hallway)))
244    ;; NPC: hotel owner
245    ('lobby:hotel-owner
246     <chatty-npc> 'lobby
247     #:name "a frumpy fellow"
248     #:desc
249     '((p "  Whoever this is, they looks totally exhausted.  They're
250 collapsed into the only comfortable looking chair in the room and you
251 don't get the sense that they're likely to move any time soon.
252   You notice they're wearing a sticker badly adhesed to their clothing
253 which says \"Hotel Proprietor\", but they look so disorganized that you
254 think that can't possibly be true... can it?
255   Despite their exhaustion, you sense they'd be happy to chat with you,
256 though the conversation may be a bit one sided."))
257     #:goes-by '("frumpy fellow" "fellow"
258                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
259                 "hotel proprietor" "proprietor")
260     #:catchphrases hotel-owner-grumps)
261    ;; Object: Sign
262    ('lobby:sign
263     <readable> 'lobby
264     #:name "the Hotel Bricabrac sign"
265     #:desc "  It strikes you that there's something funny going on with this sign.
266 Sure enough, if you look at it hard enough, you can tell that someone
267 hastily painted over an existing sign and changed the \"M\" to an \"H\".
268 Classy!"
269     #:read-text "  All it says is \"Hotel Bricabrac\" in smudged, hasty text."
270     #:goes-by '("sign"
271                 "bricabrac sign"
272                 "hotel sign"
273                 "hotel bricabrac sign"
274                 "lobby sign"))
275
276    ('lobby:bell
277     <summoning-bell> 'lobby
278     #:name "a shiny brass bell"
279     #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
280     #:desc "  A shiny brass bell.  Inscribed on its wooden base is the text
281 \"ring me for service\".  You probably could \"ring the bell\" if you 
282 wanted to."
283     #:summons 'break-room:desk-clerk)
284
285    ('lobby:sign-in-form
286     <sign-in-form> 'lobby
287     #:name "sign-in form"
288     #:goes-by '("sign-in form" "form" "signin form")
289     #:desc '("It looks like you could sign this form and set your name like so: "
290              (i "sign form as <my-name-here>")))
291
292    ;; Object: curio cabinets
293    ;; TODO: respond to attempts to open the curio cabinet
294    ('lobby:cabinet
295     <proxy-items> 'lobby
296     #:proxy-items '(lobby:porcelain-doll
297                     lobby:1950s-robots
298                     lobby:tea-set lobby:mustard-pot
299                     lobby:head-of-elvis lobby:circuitboard-of-evlis
300                     lobby:teletype-scroll lobby:orange-cat-phone)
301     #:name "a curio cabinet"
302     #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
303                 "cabinet of curiosities")
304     #:desc (lambda _
305              (format #f "  The curio cabinet is full of all sorts of oddities!
306 Something catches your eye!
307 Ooh, ~a!" (random-choice
308            '("a creepy porcelain doll"
309              "assorted 1950s robots"
310              "an exquisite tea set"
311              "an antique mustard pot"
312              "the pickled head of Elvis"
313              "the pickled circuitboard of EVLIS"
314              "a scroll of teletype paper holding the software Four Freedoms"
315              "a telephone shaped like an orange cartoon cat")))))
316
317    ('lobby:porcelain-doll
318     <cabinet-item> 'lobby
319     #:invisible? #t
320     #:name "a creepy porcelain doll"
321     #:desc "It strikes you that while the doll is technically well crafted,
322 it's also the stuff of nightmares."
323     #:goes-by '("porcelain doll" "doll"))
324    ('lobby:1950s-robots
325     <cabinet-item> 'lobby
326     #:invisible? #t
327     #:name "a set of 1950s robots"
328     #:desc "There's a whole set of these 1950s style robots.
329 They seem to be stamped out of tin, and have various decorations of levers
330 and buttons and springs.  Some of them have wind-up knobs on them."
331     #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
332    ('lobby:tea-set
333     <cabinet-item> 'lobby
334     #:invisible? #t
335     #:name "a tea set"
336     #:desc "A complete tea set.  Some of the cups are chipped.
337 You can imagine yourself joining a tea party using this set, around a
338 nice table with some doilies, drinking some Earl Grey tea, hot.  Mmmm."
339     #:goes-by '("tea set" "tea"))
340    ('lobby:cups
341     <cabinet-item> 'lobby
342     #:invisible? #t
343     #:name "cups from the tea set"
344     #:desc "They're chipped."
345     #:goes-by '("cups"))
346    ('lobby:mustard-pot
347     <cabinet-item> 'lobby
348     #:invisible? #t
349     #:name "a mustard pot"
350     #:desc '((p "It's a mustard pot.  I mean, it's kind of cool, it has a
351 nice design, and it's an antique, but you can't imagine putting something
352 like this in a museum.")
353              (p "Ha... imagine that... a mustard museum."))
354     #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
355    ('lobby:head-of-elvis
356     <cabinet-item> 'lobby
357     #:invisible? #t
358     #:name "the pickled head of Elvis"
359     #:desc '((p "It's a jar full of some briny-looking liquid and...
360 a free floating head.  The head looks an awful lot like Elvis, and
361 definitely not the younger Elvis.  The hair even somehow maintains
362 that signature swoop while suspended in liquid.  But of course it's
363 not Elvis.")
364              (p "Oh, wait, it has a label at the bottom which says:
365 \"This is really the head of Elvis\".  Well... maybe don't believe
366 everything you read."))
367     #:goes-by '("pickled head of elvis" "pickled head of Elvis"
368                 "elvis" "Elvis" "head" "pickled head"))
369    ('lobby:circuitboard-of-evlis
370     <cabinet-item> 'lobby
371     #:invisible? #t
372     #:name "the pickled circuitboard of Evlis"
373     #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
374 This is quite the find, and you bet just about anyone interested in
375 preserving computer history would love to get their hands on this.")
376              (p "Unfortunately, whatever moron did acquire this has
377 no idea what it means to preserve computers, so here it is floating
378 in some kind of briny liquid.  It appears to be heavily corroded.
379 Too bad..."))
380     #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
381                 "pickled circuitboard of EVLIS"
382                 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
383    ('lobby:teletype-scroll
384     <cabinet-item> 'lobby
385     #:invisible? #t
386     #:name "a scroll of teletype"
387     #:desc '((p "This is a scroll of teletype paper.  It's a bit old
388 and yellowed but the type is very legible.  It says:")
389              (br)
390              (i
391               (p (strong "== The four essential freedoms =="))
392               (p "A program is free software if the program's users have
393 the four essential freedoms: ")
394               (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
395                   (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.")
396                   (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
397                   (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.")))
398              (p "You get this feeling that ambiguities in the
399 English language surrounding the word 'free' have lead to a lot of terminology debates."))
400     #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
401                 "teletype paper" "scroll" "four freedoms"
402                 "scroll of teletype paper holding the software Four Freedoms"
403                 "scroll of teletype paper holding the software four freedoms"))
404    ('lobby:orange-cat-phone
405     <cabinet-item> 'lobby
406     #:invisible? #t
407     #:name "a telephone shaped like an orange cartoon cat"
408     #:desc "It's made out of a cheap plastic, and it's very orange.
409 It resembles a striped tabby, and it's eyes hold the emotion of
410 a being both sleepy and smarmy.
411 You suspect that someone, somewhere made a ton of cash on items holding
412 this general shape in the 1990s."
413     #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
414                 "orange cat phone" "orange cat telephone"
415                 "cartoon cat phone" "cartoon cat"
416                 "cat phone" "cat telephone" "phone" "telephone"))))
417
418
419 \f
420 ;;; Grand hallway
421 ;;; -------------
422
423 (define-actor <disc-shield> (<gameobj>)
424   ((cmd-take disc-shield-take)))
425
426 (define* (disc-shield-take gameobj message
427                            #:key direct-obj
428                            (player (message-from message)))
429   (create-gameobj <glowing-disc> (gameobj-gm gameobj)
430                   player)  ;; set loc to player to put in player's inventory
431   (<- player 'tell
432       #:text '((p "As you attempt to pull the shield / disk platter
433 from the statue a shining outline appears around it... and a
434 completely separate, glowing copy of the disc materializes into your
435 hands!")))
436   (<- (gameobj-loc gameobj) 'tell-room
437         #:text `(,(mbody-val (<-wait player 'get-name))
438                  " pulls on the shield of the statue, and a glowing "
439                  "copy of it materializes into their hands!")
440         #:exclude player)
441   (<- (gameobj-loc gameobj) 'tell-room
442       #:text
443       '(p "You hear a voice whisper: "
444           (i "\"Share the software... and you'll be free...\""))))
445
446 ;;; This is the disc that gets put in the player's inventory
447 (define-actor <glowing-disc> (<gameobj>)
448   ((cmd-drop glowing-disc-drop-cmd))
449   (initial-props
450    #:allocation #:each-subclass
451    #:init-thunk (build-props
452                  '((hd-platter? . #t))))
453   (name #:allocation #:each-subclass
454         #:init-value "a glowing disc")
455   (desc #:allocation #:each-subclass
456         #:init-value "A brightly glowing disc.  It's shaped like a hard
457 drive platter, not unlike the one from the statue it came from.  It's
458 labeled \"RL02.5\".")
459   (goes-by #:init-value '("glowing disc" "glowing platter"
460                           "glowing disc platter" "glowing disk platter"
461                           "platter" "disc" "disk" "glowing shield")))
462
463 (define* (glowing-disc-drop-cmd gameobj message
464                    #:key direct-obj
465                    (player (message-from message)))
466   (<- player 'tell
467       #:text "You drop the glowing disc, and it shatters into a million pieces!")
468   (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
469       #:text `(,(mbody-val (<-wait player 'get-name))
470                " drops a glowing disc, and it shatters into a million pieces!")
471       #:exclude player)
472   (gameobj-self-destruct gameobj))
473
474 \f
475 ;;; Grand hallway
476
477 (define lobby-map-text
478   "\
479                         |  :       :  |
480   .----------.----------.  :   &   :  .----------.----------.
481   | computer |          |& :YOU ARE: &|  smoking | *UNDER*  |
482   | room     + playroom +  : HERE  :  +  parlor  | *CONS-   |
483   |    >     |          |& :       : &|          | TRUCTION*|
484   '----------'----------'-++-------++-'-------+--'----------'
485                        |    '-----'    |     |   |
486                        :     LOBBY     :     '---'
487                         '.           .'
488                           '---------'")
489
490 (define grand-hallway
491   (lol
492    ('grand-hallway
493     <room> #f
494     #:name "Grand Hallway"
495     #:desc '((p "  A majestic red carpet runs down the center of the room.
496 Busts of serious looking people line the walls, but there's no
497 clear indication that they have any logical relation to this place.")
498              (p "In the center is a large statue of a woman in a warrior's
499 pose, but something is strange about her weapon and shield.  You wonder what
500 that's all about?")
501              (p "To the south is the lobby.  A door to the east is labeled \"smoking
502 room\", while a door to the west is labeled \"playroom\"."))
503     #:exits
504     (list (make <exit>
505             #:name "south"
506             #:to 'lobby)
507           (make <exit>
508             #:name "west"
509             #:to 'playroom)
510           (make <exit>
511             #:name "east"
512             #:to 'smoking-parlor)))
513    ('grand-hallway:map
514     <readable> 'grand-hallway
515     #:name "the hotel map"
516     #:desc '("This appears to be a map of the hotel. "
517              "Like the hotel itself, it seems to be "
518              "incomplete."
519              "You could read it if you want to.")
520     #:read-text `(pre ,lobby-map-text)
521     #:goes-by '("map" "hotel map"))
522    ('grand-hallway:carpet
523     <gameobj> 'grand-hallway
524     #:name "the Grand Hallway carpet"
525     #:desc "It's very red, except in the places where it's very worn."
526     #:invisible? #t
527     #:goes-by '("red carpet" "carpet"))
528    ('grand-hallway:busts
529     <gameobj> 'grand-hallway
530     #:name "the busts of serious people"
531     #:desc "There are about 6 of them in total.  They look distinguished
532 but there's no indication of who they are."
533     #:invisible? #t
534     #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
535    ('grand-hallway:hackthena-statue
536     <proxy-items> 'grand-hallway
537     #:name "the statue of Hackthena"
538     #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
539 spirit\".  You've heard of Hackthena... not a goddess, but spiritual protector of
540 all good hacks, and legendary hacker herself.")
541              (p "Hackthena holds the form of a human woman.  She wears flowing
542 robes, has a pear of curly bovine-esque horns protruding from the sides of her
543 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
544 But instead of a weapon, she seems to hold some sort of keyboard.  And her
545 shield... well it's round like a shield, but something seems off about it.
546 You'd better take a closer look to be sure."))
547     #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
548     #:proxy-items '(grand-hallway:keyboard
549                     grand-hallway:disc-platter
550                     grand-hallway:hackthena-horns))
551    ('grand-hallway:keyboard
552     <gameobj> 'grand-hallway
553     #:name "a Knight Keyboard"
554     #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
555 Any space cadet can see that with that kind of layout a hack-and-slayer could
556 thrash out some serious key-chords like there's no tomorrow.  You guess
557 Hackthena must be an emacs user."
558     #:invisible? #t
559     #:take-me? (lambda _
560                  (values #f
561                          #:why-not
562                          `("Are you kidding?  Do you know how hard it is to find "
563                               "a Knight Keyboard?  There's no way she's going "
564                               "to give that up.")))
565     #:goes-by '("knight keyboard" "keyboard"))
566    ('grand-hallway:hackthena-horns
567     <gameobj> 'grand-hallway
568     #:name "Hackthena's horns"
569     #:desc "They're not unlike a Gnu's horns."
570     #:invisible? #t
571     #:take-me? (lambda _
572                  (values #f
573                          #:why-not
574                          `("Are you seriously considering desecrating a statue?")))
575     #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
576    ('grand-hallway:disc-platter
577     <disc-shield> 'grand-hallway
578     #:name "Hackthena's shield"
579     #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
580 platter!  It has \"RL02.5\" written on it.  It looks kind of loose."
581     #:invisible? #t
582     #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
583
584 \f
585 ;;; Playroom
586 ;;; --------
587
588 (define playroom
589   (lol
590    ('playroom
591     <room> #f
592     #:name "The Playroom"
593     #:desc '(p ("  There are toys scattered everywhere here.  It's really unclear
594 if this room is intended for children or child-like adults.")
595                ("  There are doors to both the east and the west."))
596     #:exits
597     (list (make <exit>
598             #:name "east"
599             #:to 'grand-hallway)
600           (make <exit>
601             #:name "west"
602             #:to 'computer-room)))
603    ('playroom:cubey
604     <gameobj> 'playroom
605     #:name "Cubey"
606     #:take-me? #t
607     #:desc "  It's a little foam cube with googly eyes on it.  So cute!")
608    ('playroom:cuddles-plushie
609     <gameobj> 'playroom
610     #:name "a Cuddles plushie"
611     #:goes-by '("plushie" "cuddles plushie" "cuddles")
612     #:take-me? #t
613     #:desc "  A warm and fuzzy cuddles plushie!  It's a cuddlefish!")
614
615    ('playroom:toy-chest
616     <container> 'playroom
617     #:name "a toy chest"
618     #:goes-by '("toy chest" "chest")
619     #:desc (lambda (toy-chest whos-looking)
620              (let ((contents (gameobj-occupants toy-chest)))
621                `((p "A brightly painted wooden chest.  The word \"TOYS\" is "
622                     "engraved on it.")
623                  (p "Inside you see:"
624                     ,(if (eq? contents '())
625                          " nothing!  It's empty!"
626                          `(ul ,(map (lambda (occupant)
627                                       `(li ,(mbody-val
628                                              (<-wait occupant 'get-name))))
629                                     (gameobj-occupants toy-chest))))))))
630     #:take-from-me? #t
631     #:put-in-me? #t)
632
633    ;; Things inside the toy chest
634    ('playroom:toy-chest:rubber-duck
635     <gameobj> 'playroom:toy-chest
636     #:name "a rubber duck"
637     #:goes-by '("rubber duck" "duck")
638     #:take-me? #t
639     #:desc "It's a yellow rubber duck with a bright orange beak.")))
640
641
642 \f
643 ;;; Writing room
644 ;;; ------------
645
646 \f
647 ;;; Armory???
648 ;;; ---------
649
650 ;; ... full of NURPH weapons?
651
652 \f
653 ;;; Smoking parlor
654 ;;; --------------
655
656 (define-class <furniture> (<gameobj>)
657   (sit-phrase #:init-keyword #:sit-phrase)
658   (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
659   (sit-name #:init-keyword #:sit-name)
660
661   (commands
662    #:allocation #:each-subclass
663    #:init-thunk (build-commands
664                  ("sit" ((direct-command cmd-sit-furniture)))))
665   (actions #:allocation #:each-subclass
666            #:init-thunk (build-actions
667                          (cmd-sit-furniture furniture-cmd-sit))))
668
669 (define* (furniture-cmd-sit actor message #:key direct-obj)
670   (define player-name
671     (mbody-val (<-wait (message-from message) 'get-name)))
672   (<- (message-from message) 'tell
673       #:text (format #f "You ~a ~a.\n"
674                      (slot-ref actor 'sit-phrase)
675                      (slot-ref actor 'sit-name)))
676   (<- (slot-ref actor 'loc) 'tell-room
677       #:text (format #f "~a ~a on ~a.\n"
678                      player-name
679                      (slot-ref actor 'sit-phrase-third-person)
680                      (slot-ref actor 'sit-name))
681       #:exclude (message-from message)))
682
683
684 (define smoking-parlor
685   (lol
686    ('smoking-parlor
687     <room> #f
688     #:name "Smoking Parlor"
689     #:desc
690     '((p "This room looks quite posh.  There are huge comfy seats you can sit in
691 if you like. Strangely, you see a large sign saying \"No Smoking\".  The owners must
692 have installed this place and then changed their mind later.")
693       (p "There's a door to the west leading back to the grand hallway, and
694 a nondescript steel door to the south, leading apparently outside."))
695     #:exits
696     (list (make <exit>
697             #:name "west"
698             #:to 'grand-hallway)
699           (make <exit>
700             #:name "south"
701             #:to 'break-room)))
702    ('smoking-parlor:chair
703     <furniture> 'smoking-parlor
704     #:name "a comfy leather chair"
705     #:desc "  That leather chair looks really comfy!"
706     #:goes-by '("leather chair" "comfy leather chair" "chair")
707     #:sit-phrase "sink into"
708     #:sit-phrase-third-person "sinks into"
709     #:sit-name "the comfy leather chair")
710    ('smoking-parlor:sofa
711     <furniture> 'smoking-parlor
712     #:name "a plush leather sofa"
713     #:desc "  That leather chair looks really comfy!"
714     #:goes-by '("leather sofa" "plush leather sofa" "sofa"
715                 "leather couch" "plush leather couch" "couch")
716     #:sit-phrase "sprawl out on"
717     #:sit-phrase-third-person "sprawls out on into"
718     #:sit-name "the plush leather couch")
719    ('smoking-parlor:bar-stool
720     <furniture> 'smoking-parlor
721     #:name "a bar stool"
722     #:desc "  Conveniently located near the bar!  Not the most comfortable
723 seat in the room, though."
724     #:goes-by '("stool" "bar stool" "seat")
725     #:sit-phrase "hop on"
726     #:sit-phrase-third-person "hops onto"
727     #:sit-name "the bar stool")
728    ('ford-prefect
729     <chatty-npc> 'smoking-parlor
730     #:name "Ford Prefect"
731     #:desc "Just some guy, you know?"
732     #:goes-by '("Ford Prefect" "ford prefect"
733                 "frood" "prefect" "ford")
734     #:catchphrases prefect-quotes)
735
736    ('smoking-parlor:no-smoking-sign
737     <readable> 'smoking-parlor
738     #:invisible? #t
739     #:name "No Smoking Sign"
740     #:desc "This sign says \"No Smoking\" in big, red letters.
741 It has some bits of bubble gum stuck to it... yuck."
742     #:goes-by '("no smoking sign" "sign")
743     #:read-text "It says \"No Smoking\", just like you'd expect from
744 a No Smoking sign.")
745    ;; TODO: Cigar dispenser
746    ))
747
748 \f
749
750 ;;; Breakroom
751 ;;; ---------
752
753 (define-class <desk-clerk> (<gameobj>)
754   ;; The desk clerk has three states:
755   ;;  - on-duty: Arrived, and waiting for instructions (and losing patience
756   ;;    gradually)
757   ;;  - slacking: In the break room, probably smoking a cigarette
758   ;;    or checking text messages
759   (state #:init-value 'slacking)
760   (commands #:allocation #:each-subclass
761             #:init-thunk
762             (build-commands
763              (("talk" "chat") ((direct-command cmd-chat)))
764              ("ask" ((direct-command cmd-ask-incomplete)
765                      (prep-direct-command cmd-ask-about)))
766              ("dismiss" ((direct-command cmd-dismiss)))))
767   (patience #:init-value 0)
768   (actions #:allocation #:each-subclass
769            #:init-thunk (build-actions
770                          (init clerk-act-init)
771                          (cmd-chat clerk-cmd-chat)
772                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
773                          (cmd-ask-about clerk-cmd-ask)
774                          (cmd-dismiss clerk-cmd-dismiss)
775                          (update-loop clerk-act-update-loop)
776                          (be-summoned clerk-act-be-summoned))))
777
778 (define (clerk-act-init clerk message . _)
779   ;; call the gameobj main init method
780   (gameobj-act-init clerk message)
781   ;; start our main loop
782   (<- (actor-id clerk) 'update-loop))
783
784 (define changing-name-text "Changing your name is easy!
785 We have a clipboard here at the desk
786 where you can make yourself known to other participants in the hotel
787 if you sign it.  Try 'sign form as <your-name>', replacing
788 <your-name>, obviously!")
789
790 (define phd-text
791   "Ah... when I'm not here, I've got a PHD to finish.")
792
793 (define clerk-help-topics
794   `(("changing name" . ,changing-name-text)
795     ("sign-in form" . ,changing-name-text)
796     ("form" . ,changing-name-text)
797     ("common commands" .
798      "Here are some useful commands you might like to try: chat,
799 go, take, drop, say...")
800     ("hotel" .
801      "We hope you enjoy your stay at Hotel Bricabrac.  As you may see,
802 our hotel emphasizes interesting experiences over rest and lodging.
803 The origins of the hotel are... unclear... and it has recently come
804 under new... 'management'.  But at Hotel Bricabrac we believe these
805 aspects make the hotel into a fun and unique experience!  Please,
806 feel free to walk around and explore.")
807     ("physics paper" . ,phd-text)
808     ("paper" . ,phd-text)
809     ("proprietor" . "Oh, he's that frumpy looking fellow sitting over there.")))
810
811
812 (define clerk-knows-about
813   "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
814
815 (define clerk-general-helpful-line
816   (string-append
817    "The clerk says, \"If you need help with anything, feel free to ask me about it.
818 For example, 'ask clerk about changing name'. You can ask me about the following:
819 " clerk-knows-about ".\"\n"))
820
821 (define clerk-slacking-complaints
822   '("The pay here is absolutely lousy."
823     "The owner here has no idea what they're doing."
824     "Some times you just gotta step away, you know?"
825     "You as exhausted as I am?"
826     "Yeah well, this is just temporary.  I'm studying to be a high
827 energy particle physicist.  But ya gotta pay the bills, especially
828 with tuition at where it is..."))
829
830 (define* (clerk-cmd-chat clerk message #:key direct-obj)
831   (match (slot-ref clerk 'state)
832     ('on-duty
833      (<- (message-from message) 'tell
834          #:text clerk-general-helpful-line))
835     ('slacking
836      (<- (message-from message) 'tell
837          #:text
838          (string-append
839           "The clerk says, \""
840           (random-choice clerk-slacking-complaints)
841           "\"\n")))))
842
843 (define (clerk-cmd-ask-incomplete clerk message . _)
844   (<- (message-from message) 'tell
845       #:text "The clerk says, \"Ask about what?\"\n"))
846
847 (define clerk-doesnt-know-text
848   "The clerk apologizes and says she doesn't know about that topic.\n")
849
850 (define* (clerk-cmd-ask clerk message #:key indir-obj
851                         #:allow-other-keys)
852   (match (slot-ref clerk 'state)
853     ('on-duty
854      (match (assoc indir-obj clerk-help-topics)
855        ((_ . info)
856            (<- (message-from message) 'tell
857                #:text
858                (string-append "The clerk clears her throat and says:\n  \""
859                               info
860                               "\"\n")))
861        (#f
862         (<- (message-from message) 'tell
863             #:text clerk-doesnt-know-text))))
864     ('slacking
865      (<- (message-from message) 'tell
866          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
867
868 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
869   (match (slot-ref clerk 'state)
870     ('on-duty
871      (<- who-summoned 'tell
872          #:text
873          "The clerk tells you as politely as she can that she's already here,
874 so there's no need to ring the bell.\n"))
875     ('slacking
876      (<- (gameobj-loc clerk) 'tell-room
877          #:text
878          "The clerk's ears perk up, she stamps out a cigarette, and she
879 runs out of the room!\n")
880      (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
881      (slot-set! clerk 'patience 8)
882      (slot-set! clerk 'state 'on-duty)
883      (<- (gameobj-loc clerk) 'tell-room
884          #:text
885          (string-append
886           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
887 badge that says \"Desk Clerk\".
888   \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
889 We look forward to your stay.  If you'd like help getting acclimated,
890 feel free to ask me.  For example, 'ask clerk about changing name'.
891 You can ask me about the following:
892 " clerk-knows-about ".\"\n")))))
893
894 (define* (clerk-cmd-dismiss clerk message . _)
895   (define player-name
896     (mbody-val (<-wait (message-from message) 'get-name)))
897   (match (slot-ref clerk 'state)
898     ('on-duty
899      (<- (gameobj-loc clerk) 'tell-room
900          #:text
901          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
902 The clerk leaves the room in a hurry.\n"
903                  player-name)
904          #:exclude (actor-id clerk))
905      (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
906      (slot-set! clerk 'state 'slacking)
907      (<- (gameobj-loc clerk) 'tell-room
908          #:text clerk-return-to-slacking-text
909          #:exclude (actor-id clerk)))
910     ('slacking
911      (<- (message-from message) 'tell
912          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
913
914 (define clerk-slacking-texts
915   '("The clerk takes a long drag on her cigarette.\n"
916     "The clerk scrolls through text messages on her phone.\n"
917     "The clerk coughs a few times.\n"
918     "The clerk checks her watch and justifies a few more minutes outside.\n"
919     "The clerk fumbles around for a lighter.\n"
920     "The clerk sighs deeply and exhaustedly.\n"
921     "The clerk fumbles around for a cigarette.\n"))
922
923 (define clerk-working-impatience-texts
924   '("The clerk hums something, but you're not sure what it is."
925     "The clerk attempts to change the overhead music, but the dial seems broken."
926     "The clerk clicks around on the desk computer."
927     "The clerk scribbles an equation on a memo pad, then crosses it out."
928     "The clerk mutters something about the proprietor having no idea how to run a hotel."
929     "The clerk thumbs through a printout of some physics paper."))
930
931 (define clerk-slack-excuse-text
932   "The desk clerk excuses herself, but says you are welcome to ring the bell
933 if you need further help.")
934
935 (define clerk-return-to-slacking-text
936   "The desk clerk enters and slams the door behind her.\n")
937
938
939 (define (clerk-act-update-loop clerk message)
940   (define (tell-room text)
941     (<- (gameobj-loc clerk) 'tell-room
942         #:text text
943         #:exclude (actor-id clerk)))
944   (define (loop-if-not-destructed)
945     (if (not (slot-ref clerk 'destructed))
946         ;; This iterates by "recursing" on itself by calling itself
947         ;; (as the message handler) again.  It used to be that we had to do
948         ;; this, because there was a bug where a loop which yielded like this
949         ;; would keep growing the stack due to some parameter goofiness.
950         ;; That's no longer true, but there's an added advantage to this
951         ;; route: it's much more live hackable.  If we change the definition
952         ;; of this method, the character will act differently on the next
953         ;; "tick" of the loop.
954         (<- (actor-id clerk) 'update-loop)))
955   (match (slot-ref clerk 'state)
956     ('slacking
957      (tell-room (random-choice clerk-slacking-texts))
958      (8sleep (+ (random 20) 15))
959      (loop-if-not-destructed))
960     ('on-duty
961      (if (> (slot-ref clerk 'patience) 0)
962          ;; Keep working but lose patience gradually
963          (begin
964            (tell-room (random-choice clerk-working-impatience-texts))
965            (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
966                                          (+ (random 2) 1)))
967            (8sleep (+ (random 60) 40))
968            (loop-if-not-destructed))
969          ;; Back to slacking
970          (begin
971            (tell-room clerk-slack-excuse-text)
972            ;; back bto the break room
973            (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
974            (tell-room clerk-return-to-slacking-text)
975            ;; annnnnd back to slacking
976            (slot-set! clerk 'state 'slacking)
977            (8sleep (+ (random 30) 15))
978            (loop-if-not-destructed))))))
979
980
981 (define break-room
982   (lol
983    ('break-room
984     <room> #f
985     #:name "Employee Break Room"
986     #:desc "  This is less a room and more of an outdoor wire cage.  You get
987 a bit of a view of the brick exterior of the building, and a crisp wind blows,
988 whistling, through the openings of the fenced area.  Partly smoked cigarettes
989 and various other debris cover the floor.
990   Through the wires you can see... well... hm.  It looks oddly like
991 the scenery tapers off nothingness.  But that can't be right, can it?"
992     #:exits
993     (list (make <exit>
994             #:name "north"
995             #:to 'smoking-parlor)))
996    ('break-room:desk-clerk
997     <desk-clerk> 'break-room
998     #:name "the hotel desk clerk"
999     #:desc "  The hotel clerk is wearing a neatly pressed uniform bearing the
1000 hotel insignia.  She appears to be rather exhausted."
1001     #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
1002    ('break-room:void
1003     <gameobj> 'break-room
1004     #:invisible? #t
1005     #:name "The Void"
1006     #:desc "As you stare into the void, the void stares back into you."
1007     #:goes-by '("void" "abyss" "nothingness" "scenery"))
1008    ('break-room:fence
1009     <gameobj> 'break-room
1010     #:invisible? #t
1011     #:name "break room cage"
1012     #:desc "It's a mostly-cubical wire mesh surrounding the break area.
1013 You can see through the gaps, but they're too small to put more than a
1014 couple of fingers through.  There appears to be some wear and tear to
1015 the paint, but the wires themselves seem to be unusually sturdy."
1016     #:goes-by '("fence" "cage" "wire cage"))))
1017
1018
1019 \f
1020 ;;; Ennpie's Sea Lounge
1021 ;;; -------------------
1022
1023 \f
1024 ;;; Computer room
1025 ;;; -------------
1026
1027 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
1028 ;; RL02 disk drives.  However we increment both by .5 (a true heresy)
1029 ;; to distinguish both from the real thing.
1030
1031 (define-actor <hard-drive> (<gameobj>)
1032   ((cmd-put-in hard-drive-insert)
1033    (cmd-push-button hard-drive-push-button)
1034    (get-state hard-drive-act-get-state))
1035   (commands #:allocation #:each-subclass
1036             #:init-thunk (build-commands
1037                           ("insert" ((prep-indir-command cmd-put-in
1038                                                          '("in" "inside" "into"))))
1039                           (("press" "push") ((prep-indir-command cmd-push-button)))))
1040   ;; the state moves from: empty -> with-disc -> loading -> ready
1041   (state #:init-value 'empty
1042          #:accessor .state))
1043
1044 (define (hard-drive-act-get-state hard-drive message)
1045   (<-reply message (.state hard-drive)))
1046
1047 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1048   `((p "The hard drive is labeled \"RL02.5\".  It's a little under a meter tall.")
1049     (p "There is a slot where a disk platter could be inserted, "
1050        ,(if (eq? (.state hard-drive) 'empty)
1051             "which is currently empty"
1052             "which contains a glowing platter")
1053        ". There is a LOAD button "
1054        ,(if (member (.state hard-drive) '(empty with-disc))
1055             "which is glowing"
1056             "which is pressed in and unlit")
1057        ". There is a READY indicator "
1058        ,(if (eq? (.state hard-drive) 'ready)
1059             "which is glowing."
1060             "which is unlit.")
1061        ,(if (member (.state hard-drive) '(loading ready))
1062             "  The machine emits a gentle whirring noise."
1063             ""))))
1064
1065 (define* (hard-drive-push-button gameobj message
1066                                  #:key direct-obj indir-obj preposition
1067                                  (player (message-from message)))
1068   (define (tell-room text)
1069     (<-wait (gameobj-loc gameobj) 'tell-room
1070             #:text text))
1071   (define (tell-room-excluding-player text)
1072     (<-wait (gameobj-loc gameobj) 'tell-room
1073             #:text text
1074             #:exclude player))
1075   (cond
1076    ((ci-member direct-obj '("button" "load button" "load"))
1077     (tell-room-excluding-player
1078      `(,(mbody-val (<-wait player 'get-name))
1079        " presses the button on the hard disk."))
1080     (<- player 'tell
1081         #:text "You press the button on the hard disk.")
1082
1083     (case (.state gameobj)
1084       ((empty)
1085        ;; I have no idea what this drive did when you didn't have a platter
1086        ;; in it and pressed load, but I know there was a FAULT button.
1087        (tell-room "You hear some movement inside the hard drive...")
1088        (8sleep 1.5)
1089        (tell-room
1090         '("... but then the FAULT button blinks a couple times. "
1091           "What could be missing?")))
1092       ((with-disc)
1093        (set! (.state gameobj) 'loading)
1094        (tell-room "The hard disk begins to spin up!")
1095        (8sleep 2)
1096        (set! (.state gameobj) 'ready)
1097        (tell-room "The READY light turns on!"))
1098       ((loading ready)
1099        (<- player 'tell
1100            #:text '("Pressing the button does nothing right now, "
1101                     "but it does feel satisfying.")))))
1102    (else
1103     (<- player 'tell
1104         #:text '("How could you think of pressing anything else "
1105                  "but that tantalizing button right in front of you?")))))
1106
1107 (define* (hard-drive-insert gameobj message
1108                             #:key direct-obj indir-obj preposition
1109                             (player (message-from message)))
1110   (define our-name (slot-ref gameobj 'name))
1111   (define this-thing
1112     (call/ec
1113      (lambda (return)
1114        (for-each (lambda (occupant)
1115                    (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1116                    (when (ci-member direct-obj goes-by)
1117                      (return occupant)))
1118                  (mbody-val (<-wait player 'get-occupants)))
1119        ;; nothing found
1120        #f)))
1121   (cond
1122    ((not this-thing)
1123     (<- player 'tell
1124         #:text `("You don't seem to have any such " ,direct-obj " to put "
1125                  ,preposition " " ,our-name ".")))
1126    ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1127     (<- player 'tell
1128         #:text `("It wouldn't make sense to put "
1129                  ,(mbody-val (<-wait this-thing 'get-name))
1130                  " " ,preposition " " ,our-name ".")))
1131    ((not (eq? (.state gameobj) 'empty))
1132     (<- player 'tell
1133         #:text "The disk drive already has a platter in it."))
1134    (else
1135     (set! (.state gameobj) 'with-disc)
1136     (<- player 'tell
1137         #:text '((p "You insert the glowing disc into the drive.")
1138                  (p "The LOAD button begins to glow."))))))
1139
1140 ;; The computar
1141 (define-actor <computer> (<gameobj>)
1142   ((cmd-run-program computer-run-program)
1143    (cmd-run-what (lambda (gameobj message . _)
1144                    (<- (message-from message) 'tell
1145                        #:text '("The computer is already running, and a program appears "
1146                                 "ready to run."
1147                                 "you mean to \"run the program on the computer\""))))
1148    (cmd-help-run-not-press
1149     (lambda (gameobj message . _)
1150       (<- (message-from message) 'tell
1151           #:text '("You don't need to press / push / flip anything. "
1152                    "You could " (i "run program on computer")
1153                    " already if you wanted to.")))))
1154   (commands #:allocation #:each-subclass
1155             #:init-thunk (build-commands
1156                           ("run" ((prep-indir-command cmd-run-program
1157                                                       '("on"))
1158                                   (direct-command cmd-run-what)))
1159                           (("press" "push" "flip")
1160                            ((prep-indir-command cmd-help-run-not-press))))))
1161
1162 (define* (computer-run-program gameobj message
1163                                #:key direct-obj indir-obj preposition
1164                                (player (message-from message)))
1165   (define (hd-state)
1166     (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
1167   (define (tell-room text)
1168     (<-wait (gameobj-loc gameobj) 'tell-room
1169         #:text text))
1170   (define (tell-room-excluding-player text)
1171     (<-wait (gameobj-loc gameobj) 'tell-room
1172             #:text text
1173             #:exclude player))
1174   (define (tell-player text)
1175     (<-wait player 'tell
1176             #:text text))
1177   (cond
1178    ((ci-member direct-obj '("program"))
1179     (tell-room-excluding-player
1180      `(,(mbody-val (<-wait player 'get-name))
1181        " runs the program loaded on the computer..."))
1182     (tell-player "You run the program on the computer...")
1183
1184     (cond
1185      ((not (eq? (hd-state) 'ready))
1186       (tell-room '("... but it errors out. "
1187                    "It seems to be complaining about a " (b "DISK ERROR!")
1188                    ". It looks like it is missing some essential software.")))
1189      (else
1190       (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
1191
1192
1193 ;; floor panel
1194 (define-actor <floor-panel> (<gameobj>)
1195   ;; TODO: Add "open" verb, since obviously people will try that
1196   ((open? (lambda (panel message)
1197             (<-reply message (slot-ref panel 'open))))
1198    (open-up floor-panel-open-up))
1199   (open #:init-value #f))
1200
1201 (define (floor-panel-open-up panel message)
1202   (if (slot-ref panel 'open)
1203       (<- (gameobj-loc panel) 'tell-room
1204           #:text '("You hear some gears grind around the hinges of the "
1205                    "floor panel, but it appears to already be open."))
1206       (begin
1207         (slot-set! panel 'open #t)
1208         (<- (gameobj-loc panel) 'tell-room
1209             #:text '("You hear some gears grind, as the metal panel on "
1210                      "the ground opens and reveals a stairwell going down!")))))
1211
1212 (define* (floor-panel-desc panel #:optional whos-looking)
1213   `("It's a large metal panel on the floor in the middle of the room. "
1214     ,(if (slot-ref panel 'open)
1215          '("It's currently wide open, revealing a spiraling staircase "
1216            "which descends into darkness.")
1217          '("It's currently closed shut, but there are clearly hinges, and "
1218            "it seems like there is a mechanism which probably opens it via "
1219            "some automation.  What could be down there?"))))
1220
1221 (define computer-room
1222   (lol
1223    ('computer-room
1224     <room> #f
1225     #:name "Computer Room"
1226     #:desc (lambda (gameobj whos-looking)
1227              (define panel-open
1228                (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
1229                                   'open?)))
1230              `((p "A sizable computer cabinet covers a good portion of the left
1231  wall.  It emits a pleasant hum which covers the room like a warm blanket.
1232  Connected to a computer is a large hard drive.")
1233                (p "On the floor is a large steel panel.  "
1234                   ,(if panel-open
1235                        '("It is wide open, exposing a spiral staircase "
1236                          "which descends into darkness.")
1237                        '("It is closed, but it has hinges which "
1238                          "suggest it could be opened.")))))
1239     #:exits
1240     (list (make <exit>
1241             #:name "east"
1242             #:to 'playroom)
1243           (make <exit>
1244             #:name "down"
1245             #:to 'underground-lab
1246             #:traverse-check
1247             (lambda (exit room whos-exiting)
1248               (define panel-open
1249                 (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
1250                                    'open?)))
1251               (if panel-open
1252                   (values #t "You descend the spiral staircase.")
1253                   (values #f '("You'd love to go down, but the only way "
1254                                "through is through that metal panel, "
1255                                "which seems closed.")))))))
1256    ('computer-room:hard-drive
1257     <hard-drive> 'computer-room
1258     #:name "the hard drive"
1259     #:desc (wrap-apply hard-drive-desc)
1260     #:goes-by '("hard drive" "drive" "hard disk"))
1261    ('computer-room:computer
1262     <computer> 'computer-room
1263     #:name "the computer"
1264     #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
1265              (p "The computer is itself turned on, and it looks like it is "
1266                 "all set up for you to run a program on it."))
1267     #:goes-by '("computer"))
1268    ('computer-room:floor-panel
1269     <floor-panel> 'computer-room
1270     #:name "a floor panel"
1271     #:desc (wrap-apply floor-panel-desc)
1272     #:invisible? #t
1273     #:goes-by '("floor panel" "panel"))))
1274
1275 \f
1276 ;;; * UNDERGROUND SECTION OF THE GAME! *
1277
1278 \f
1279 ;;; The lab
1280
1281 (define underground-map-text
1282   "\
1283                             _______           |
1284                          .-' @     '-.         \\   ?????
1285                        .'             '.       .\\             
1286                        |  [8sync Hive] |======'  '-_____
1287                        ',      M      ,'
1288                         '.         @ .'                                  
1289                           \\  @     /                    
1290                            '-__+__-'                
1291                             '.  @ .'
1292      .--------------.         \\ /
1293      | [Guile Async |  .-------+------.
1294      |    Museum]   |  |     [Lab] #!#|  .-------------.
1295      |             @|  |  MM          |  |[Federation  |
1296      | &      ^     +##+@ ||     <    +##|     Station]|
1297      |              |  |           @  |  |             |
1298      |         &  # |  |*You-Are-Here*|  '-------------'
1299      | #   ^        | #+-------+------'
1300      '-------+------' #        #
1301              #        #        #
1302              #        #   .-----------.
1303            .-+----.   #   |#       F  |
1304            |@?+%? +####   | ^   f##   |
1305            '------'       |  f    f  %|
1306                           |F [Mudsync |
1307                           | $  Swamp] |
1308                           '-----------'")
1309
1310 (define 8sync-design-goals
1311   '(ul (li (b "Actor based, shared nothing environment: ")
1312            "Shared resources are hard to control and result in fighting
1313 deadlocks, etc.  Escape the drudgery: only one actor controls a resource,
1314 and they only receive one message at a time (though they can \"juggle\"
1315 messages).")
1316        (li (b "Live hackable: ")
1317            "It's hard to plan out a concurrent system; the right structure
1318 is often found by evolving the system while it runs.  Make it easy to
1319 build, shape, and change a running system, as well as observe and correct
1320 errors.")
1321        (li (b "No callback hell: ")
1322            "Just because you're calling out to some other asynchronous 
1323 code doesn't mean you should need to chop up your program into a bunch of bits.
1324 Clever use of delimited continuations makes it easy.")))
1325
1326 (define underground-lab
1327   (lol
1328    ('underground-lab
1329     <room> #f
1330     #:name "Underground laboratory"
1331     #:desc '((p "This appears to be some sort of underground laboratory."
1332                 "There is a spiral staircase here leading upwards, where "
1333                 "it seems much brighter.")
1334              (p "There are a number of doors leading in different directions:
1335 north, south, east, and west, as well as a revolving door to the southwest.
1336 It looks like it could be easy to get lost, but luckily there
1337 is a map detailing the layout of the underground structure."))
1338     #:exits
1339     (list (make <exit>
1340             #:name "up"
1341             #:to 'computer-room
1342             #:traverse-check
1343             (lambda (exit room whos-exiting)
1344               (values #t "You climb the spiral staircase.")))
1345           (make <exit>
1346             #:name "west"
1347             #:to 'async-museum
1348             #:traverse-check
1349             (lambda (exit room whos-exiting)
1350               (values #t '("You head west through a fancy-looking entrance. "
1351                            "A security guard steps aside for you to pass through, "
1352                            "into the room, then stands in front of the door."))))))
1353
1354    ;; map
1355    ('underground-lab:map
1356     <readable> 'underground-lab
1357     #:name "the underground map"
1358     #:desc '("This appears to be a map of the surrounding area. "
1359              "You could read it if you want to.")
1360     #:read-text `(pre ,underground-map-text)
1361     #:goes-by '("map" "underground map" "lab map"))
1362
1363    ('underground-lab:8sync-sign
1364     <readable> 'underground-lab
1365     #:name "a sign labeled \"8sync design goals\""
1366     #:goes-by '("sign" "8sync design goals sign" "8sync sign")
1367     #:read-text 8sync-design-goals
1368     #:desc `((p "The sign says:")
1369              ,8sync-design-goals))))
1370
1371 \f
1372 ;;; guile async museum
1373
1374 (define async-museum
1375   (list
1376    (list
1377     'async-museum
1378     <room> #f
1379     #:name "Guile Asynchronous Museum"
1380     #:desc '((p "You're in the Guile Asynchronous Museum.  There is a list of exhibits
1381 on the wall near the entrance.  Scattered around the room are the exhibits
1382 themselves, but it's difficult to pick them out.  Maybe you should read the list
1383 to orient yourself.")
1384              (p "There is a door to the east, watched by a security guard,
1385 as well as an exit leading to the south."))
1386     #:exits (list
1387              (make <exit>
1388                #:name "south"
1389                #:to 'gift-shop)
1390              (make <exit>
1391                #:name "east"
1392                #:to 'underground-lab
1393                #:traverse-check
1394                (lambda (exit room whos-exiting)
1395                  (values #f '("The security guard stops you and tells you "
1396                               "that the only exit is through the gift shop."))))))
1397    (list
1398     'async-museum:security-guard
1399     <chatty-npc> 'async-museum
1400     #:name "a security guard"
1401     #:desc
1402     '(p "The security guard is blocking the eastern entrance, where "
1403         "you came in from.")
1404     #:goes-by '("security guard" "guard" "security")
1405     #:catchphrases '("It's hard standing here all day."
1406                      "I just want to go home."
1407                      "The exhibits are nice, but I've seen them all before."))
1408    (let ((placard
1409           `((p "Welcome to our humble museum!  The exhibits are listed below. "
1410                (br)
1411                "To look at one, simply type: " (i "look at <exhibit-name>"))
1412             (p "Available exhibits:")
1413             (ul ,@(map (lambda (exhibit)
1414                          `(li ,exhibit))
1415                        '("2016 Progress"
1416                          "8sync and Fibers"
1417                          "Suspendable Ports"
1418                          "The Actor Model"))))))
1419      (list
1420       'async-museum:list-of-exhibits
1421       <readable> 'async-museum
1422       #:name "list of exhibits"
1423       #:desc
1424       `((p "It's a list of exibits in the room.  The placard says:")
1425         ,@placard)
1426       #:goes-by '("list of exhibits" "exhibit list" "list" "exhibits")
1427       #:read-text placard))
1428    (let ((desc '((p "It's a three-piece exhibit, with three little dioramas and some text "
1429                     "explaining what they represent.  They are:")
1430                  (ul (li (b "Late 2015/Early 2016 talk: ")
1431                          "This one explains the run-up conversation from late 2015 "
1432                          "and early 2016 about the need for an "
1433                          "\"asynchronous event loop for Guile\".  The diorama "
1434                          "is a model of the Veggie Galaxy restaurant where after "
1435                          "the FSF 30th anniversary party; Mark Weaver, Christopher "
1436                          "Allan Webber, David Thompson, and Andrew Engelbrecht chat "
1437                          "about the need for Guile to have an answer to asynchronous "
1438                          "programming.  A mailing list post " ; TODO: link it?
1439                          "summarizing the discussion is released along with various "
1440                          "conversations around what is needed, as well as further "
1441                          "discussion at FOSDEM 2016.")
1442                      (li (b "Early implementations: ")
1443                          "This one shows Chris Webber's 8sync and Chris Vine's "
1444                          "guile-a-sync, both appearing in late 2015 and evolving "
1445                          "into their basic designs in early 2016.  It's less a diorama "
1446                          "than a printout of some mailing list posts.  Come on, the "
1447                          "curators could have done better with this one.")
1448                      (li (b "Suspendable ports and Fibers: ")
1449                          "The diorama shows Andy Wingo furiously hacking at his keyboard. "
1450                          "The description talks about Wingo's mailing list thread "
1451                          "about possibly breaking Guile compatibility for a \"ports refactor\". "
1452                          "Wingo releases Fibers, another asynchronous library, making use of "
1453                          "the new interface, and 8sync and guile-a-sync "
1454                          "quickly move to support suspendable ports as well. "
1455                          "The description also mentions that there is an exhibit entirely "
1456                          "devoted to suspendable ports."))
1457                  (p "Attached at the bottom is a post it note mentioning "
1458                     "https integration landing in Guile 2.2."))))
1459      (list
1460       'async-museum:2016-progress-exhibit
1461       <readable> 'async-museum
1462       #:name "2016 Progress Exhibit"
1463       #:goes-by '("2016 progress exhibit" "2016 progress" "2016 exhibit")
1464       #:desc desc
1465       #:read-text desc))
1466    (let ((desc '((p "This exhibit is a series of charts explaining the similarities "
1467                     "and differences between 8sync and Fibers, two asynchronous programming "
1468                     "libraries for GNU Guile.  It's way too wordy, but you get the general gist.")
1469                  (p (b "Similarities:")
1470                     (ul (li "Both use Guile's suspendable-ports facility")
1471                         (li "Both use message passing")))
1472                  (p (b "Differences:")
1473                     (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1474                             "but 8sync actors only read from one \"inbox\" each.")
1475                         (li "Different theoretical basis:"
1476                             (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1477                                     "a form of Process Calculi")
1478                                 (li "8sync: based on the Actor Model")
1479                                 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1480                  (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1481                     "whereas 8sync is designed by Chris Webber, who built this crappy "
1482                     "hotel simulator."))))
1483      (list
1484       'async-museum:8sync-and-fibers-exhibit
1485       <readable> 'async-museum
1486       #:name "8sync and Fibers Exhibit"
1487       #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1488       #:desc desc
1489       #:read-text desc))
1490    (let ((desc '((p "This exhibit is a series of charts explaining the similarities "
1491                     "and differences between 8sync and Fibers, two asynchronous programming "
1492                     "libraries for GNU Guile.  It's way too wordy, but you get the general gist.")
1493                  (p (b "Similarities:")
1494                     (ul (li "Both use Guile's suspendable-ports facility")
1495                         (li "Both use message passing")))
1496                  (p (b "Differences:")
1497                     (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1498                             "but 8sync actors only read from one \"inbox\" each.")
1499                         (li "Different theoretical basis:"
1500                             (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1501                                     "a form of Process Calculi")
1502                                 (li "8sync: based on the Actor Model")
1503                                 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1504                  (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1505                     "whereas 8sync is designed by Chris Webber, who built this crappy "
1506                     "hotel simulator."))))
1507      (list
1508       'async-museum:8sync-and-fibers-exhibit
1509       <readable> 'async-museum
1510       #:name "8sync and Fibers Exhibit"
1511       #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1512       #:desc desc
1513       #:read-text desc))
1514    (list
1515     'async-museum:suspendable-ports-exhibit
1516     <gameobj> 'async-museum
1517     #:name "Suspendable Ports Exhibit"
1518     #:goes-by '("suspendable ports exhibit" "ports exhibit"
1519                 "suspendable exhibit" "suspendable ports" "ports")
1520     #:desc
1521     '((p "Suspendable ports are a new feature in Guile 2.2, and allows code "
1522          "that would normally block on IO to " (i "automatically") " suspend "
1523          "to the scheduler until information is ready to be read/written!")
1524       (p "Yow!  You might barely need to change your existing blocking code!")
1525       (p "Fibers, 8sync, and guile-a-sync now support suspendable ports.")))
1526    (list
1527     'async-museum:actor-model-exhibit
1528     <gameobj> 'async-museum
1529     #:name "Actor Model Exhibit"
1530     #:goes-by '("actor model exhibit" "actor exhibit"
1531                 "actor model")
1532     #:desc
1533     '((p "Here are some fact(oids) about the actor model!")
1534       (ul (li "Originally the research goal of Scheme!  (message passing anecdote here)")
1535           (li "foooo"))
1536       ))
1537    
1538    ))
1539
1540 (define gift-shop
1541   (lol
1542    ('gift-shop
1543     <room> #f
1544     #:name "Museum Gift Shop"
1545     #:desc "foo"
1546     #:exits (list
1547              (make <exit>
1548                #:name "northeast"
1549                #:to 'underground-lab)
1550              (make <exit>
1551                #:name "north"
1552                #:to 'async-museum)))))
1553
1554
1555 \f
1556 ;;; Game
1557 ;;; ----
1558
1559 (define (game-spec)
1560   (append lobby grand-hallway smoking-parlor
1561           playroom break-room computer-room underground-lab
1562           async-museum gift-shop))
1563
1564 ;; TODO: Provide command line args
1565 (define (run-game . args)
1566   (run-demo (game-spec) 'lobby #:repl-server #t))
1567