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> (<thing>)
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")))
69 (define (npc-chat-randomly actor message . _)
71 (format #f "~a says: \"~a\"\n"
72 (slot-ref actor 'name)
73 (random-choice (slot-ref actor 'catchphrases))))
74 (<- (message-from message) 'tell
77 (define hotel-owner-grumps
78 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
79 "Don't mind the mess. I built this place on a dare, you
81 "(*tearfully*) Here, take this parenthesis. May it serve
83 "I gotta get back to the goblin farm soon..."
84 "Oh, but I was going to make a mansion... a great,
85 beautiful mansion! Full of ghosts! Now all I have is this cruddy
86 mo... hotel. Oh... If only I had more time!"
87 "I told them to paint more of the walls purple.
88 Why didn't they listen?"
89 "Listen to that overhead muzak. Whoever made that doesn't
90 know how to compose very well! Have you heard of the bands 'fmt'
91 or 'skribe'? Now *that's* composition!"))
93 (define-class <chatty-npc> (<gameobj>)
94 (catchphrases #:init-value '("Blarga blarga blarga!")
95 #:init-keyword #:catchphrases)
97 #:allocation #:each-subclass
98 #:init-thunk (build-commands
99 (("chat" "talk") ((direct-command cmd-chat)))))
100 (actions #:allocation #:each-subclass
103 (cmd-chat npc-chat-randomly))))
105 (define-class <sign-in-form> (<gameobj>)
107 #:allocation #:each-subclass
108 #:init-thunk (build-commands
109 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
110 (actions #:allocation #:each-subclass
111 #:init-thunk (build-actions
112 (cmd-sign-form sign-cmd-sign-in))))
116 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
118 (define forbidden-words
119 (append article preposition
120 '("and" "or" "but" "admin")))
122 (define (valid-name? name)
123 (and (irregex-match name-sre name)
124 (not (member name forbidden-words))))
126 (define* (sign-cmd-sign-in actor message
127 #:key direct-obj indir-obj preposition)
129 (mbody-val (<-wait (message-from message) 'get-name)))
130 (define name indir-obj)
131 (if (valid-name? indir-obj)
133 (<-wait (message-from message) 'set-name! name)
134 (<- (slot-ref actor 'loc) 'tell-room
135 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
136 old-name old-name name)))
137 (<- (message-from message) 'tell
138 #:text "Sorry, that's not a valid name.
139 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
143 (define-class <summoning-bell> (<thing>)
144 (summons #:init-keyword #:summons)
147 #:allocation #:each-subclass
148 #:init-thunk (build-commands
149 ("ring" ((direct-command cmd-ring)))))
150 (actions #:allocation #:each-subclass
151 #:init-thunk (build-actions
152 (cmd-ring summoning-bell-cmd-ring))))
154 (define* (summoning-bell-cmd-ring bell message . _)
155 ;; Call back to actor who invoked this message handler
156 ;; and find out their name. We'll call *their* get-name message
157 ;; handler... meanwhile, this procedure suspends until we get
160 (mbody-val (<-wait (message-from message) 'get-name)))
162 ;; Now we'll invoke the "tell" message handler on the player
163 ;; who rang us, displaying this text on their screen.
164 ;; This one just uses <- instead of <-wait, since we don't
165 ;; care when it's delivered; we're not following up on it.
166 (<- (message-from message) 'tell
167 #:text "*ring ring!* You ring the bell!\n")
168 ;; We also want everyone else in the room to "hear" the bell,
169 ;; but they get a different message since they aren't the ones
170 ;; ringing it. Notice here's where we make use of the invoker's
171 ;; name as extracted and assigned to the who-rang variable.
172 ;; Notice how we send this message to our "location", which
173 ;; forwards it to the rest of the occupants in the room.
174 (<- (gameobj-loc bell) 'tell-room
176 (format #f "*ring ring!* ~a rings the bell!\n"
178 #:exclude (message-from message))
179 ;; Now we perform the primary task of the bell, which is to summon
180 ;; the "clerk" character to the room. (This is configurable,
181 ;; so we dynamically look up their address.)
182 (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
183 #:who-summoned (message-from message)))
186 (define prefect-quotes
187 '("I'm a frood who really knows where my towel is!"
188 "On no account allow a Vogon to read poetry at you."
189 "Time is an illusion, lunchtime doubly so!"
190 "How can you have money if none of you produces anything?"
191 "On no account allow Arthur to request tea on this ship."))
199 '((p "You're in some sort of hotel lobby. You see a large sign hanging "
200 "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
201 "that says \"'ring bell' for service\". Terrible music plays from a speaker "
202 "somewhere overhead. "
203 "The room is lined with various curio cabinets, filled with all sorts "
204 "of kitschy junk. It looks like whoever decorated this place had great "
205 "ambitions, but actually assembled it all in a hurry and used whatever "
206 "kind of objects they found lying around.")
207 (p "There's a door to the north leading to some kind of hallway."))
211 #:to 'room:grand-hallway)))
213 ('npc:lobby:hotel-owner
214 <chatty-npc> 'room:lobby
215 #:name "a frumpy fellow"
217 '((p " Whoever this is, they looks totally exhausted. They're
218 collapsed into the only comfortable looking chair in the room and you
219 don't get the sense that they're likely to move any time soon.
220 You notice they're wearing a sticker badly adhesed to their clothing
221 which says \"Hotel Proprietor\", but they look so disorganized that you
222 think that can't possibly be true... can it?
223 Despite their exhaustion, you sense they'd be happy to chat with you,
224 though the conversation may be a bit one sided."))
225 #:goes-by '("frumpy fellow" "fellow"
226 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
227 "hotel proprietor" "proprietor")
228 #:catchphrases hotel-owner-grumps)
231 <readable> 'room:lobby
232 #:name "the Hotel Bricabrac sign"
233 #:desc " It strikes you that there's something funny going on with this sign.
234 Sure enough, if you look at it hard enough, you can tell that someone
235 hastily painted over an existing sign and changed the \"M\" to an \"H\".
237 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
241 "hotel bricabrac sign"
245 <summoning-bell> 'room:lobby
246 #:name "a shiny brass bell"
247 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
248 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
249 \"ring me for service\". You probably could \"ring the bell\" if you
251 #:summons 'npc:break-room:desk-clerk)
253 ;; Object: curio cabinets
254 ('thing:lobby:cabinet
255 <gameobj> 'room:lobby
256 #:name "a curio cabinet"
257 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
258 "cabinet of curiosities")
260 (format #f " The curio cabinet is full of all sorts of oddities!
261 Something catches your eye!
262 Ooh, ~a!" (random-choice
263 '("a creepy porcelain doll"
264 "assorted 1950s robots"
265 "an exquisite tea set"
266 "an antique mustard pot"
267 "the pickled head of Elvis"
268 "the pickled circuitboard of EVLIS"
269 "a scroll of teletype paper holding the software Four Freedoms"
270 "a telephone shaped like an orange cartoon cat")))))
271 ('thing:lobby:sign-in-form
272 <sign-in-form> 'room:lobby
273 #:name "sign-in form"
274 #:goes-by '("sign-in form" "form" "signin form")
275 #:desc "It looks like you could sign this form and set your name.")
277 ('thing:lobby:porcelain-doll
279 #:generally-visible #f
280 #:name "a creepy porcelain doll"
281 #:desc "It strikes you that while the doll is technically well crafted,
282 it's also the stuff of nightmares."
283 #:goes-by '("porcelain doll" "doll"))
284 ('thing:lobby:1950s-robots
286 #:generally-visible #f
287 #:name "a set of 1950s robots"
288 #:desc "There's a whole set of these 1950s style robots.
289 They seem to be stamped out of tin, and have various decorations of levers
290 and buttons and springs. Some of them have wind-up knobs on them."
291 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
292 ('thing:lobby:tea-set
294 #:generally-visible #f
296 #:desc "A complete tea set. Some of the cups are chipped.
297 You can imagine yourself joining a tea party using this set, around a
298 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
299 #:goes-by '("tea set" "tea"))
300 ('thing:lobby:mustard-pot
302 #:generally-visible #f
303 #:name "a mustard pot"
304 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
305 nice design, and it's an antique, but you can't imagine putting something
306 like this in a museum.")
307 (p "Ha... imagine that... a mustard museum."))
308 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
309 ('thing:lobby:head-of-elvis
311 #:generally-visible #f
312 #:name "the pickled head of Elvis"
313 #:desc '((p "It's a jar full of some briny-looking liquid and...
314 a free floating head. The head looks an awful lot like Elvis, and
315 definitely not the younger Elvis. The hair even somehow maintains
316 that signature swoop while suspended in liquid. But of course it's
318 (p "Oh, wait, it has a label at the bottom which says:
319 \"This is really the head of Elvis\". Well... maybe don't believe
320 everything you read."))
321 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
322 "elvis" "Elvis" "head" "pickled head"))
323 ('thing:lobby:circuitboard-of-evlis
325 #:generally-visible #f
326 #:name "the pickled circuitboard of Evlis"
327 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
328 This is quite the find, and you bet just about anyone interested in
329 preserving computer history would love to get their hands on this.")
330 (p "Unfortunately, whatever moron did acquire this has
331 no idea what it means to preserve computers, so here it is floating
332 in some kind of briny liquid. It appears to be heavily corroded.
334 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
335 "pickled circuitboard of EVLIS"
336 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
337 ('thing:lobby:teletype-scroll
339 #:generally-visible #f
340 #:name "a scroll of teletype"
341 #:desc '((p "This is a scroll of teletype paper. It's a bit old
342 and yellowed but the type is very legible. It says:")
345 (p (strong "== The four essential freedoms =="))
346 (p "A program is free software if the program's users have
347 the four essential freedoms: ")
348 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
349 (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.")
350 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
351 (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.")))
352 (p "You get this feeling that ambiguities in the
353 English language surrounding the word 'free' have lead to a lot of terminology debates."))
354 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
355 "teletype paper" "scroll" "four freedoms"
356 "scroll of teletype paper holding the software Four Freedoms"
357 "scroll of teletype paper holding the software four freedoms"))
358 ('thing:lobby:orange-cat-phone
360 #:generally-visible #f
361 #:name "a telephone shaped like an orange cartoon cat"
362 #:desc "It's made out of a cheap plastic, and it's very orange.
363 It resembles a striped tabby, and it's eyes hold the emotion of
364 a being both sleepy and smarmy.
365 You suspect that someone, somewhere made a ton of cash on items holding
366 this general shape in the 1990s."
367 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
368 "orange cat phone" "orange cat telephone"
369 "cartoon cat phone" "cartoon cat"
370 "cat phone" "cat telephone" "phone" "telephone"))))
377 (define grand-hallway
381 #:name "Grand Hallway"
382 #:desc " A majestic red carpet runs down the center of the room.
383 Busts of serious looking people line the walls, but there's no
384 clear indication that they have any logical relation to this place.
385 In the center is a large statue of a bearded man. You wonder what
387 To the south is the lobby. A door to the east is labeled \"smoking
388 room\", while a door to the west is labeled \"playroom\"."
398 #:to 'room:smoking-parlor)))
399 ('thing:ignucius-statue
400 <gameobj> 'room:grand-hallway
402 #:desc " The statue is of a serious-looking bearded man with long, flowing hair.
403 It has a large physical halo. Removing it is tempting, but it looks pretty
405 #:goes-by '("statue" "st ignucius" "st. ignucius"))))
415 #:name "The Playroom"
416 #:desc " There are toys scattered everywhere here. It's really unclear
417 if this room is intended for children or child-like adults."
421 #:to 'room:grand-hallway)))
422 ('thing:playroom:cubey
423 <thing> 'room:playroom
426 #:desc " It's a little foam cube with googly eyes on it. So cute!")
427 ('thing:cuddles-plushie
428 <thing> 'room:playroom
429 #:name "a cuddles plushie"
430 #:goes-by '("plushie" "cuddles plushie" "cuddles")
432 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")))
443 ;; ... full of NURPH weapons?
449 (define-class <furniture> (<gameobj>)
450 (sit-phrase #:init-keyword #:sit-phrase)
451 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
452 (sit-name #:init-keyword #:sit-name)
455 #:allocation #:each-subclass
456 #:init-thunk (build-commands
457 ("sit" ((direct-command cmd-sit-furniture)))))
458 (actions #:allocation #:each-subclass
459 #:init-thunk (build-actions
460 (cmd-sit-furniture furniture-cmd-sit))))
462 (define* (furniture-cmd-sit actor message #:key direct-obj)
464 (mbody-val (<-wait (message-from message) 'get-name)))
465 (<- (message-from message) 'tell
466 #:text (format #f "You ~a ~a.\n"
467 (slot-ref actor 'sit-phrase)
468 (slot-ref actor 'sit-name)))
469 (<- (slot-ref actor 'loc) 'tell-room
470 #:text (format #f "~a ~a on ~a.\n"
472 (slot-ref actor 'sit-phrase-third-person)
473 (slot-ref actor 'sit-name))
474 #:exclude (message-from message)))
477 (define smoking-parlor
479 ('room:smoking-parlor
481 #:name "Smoking Parlor"
483 '((p "This room looks quite posh. There are huge comfy seats you can sit in
484 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
485 have installed this place and then changed their mind later.")
486 (p "There's a door to the west leading back to the grand hallway, and
487 a nondescript steel door to the south, leading apparently outside."))
491 #:to 'room:grand-hallway)
494 #:to 'room:break-room)))
495 ('thing:smoking-parlor:chair
496 <furniture> 'room:smoking-parlor
497 #:name "a comfy leather chair"
498 #:desc " That leather chair looks really comfy!"
499 #:goes-by '("leather chair" "comfy leather chair" "chair")
500 #:sit-phrase "sink into"
501 #:sit-phrase-third-person "sinks into"
502 #:sit-name "the comfy leather chair")
503 ('thing:smoking-parlor:sofa
504 <furniture> 'room:smoking-parlor
505 #:name "a plush leather sofa"
506 #:desc " That leather chair looks really comfy!"
507 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
508 "leather couch" "plush leather couch" "couch")
509 #:sit-phrase "sprawl out on"
510 #:sit-phrase-third-person "sprawls out on into"
511 #:sit-name "the plush leather couch")
512 ('thing:smoking-parlor:bar-stool
513 <furniture> 'room:smoking-parlor
515 #:desc " Conveniently located near the bar! Not the most comfortable
516 seat in the room, though."
517 #:goes-by '("stool" "bar stool" "seat")
518 #:sit-phrase "hop on"
519 #:sit-phrase-third-person "hops onto"
520 #:sit-name "the bar stool")
522 <chatty-npc> 'room:smoking-parlor
523 #:name "Ford Prefect"
524 #:desc "Just some guy, you know?"
525 #:goes-by '("Ford Prefect" "ford prefect"
526 "frood" "prefect" "ford")
527 #:catchphrases prefect-quotes)
529 ('thing:smoking-parlor:no-smoking-sign
530 <thing> 'room:smoking-parlor
531 #:generally-visible #f
532 #:name "No Smoking Sign"
533 #:desc "This sign says \"No Smoking\" in big, red letters.
534 It has some bits of bubble gum stuck to it... yuck."
535 #:goes-by '("no smoking sign" "sign"))
537 ;; TODO: Cigar dispenser
545 (define-class <desk-clerk> (<thing>)
546 ;; The desk clerk has three states:
547 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
549 ;; - slacking: In the break room, probably smoking a cigarette
550 ;; or checking text messages
551 (state #:init-value 'slacking)
552 (commands #:allocation #:each-subclass
555 (("talk" "chat") ((direct-command cmd-chat)))
556 ("ask" ((direct-command cmd-ask-incomplete)
557 (prep-direct-command cmd-ask-about)))
558 ("dismiss" ((direct-command cmd-dismiss)))))
559 (patience #:init-value 0)
560 (actions #:allocation #:each-subclass
561 #:init-thunk (build-actions
562 (init clerk-act-init)
563 (cmd-chat clerk-cmd-chat)
564 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
565 (cmd-ask-about clerk-cmd-ask)
566 (cmd-dismiss clerk-cmd-dismiss)
567 (update-loop clerk-act-update-loop)
568 (be-summoned clerk-act-be-summoned))))
570 (define (clerk-act-init clerk message . _)
571 ;; call the gameobj main init method
572 (gameobj-act-init clerk message)
573 ;; start our main loop
574 (<- (actor-id clerk) 'update-loop))
576 (define clerk-help-topics
578 "Changing your name is easy! We have a clipboard here at the desk
579 where you can make yourself known to other participants in the hotel
580 if you sign it. Try 'sign form as <your-name>', replacing
581 <your-name>, obviously!")
583 "Here are some useful commands you might like to try: chat,
584 go, take, drop, say...")
586 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
587 our hotel emphasizes interesting experiences over rest and lodging.
588 The origins of the hotel are... unclear... and it has recently come
589 under new... 'management'. But at Hotel Bricabrac we believe these
590 aspects make the hotel into a fun and unique experience! Please,
591 feel free to walk around and explore.")))
594 (define clerk-knows-about
595 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
597 (define clerk-general-helpful-line
599 "The clerk says, \"If you need help with anything, feel free to ask me about it.
600 For example, 'ask clerk about changing name'. You can ask me about the following:
601 " clerk-knows-about ".\"\n"))
603 (define clerk-slacking-complaints
604 '("The pay here is absolutely lousy."
605 "The owner here has no idea what they're doing."
606 "Some times you just gotta step away, you know?"
607 "You as exhausted as I am?"
608 "Yeah well, this is just temporary. I'm studying to be a high
609 energy particle physicist. But ya gotta pay the bills, especially
610 with tuition at where it is..."))
612 (define* (clerk-cmd-chat clerk message #:key direct-obj)
613 (match (slot-ref clerk 'state)
615 (<- (message-from message) 'tell
616 #:text clerk-general-helpful-line))
618 (<- (message-from message) 'tell
622 (random-choice clerk-slacking-complaints)
625 (define (clerk-cmd-ask-incomplete clerk message . _)
626 (<- (message-from message) 'tell
627 #:text "The clerk says, \"Ask about what?\"\n"))
629 (define clerk-doesnt-know-text
630 "The clerk apologizes and says she doesn't know about that topic.\n")
632 (define* (clerk-cmd-ask clerk message #:key indir-obj
634 (match (slot-ref clerk 'state)
636 (match (assoc (pk 'indir indir-obj) clerk-help-topics)
638 (<- (message-from message) 'tell
640 (string-append "The clerk clears her throat and says:\n \""
644 (<- (message-from message) 'tell
645 #:text clerk-doesnt-know-text))))
647 (<- (message-from message) 'tell
648 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
650 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
651 (match (slot-ref clerk 'state)
653 (<- who-summoned 'tell
655 "The clerk tells you as politely as she can that she's already here,
656 so there's no need to ring the bell.\n"))
658 (<- (gameobj-loc clerk) 'tell-room
660 "The clerk's ears perk up, she stamps out a cigarette, and she
661 runs out of the room!\n")
662 (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
663 (slot-set! clerk 'patience 8)
664 (slot-set! clerk 'state 'on-duty)
665 (<- (gameobj-loc clerk) 'tell-room
668 " Suddenly, a uniformed woman rushes into the room! She's wearing a
669 badge that says \"Desk Clerk\".
670 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
671 We look forward to your stay. If you'd like help getting acclimated,
672 feel free to ask me. For example, 'ask clerk about changing name'.
673 You can ask me about the following:
674 " clerk-knows-about ".\"\n")))))
676 (define* (clerk-cmd-dismiss clerk message . _)
678 (mbody-val (<-wait (message-from message) 'get-name)))
679 (match (slot-ref clerk 'state)
681 (<- (gameobj-loc clerk) 'tell-room
683 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
684 The clerk leaves the room in a hurry.\n"
686 #:exclude (actor-id clerk))
687 (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
688 (slot-set! clerk 'state 'slacking)
689 (<- (gameobj-loc clerk) 'tell-room
690 #:text clerk-return-to-slacking-text
691 #:exclude (actor-id clerk)))
693 (<- (message-from message) 'tell
694 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
696 (define clerk-slacking-texts
697 '("The clerk takes a long drag on her cigarette.\n"
698 "The clerk scrolls through text messages on her phone.\n"
699 "The clerk coughs a few times.\n"
700 "The clerk checks her watch and justifies a few more minutes outside.\n"
701 "The clerk fumbles around for a lighter.\n"
702 "The clerk sighs deeply and exhaustedly.\n"
703 "The clerk fumbles around for a cigarette.\n"))
705 (define clerk-working-impatience-texts
706 '("The clerk hums something, but you're not sure what it is."
707 "The clerk attempts to change the overhead music, but the dial seems broken."
708 "The clerk clicks around on the desk computer."
709 "The clerk scribbles an equation on a memo pad, then crosses it out."
710 "The clerk mutters something about the proprietor having no idea how to run a hotel."
711 "The clerk thumbs through a printout of some physics paper."))
713 (define clerk-slack-excuse-text
714 "The desk clerk excuses herself, but says you are welcome to ring the bell
715 if you need further help.")
717 (define clerk-return-to-slacking-text
718 "The desk clerk enters and slams the door behind her.\n")
721 (define (clerk-act-update-loop clerk message)
722 (define (tell-room text)
723 (<- (gameobj-loc clerk) 'tell-room
725 #:exclude (actor-id clerk)))
726 (define (loop-if-not-destructed)
727 (if (not (slot-ref clerk 'destructed))
728 ;; This iterates by "recursing" on itself by calling itself
729 ;; (as the message handler) again. It used to be that we had to do
730 ;; this, because there was a bug where a loop which yielded like this
731 ;; would keep growing the stack due to some parameter goofiness.
732 ;; That's no longer true, but there's an added advantage to this
733 ;; route: it's much more live hackable. If we change the definition
734 ;; of this method, the character will act differently on the next
735 ;; "tick" of the loop.
736 (<- (actor-id clerk) 'update-loop)))
737 (match (slot-ref clerk 'state)
739 (tell-room (random-choice clerk-slacking-texts))
740 (8sleep (+ (random 20) 15))
741 (loop-if-not-destructed))
743 (if (> (slot-ref clerk 'patience) 0)
744 ;; Keep working but lose patience gradually
746 (tell-room (random-choice clerk-working-impatience-texts))
747 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
749 (8sleep (+ (random 60) 40))
750 (loop-if-not-destructed))
753 (tell-room clerk-slack-excuse-text)
754 ;; back bto the break room
755 (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'room:break-room)))
756 (tell-room clerk-return-to-slacking-text)
757 ;; annnnnd back to slacking
758 (slot-set! clerk 'state 'slacking)
759 (8sleep (+ (random 30) 15))
760 (loop-if-not-destructed))))))
767 #:name "Employee Break Room"
768 #:desc " This is less a room and more of an outdoor wire cage. You get
769 a bit of a view of the brick exterior of the building, and a crisp wind blows,
770 whistling, through the openings of the fenced area. Partly smoked cigarettes
771 and various other debris cover the floor.
772 Through the wires you can see... well... hm. It looks oddly like
773 the scenery tapers off nothingness. But that can't be right, can it?"
777 #:to 'room:smoking-parlor))
779 ('npc:break-room:desk-clerk
780 <desk-clerk> 'room:break-room
781 #:name "the hotel desk clerk"
782 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
783 hotel insignia. She appears to be rather exhausted."
784 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
785 ('thing:break-room:void
786 <thing> 'room:break-room
787 #:generally-visible #f
789 #:desc "As you stare into the void, the void stares back into you."
790 #:goes-by '("void" "abyss" "nothingness"))))
794 ;;; Ennpie's Sea Lounge
795 ;;; -------------------
806 (append lobby grand-hallway smoking-parlor
807 playroom break-room))
809 ;; TODO: Provide command line args
810 (define (run-game . args)
811 (run-demo (game-spec) 'room:lobby #:repl-server #t))