1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4 ;;; This file is part of Mudsync.
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.
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.
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/>.
21 (use-modules (mudsync)
33 ;;; Utilities, useful or otherwise
34 ;;; ==============================
36 (set! *random-state* (random-state-from-platform))
38 (define (random-choice lst)
39 (list-ref lst (random (length lst))))
41 ;; list of lists, lol.
42 (define-syntax-rule (lol (list-contents ...) ...)
43 (list (list list-contents ...) ...))
46 ;;; Some simple object types.
47 ;;; =========================
49 (define-class <readable> (<gameobj>)
50 (read-text #:init-value "All it says is: \"Blah blah blah.\""
51 #:init-keyword #:read-text)
53 #:allocation #:each-subclass
54 #:init-thunk (build-commands
55 ("read" ((direct-command cmd-read)))))
56 (actions #:allocation #:each-subclass
57 #:init-thunk (build-actions
58 (cmd-read readable-cmd-read))))
60 (define (readable-cmd-read actor message)
61 (<- (message-from message) 'tell
62 #:text (string-append (slot-ref actor 'read-text) "\n")))
65 ;; This one allows you to take from items that are proxied by it
66 (define-actor <proxy-items> (<gameobj>)
67 ((cmd-take-from take-from-proxy))
68 (proxy-items #:init-keyword #:proxy-items))
70 (define* (take-from-proxy gameobj message
71 #:key direct-obj indir-obj preposition
72 (player (message-from message)))
77 (define obj-id (dyn-ref gameobj obj-sym))
79 (mbody-val (<-wait obj-id 'goes-by)))
80 (when (ci-member direct-obj goes-by)
81 (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
83 (slot-ref gameobj 'proxy-items))
86 #:text `("You don't see any such " ,direct-obj " to take "
87 ,preposition " " ,(slot-ref gameobj 'name) ".")))))
94 (define (npc-chat-randomly actor message . _)
96 (format #f "~a says: \"~a\"\n"
97 (slot-ref actor 'name)
98 (random-choice (slot-ref actor 'catchphrases))))
99 (<- (message-from message) 'tell
100 #:text text-to-send))
102 (define hotel-owner-grumps
103 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
104 "Don't mind the mess. I built this place on a dare, you
106 "(*tearfully*) Here, take this parenthesis. May it serve
108 "I gotta get back to the goblin farm soon..."
109 "Oh, but I was going to make a mansion... a great,
110 beautiful mansion! Full of ghosts! Now all I have is this cruddy
111 mo... hotel. Oh... If only I had more time!"
112 "I told them to paint more of the walls purple.
113 Why didn't they listen?"
114 "Listen to that overhead muzak. Whoever made that doesn't
115 know how to compose very well! Have you heard of the bands 'fmt'
116 or 'skribe'? Now *that's* composition!"))
118 (define-class <chatty-npc> (<gameobj>)
119 (catchphrases #:init-value '("Blarga blarga blarga!")
120 #:init-keyword #:catchphrases)
122 #:allocation #:each-subclass
123 #:init-thunk (build-commands
124 (("chat" "talk") ((direct-command cmd-chat)))))
125 (actions #:allocation #:each-subclass
128 (cmd-chat npc-chat-randomly))))
130 (define-class <sign-in-form> (<gameobj>)
132 #:allocation #:each-subclass
133 #:init-thunk (build-commands
134 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
135 (actions #:allocation #:each-subclass
136 #:init-thunk (build-actions
137 (cmd-sign-form sign-cmd-sign-in))))
141 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
143 (define forbidden-words
144 (append article preposition
145 '("and" "or" "but" "admin")))
147 (define (valid-name? name)
148 (and (irregex-match name-sre name)
149 (not (member name forbidden-words))))
151 (define* (sign-cmd-sign-in actor message
152 #:key direct-obj indir-obj preposition)
154 (mbody-val (<-wait (message-from message) 'get-name)))
155 (define name indir-obj)
156 (if (valid-name? indir-obj)
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
168 (define-class <summoning-bell> (<gameobj>)
169 (summons #:init-keyword #:summons)
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))))
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
185 (mbody-val (<-wait (message-from message) 'get-name)))
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
201 (format #f "*ring ring!* ~a rings the bell!\n"
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)))
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."))
218 (define-class <cabinet-item> (<gameobj>)
219 (take-me? #:init-value
222 `("Hm, well... the cabinet is locked and the properitor "
223 "is right over there.")))))
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."))
243 #:to 'grand-hallway)))
247 #:name "a frumpy fellow"
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)
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\".
269 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
273 "hotel bricabrac sign"
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
283 #:summons 'break-room:desk-clerk)
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.")
291 ;; Object: curio cabinets
294 #:proxy-items '(lobby:porcelain-doll
296 lobby:tea-set lobby:mustard-pot
297 lobby:head-of-elvis lobby:circuitboard-of-evlis
298 lobby:teletype-scroll lobby:orange-cat-phone)
299 #:name "a curio cabinet"
300 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
301 "cabinet of curiosities")
303 (format #f " The curio cabinet is full of all sorts of oddities!
304 Something catches your eye!
305 Ooh, ~a!" (random-choice
306 '("a creepy porcelain doll"
307 "assorted 1950s robots"
308 "an exquisite tea set"
309 "an antique mustard pot"
310 "the pickled head of Elvis"
311 "the pickled circuitboard of EVLIS"
312 "a scroll of teletype paper holding the software Four Freedoms"
313 "a telephone shaped like an orange cartoon cat")))))
315 ('lobby:porcelain-doll
316 <cabinet-item> 'lobby
318 #:name "a creepy porcelain doll"
319 #:desc "It strikes you that while the doll is technically well crafted,
320 it's also the stuff of nightmares."
321 #:goes-by '("porcelain doll" "doll"))
323 <cabinet-item> 'lobby
325 #:name "a set of 1950s robots"
326 #:desc "There's a whole set of these 1950s style robots.
327 They seem to be stamped out of tin, and have various decorations of levers
328 and buttons and springs. Some of them have wind-up knobs on them."
329 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
331 <cabinet-item> 'lobby
334 #:desc "A complete tea set. Some of the cups are chipped.
335 You can imagine yourself joining a tea party using this set, around a
336 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
337 #:goes-by '("tea set" "tea"))
339 <cabinet-item> 'lobby
341 #:name "a mustard pot"
342 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
343 nice design, and it's an antique, but you can't imagine putting something
344 like this in a museum.")
345 (p "Ha... imagine that... a mustard museum."))
346 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
347 ('lobby:head-of-elvis
348 <cabinet-item> 'lobby
350 #:name "the pickled head of Elvis"
351 #:desc '((p "It's a jar full of some briny-looking liquid and...
352 a free floating head. The head looks an awful lot like Elvis, and
353 definitely not the younger Elvis. The hair even somehow maintains
354 that signature swoop while suspended in liquid. But of course it's
356 (p "Oh, wait, it has a label at the bottom which says:
357 \"This is really the head of Elvis\". Well... maybe don't believe
358 everything you read."))
359 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
360 "elvis" "Elvis" "head" "pickled head"))
361 ('lobby:circuitboard-of-evlis
362 <cabinet-item> 'lobby
364 #:name "the pickled circuitboard of Evlis"
365 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
366 This is quite the find, and you bet just about anyone interested in
367 preserving computer history would love to get their hands on this.")
368 (p "Unfortunately, whatever moron did acquire this has
369 no idea what it means to preserve computers, so here it is floating
370 in some kind of briny liquid. It appears to be heavily corroded.
372 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
373 "pickled circuitboard of EVLIS"
374 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
375 ('lobby:teletype-scroll
376 <cabinet-item> 'lobby
378 #:name "a scroll of teletype"
379 #:desc '((p "This is a scroll of teletype paper. It's a bit old
380 and yellowed but the type is very legible. It says:")
383 (p (strong "== The four essential freedoms =="))
384 (p "A program is free software if the program's users have
385 the four essential freedoms: ")
386 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
387 (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.")
388 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
389 (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.")))
390 (p "You get this feeling that ambiguities in the
391 English language surrounding the word 'free' have lead to a lot of terminology debates."))
392 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
393 "teletype paper" "scroll" "four freedoms"
394 "scroll of teletype paper holding the software Four Freedoms"
395 "scroll of teletype paper holding the software four freedoms"))
396 ('lobby:orange-cat-phone
397 <cabinet-item> 'lobby
399 #:name "a telephone shaped like an orange cartoon cat"
400 #:desc "It's made out of a cheap plastic, and it's very orange.
401 It resembles a striped tabby, and it's eyes hold the emotion of
402 a being both sleepy and smarmy.
403 You suspect that someone, somewhere made a ton of cash on items holding
404 this general shape in the 1990s."
405 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
406 "orange cat phone" "orange cat telephone"
407 "cartoon cat phone" "cartoon cat"
408 "cat phone" "cat telephone" "phone" "telephone"))))
415 (define grand-hallway
419 #:name "Grand Hallway"
420 #:desc '((p " A majestic red carpet runs down the center of the room.
421 Busts of serious looking people line the walls, but there's no
422 clear indication that they have any logical relation to this place.")
423 (p "In the center is a large statue of a woman in a warrior's
424 pose, but something is strange about her weapon and shield. You wonder what
426 (p "To the south is the lobby. A door to the east is labeled \"smoking
427 room\", while a door to the west is labeled \"playroom\"."))
437 #:to 'smoking-parlor)))
438 ('grand-hallway:carpet
439 <gameobj> 'grand-hallway
440 #:name "the Grand Hallway carpet"
441 #:desc "It's very red, except in the places where it's very worn."
443 #:goes-by '("red carpet" "carpet"))
444 ('grand-hallway:busts
445 <gameobj> 'grand-hallway
446 #:name "the busts of serious people"
447 #:desc "There are about 6 of them in total. They look distinguished
448 but there's no indication of who they are."
450 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
451 ('grand-hallway:hackthena-statue
452 <proxy-items> 'grand-hallway
453 #:name "the statue of Hackthena"
454 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
455 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
456 all good hacks, and legendary hacker herself.")
457 (p "Hackthena holds the form of a human woman. She wears flowing
458 robes, has a pear of curly bovine-esque horns protruding from the sides of her
459 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
460 But instead of a weapon, she seems to hold some sort of keyboard. And her
461 shield... well it's round like a shield, but something seems off about it.
462 You'd better take a closer look to be sure."))
463 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
464 #:proxy-items '(grand-hallway:keyboard
465 grand-hallway:disc-platter
466 grand-hallway:hackthena-horns))
467 ('grand-hallway:keyboard
468 <gameobj> 'grand-hallway
469 #:name "a Knight Keyboard"
470 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
471 Any space cadet can see that with that kind of layout a hack-and-slayer could
472 thrash out some serious key-chords like there's no tomorrow. You guess
473 Hackthena must be an emacs user."
478 `("Are you kidding? Do you know how hard it is to find "
479 "a Knight Keyboard? There's no way she's going "
480 "to give that up.")))
481 #:goes-by '("knight keyboard" "keyboard"))
482 ('grand-hallway:hackthena-horns
483 <gameobj> 'grand-hallway
484 #:name "Hackthena's horns"
485 #:desc "They're not unlike a Gnu's horns."
490 `("Are you seriously considering desecrating a statue?")))
491 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
492 ('grand-hallway:disc-platter
493 <gameobj> 'grand-hallway
494 #:name "a hard disc platter"
495 #:desc "This isn't a shield after all, it seems to be a hard disc
496 platter! It looks kind of loose..."
498 #:goes-by '("hard disc platter" "disc platter" "disc"
499 "hard disk platter" "disk platter"
500 "shield" "platter"))))
510 #:name "The Playroom"
511 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
512 if this room is intended for children or child-like adults.")
513 (" There are doors to both the east and the west."))
520 #:to 'computer-room)))
525 #:desc " It's a little foam cube with googly eyes on it. So cute!")
526 ('playroom:cuddles-plushie
528 #:name "a Cuddles plushie"
529 #:goes-by '("plushie" "cuddles plushie" "cuddles")
531 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
534 <container> 'playroom
536 #:goes-by '("toy chest" "chest")
537 #:desc (lambda (toy-chest whos-looking)
538 (let ((contents (gameobj-occupants toy-chest)))
539 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
542 ,(if (eq? contents '())
543 " nothing! It's empty!"
544 `(ul ,(map (lambda (occupant)
546 (<-wait occupant 'get-name))))
547 (gameobj-occupants toy-chest))))))))
551 ;; Things inside the toy chest
552 ('playroom:toy-chest:rubber-duck
553 <gameobj> 'playroom:toy-chest
554 #:name "a rubber duck"
555 #:goes-by '("rubber duck" "duck")
557 #:desc "It's a yellow rubber duck with a bright orange beak.")))
568 ;; ... full of NURPH weapons?
574 (define-class <furniture> (<gameobj>)
575 (sit-phrase #:init-keyword #:sit-phrase)
576 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
577 (sit-name #:init-keyword #:sit-name)
580 #:allocation #:each-subclass
581 #:init-thunk (build-commands
582 ("sit" ((direct-command cmd-sit-furniture)))))
583 (actions #:allocation #:each-subclass
584 #:init-thunk (build-actions
585 (cmd-sit-furniture furniture-cmd-sit))))
587 (define* (furniture-cmd-sit actor message #:key direct-obj)
589 (mbody-val (<-wait (message-from message) 'get-name)))
590 (<- (message-from message) 'tell
591 #:text (format #f "You ~a ~a.\n"
592 (slot-ref actor 'sit-phrase)
593 (slot-ref actor 'sit-name)))
594 (<- (slot-ref actor 'loc) 'tell-room
595 #:text (format #f "~a ~a on ~a.\n"
597 (slot-ref actor 'sit-phrase-third-person)
598 (slot-ref actor 'sit-name))
599 #:exclude (message-from message)))
602 (define smoking-parlor
606 #:name "Smoking Parlor"
608 '((p "This room looks quite posh. There are huge comfy seats you can sit in
609 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
610 have installed this place and then changed their mind later.")
611 (p "There's a door to the west leading back to the grand hallway, and
612 a nondescript steel door to the south, leading apparently outside."))
620 ('smoking-parlor:chair
621 <furniture> 'smoking-parlor
622 #:name "a comfy leather chair"
623 #:desc " That leather chair looks really comfy!"
624 #:goes-by '("leather chair" "comfy leather chair" "chair")
625 #:sit-phrase "sink into"
626 #:sit-phrase-third-person "sinks into"
627 #:sit-name "the comfy leather chair")
628 ('smoking-parlor:sofa
629 <furniture> 'smoking-parlor
630 #:name "a plush leather sofa"
631 #:desc " That leather chair looks really comfy!"
632 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
633 "leather couch" "plush leather couch" "couch")
634 #:sit-phrase "sprawl out on"
635 #:sit-phrase-third-person "sprawls out on into"
636 #:sit-name "the plush leather couch")
637 ('smoking-parlor:bar-stool
638 <furniture> 'smoking-parlor
640 #:desc " Conveniently located near the bar! Not the most comfortable
641 seat in the room, though."
642 #:goes-by '("stool" "bar stool" "seat")
643 #:sit-phrase "hop on"
644 #:sit-phrase-third-person "hops onto"
645 #:sit-name "the bar stool")
647 <chatty-npc> 'smoking-parlor
648 #:name "Ford Prefect"
649 #:desc "Just some guy, you know?"
650 #:goes-by '("Ford Prefect" "ford prefect"
651 "frood" "prefect" "ford")
652 #:catchphrases prefect-quotes)
654 ('smoking-parlor:no-smoking-sign
655 <gameobj> 'smoking-parlor
657 #:name "No Smoking Sign"
658 #:desc "This sign says \"No Smoking\" in big, red letters.
659 It has some bits of bubble gum stuck to it... yuck."
660 #:goes-by '("no smoking sign" "sign"))
662 ;; TODO: Cigar dispenser
670 (define-class <desk-clerk> (<gameobj>)
671 ;; The desk clerk has three states:
672 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
674 ;; - slacking: In the break room, probably smoking a cigarette
675 ;; or checking text messages
676 (state #:init-value 'slacking)
677 (commands #:allocation #:each-subclass
680 (("talk" "chat") ((direct-command cmd-chat)))
681 ("ask" ((direct-command cmd-ask-incomplete)
682 (prep-direct-command cmd-ask-about)))
683 ("dismiss" ((direct-command cmd-dismiss)))))
684 (patience #:init-value 0)
685 (actions #:allocation #:each-subclass
686 #:init-thunk (build-actions
687 (init clerk-act-init)
688 (cmd-chat clerk-cmd-chat)
689 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
690 (cmd-ask-about clerk-cmd-ask)
691 (cmd-dismiss clerk-cmd-dismiss)
692 (update-loop clerk-act-update-loop)
693 (be-summoned clerk-act-be-summoned))))
695 (define (clerk-act-init clerk message . _)
696 ;; call the gameobj main init method
697 (gameobj-act-init clerk message)
698 ;; start our main loop
699 (<- (actor-id clerk) 'update-loop))
701 (define clerk-help-topics
703 "Changing your name is easy! We have a clipboard here at the desk
704 where you can make yourself known to other participants in the hotel
705 if you sign it. Try 'sign form as <your-name>', replacing
706 <your-name>, obviously!")
708 "Here are some useful commands you might like to try: chat,
709 go, take, drop, say...")
711 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
712 our hotel emphasizes interesting experiences over rest and lodging.
713 The origins of the hotel are... unclear... and it has recently come
714 under new... 'management'. But at Hotel Bricabrac we believe these
715 aspects make the hotel into a fun and unique experience! Please,
716 feel free to walk around and explore.")))
719 (define clerk-knows-about
720 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
722 (define clerk-general-helpful-line
724 "The clerk says, \"If you need help with anything, feel free to ask me about it.
725 For example, 'ask clerk about changing name'. You can ask me about the following:
726 " clerk-knows-about ".\"\n"))
728 (define clerk-slacking-complaints
729 '("The pay here is absolutely lousy."
730 "The owner here has no idea what they're doing."
731 "Some times you just gotta step away, you know?"
732 "You as exhausted as I am?"
733 "Yeah well, this is just temporary. I'm studying to be a high
734 energy particle physicist. But ya gotta pay the bills, especially
735 with tuition at where it is..."))
737 (define* (clerk-cmd-chat clerk message #:key direct-obj)
738 (match (slot-ref clerk 'state)
740 (<- (message-from message) 'tell
741 #:text clerk-general-helpful-line))
743 (<- (message-from message) 'tell
747 (random-choice clerk-slacking-complaints)
750 (define (clerk-cmd-ask-incomplete clerk message . _)
751 (<- (message-from message) 'tell
752 #:text "The clerk says, \"Ask about what?\"\n"))
754 (define clerk-doesnt-know-text
755 "The clerk apologizes and says she doesn't know about that topic.\n")
757 (define* (clerk-cmd-ask clerk message #:key indir-obj
759 (match (slot-ref clerk 'state)
761 (match (assoc (pk 'indir indir-obj) clerk-help-topics)
763 (<- (message-from message) 'tell
765 (string-append "The clerk clears her throat and says:\n \""
769 (<- (message-from message) 'tell
770 #:text clerk-doesnt-know-text))))
772 (<- (message-from message) 'tell
773 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
775 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
776 (match (slot-ref clerk 'state)
778 (<- who-summoned 'tell
780 "The clerk tells you as politely as she can that she's already here,
781 so there's no need to ring the bell.\n"))
783 (<- (gameobj-loc clerk) 'tell-room
785 "The clerk's ears perk up, she stamps out a cigarette, and she
786 runs out of the room!\n")
787 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
788 (slot-set! clerk 'patience 8)
789 (slot-set! clerk 'state 'on-duty)
790 (<- (gameobj-loc clerk) 'tell-room
793 " Suddenly, a uniformed woman rushes into the room! She's wearing a
794 badge that says \"Desk Clerk\".
795 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
796 We look forward to your stay. If you'd like help getting acclimated,
797 feel free to ask me. For example, 'ask clerk about changing name'.
798 You can ask me about the following:
799 " clerk-knows-about ".\"\n")))))
801 (define* (clerk-cmd-dismiss clerk message . _)
803 (mbody-val (<-wait (message-from message) 'get-name)))
804 (match (slot-ref clerk 'state)
806 (<- (gameobj-loc clerk) 'tell-room
808 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
809 The clerk leaves the room in a hurry.\n"
811 #:exclude (actor-id clerk))
812 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
813 (slot-set! clerk 'state 'slacking)
814 (<- (gameobj-loc clerk) 'tell-room
815 #:text clerk-return-to-slacking-text
816 #:exclude (actor-id clerk)))
818 (<- (message-from message) 'tell
819 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
821 (define clerk-slacking-texts
822 '("The clerk takes a long drag on her cigarette.\n"
823 "The clerk scrolls through text messages on her phone.\n"
824 "The clerk coughs a few times.\n"
825 "The clerk checks her watch and justifies a few more minutes outside.\n"
826 "The clerk fumbles around for a lighter.\n"
827 "The clerk sighs deeply and exhaustedly.\n"
828 "The clerk fumbles around for a cigarette.\n"))
830 (define clerk-working-impatience-texts
831 '("The clerk hums something, but you're not sure what it is."
832 "The clerk attempts to change the overhead music, but the dial seems broken."
833 "The clerk clicks around on the desk computer."
834 "The clerk scribbles an equation on a memo pad, then crosses it out."
835 "The clerk mutters something about the proprietor having no idea how to run a hotel."
836 "The clerk thumbs through a printout of some physics paper."))
838 (define clerk-slack-excuse-text
839 "The desk clerk excuses herself, but says you are welcome to ring the bell
840 if you need further help.")
842 (define clerk-return-to-slacking-text
843 "The desk clerk enters and slams the door behind her.\n")
846 (define (clerk-act-update-loop clerk message)
847 (define (tell-room text)
848 (<- (gameobj-loc clerk) 'tell-room
850 #:exclude (actor-id clerk)))
851 (define (loop-if-not-destructed)
852 (if (not (slot-ref clerk 'destructed))
853 ;; This iterates by "recursing" on itself by calling itself
854 ;; (as the message handler) again. It used to be that we had to do
855 ;; this, because there was a bug where a loop which yielded like this
856 ;; would keep growing the stack due to some parameter goofiness.
857 ;; That's no longer true, but there's an added advantage to this
858 ;; route: it's much more live hackable. If we change the definition
859 ;; of this method, the character will act differently on the next
860 ;; "tick" of the loop.
861 (<- (actor-id clerk) 'update-loop)))
862 (match (slot-ref clerk 'state)
864 (tell-room (random-choice clerk-slacking-texts))
865 (8sleep (+ (random 20) 15))
866 (loop-if-not-destructed))
868 (if (> (slot-ref clerk 'patience) 0)
869 ;; Keep working but lose patience gradually
871 (tell-room (random-choice clerk-working-impatience-texts))
872 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
874 (8sleep (+ (random 60) 40))
875 (loop-if-not-destructed))
878 (tell-room clerk-slack-excuse-text)
879 ;; back bto the break room
880 (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'break-room)))
881 (tell-room clerk-return-to-slacking-text)
882 ;; annnnnd back to slacking
883 (slot-set! clerk 'state 'slacking)
884 (8sleep (+ (random 30) 15))
885 (loop-if-not-destructed))))))
892 #:name "Employee Break Room"
893 #:desc " This is less a room and more of an outdoor wire cage. You get
894 a bit of a view of the brick exterior of the building, and a crisp wind blows,
895 whistling, through the openings of the fenced area. Partly smoked cigarettes
896 and various other debris cover the floor.
897 Through the wires you can see... well... hm. It looks oddly like
898 the scenery tapers off nothingness. But that can't be right, can it?"
902 #:to 'smoking-parlor)))
903 ('break-room:desk-clerk
904 <desk-clerk> 'break-room
905 #:name "the hotel desk clerk"
906 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
907 hotel insignia. She appears to be rather exhausted."
908 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
910 <gameobj> 'break-room
913 #:desc "As you stare into the void, the void stares back into you."
914 #:goes-by '("void" "abyss" "nothingness" "scenery"))
916 <gameobj> 'break-room
918 #:name "break room cage"
919 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
920 You can see through the gaps, but they're too small to put more than a
921 couple of fingers through. There appears to be some wear and tear to
922 the paint, but the wires themselves seem to be unusually sturdy."
923 #:goes-by '("fence" "cage" "wire cage"))))
927 ;;; Ennpie's Sea Lounge
928 ;;; -------------------
934 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
935 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
936 ;; to distinguish both from the real thing.
938 (define-actor <hard-drive> (<gameobj>)
940 ;; the state moves from: empty -> with-disc -> loading -> ready
941 (state #:init-value 'empty
944 (define* (hard-drive-desc hard-drive #:optional whos-looking)
945 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
946 (p "There is a slot where a disk platter could be inserted, "
947 ,(if (eq? (.state hard-drive) 'empty)
948 "which is currently empty"
949 "which contains a glowing platter")
950 ". There is a LOAD button "
951 ,(if (member (.state hard-drive) '(empty with-disc))
953 "which is pressed in and unlit")
954 ". There is a READY indicator "
955 ,(if (eq? (.state hard-drive) 'ready)
956 "which is glowing. The machine emits a gentle whirring noise."
957 "which is unlit."))))
959 (define computer-room
963 #:name "Computer Room"
964 #:desc '((p "A sizable computer cabinet covers a good portion of the left
965 wall. It emits a pleasant hum which covers the room like a warm blanket.
966 Connected to a computer is a large hard drive.")
967 (p "On the floor is a large steel panel. It is closed, but it has
968 hinges which suggest it could be opened."))
973 ('computer-room:hard-drive
974 <hard-drive> 'computer-room
975 #:name "a hard drive"
976 #:desc (wrap-apply hard-drive-desc)
977 #:goes-by '("hard drive" "drive" "hard disk"))))
985 (append lobby grand-hallway smoking-parlor
986 playroom break-room computer-room))
988 ;; TODO: Provide command line args
989 (define (run-game . args)
990 (run-demo (game-spec) 'lobby #:repl-server #t))