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-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" "shield" "platter"))))
508 #:name "The Playroom"
509 #:desc " There are toys scattered everywhere here. It's really unclear
510 if this room is intended for children or child-like adults."
514 #:to 'grand-hallway)))
519 #:desc " It's a little foam cube with googly eyes on it. So cute!")
520 ('playroom:cuddles-plushie
522 #:name "a Cuddles plushie"
523 #:goes-by '("plushie" "cuddles plushie" "cuddles")
525 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
528 <container> 'playroom
530 #:goes-by '("toy chest" "chest")
531 #:desc (lambda (toy-chest whos-looking)
532 (let ((contents (gameobj-occupants toy-chest)))
533 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
536 ,(if (eq? contents '())
537 " nothing! It's empty!"
538 `(ul ,(map (lambda (occupant)
540 (<-wait occupant 'get-name))))
541 (gameobj-occupants toy-chest))))))))
545 ;; Things inside the toy chest
546 ('playroom:toy-chest:rubber-duck
547 <gameobj> 'playroom:toy-chest
548 #:name "a rubber duck"
549 #:goes-by '("rubber duck" "duck")
551 #:desc "It's a yellow rubber duck with a bright orange beak.")))
562 ;; ... full of NURPH weapons?
568 (define-class <furniture> (<gameobj>)
569 (sit-phrase #:init-keyword #:sit-phrase)
570 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
571 (sit-name #:init-keyword #:sit-name)
574 #:allocation #:each-subclass
575 #:init-thunk (build-commands
576 ("sit" ((direct-command cmd-sit-furniture)))))
577 (actions #:allocation #:each-subclass
578 #:init-thunk (build-actions
579 (cmd-sit-furniture furniture-cmd-sit))))
581 (define* (furniture-cmd-sit actor message #:key direct-obj)
583 (mbody-val (<-wait (message-from message) 'get-name)))
584 (<- (message-from message) 'tell
585 #:text (format #f "You ~a ~a.\n"
586 (slot-ref actor 'sit-phrase)
587 (slot-ref actor 'sit-name)))
588 (<- (slot-ref actor 'loc) 'tell-room
589 #:text (format #f "~a ~a on ~a.\n"
591 (slot-ref actor 'sit-phrase-third-person)
592 (slot-ref actor 'sit-name))
593 #:exclude (message-from message)))
596 (define smoking-parlor
600 #:name "Smoking Parlor"
602 '((p "This room looks quite posh. There are huge comfy seats you can sit in
603 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
604 have installed this place and then changed their mind later.")
605 (p "There's a door to the west leading back to the grand hallway, and
606 a nondescript steel door to the south, leading apparently outside."))
614 ('smoking-parlor:chair
615 <furniture> 'smoking-parlor
616 #:name "a comfy leather chair"
617 #:desc " That leather chair looks really comfy!"
618 #:goes-by '("leather chair" "comfy leather chair" "chair")
619 #:sit-phrase "sink into"
620 #:sit-phrase-third-person "sinks into"
621 #:sit-name "the comfy leather chair")
622 ('smoking-parlor:sofa
623 <furniture> 'smoking-parlor
624 #:name "a plush leather sofa"
625 #:desc " That leather chair looks really comfy!"
626 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
627 "leather couch" "plush leather couch" "couch")
628 #:sit-phrase "sprawl out on"
629 #:sit-phrase-third-person "sprawls out on into"
630 #:sit-name "the plush leather couch")
631 ('smoking-parlor:bar-stool
632 <furniture> 'smoking-parlor
634 #:desc " Conveniently located near the bar! Not the most comfortable
635 seat in the room, though."
636 #:goes-by '("stool" "bar stool" "seat")
637 #:sit-phrase "hop on"
638 #:sit-phrase-third-person "hops onto"
639 #:sit-name "the bar stool")
641 <chatty-npc> 'smoking-parlor
642 #:name "Ford Prefect"
643 #:desc "Just some guy, you know?"
644 #:goes-by '("Ford Prefect" "ford prefect"
645 "frood" "prefect" "ford")
646 #:catchphrases prefect-quotes)
648 ('smoking-parlor:no-smoking-sign
649 <gameobj> 'smoking-parlor
651 #:name "No Smoking Sign"
652 #:desc "This sign says \"No Smoking\" in big, red letters.
653 It has some bits of bubble gum stuck to it... yuck."
654 #:goes-by '("no smoking sign" "sign"))
656 ;; TODO: Cigar dispenser
664 (define-class <desk-clerk> (<gameobj>)
665 ;; The desk clerk has three states:
666 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
668 ;; - slacking: In the break room, probably smoking a cigarette
669 ;; or checking text messages
670 (state #:init-value 'slacking)
671 (commands #:allocation #:each-subclass
674 (("talk" "chat") ((direct-command cmd-chat)))
675 ("ask" ((direct-command cmd-ask-incomplete)
676 (prep-direct-command cmd-ask-about)))
677 ("dismiss" ((direct-command cmd-dismiss)))))
678 (patience #:init-value 0)
679 (actions #:allocation #:each-subclass
680 #:init-thunk (build-actions
681 (init clerk-act-init)
682 (cmd-chat clerk-cmd-chat)
683 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
684 (cmd-ask-about clerk-cmd-ask)
685 (cmd-dismiss clerk-cmd-dismiss)
686 (update-loop clerk-act-update-loop)
687 (be-summoned clerk-act-be-summoned))))
689 (define (clerk-act-init clerk message . _)
690 ;; call the gameobj main init method
691 (gameobj-act-init clerk message)
692 ;; start our main loop
693 (<- (actor-id clerk) 'update-loop))
695 (define clerk-help-topics
697 "Changing your name is easy! We have a clipboard here at the desk
698 where you can make yourself known to other participants in the hotel
699 if you sign it. Try 'sign form as <your-name>', replacing
700 <your-name>, obviously!")
702 "Here are some useful commands you might like to try: chat,
703 go, take, drop, say...")
705 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
706 our hotel emphasizes interesting experiences over rest and lodging.
707 The origins of the hotel are... unclear... and it has recently come
708 under new... 'management'. But at Hotel Bricabrac we believe these
709 aspects make the hotel into a fun and unique experience! Please,
710 feel free to walk around and explore.")))
713 (define clerk-knows-about
714 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
716 (define clerk-general-helpful-line
718 "The clerk says, \"If you need help with anything, feel free to ask me about it.
719 For example, 'ask clerk about changing name'. You can ask me about the following:
720 " clerk-knows-about ".\"\n"))
722 (define clerk-slacking-complaints
723 '("The pay here is absolutely lousy."
724 "The owner here has no idea what they're doing."
725 "Some times you just gotta step away, you know?"
726 "You as exhausted as I am?"
727 "Yeah well, this is just temporary. I'm studying to be a high
728 energy particle physicist. But ya gotta pay the bills, especially
729 with tuition at where it is..."))
731 (define* (clerk-cmd-chat clerk message #:key direct-obj)
732 (match (slot-ref clerk 'state)
734 (<- (message-from message) 'tell
735 #:text clerk-general-helpful-line))
737 (<- (message-from message) 'tell
741 (random-choice clerk-slacking-complaints)
744 (define (clerk-cmd-ask-incomplete clerk message . _)
745 (<- (message-from message) 'tell
746 #:text "The clerk says, \"Ask about what?\"\n"))
748 (define clerk-doesnt-know-text
749 "The clerk apologizes and says she doesn't know about that topic.\n")
751 (define* (clerk-cmd-ask clerk message #:key indir-obj
753 (match (slot-ref clerk 'state)
755 (match (assoc (pk 'indir indir-obj) clerk-help-topics)
757 (<- (message-from message) 'tell
759 (string-append "The clerk clears her throat and says:\n \""
763 (<- (message-from message) 'tell
764 #:text clerk-doesnt-know-text))))
766 (<- (message-from message) 'tell
767 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
769 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
770 (match (slot-ref clerk 'state)
772 (<- who-summoned 'tell
774 "The clerk tells you as politely as she can that she's already here,
775 so there's no need to ring the bell.\n"))
777 (<- (gameobj-loc clerk) 'tell-room
779 "The clerk's ears perk up, she stamps out a cigarette, and she
780 runs out of the room!\n")
781 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
782 (slot-set! clerk 'patience 8)
783 (slot-set! clerk 'state 'on-duty)
784 (<- (gameobj-loc clerk) 'tell-room
787 " Suddenly, a uniformed woman rushes into the room! She's wearing a
788 badge that says \"Desk Clerk\".
789 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
790 We look forward to your stay. If you'd like help getting acclimated,
791 feel free to ask me. For example, 'ask clerk about changing name'.
792 You can ask me about the following:
793 " clerk-knows-about ".\"\n")))))
795 (define* (clerk-cmd-dismiss clerk message . _)
797 (mbody-val (<-wait (message-from message) 'get-name)))
798 (match (slot-ref clerk 'state)
800 (<- (gameobj-loc clerk) 'tell-room
802 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
803 The clerk leaves the room in a hurry.\n"
805 #:exclude (actor-id clerk))
806 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
807 (slot-set! clerk 'state 'slacking)
808 (<- (gameobj-loc clerk) 'tell-room
809 #:text clerk-return-to-slacking-text
810 #:exclude (actor-id clerk)))
812 (<- (message-from message) 'tell
813 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
815 (define clerk-slacking-texts
816 '("The clerk takes a long drag on her cigarette.\n"
817 "The clerk scrolls through text messages on her phone.\n"
818 "The clerk coughs a few times.\n"
819 "The clerk checks her watch and justifies a few more minutes outside.\n"
820 "The clerk fumbles around for a lighter.\n"
821 "The clerk sighs deeply and exhaustedly.\n"
822 "The clerk fumbles around for a cigarette.\n"))
824 (define clerk-working-impatience-texts
825 '("The clerk hums something, but you're not sure what it is."
826 "The clerk attempts to change the overhead music, but the dial seems broken."
827 "The clerk clicks around on the desk computer."
828 "The clerk scribbles an equation on a memo pad, then crosses it out."
829 "The clerk mutters something about the proprietor having no idea how to run a hotel."
830 "The clerk thumbs through a printout of some physics paper."))
832 (define clerk-slack-excuse-text
833 "The desk clerk excuses herself, but says you are welcome to ring the bell
834 if you need further help.")
836 (define clerk-return-to-slacking-text
837 "The desk clerk enters and slams the door behind her.\n")
840 (define (clerk-act-update-loop clerk message)
841 (define (tell-room text)
842 (<- (gameobj-loc clerk) 'tell-room
844 #:exclude (actor-id clerk)))
845 (define (loop-if-not-destructed)
846 (if (not (slot-ref clerk 'destructed))
847 ;; This iterates by "recursing" on itself by calling itself
848 ;; (as the message handler) again. It used to be that we had to do
849 ;; this, because there was a bug where a loop which yielded like this
850 ;; would keep growing the stack due to some parameter goofiness.
851 ;; That's no longer true, but there's an added advantage to this
852 ;; route: it's much more live hackable. If we change the definition
853 ;; of this method, the character will act differently on the next
854 ;; "tick" of the loop.
855 (<- (actor-id clerk) 'update-loop)))
856 (match (slot-ref clerk 'state)
858 (tell-room (random-choice clerk-slacking-texts))
859 (8sleep (+ (random 20) 15))
860 (loop-if-not-destructed))
862 (if (> (slot-ref clerk 'patience) 0)
863 ;; Keep working but lose patience gradually
865 (tell-room (random-choice clerk-working-impatience-texts))
866 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
868 (8sleep (+ (random 60) 40))
869 (loop-if-not-destructed))
872 (tell-room clerk-slack-excuse-text)
873 ;; back bto the break room
874 (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'break-room)))
875 (tell-room clerk-return-to-slacking-text)
876 ;; annnnnd back to slacking
877 (slot-set! clerk 'state 'slacking)
878 (8sleep (+ (random 30) 15))
879 (loop-if-not-destructed))))))
886 #:name "Employee Break Room"
887 #:desc " This is less a room and more of an outdoor wire cage. You get
888 a bit of a view of the brick exterior of the building, and a crisp wind blows,
889 whistling, through the openings of the fenced area. Partly smoked cigarettes
890 and various other debris cover the floor.
891 Through the wires you can see... well... hm. It looks oddly like
892 the scenery tapers off nothingness. But that can't be right, can it?"
896 #:to 'smoking-parlor)))
897 ('break-room:desk-clerk
898 <desk-clerk> 'break-room
899 #:name "the hotel desk clerk"
900 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
901 hotel insignia. She appears to be rather exhausted."
902 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
904 <gameobj> 'break-room
907 #:desc "As you stare into the void, the void stares back into you."
908 #:goes-by '("void" "abyss" "nothingness" "scenery"))
910 <gameobj> 'break-room
912 #:name "break room cage"
913 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
914 You can see through the gaps, but they're too small to put more than a
915 couple of fingers through. There appears to be some wear and tear to
916 the paint, but the wires themselves seem to be unusually sturdy."
917 #:goes-by '("fence" "cage" "wire cage"))))
921 ;;; Ennpie's Sea Lounge
922 ;;; -------------------
933 (append lobby grand-hallway smoking-parlor
934 playroom break-room))
936 ;; TODO: Provide command line args
937 (define (run-game . args)
938 (run-demo (game-spec) 'lobby #:repl-server #t))