Adjust disc-shield description
[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 (string-append (slot-ref actor 'read-text) "\n")))
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.")
290
291    ;; Object: curio cabinets
292    ;; TODO: respond to attempts to open the curio cabinet
293    ('lobby:cabinet
294     <proxy-items> 'lobby
295     #:proxy-items '(lobby:porcelain-doll
296                     lobby:1950s-robots
297                     lobby:tea-set lobby:mustard-pot
298                     lobby:head-of-elvis lobby:circuitboard-of-evlis
299                     lobby:teletype-scroll lobby:orange-cat-phone)
300     #:name "a curio cabinet"
301     #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
302                 "cabinet of curiosities")
303     #:desc (lambda _
304              (format #f "  The curio cabinet is full of all sorts of oddities!
305 Something catches your eye!
306 Ooh, ~a!" (random-choice
307            '("a creepy porcelain doll"
308              "assorted 1950s robots"
309              "an exquisite tea set"
310              "an antique mustard pot"
311              "the pickled head of Elvis"
312              "the pickled circuitboard of EVLIS"
313              "a scroll of teletype paper holding the software Four Freedoms"
314              "a telephone shaped like an orange cartoon cat")))))
315
316    ('lobby:porcelain-doll
317     <cabinet-item> 'lobby
318     #:invisible? #t
319     #:name "a creepy porcelain doll"
320     #:desc "It strikes you that while the doll is technically well crafted,
321 it's also the stuff of nightmares."
322     #:goes-by '("porcelain doll" "doll"))
323    ('lobby:1950s-robots
324     <cabinet-item> 'lobby
325     #:invisible? #t
326     #:name "a set of 1950s robots"
327     #:desc "There's a whole set of these 1950s style robots.
328 They seem to be stamped out of tin, and have various decorations of levers
329 and buttons and springs.  Some of them have wind-up knobs on them."
330     #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
331    ('lobby:tea-set
332     <cabinet-item> 'lobby
333     #:invisible? #t
334     #:name "a tea set"
335     #:desc "A complete tea set.  Some of the cups are chipped.
336 You can imagine yourself joining a tea party using this set, around a
337 nice table with some doilies, drinking some Earl Grey tea, hot.  Mmmm."
338     #:goes-by '("tea set" "tea"))
339    ('lobby:mustard-pot
340     <cabinet-item> 'lobby
341     #:invisible? #t
342     #:name "a mustard pot"
343     #:desc '((p "It's a mustard pot.  I mean, it's kind of cool, it has a
344 nice design, and it's an antique, but you can't imagine putting something
345 like this in a museum.")
346              (p "Ha... imagine that... a mustard museum."))
347     #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
348    ('lobby:head-of-elvis
349     <cabinet-item> 'lobby
350     #:invisible? #t
351     #:name "the pickled head of Elvis"
352     #:desc '((p "It's a jar full of some briny-looking liquid and...
353 a free floating head.  The head looks an awful lot like Elvis, and
354 definitely not the younger Elvis.  The hair even somehow maintains
355 that signature swoop while suspended in liquid.  But of course it's
356 not Elvis.")
357              (p "Oh, wait, it has a label at the bottom which says:
358 \"This is really the head of Elvis\".  Well... maybe don't believe
359 everything you read."))
360     #:goes-by '("pickled head of elvis" "pickled head of Elvis"
361                 "elvis" "Elvis" "head" "pickled head"))
362    ('lobby:circuitboard-of-evlis
363     <cabinet-item> 'lobby
364     #:invisible? #t
365     #:name "the pickled circuitboard of Evlis"
366     #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
367 This is quite the find, and you bet just about anyone interested in
368 preserving computer history would love to get their hands on this.")
369              (p "Unfortunately, whatever moron did acquire this has
370 no idea what it means to preserve computers, so here it is floating
371 in some kind of briny liquid.  It appears to be heavily corroded.
372 Too bad..."))
373     #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
374                 "pickled circuitboard of EVLIS"
375                 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
376    ('lobby:teletype-scroll
377     <cabinet-item> 'lobby
378     #:invisible? #t
379     #:name "a scroll of teletype"
380     #:desc '((p "This is a scroll of teletype paper.  It's a bit old
381 and yellowed but the type is very legible.  It says:")
382              (br)
383              (i
384               (p (strong "== The four essential freedoms =="))
385               (p "A program is free software if the program's users have
386 the four essential freedoms: ")
387               (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
388                   (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.")
389                   (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
390                   (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.")))
391              (p "You get this feeling that ambiguities in the
392 English language surrounding the word 'free' have lead to a lot of terminology debates."))
393     #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
394                 "teletype paper" "scroll" "four freedoms"
395                 "scroll of teletype paper holding the software Four Freedoms"
396                 "scroll of teletype paper holding the software four freedoms"))
397    ('lobby:orange-cat-phone
398     <cabinet-item> 'lobby
399     #:invisible? #t
400     #:name "a telephone shaped like an orange cartoon cat"
401     #:desc "It's made out of a cheap plastic, and it's very orange.
402 It resembles a striped tabby, and it's eyes hold the emotion of
403 a being both sleepy and smarmy.
404 You suspect that someone, somewhere made a ton of cash on items holding
405 this general shape in the 1990s."
406     #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
407                 "orange cat phone" "orange cat telephone"
408                 "cartoon cat phone" "cartoon cat"
409                 "cat phone" "cat telephone" "phone" "telephone"))))
410
411
412 \f
413 ;;; Grand hallway
414 ;;; -------------
415
416 (define-actor <disc-shield> (<gameobj>)
417   ((cmd-take disc-shield-take)))
418
419 (define* (disc-shield-take gameobj message
420                            #:key direct-obj
421                            (player (message-from message)))
422   (create-gameobj <glowing-disc> (gameobj-gm gameobj)
423                   player)  ;; set loc to player to put in player's inventory
424   (<- player 'tell
425       #:text '((p "As you attempt to pull the shield / disk platter
426 from the statue a shining outline appears around it... and a
427 completely separate, glowing copy of the disc materializes into your
428 hands!")
429                (p "You hear a voice whispering: "
430                   (i "\"Share the software... and you'll be free...\"")))))
431
432 ;;; This is the disc that gets put in the player's inventory
433 (define-actor <glowing-disc> (<gameobj>)
434   ((cmd-drop glowing-disc-drop-cmd))
435   (initial-props
436    #:allocation #:each-subclass
437    #:init-thunk (build-props
438                  '((hd-platter? . #t))))
439   (name #:allocation #:each-subclass
440         #:init-value "a glowing disc")
441   (desc #:allocation #:each-subclass
442         #:init-value "A brightly glowing disc.  It's shaped like a hard
443 drive platter, not unlike the one from the statue it came from.  It's
444 labeled \"RL02.5\".")
445   (goes-by #:init-value '("glowing disc" "glowing platter"
446                           "glowing disc platter" "glowing disk platter"
447                           "platter" "disc" "disk" "glowing shield")))
448
449 (define* (glowing-disc-drop-cmd gameobj message
450                    #:key direct-obj
451                    (player (message-from message)))
452   (<- player 'tell
453       #:text "You drop the glowing disc, and it shatters into a million
454 pieces!")
455   (gameobj-self-destruct gameobj))
456
457 (define grand-hallway
458   (lol
459    ('grand-hallway
460     <room> #f
461     #:name "Grand Hallway"
462     #:desc '((p "  A majestic red carpet runs down the center of the room.
463 Busts of serious looking people line the walls, but there's no
464 clear indication that they have any logical relation to this place.")
465              (p "In the center is a large statue of a woman in a warrior's
466 pose, but something is strange about her weapon and shield.  You wonder what
467 that's all about?")
468              (p "To the south is the lobby.  A door to the east is labeled \"smoking
469 room\", while a door to the west is labeled \"playroom\"."))
470     #:exits
471     (list (make <exit>
472             #:name "south"
473             #:to 'lobby)
474           (make <exit>
475             #:name "west"
476             #:to 'playroom)
477           (make <exit>
478             #:name "east"
479             #:to 'smoking-parlor)))
480    ('grand-hallway:carpet
481     <gameobj> 'grand-hallway
482     #:name "the Grand Hallway carpet"
483     #:desc "It's very red, except in the places where it's very worn."
484     #:invisible? #t
485     #:goes-by '("red carpet" "carpet"))
486    ('grand-hallway:busts
487     <gameobj> 'grand-hallway
488     #:name "the busts of serious people"
489     #:desc "There are about 6 of them in total.  They look distinguished
490 but there's no indication of who they are."
491     #:invisible? #t
492     #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
493    ('grand-hallway:hackthena-statue
494     <proxy-items> 'grand-hallway
495     #:name "the statue of Hackthena"
496     #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
497 spirit\".  You've heard of Hackthena... not a goddess, but spiritual protector of
498 all good hacks, and legendary hacker herself.")
499              (p "Hackthena holds the form of a human woman.  She wears flowing
500 robes, has a pear of curly bovine-esque horns protruding from the sides of her
501 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
502 But instead of a weapon, she seems to hold some sort of keyboard.  And her
503 shield... well it's round like a shield, but something seems off about it.
504 You'd better take a closer look to be sure."))
505     #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
506     #:proxy-items '(grand-hallway:keyboard
507                     grand-hallway:disc-platter
508                     grand-hallway:hackthena-horns))
509    ('grand-hallway:keyboard
510     <gameobj> 'grand-hallway
511     #:name "a Knight Keyboard"
512     #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
513 Any space cadet can see that with that kind of layout a hack-and-slayer could
514 thrash out some serious key-chords like there's no tomorrow.  You guess
515 Hackthena must be an emacs user."
516     #:invisible? #t
517     #:take-me? (lambda _
518                  (values #f
519                          #:why-not
520                          `("Are you kidding?  Do you know how hard it is to find "
521                               "a Knight Keyboard?  There's no way she's going "
522                               "to give that up.")))
523     #:goes-by '("knight keyboard" "keyboard"))
524    ('grand-hallway:hackthena-horns
525     <gameobj> 'grand-hallway
526     #:name "Hackthena's horns"
527     #:desc "They're not unlike a Gnu's horns."
528     #:invisible? #t
529     #:take-me? (lambda _
530                  (values #f
531                          #:why-not
532                          `("Are you seriously considering desecrating a statue?")))
533     #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
534    ('grand-hallway:disc-platter
535     <disc-shield> 'grand-hallway
536     #:name "Hackthena's shield"
537     #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
538 platter!  It has \"RL02.5\" written on it.  It looks kind of loose."
539     #:invisible? #t
540     #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
541
542 \f
543 ;;; Playroom
544 ;;; --------
545
546 (define playroom
547   (lol
548    ('playroom
549     <room> #f
550     #:name "The Playroom"
551     #:desc '(p ("  There are toys scattered everywhere here.  It's really unclear
552 if this room is intended for children or child-like adults.")
553                ("  There are doors to both the east and the west."))
554     #:exits
555     (list (make <exit>
556             #:name "east"
557             #:to 'grand-hallway)
558           (make <exit>
559             #:name "west"
560             #:to 'computer-room)))
561    ('playroom:cubey
562     <gameobj> 'playroom
563     #:name "Cubey"
564     #:take-me? #t
565     #:desc "  It's a little foam cube with googly eyes on it.  So cute!")
566    ('playroom:cuddles-plushie
567     <gameobj> 'playroom
568     #:name "a Cuddles plushie"
569     #:goes-by '("plushie" "cuddles plushie" "cuddles")
570     #:take-me? #t
571     #:desc "  A warm and fuzzy cuddles plushie!  It's a cuddlefish!")
572
573    ('playroom:toy-chest
574     <container> 'playroom
575     #:name "a toy chest"
576     #:goes-by '("toy chest" "chest")
577     #:desc (lambda (toy-chest whos-looking)
578              (let ((contents (gameobj-occupants toy-chest)))
579                `((p "A brightly painted wooden chest.  The word \"TOYS\" is "
580                     "engraved on it.")
581                  (p "Inside you see:"
582                     ,(if (eq? contents '())
583                          " nothing!  It's empty!"
584                          `(ul ,(map (lambda (occupant)
585                                       `(li ,(mbody-val
586                                              (<-wait occupant 'get-name))))
587                                     (gameobj-occupants toy-chest))))))))
588     #:take-from-me? #t
589     #:put-in-me? #t)
590
591    ;; Things inside the toy chest
592    ('playroom:toy-chest:rubber-duck
593     <gameobj> 'playroom:toy-chest
594     #:name "a rubber duck"
595     #:goes-by '("rubber duck" "duck")
596     #:take-me? #t
597     #:desc "It's a yellow rubber duck with a bright orange beak.")))
598
599
600 \f
601 ;;; Writing room
602 ;;; ------------
603
604 \f
605 ;;; Armory???
606 ;;; ---------
607
608 ;; ... full of NURPH weapons?
609
610 \f
611 ;;; Smoking parlor
612 ;;; --------------
613
614 (define-class <furniture> (<gameobj>)
615   (sit-phrase #:init-keyword #:sit-phrase)
616   (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
617   (sit-name #:init-keyword #:sit-name)
618
619   (commands
620    #:allocation #:each-subclass
621    #:init-thunk (build-commands
622                  ("sit" ((direct-command cmd-sit-furniture)))))
623   (actions #:allocation #:each-subclass
624            #:init-thunk (build-actions
625                          (cmd-sit-furniture furniture-cmd-sit))))
626
627 (define* (furniture-cmd-sit actor message #:key direct-obj)
628   (define player-name
629     (mbody-val (<-wait (message-from message) 'get-name)))
630   (<- (message-from message) 'tell
631       #:text (format #f "You ~a ~a.\n"
632                      (slot-ref actor 'sit-phrase)
633                      (slot-ref actor 'sit-name)))
634   (<- (slot-ref actor 'loc) 'tell-room
635       #:text (format #f "~a ~a on ~a.\n"
636                      player-name
637                      (slot-ref actor 'sit-phrase-third-person)
638                      (slot-ref actor 'sit-name))
639       #:exclude (message-from message)))
640
641
642 (define smoking-parlor
643   (lol
644    ('smoking-parlor
645     <room> #f
646     #:name "Smoking Parlor"
647     #:desc
648     '((p "This room looks quite posh.  There are huge comfy seats you can sit in
649 if you like. Strangely, you see a large sign saying \"No Smoking\".  The owners must
650 have installed this place and then changed their mind later.")
651       (p "There's a door to the west leading back to the grand hallway, and
652 a nondescript steel door to the south, leading apparently outside."))
653     #:exits
654     (list (make <exit>
655             #:name "west"
656             #:to 'grand-hallway)
657           (make <exit>
658             #:name "south"
659             #:to 'break-room)))
660    ('smoking-parlor:chair
661     <furniture> 'smoking-parlor
662     #:name "a comfy leather chair"
663     #:desc "  That leather chair looks really comfy!"
664     #:goes-by '("leather chair" "comfy leather chair" "chair")
665     #:sit-phrase "sink into"
666     #:sit-phrase-third-person "sinks into"
667     #:sit-name "the comfy leather chair")
668    ('smoking-parlor:sofa
669     <furniture> 'smoking-parlor
670     #:name "a plush leather sofa"
671     #:desc "  That leather chair looks really comfy!"
672     #:goes-by '("leather sofa" "plush leather sofa" "sofa"
673                 "leather couch" "plush leather couch" "couch")
674     #:sit-phrase "sprawl out on"
675     #:sit-phrase-third-person "sprawls out on into"
676     #:sit-name "the plush leather couch")
677    ('smoking-parlor:bar-stool
678     <furniture> 'smoking-parlor
679     #:name "a bar stool"
680     #:desc "  Conveniently located near the bar!  Not the most comfortable
681 seat in the room, though."
682     #:goes-by '("stool" "bar stool" "seat")
683     #:sit-phrase "hop on"
684     #:sit-phrase-third-person "hops onto"
685     #:sit-name "the bar stool")
686    ('ford-prefect
687     <chatty-npc> 'smoking-parlor
688     #:name "Ford Prefect"
689     #:desc "Just some guy, you know?"
690     #:goes-by '("Ford Prefect" "ford prefect"
691                 "frood" "prefect" "ford")
692     #:catchphrases prefect-quotes)
693
694    ('smoking-parlor:no-smoking-sign
695     <gameobj> 'smoking-parlor
696     #:invisible? #t
697     #:name "No Smoking Sign"
698     #:desc "This sign says \"No Smoking\" in big, red letters.
699 It has some bits of bubble gum stuck to it... yuck."
700     #:goes-by '("no smoking sign" "sign"))
701
702    ;; TODO: Cigar dispenser
703    ))
704
705 \f
706
707 ;;; Breakroom
708 ;;; ---------
709
710 (define-class <desk-clerk> (<gameobj>)
711   ;; The desk clerk has three states:
712   ;;  - on-duty: Arrived, and waiting for instructions (and losing patience
713   ;;    gradually)
714   ;;  - slacking: In the break room, probably smoking a cigarette
715   ;;    or checking text messages
716   (state #:init-value 'slacking)
717   (commands #:allocation #:each-subclass
718             #:init-thunk
719             (build-commands
720              (("talk" "chat") ((direct-command cmd-chat)))
721              ("ask" ((direct-command cmd-ask-incomplete)
722                      (prep-direct-command cmd-ask-about)))
723              ("dismiss" ((direct-command cmd-dismiss)))))
724   (patience #:init-value 0)
725   (actions #:allocation #:each-subclass
726            #:init-thunk (build-actions
727                          (init clerk-act-init)
728                          (cmd-chat clerk-cmd-chat)
729                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
730                          (cmd-ask-about clerk-cmd-ask)
731                          (cmd-dismiss clerk-cmd-dismiss)
732                          (update-loop clerk-act-update-loop)
733                          (be-summoned clerk-act-be-summoned))))
734
735 (define (clerk-act-init clerk message . _)
736   ;; call the gameobj main init method
737   (gameobj-act-init clerk message)
738   ;; start our main loop
739   (<- (actor-id clerk) 'update-loop))
740
741 (define clerk-help-topics
742   '(("changing name" .
743      "Changing your name is easy!  We have a clipboard here at the desk
744 where you can make yourself known to other participants in the hotel
745 if you sign it.  Try 'sign form as <your-name>', replacing
746 <your-name>, obviously!")
747     ("common commands" .
748      "Here are some useful commands you might like to try: chat,
749 go, take, drop, say...")
750     ("hotel" .
751      "We hope you enjoy your stay at Hotel Bricabrac.  As you may see,
752 our hotel emphasizes interesting experiences over rest and lodging.
753 The origins of the hotel are... unclear... and it has recently come
754 under new... 'management'.  But at Hotel Bricabrac we believe these
755 aspects make the hotel into a fun and unique experience!  Please,
756 feel free to walk around and explore.")))
757
758
759 (define clerk-knows-about
760   "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
761
762 (define clerk-general-helpful-line
763   (string-append
764    "The clerk says, \"If you need help with anything, feel free to ask me about it.
765 For example, 'ask clerk about changing name'. You can ask me about the following:
766 " clerk-knows-about ".\"\n"))
767
768 (define clerk-slacking-complaints
769   '("The pay here is absolutely lousy."
770     "The owner here has no idea what they're doing."
771     "Some times you just gotta step away, you know?"
772     "You as exhausted as I am?"
773     "Yeah well, this is just temporary.  I'm studying to be a high
774 energy particle physicist.  But ya gotta pay the bills, especially
775 with tuition at where it is..."))
776
777 (define* (clerk-cmd-chat clerk message #:key direct-obj)
778   (match (slot-ref clerk 'state)
779     ('on-duty
780      (<- (message-from message) 'tell
781          #:text clerk-general-helpful-line))
782     ('slacking
783      (<- (message-from message) 'tell
784          #:text
785          (string-append
786           "The clerk says, \""
787           (random-choice clerk-slacking-complaints)
788           "\"\n")))))
789
790 (define (clerk-cmd-ask-incomplete clerk message . _)
791   (<- (message-from message) 'tell
792       #:text "The clerk says, \"Ask about what?\"\n"))
793
794 (define clerk-doesnt-know-text
795   "The clerk apologizes and says she doesn't know about that topic.\n")
796
797 (define* (clerk-cmd-ask clerk message #:key indir-obj
798                         #:allow-other-keys)
799   (match (slot-ref clerk 'state)
800     ('on-duty
801      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
802        ((_ . info)
803            (<- (message-from message) 'tell
804                #:text
805                (string-append "The clerk clears her throat and says:\n  \""
806                               info
807                               "\"\n")))
808        (#f
809         (<- (message-from message) 'tell
810             #:text clerk-doesnt-know-text))))
811     ('slacking
812      (<- (message-from message) 'tell
813          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
814
815 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
816   (match (slot-ref clerk 'state)
817     ('on-duty
818      (<- who-summoned 'tell
819          #:text
820          "The clerk tells you as politely as she can that she's already here,
821 so there's no need to ring the bell.\n"))
822     ('slacking
823      (<- (gameobj-loc clerk) 'tell-room
824          #:text
825          "The clerk's ears perk up, she stamps out a cigarette, and she
826 runs out of the room!\n")
827      (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
828      (slot-set! clerk 'patience 8)
829      (slot-set! clerk 'state 'on-duty)
830      (<- (gameobj-loc clerk) 'tell-room
831          #:text
832          (string-append
833           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
834 badge that says \"Desk Clerk\".
835   \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
836 We look forward to your stay.  If you'd like help getting acclimated,
837 feel free to ask me.  For example, 'ask clerk about changing name'.
838 You can ask me about the following:
839 " clerk-knows-about ".\"\n")))))
840
841 (define* (clerk-cmd-dismiss clerk message . _)
842   (define player-name
843     (mbody-val (<-wait (message-from message) 'get-name)))
844   (match (slot-ref clerk 'state)
845     ('on-duty
846      (<- (gameobj-loc clerk) 'tell-room
847          #:text
848          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
849 The clerk leaves the room in a hurry.\n"
850                  player-name)
851          #:exclude (actor-id clerk))
852      (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
853      (slot-set! clerk 'state 'slacking)
854      (<- (gameobj-loc clerk) 'tell-room
855          #:text clerk-return-to-slacking-text
856          #:exclude (actor-id clerk)))
857     ('slacking
858      (<- (message-from message) 'tell
859          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
860
861 (define clerk-slacking-texts
862   '("The clerk takes a long drag on her cigarette.\n"
863     "The clerk scrolls through text messages on her phone.\n"
864     "The clerk coughs a few times.\n"
865     "The clerk checks her watch and justifies a few more minutes outside.\n"
866     "The clerk fumbles around for a lighter.\n"
867     "The clerk sighs deeply and exhaustedly.\n"
868     "The clerk fumbles around for a cigarette.\n"))
869
870 (define clerk-working-impatience-texts
871   '("The clerk hums something, but you're not sure what it is."
872     "The clerk attempts to change the overhead music, but the dial seems broken."
873     "The clerk clicks around on the desk computer."
874     "The clerk scribbles an equation on a memo pad, then crosses it out."
875     "The clerk mutters something about the proprietor having no idea how to run a hotel."
876     "The clerk thumbs through a printout of some physics paper."))
877
878 (define clerk-slack-excuse-text
879   "The desk clerk excuses herself, but says you are welcome to ring the bell
880 if you need further help.")
881
882 (define clerk-return-to-slacking-text
883   "The desk clerk enters and slams the door behind her.\n")
884
885
886 (define (clerk-act-update-loop clerk message)
887   (define (tell-room text)
888     (<- (gameobj-loc clerk) 'tell-room
889         #:text text
890         #:exclude (actor-id clerk)))
891   (define (loop-if-not-destructed)
892     (if (not (slot-ref clerk 'destructed))
893         ;; This iterates by "recursing" on itself by calling itself
894         ;; (as the message handler) again.  It used to be that we had to do
895         ;; this, because there was a bug where a loop which yielded like this
896         ;; would keep growing the stack due to some parameter goofiness.
897         ;; That's no longer true, but there's an added advantage to this
898         ;; route: it's much more live hackable.  If we change the definition
899         ;; of this method, the character will act differently on the next
900         ;; "tick" of the loop.
901         (<- (actor-id clerk) 'update-loop)))
902   (match (slot-ref clerk 'state)
903     ('slacking
904      (tell-room (random-choice clerk-slacking-texts))
905      (8sleep (+ (random 20) 15))
906      (loop-if-not-destructed))
907     ('on-duty
908      (if (> (slot-ref clerk 'patience) 0)
909          ;; Keep working but lose patience gradually
910          (begin
911            (tell-room (random-choice clerk-working-impatience-texts))
912            (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
913                                          (+ (random 2) 1)))
914            (8sleep (+ (random 60) 40))
915            (loop-if-not-destructed))
916          ;; Back to slacking
917          (begin
918            (tell-room clerk-slack-excuse-text)
919            ;; back bto the break room
920            (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'break-room)))
921            (tell-room clerk-return-to-slacking-text)
922            ;; annnnnd back to slacking
923            (slot-set! clerk 'state 'slacking)
924            (8sleep (+ (random 30) 15))
925            (loop-if-not-destructed))))))
926
927
928 (define break-room
929   (lol
930    ('break-room
931     <room> #f
932     #:name "Employee Break Room"
933     #:desc "  This is less a room and more of an outdoor wire cage.  You get
934 a bit of a view of the brick exterior of the building, and a crisp wind blows,
935 whistling, through the openings of the fenced area.  Partly smoked cigarettes
936 and various other debris cover the floor.
937   Through the wires you can see... well... hm.  It looks oddly like
938 the scenery tapers off nothingness.  But that can't be right, can it?"
939     #:exits
940     (list (make <exit>
941             #:name "north"
942             #:to 'smoking-parlor)))
943    ('break-room:desk-clerk
944     <desk-clerk> 'break-room
945     #:name "the hotel desk clerk"
946     #:desc "  The hotel clerk is wearing a neatly pressed uniform bearing the
947 hotel insignia.  She appears to be rather exhausted."
948     #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
949    ('break-room:void
950     <gameobj> 'break-room
951     #:invisible? #t
952     #:name "The Void"
953     #:desc "As you stare into the void, the void stares back into you."
954     #:goes-by '("void" "abyss" "nothingness" "scenery"))
955    ('break-room:fence
956     <gameobj> 'break-room
957     #:invisible? #t
958     #:name "break room cage"
959     #:desc "It's a mostly-cubical wire mesh surrounding the break area.
960 You can see through the gaps, but they're too small to put more than a
961 couple of fingers through.  There appears to be some wear and tear to
962 the paint, but the wires themselves seem to be unusually sturdy."
963     #:goes-by '("fence" "cage" "wire cage"))))
964
965
966 \f
967 ;;; Ennpie's Sea Lounge
968 ;;; -------------------
969
970 \f
971 ;;; Computer room
972 ;;; -------------
973
974 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
975 ;; RL02 disk drives.  However we increment both by .5 (a true heresy)
976 ;; to distinguish both from the real thing.
977
978 (define-actor <hard-drive> (<gameobj>)
979   ()
980   ;; the state moves from: empty -> with-disc -> loading -> ready
981   (state #:init-value 'empty
982          #:accessor .state))
983
984 (define* (hard-drive-desc hard-drive #:optional whos-looking)
985   `((p "The hard drive is labeled \"RL02.5\".  It's a little under a meter tall.")
986     (p "There is a slot where a disk platter could be inserted, "
987        ,(if (eq? (.state hard-drive) 'empty)
988             "which is currently empty"
989             "which contains a glowing platter")
990        ". There is a LOAD button "
991        ,(if (member (.state hard-drive) '(empty with-disc))
992             "which is glowing"
993             "which is pressed in and unlit")
994        ". There is a READY indicator "
995        ,(if (eq? (.state hard-drive) 'ready)
996             "which is glowing.  The machine emits a gentle whirring noise."
997             "which is unlit."))))
998
999 (define computer-room
1000   (lol
1001    ('computer-room
1002     <room> #f
1003     #:name "Computer Room"
1004     #:desc '((p "A sizable computer cabinet covers a good portion of the left
1005 wall.  It emits a pleasant hum which covers the room like a warm blanket.
1006 Connected to a computer is a large hard drive.")
1007              (p "On the floor is a large steel panel.  It is closed, but it has
1008 hinges which suggest it could be opened."))
1009     #:exits
1010     (list (make <exit>
1011             #:name "east"
1012             #:to 'playroom)))
1013    ('computer-room:hard-drive
1014     <hard-drive> 'computer-room
1015     #:name "a hard drive"
1016     #:desc (wrap-apply hard-drive-desc)
1017     #:goes-by '("hard drive" "drive" "hard disk"))))
1018
1019
1020 \f
1021 ;;; Game
1022 ;;; ----
1023
1024 (define (game-spec)
1025   (append lobby grand-hallway smoking-parlor
1026           playroom break-room computer-room))
1027
1028 ;; TODO: Provide command line args
1029 (define (run-game . args)
1030   (run-demo (game-spec) 'lobby #:repl-server #t))
1031