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
67 (define-actor <proxy-items> (<gameobj>)
68 ((cmd-take-from take-from-proxy))
69 (proxy-items #:init-keyword #:proxy-items))
71 (define* (take-from-proxy gameobj message
72 #:key direct-obj indir-obj preposition
73 (player (message-from message)))
78 (define obj-id (dyn-ref gameobj obj-sym))
80 (mbody-val (<-wait obj-id 'goes-by)))
81 (when (ci-member direct-obj goes-by)
82 (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
84 (slot-ref gameobj 'proxy-items))
87 #:text `("You don't see any such " ,direct-obj " to take "
88 ,preposition " " ,(slot-ref gameobj 'name) ".")))))
95 (define (npc-chat-randomly actor message . _)
97 (format #f "~a says: \"~a\"\n"
98 (slot-ref actor 'name)
99 (random-choice (slot-ref actor 'catchphrases))))
100 (<- (message-from message) 'tell
101 #:text text-to-send))
103 (define hotel-owner-grumps
104 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
105 "Don't mind the mess. I built this place on a dare, you
107 "(*tearfully*) Here, take this parenthesis. May it serve
109 "I gotta get back to the goblin farm soon..."
110 "Oh, but I was going to make a mansion... a great,
111 beautiful mansion! Full of ghosts! Now all I have is this cruddy
112 mo... hotel. Oh... If only I had more time!"
113 "I told them to paint more of the walls purple.
114 Why didn't they listen?"
115 "Listen to that overhead muzak. Whoever made that doesn't
116 know how to compose very well! Have you heard of the bands 'fmt'
117 or 'skribe'? Now *that's* composition!"))
119 (define-class <chatty-npc> (<gameobj>)
120 (catchphrases #:init-value '("Blarga blarga blarga!")
121 #:init-keyword #:catchphrases)
123 #:allocation #:each-subclass
124 #:init-thunk (build-commands
125 (("chat" "talk") ((direct-command cmd-chat)))))
126 (actions #:allocation #:each-subclass
129 (cmd-chat npc-chat-randomly))))
131 (define-class <sign-in-form> (<gameobj>)
133 #:allocation #:each-subclass
134 #:init-thunk (build-commands
135 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
136 (actions #:allocation #:each-subclass
137 #:init-thunk (build-actions
138 (cmd-sign-form sign-cmd-sign-in))))
142 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
144 (define forbidden-words
145 (append article preposition
146 '("and" "or" "but" "admin")))
148 (define (valid-name? name)
149 (and (irregex-match name-sre name)
150 (not (member name forbidden-words))))
152 (define* (sign-cmd-sign-in actor message
153 #:key direct-obj indir-obj preposition)
155 (mbody-val (<-wait (message-from message) 'get-name)))
156 (define name indir-obj)
157 (if (valid-name? indir-obj)
159 (<-wait (message-from message) 'set-name! name)
160 (<- (slot-ref actor 'loc) 'tell-room
161 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
162 old-name old-name name)))
163 (<- (message-from message) 'tell
164 #:text "Sorry, that's not a valid name.
165 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
169 (define-class <summoning-bell> (<gameobj>)
170 (summons #:init-keyword #:summons)
173 #:allocation #:each-subclass
174 #:init-thunk (build-commands
175 ("ring" ((direct-command cmd-ring)))))
176 (actions #:allocation #:each-subclass
177 #:init-thunk (build-actions
178 (cmd-ring summoning-bell-cmd-ring))))
180 (define* (summoning-bell-cmd-ring bell message . _)
181 ;; Call back to actor who invoked this message handler
182 ;; and find out their name. We'll call *their* get-name message
183 ;; handler... meanwhile, this procedure suspends until we get
186 (mbody-val (<-wait (message-from message) 'get-name)))
188 ;; Now we'll invoke the "tell" message handler on the player
189 ;; who rang us, displaying this text on their screen.
190 ;; This one just uses <- instead of <-wait, since we don't
191 ;; care when it's delivered; we're not following up on it.
192 (<- (message-from message) 'tell
193 #:text "*ring ring!* You ring the bell!\n")
194 ;; We also want everyone else in the room to "hear" the bell,
195 ;; but they get a different message since they aren't the ones
196 ;; ringing it. Notice here's where we make use of the invoker's
197 ;; name as extracted and assigned to the who-rang variable.
198 ;; Notice how we send this message to our "location", which
199 ;; forwards it to the rest of the occupants in the room.
200 (<- (gameobj-loc bell) 'tell-room
202 (format #f "*ring ring!* ~a rings the bell!\n"
204 #:exclude (message-from message))
205 ;; Now we perform the primary task of the bell, which is to summon
206 ;; the "clerk" character to the room. (This is configurable,
207 ;; so we dynamically look up their address.)
208 (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
209 #:who-summoned (message-from message)))
212 (define prefect-quotes
213 '("I'm a frood who really knows where my towel is!"
214 "On no account allow a Vogon to read poetry at you."
215 "Time is an illusion, lunchtime doubly so!"
216 "How can you have money if none of you produces anything?"
217 "On no account allow Arthur to request tea on this ship."))
219 (define-class <cabinet-item> (<gameobj>)
220 (take-me? #:init-value
223 `("Hm, well... the cabinet is locked and the properitor "
224 "is right over there.")))))
232 '((p "You're in some sort of hotel lobby. You see a large sign hanging "
233 "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
234 "that says \"'ring bell' for service\". Terrible music plays from a speaker "
235 "somewhere overhead. "
236 "The room is lined with various curio cabinets, filled with all sorts "
237 "of kitschy junk. It looks like whoever decorated this place had great "
238 "ambitions, but actually assembled it all in a hurry and used whatever "
239 "kind of objects they found lying around.")
240 (p "There's a door to the north leading to some kind of hallway."))
244 #:to 'grand-hallway)))
248 #:name "a frumpy fellow"
250 '((p " Whoever this is, they looks totally exhausted. They're
251 collapsed into the only comfortable looking chair in the room and you
252 don't get the sense that they're likely to move any time soon.
253 You notice they're wearing a sticker badly adhesed to their clothing
254 which says \"Hotel Proprietor\", but they look so disorganized that you
255 think that can't possibly be true... can it?
256 Despite their exhaustion, you sense they'd be happy to chat with you,
257 though the conversation may be a bit one sided."))
258 #:goes-by '("frumpy fellow" "fellow"
259 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
260 "hotel proprietor" "proprietor")
261 #:catchphrases hotel-owner-grumps)
265 #:name "the Hotel Bricabrac sign"
266 #:desc " It strikes you that there's something funny going on with this sign.
267 Sure enough, if you look at it hard enough, you can tell that someone
268 hastily painted over an existing sign and changed the \"M\" to an \"H\".
270 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
274 "hotel bricabrac sign"
278 <summoning-bell> 'lobby
279 #:name "a shiny brass bell"
280 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
281 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
282 \"ring me for service\". You probably could \"ring the bell\" if you
284 #:summons 'break-desk-clerk)
287 <sign-in-form> 'lobby
288 #:name "sign-in form"
289 #:goes-by '("sign-in form" "form" "signin form")
290 #:desc "It looks like you could sign this form and set your name.")
292 ;; Object: curio cabinets
295 #:proxy-items '(lobby:porcelain-doll
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")
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")))))
316 ('lobby:porcelain-doll
317 <cabinet-item> 'lobby
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"))
324 <cabinet-item> 'lobby
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"))
332 <cabinet-item> 'lobby
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"))
340 <cabinet-item> 'lobby
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
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
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
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.
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
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:")
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
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"))))
416 (define grand-hallway
420 #:name "Grand Hallway"
421 #:desc '((p " A majestic red carpet runs down the center of the room.
422 Busts of serious looking people line the walls, but there's no
423 clear indication that they have any logical relation to this place.")
424 (p "In the center is a large statue of a woman in a warrior's
425 pose, but something is strange about her weapon and shield. You wonder what
427 (p "To the south is the lobby. A door to the east is labeled \"smoking
428 room\", while a door to the west is labeled \"playroom\"."))
438 #:to 'smoking-parlor)))
439 ('grand-hallway:carpet
440 <gameobj> 'grand-hallway
441 #:name "the Grand Hallway carpet"
442 #:desc "It's very red, except in the places where it's very worn."
444 #:goes-by '("red carpet" "carpet"))
445 ('grand-hallway:busts
446 <gameobj> 'grand-hallway
447 #:name "the busts of serious people"
448 #:desc "There are about 6 of them in total. They look distinguished
449 but there's no indication of who they are."
451 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
452 ('grand-hallway:hackthena-statue
453 <proxy-items> 'grand-hallway
454 #:name "the statue of Hackthena"
455 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
456 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
457 all good hacks, and legendary hacker herself.")
458 (p "Hackthena holds the form of a human woman. She wears flowing
459 robes, has a pear of curly bovine-esque horns protruding from the sides of her
460 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
461 But instead of a weapon, she seems to hold some sort of keyboard. And her
462 shield... well it's round like a shield, but something seems off about it.
463 You'd better take a closer look to be sure."))
464 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
465 #:proxy-items '(grand-hallway:keyboard
466 grand-hallway:disc-platter
467 grand-hallway:hackthena-horns))
468 ('grand-hallway:keyboard
469 <gameobj> 'grand-hallway
470 #:name "a Knight Keyboard"
471 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
472 Any space cadet can see that with that kind of layout a hack-and-slayer could
473 thrash out some serious key-chords like there's no tomorrow. You guess
474 Hackthena must be an emacs user."
479 `("Are you kidding? Do you know how hard it is to find "
480 "a Knight Keyboard? There's no way she's going "
481 "to give that up.")))
482 #:goes-by '("knight keyboard" "keyboard"))
483 ('grand-hallway:hackthena-horns
484 <gameobj> 'grand-hallway
485 #:name "Hackthena's horns"
486 #:desc "They're not unlike a Gnu's horns."
491 `("Are you seriously considering desecrating a statue?")))
492 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
493 ('grand-hallway:disc-platter
494 <gameobj> 'grand-hallway
495 #:name "a hard disc platter"
496 #:desc "This isn't a shield after all, it seems to be a hard disc
497 platter! It looks kind of loose..."
499 #:goes-by '("hard disc platter" "disc platter" "disc" "shield" "platter"))))
509 #:name "The Playroom"
510 #:desc " There are toys scattered everywhere here. It's really unclear
511 if this room is intended for children or child-like adults."
515 #:to 'grand-hallway)))
520 #:desc " It's a little foam cube with googly eyes on it. So cute!")
521 ('playroom:cuddles-plushie
523 #:name "a Cuddles plushie"
524 #:goes-by '("plushie" "cuddles plushie" "cuddles")
526 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
529 <container> 'playroom
531 #:goes-by '("toy chest" "chest")
532 #:desc (lambda (toy-chest whos-looking)
533 (let ((contents (gameobj-occupants toy-chest)))
534 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
537 ,(if (eq? contents '())
538 " nothing! It's empty!"
539 `(ul ,(map (lambda (occupant)
541 (<-wait occupant 'get-name))))
542 (gameobj-occupants toy-chest))))))))
546 ;; Things inside the toy chest
547 ('playroom:toy-chest:rubber-duck
548 <gameobj> 'playroom:toy-chest
549 #:name "a rubber duck"
550 #:goes-by '("rubber duck" "duck")
552 #:desc "It's a yellow rubber duck with a bright orange beak.")))
563 ;; ... full of NURPH weapons?
569 (define-class <furniture> (<gameobj>)
570 (sit-phrase #:init-keyword #:sit-phrase)
571 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
572 (sit-name #:init-keyword #:sit-name)
575 #:allocation #:each-subclass
576 #:init-thunk (build-commands
577 ("sit" ((direct-command cmd-sit-furniture)))))
578 (actions #:allocation #:each-subclass
579 #:init-thunk (build-actions
580 (cmd-sit-furniture furniture-cmd-sit))))
582 (define* (furniture-cmd-sit actor message #:key direct-obj)
584 (mbody-val (<-wait (message-from message) 'get-name)))
585 (<- (message-from message) 'tell
586 #:text (format #f "You ~a ~a.\n"
587 (slot-ref actor 'sit-phrase)
588 (slot-ref actor 'sit-name)))
589 (<- (slot-ref actor 'loc) 'tell-room
590 #:text (format #f "~a ~a on ~a.\n"
592 (slot-ref actor 'sit-phrase-third-person)
593 (slot-ref actor 'sit-name))
594 #:exclude (message-from message)))
597 (define smoking-parlor
601 #:name "Smoking Parlor"
603 '((p "This room looks quite posh. There are huge comfy seats you can sit in
604 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
605 have installed this place and then changed their mind later.")
606 (p "There's a door to the west leading back to the grand hallway, and
607 a nondescript steel door to the south, leading apparently outside."))
615 ('smoking-parlor:chair
616 <furniture> 'smoking-parlor
617 #:name "a comfy leather chair"
618 #:desc " That leather chair looks really comfy!"
619 #:goes-by '("leather chair" "comfy leather chair" "chair")
620 #:sit-phrase "sink into"
621 #:sit-phrase-third-person "sinks into"
622 #:sit-name "the comfy leather chair")
623 ('smoking-parlor:sofa
624 <furniture> 'smoking-parlor
625 #:name "a plush leather sofa"
626 #:desc " That leather chair looks really comfy!"
627 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
628 "leather couch" "plush leather couch" "couch")
629 #:sit-phrase "sprawl out on"
630 #:sit-phrase-third-person "sprawls out on into"
631 #:sit-name "the plush leather couch")
632 ('smoking-parlor:bar-stool
633 <furniture> 'smoking-parlor
635 #:desc " Conveniently located near the bar! Not the most comfortable
636 seat in the room, though."
637 #:goes-by '("stool" "bar stool" "seat")
638 #:sit-phrase "hop on"
639 #:sit-phrase-third-person "hops onto"
640 #:sit-name "the bar stool")
642 <chatty-npc> 'smoking-parlor
643 #:name "Ford Prefect"
644 #:desc "Just some guy, you know?"
645 #:goes-by '("Ford Prefect" "ford prefect"
646 "frood" "prefect" "ford")
647 #:catchphrases prefect-quotes)
649 ('smoking-parlor:no-smoking-sign
650 <gameobj> 'smoking-parlor
652 #:name "No Smoking Sign"
653 #:desc "This sign says \"No Smoking\" in big, red letters.
654 It has some bits of bubble gum stuck to it... yuck."
655 #:goes-by '("no smoking sign" "sign"))
657 ;; TODO: Cigar dispenser
665 (define-class <desk-clerk> (<gameobj>)
666 ;; The desk clerk has three states:
667 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
669 ;; - slacking: In the break room, probably smoking a cigarette
670 ;; or checking text messages
671 (state #:init-value 'slacking)
672 (commands #:allocation #:each-subclass
675 (("talk" "chat") ((direct-command cmd-chat)))
676 ("ask" ((direct-command cmd-ask-incomplete)
677 (prep-direct-command cmd-ask-about)))
678 ("dismiss" ((direct-command cmd-dismiss)))))
679 (patience #:init-value 0)
680 (actions #:allocation #:each-subclass
681 #:init-thunk (build-actions
682 (init clerk-act-init)
683 (cmd-chat clerk-cmd-chat)
684 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
685 (cmd-ask-about clerk-cmd-ask)
686 (cmd-dismiss clerk-cmd-dismiss)
687 (update-loop clerk-act-update-loop)
688 (be-summoned clerk-act-be-summoned))))
690 (define (clerk-act-init clerk message . _)
691 ;; call the gameobj main init method
692 (gameobj-act-init clerk message)
693 ;; start our main loop
694 (<- (actor-id clerk) 'update-loop))
696 (define clerk-help-topics
698 "Changing your name is easy! We have a clipboard here at the desk
699 where you can make yourself known to other participants in the hotel
700 if you sign it. Try 'sign form as <your-name>', replacing
701 <your-name>, obviously!")
703 "Here are some useful commands you might like to try: chat,
704 go, take, drop, say...")
706 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
707 our hotel emphasizes interesting experiences over rest and lodging.
708 The origins of the hotel are... unclear... and it has recently come
709 under new... 'management'. But at Hotel Bricabrac we believe these
710 aspects make the hotel into a fun and unique experience! Please,
711 feel free to walk around and explore.")))
714 (define clerk-knows-about
715 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
717 (define clerk-general-helpful-line
719 "The clerk says, \"If you need help with anything, feel free to ask me about it.
720 For example, 'ask clerk about changing name'. You can ask me about the following:
721 " clerk-knows-about ".\"\n"))
723 (define clerk-slacking-complaints
724 '("The pay here is absolutely lousy."
725 "The owner here has no idea what they're doing."
726 "Some times you just gotta step away, you know?"
727 "You as exhausted as I am?"
728 "Yeah well, this is just temporary. I'm studying to be a high
729 energy particle physicist. But ya gotta pay the bills, especially
730 with tuition at where it is..."))
732 (define* (clerk-cmd-chat clerk message #:key direct-obj)
733 (match (slot-ref clerk 'state)
735 (<- (message-from message) 'tell
736 #:text clerk-general-helpful-line))
738 (<- (message-from message) 'tell
742 (random-choice clerk-slacking-complaints)
745 (define (clerk-cmd-ask-incomplete clerk message . _)
746 (<- (message-from message) 'tell
747 #:text "The clerk says, \"Ask about what?\"\n"))
749 (define clerk-doesnt-know-text
750 "The clerk apologizes and says she doesn't know about that topic.\n")
752 (define* (clerk-cmd-ask clerk message #:key indir-obj
754 (match (slot-ref clerk 'state)
756 (match (assoc (pk 'indir indir-obj) clerk-help-topics)
758 (<- (message-from message) 'tell
760 (string-append "The clerk clears her throat and says:\n \""
764 (<- (message-from message) 'tell
765 #:text clerk-doesnt-know-text))))
767 (<- (message-from message) 'tell
768 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
770 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
771 (match (slot-ref clerk 'state)
773 (<- who-summoned 'tell
775 "The clerk tells you as politely as she can that she's already here,
776 so there's no need to ring the bell.\n"))
778 (<- (gameobj-loc clerk) 'tell-room
780 "The clerk's ears perk up, she stamps out a cigarette, and she
781 runs out of the room!\n")
782 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
783 (slot-set! clerk 'patience 8)
784 (slot-set! clerk 'state 'on-duty)
785 (<- (gameobj-loc clerk) 'tell-room
788 " Suddenly, a uniformed woman rushes into the room! She's wearing a
789 badge that says \"Desk Clerk\".
790 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
791 We look forward to your stay. If you'd like help getting acclimated,
792 feel free to ask me. For example, 'ask clerk about changing name'.
793 You can ask me about the following:
794 " clerk-knows-about ".\"\n")))))
796 (define* (clerk-cmd-dismiss clerk message . _)
798 (mbody-val (<-wait (message-from message) 'get-name)))
799 (match (slot-ref clerk 'state)
801 (<- (gameobj-loc clerk) 'tell-room
803 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
804 The clerk leaves the room in a hurry.\n"
806 #:exclude (actor-id clerk))
807 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
808 (slot-set! clerk 'state 'slacking)
809 (<- (gameobj-loc clerk) 'tell-room
810 #:text clerk-return-to-slacking-text
811 #:exclude (actor-id clerk)))
813 (<- (message-from message) 'tell
814 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
816 (define clerk-slacking-texts
817 '("The clerk takes a long drag on her cigarette.\n"
818 "The clerk scrolls through text messages on her phone.\n"
819 "The clerk coughs a few times.\n"
820 "The clerk checks her watch and justifies a few more minutes outside.\n"
821 "The clerk fumbles around for a lighter.\n"
822 "The clerk sighs deeply and exhaustedly.\n"
823 "The clerk fumbles around for a cigarette.\n"))
825 (define clerk-working-impatience-texts
826 '("The clerk hums something, but you're not sure what it is."
827 "The clerk attempts to change the overhead music, but the dial seems broken."
828 "The clerk clicks around on the desk computer."
829 "The clerk scribbles an equation on a memo pad, then crosses it out."
830 "The clerk mutters something about the proprietor having no idea how to run a hotel."
831 "The clerk thumbs through a printout of some physics paper."))
833 (define clerk-slack-excuse-text
834 "The desk clerk excuses herself, but says you are welcome to ring the bell
835 if you need further help.")
837 (define clerk-return-to-slacking-text
838 "The desk clerk enters and slams the door behind her.\n")
841 (define (clerk-act-update-loop clerk message)
842 (define (tell-room text)
843 (<- (gameobj-loc clerk) 'tell-room
845 #:exclude (actor-id clerk)))
846 (define (loop-if-not-destructed)
847 (if (not (slot-ref clerk 'destructed))
848 ;; This iterates by "recursing" on itself by calling itself
849 ;; (as the message handler) again. It used to be that we had to do
850 ;; this, because there was a bug where a loop which yielded like this
851 ;; would keep growing the stack due to some parameter goofiness.
852 ;; That's no longer true, but there's an added advantage to this
853 ;; route: it's much more live hackable. If we change the definition
854 ;; of this method, the character will act differently on the next
855 ;; "tick" of the loop.
856 (<- (actor-id clerk) 'update-loop)))
857 (match (slot-ref clerk 'state)
859 (tell-room (random-choice clerk-slacking-texts))
860 (8sleep (+ (random 20) 15))
861 (loop-if-not-destructed))
863 (if (> (slot-ref clerk 'patience) 0)
864 ;; Keep working but lose patience gradually
866 (tell-room (random-choice clerk-working-impatience-texts))
867 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
869 (8sleep (+ (random 60) 40))
870 (loop-if-not-destructed))
873 (tell-room clerk-slack-excuse-text)
874 ;; back bto the break room
875 (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'break-room)))
876 (tell-room clerk-return-to-slacking-text)
877 ;; annnnnd back to slacking
878 (slot-set! clerk 'state 'slacking)
879 (8sleep (+ (random 30) 15))
880 (loop-if-not-destructed))))))
887 #:name "Employee Break Room"
888 #:desc " This is less a room and more of an outdoor wire cage. You get
889 a bit of a view of the brick exterior of the building, and a crisp wind blows,
890 whistling, through the openings of the fenced area. Partly smoked cigarettes
891 and various other debris cover the floor.
892 Through the wires you can see... well... hm. It looks oddly like
893 the scenery tapers off nothingness. But that can't be right, can it?"
897 #:to 'smoking-parlor)))
898 ('break-room:desk-clerk
899 <desk-clerk> 'break-room
900 #:name "the hotel desk clerk"
901 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
902 hotel insignia. She appears to be rather exhausted."
903 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
905 <gameobj> 'break-room
908 #:desc "As you stare into the void, the void stares back into you."
909 #:goes-by '("void" "abyss" "nothingness" "scenery"))
911 <gameobj> 'break-room
913 #:name "break room cage"
914 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
915 You can see through the gaps, but they're too small to put more than a
916 couple of fingers through. There appears to be some wear and tear to
917 the paint, but the wires themselves seem to be unusually sturdy."
918 #:goes-by '("fence" "cage" "wire cage"))))
922 ;;; Ennpie's Sea Lounge
923 ;;; -------------------
934 (append lobby grand-hallway smoking-parlor
935 playroom break-room))
937 ;; TODO: Provide command line args
938 (define (run-game . args)
939 (run-demo (game-spec) 'lobby #:repl-server #t))