548db77b0540cf9f1866dda90bbbf6ee840a076e
[mudsync.git] / worlds / bricabrac.scm
1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
3 ;;;
4 ;;; This file is part of Mudsync.
5 ;;;
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ;;; General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync.  If not, see <http://www.gnu.org/licenses/>.
18
19 ;;; Hotel Bricabrac
20
21 (use-modules (mudsync)
22              (8sync actors)
23              (8sync agenda)
24              (oop goops)
25              (ice-9 control)
26              (ice-9 format)
27              (ice-9 match)
28              (rx irregex))
29
30
31 \f
32 ;;; Utilities, useful or otherwise
33 ;;; ==============================
34
35 (set! *random-state* (random-state-from-platform))
36
37 (define (random-choice lst)
38   (list-ref lst (random (length lst))))
39
40 ;; list of lists, lol.
41 (define-syntax-rule (lol (list-contents ...) ...)
42   (list (list list-contents ...) ...))
43
44 \f
45 ;;; Some simple object types.
46 ;;; =========================
47
48 (define-class <readable> (<gameobj>)
49   (read-text #:init-value "All it says is: \"Blah blah blah.\""
50              #:init-keyword #:read-text)
51   (commands
52    #:allocation #:each-subclass
53    #:init-thunk (build-commands
54                  ("read" ((direct-command cmd-read)))))
55   (actions #:allocation #:each-subclass
56            #:init-thunk (build-actions
57                          (cmd-read readable-cmd-read))))
58
59 (define (readable-cmd-read actor message)
60   (<- (message-from message) 'tell
61       #:text (string-append (slot-ref actor 'read-text) "\n")))
62
63
64 \f
65 ;;; Lobby
66 ;;; -----
67
68 (define (npc-chat-randomly actor message . _)
69   (define text-to-send
70     (format #f "~a says: \"~a\"\n"
71             (slot-ref actor 'name)
72             (random-choice (slot-ref actor 'catchphrases))))
73   (<- (message-from message) 'tell
74       #:text text-to-send))
75
76 (define hotel-owner-grumps
77   '("Eight sinks!  Eight sinks!  And I couldn't unwind them..."
78     "Don't mind the mess.  I built this place on a dare, you
79 know?"
80     "(*tearfully*) Here, take this parenthesis.  May it serve
81 you well."
82     "I gotta get back to the goblin farm soon..."
83     "Oh, but I was going to make a mansion... a great,
84 beautiful mansion!  Full of ghosts!  Now all I have is this cruddy
85 mo... hotel.  Oh... If only I had more time!"
86     "I told them to paint more of the walls purple.
87 Why didn't they listen?"
88     "Listen to that overhead muzak.  Whoever made that doesn't
89 know how to compose very well!  Have you heard of the bands 'fmt'
90 or 'skribe'?  Now *that's* composition!"))
91
92 (define-class <chatty-npc> (<gameobj>)
93   (catchphrases #:init-value '("Blarga blarga blarga!")
94                 #:init-keyword #:catchphrases)
95   (commands
96    #:allocation #:each-subclass
97    #:init-thunk (build-commands
98                  (("chat" "talk") ((direct-command cmd-chat)))))
99   (actions #:allocation #:each-subclass
100            #:init-thunk
101            (build-actions
102             (cmd-chat npc-chat-randomly))))
103
104 (define-class <sign-in-form> (<gameobj>)
105   (commands
106    #:allocation #:each-subclass
107    #:init-thunk (build-commands
108                  ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
109   (actions #:allocation #:each-subclass
110            #:init-thunk (build-actions
111                          (cmd-sign-form sign-cmd-sign-in))))
112
113
114 (define name-sre
115   (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
116
117 (define forbidden-words
118   (append article preposition
119           '("and" "or" "but" "admin")))
120
121 (define (valid-name? name)
122   (and (irregex-match name-sre name)
123        (not (member name forbidden-words))))
124
125 (define* (sign-cmd-sign-in actor message
126                            #:key direct-obj indir-obj preposition)
127   (define old-name
128     (mbody-val (<-wait (message-from message) 'get-name)))
129   (define name indir-obj)
130   (if (valid-name? indir-obj)
131       (begin
132         (<-wait (message-from message) 'set-name! name)
133         (<- (slot-ref actor 'loc) 'tell-room
134             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
135                            old-name old-name name)))
136       (<- (message-from message) 'tell
137           #:text "Sorry, that's not a valid name.
138 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
139 character.\n")))
140
141
142 (define-class <summoning-bell> (<gameobj>)
143   (summons #:init-keyword #:summons)
144
145   (commands
146    #:allocation #:each-subclass
147    #:init-thunk (build-commands
148                  ("ring" ((direct-command cmd-ring)))))
149   (actions #:allocation #:each-subclass
150            #:init-thunk (build-actions
151                          (cmd-ring summoning-bell-cmd-ring))))
152
153 (define* (summoning-bell-cmd-ring bell message . _)
154   ;; Call back to actor who invoked this message handler
155   ;; and find out their name.  We'll call *their* get-name message
156   ;; handler... meanwhile, this procedure suspends until we get
157   ;; their response.
158   (define who-rang
159     (mbody-val (<-wait (message-from message) 'get-name)))
160
161   ;; Now we'll invoke the "tell" message handler on the player
162   ;; who rang us, displaying this text on their screen.
163   ;; This one just uses <- instead of <-wait, since we don't
164   ;; care when it's delivered; we're not following up on it.
165   (<- (message-from message) 'tell
166       #:text "*ring ring!*  You ring the bell!\n")
167   ;; We also want everyone else in the room to "hear" the bell,
168   ;; but they get a different message since they aren't the ones
169   ;; ringing it.  Notice here's where we make use of the invoker's
170   ;; name as extracted and assigned to the who-rang variable.
171   ;; Notice how we send this message to our "location", which
172   ;; forwards it to the rest of the occupants in the room.
173   (<- (gameobj-loc bell) 'tell-room
174       #:text
175       (format #f "*ring ring!*  ~a rings the bell!\n"
176               who-rang)
177       #:exclude (message-from message))
178   ;; Now we perform the primary task of the bell, which is to summon
179   ;; the "clerk" character to the room.  (This is configurable,
180   ;; so we dynamically look up their address.)
181   (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
182       #:who-summoned (message-from message)))
183
184
185 (define prefect-quotes
186   '("I'm a frood who really knows where my towel is!"
187     "On no account allow a Vogon to read poetry at you."
188     "Time is an illusion, lunchtime doubly so!"
189     "How can you have money if none of you produces anything?"
190     "On no account allow Arthur to request tea on this ship."))
191
192 (define lobby
193   (lol
194    ('lobby
195     <room> #f
196     #:name "Hotel Lobby"
197     #:desc
198     '((p "You're in some sort of hotel lobby.  You see a large sign hanging "
199          "over the desk that says \"Hotel Bricabrac\".  On the desk is a bell "
200          "that says \"'ring bell' for service\".  Terrible music plays from a speaker "
201          "somewhere overhead.  "
202          "The room is lined with various curio cabinets, filled with all sorts "
203          "of kitschy junk.  It looks like whoever decorated this place had great "
204          "ambitions, but actually assembled it all in a hurry and used whatever "
205          "kind of objects they found lying around.")
206       (p "There's a door to the north leading to some kind of hallway."))
207     #:exits
208     (list (make <exit>
209             #:name "north"
210             #:to 'grand-hallway)))
211    ;; NPC: hotel owner
212    ('lobby:hotel-owner
213     <chatty-npc> 'lobby
214     #:name "a frumpy fellow"
215     #:desc
216     '((p "  Whoever this is, they looks totally exhausted.  They're
217 collapsed into the only comfortable looking chair in the room and you
218 don't get the sense that they're likely to move any time soon.
219   You notice they're wearing a sticker badly adhesed to their clothing
220 which says \"Hotel Proprietor\", but they look so disorganized that you
221 think that can't possibly be true... can it?
222   Despite their exhaustion, you sense they'd be happy to chat with you,
223 though the conversation may be a bit one sided."))
224     #:goes-by '("frumpy fellow" "fellow"
225                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
226                 "hotel proprietor" "proprietor")
227     #:catchphrases hotel-owner-grumps)
228    ;; Object: Sign
229    ('lobby:sign
230     <readable> 'lobby
231     #:name "the Hotel Bricabrac sign"
232     #:desc "  It strikes you that there's something funny going on with this sign.
233 Sure enough, if you look at it hard enough, you can tell that someone
234 hastily painted over an existing sign and changed the \"M\" to an \"H\".
235 Classy!"
236     #:read-text "  All it says is \"Hotel Bricabrac\" in smudged, hasty text."
237     #:goes-by '("sign"
238                 "bricabrac sign"
239                 "hotel sign"
240                 "hotel bricabrac sign"
241                 "lobby sign"))
242
243    ('lobby:bell
244     <summoning-bell> 'lobby
245     #:name "a shiny brass bell"
246     #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
247     #:desc "  A shiny brass bell.  Inscribed on its wooden base is the text
248 \"ring me for service\".  You probably could \"ring the bell\" if you 
249 wanted to."
250     #:summons 'break-desk-clerk)
251
252    ;; Object: curio cabinets
253    ('lobby:cabinet
254     <gameobj> 'lobby
255     #:name "a curio cabinet"
256     #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
257                 "cabinet of curiosities")
258     #:desc (lambda _
259              (format #f "  The curio cabinet is full of all sorts of oddities!
260 Something catches your eye!
261 Ooh, ~a!" (random-choice
262            '("a creepy porcelain doll"
263              "assorted 1950s robots"
264              "an exquisite tea set"
265              "an antique mustard pot"
266              "the pickled head of Elvis"
267              "the pickled circuitboard of EVLIS"
268              "a scroll of teletype paper holding the software Four Freedoms"
269              "a telephone shaped like an orange cartoon cat")))))
270    ('lobby:sign-in-form
271     <sign-in-form> 'lobby
272     #:name "sign-in form"
273     #:goes-by '("sign-in form" "form" "signin form")
274     #:desc "It looks like you could sign this form and set your name.")
275
276    ('lobby:porcelain-doll
277     <gameobj> 'lobby
278     #:invisible? #t
279     #:name "a creepy porcelain doll"
280     #:desc "It strikes you that while the doll is technically well crafted,
281 it's also the stuff of nightmares."
282     #:goes-by '("porcelain doll" "doll"))
283    ('lobby:1950s-robots
284     <gameobj> 'lobby
285     #:invisible? #t
286     #:name "a set of 1950s robots"
287     #:desc "There's a whole set of these 1950s style robots.
288 They seem to be stamped out of tin, and have various decorations of levers
289 and buttons and springs.  Some of them have wind-up knobs on them."
290     #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
291    ('lobby:tea-set
292     <gameobj> 'lobby
293     #:invisible? #t
294     #:name "a tea set"
295     #:desc "A complete tea set.  Some of the cups are chipped.
296 You can imagine yourself joining a tea party using this set, around a
297 nice table with some doilies, drinking some Earl Grey tea, hot.  Mmmm."
298     #:goes-by '("tea set" "tea"))
299    ('lobby:mustard-pot
300     <gameobj> 'lobby
301     #:invisible? #t
302     #:name "a mustard pot"
303     #:desc '((p "It's a mustard pot.  I mean, it's kind of cool, it has a
304 nice design, and it's an antique, but you can't imagine putting something
305 like this in a museum.")
306              (p "Ha... imagine that... a mustard museum."))
307     #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
308    ('lobby:head-of-elvis
309     <gameobj> 'lobby
310     #:invisible? #t
311     #:name "the pickled head of Elvis"
312     #:desc '((p "It's a jar full of some briny-looking liquid and...
313 a free floating head.  The head looks an awful lot like Elvis, and
314 definitely not the younger Elvis.  The hair even somehow maintains
315 that signature swoop while suspended in liquid.  But of course it's
316 not Elvis.")
317              (p "Oh, wait, it has a label at the bottom which says:
318 \"This is really the head of Elvis\".  Well... maybe don't believe
319 everything you read."))
320     #:goes-by '("pickled head of elvis" "pickled head of Elvis"
321                 "elvis" "Elvis" "head" "pickled head"))
322    ('lobby:circuitboard-of-evlis
323     <gameobj> 'lobby
324     #:invisible? #t
325     #:name "the pickled circuitboard of Evlis"
326     #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
327 This is quite the find, and you bet just about anyone interested in
328 preserving computer history would love to get their hands on this.")
329              (p "Unfortunately, whatever moron did acquire this has
330 no idea what it means to preserve computers, so here it is floating
331 in some kind of briny liquid.  It appears to be heavily corroded.
332 Too bad..."))
333     #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
334                 "pickled circuitboard of EVLIS"
335                 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
336    ('lobby:teletype-scroll
337     <gameobj> 'lobby
338     #:invisible? #t
339     #:name "a scroll of teletype"
340     #:desc '((p "This is a scroll of teletype paper.  It's a bit old
341 and yellowed but the type is very legible.  It says:")
342              (br)
343              (i
344               (p (strong "== The four essential freedoms =="))
345               (p "A program is free software if the program's users have
346 the four essential freedoms: ")
347               (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
348                   (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.")
349                   (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
350                   (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.")))
351              (p "You get this feeling that ambiguities in the
352 English language surrounding the word 'free' have lead to a lot of terminology debates."))
353     #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
354                 "teletype paper" "scroll" "four freedoms"
355                 "scroll of teletype paper holding the software Four Freedoms"
356                 "scroll of teletype paper holding the software four freedoms"))
357    ('lobby:orange-cat-phone
358     <gameobj> 'lobby
359     #:invisible? #t
360     #:name "a telephone shaped like an orange cartoon cat"
361     #:desc "It's made out of a cheap plastic, and it's very orange.
362 It resembles a striped tabby, and it's eyes hold the emotion of
363 a being both sleepy and smarmy.
364 You suspect that someone, somewhere made a ton of cash on items holding
365 this general shape in the 1990s."
366     #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
367                 "orange cat phone" "orange cat telephone"
368                 "cartoon cat phone" "cartoon cat"
369                 "cat phone" "cat telephone" "phone" "telephone"))))
370
371
372 \f
373 ;;; Grand hallway
374 ;;; -------------
375
376 (define-actor <hackthena> (<gameobj>)
377   ((cmd-take-from hackthena-cmd-take-from)))
378
379 (define* (hackthena-cmd-take-from gameobj message
380                                   #:key direct-obj indir-obj preposition
381                                   (player (message-from message)))
382   (define keyboard-goes-by
383     (mbody-val (<-wait (dyn-ref gameobj 'grand-hallway:keyboard) 'goes-by)))
384   (define disc-platter-goes-by
385     (mbody-val (<-wait (dyn-ref gameobj 'grand-hallway:disc-platter) 'goes-by)))
386
387   (cond ((member direct-obj keyboard-goes-by)
388          (<- player 'tell
389              #:text `("Are you kidding?  Do you know how hard it is to find "
390                       "a Knight Keyboard?  There's no way she's going "
391                       "to give that up.")))
392         ((member direct-obj disc-platter-goes-by)
393          'TODO)
394         (else
395          (<- player 'tell
396              #:text
397              `("Hackthena doesn't appear to be holding " ,direct-obj
398                ".")))))
399
400
401 (define grand-hallway
402   (lol
403    ('grand-hallway
404     <room> #f
405     #:name "Grand Hallway"
406     #:desc '((p "  A majestic red carpet runs down the center of the room.
407 Busts of serious looking people line the walls, but there's no
408 clear indication that they have any logical relation to this place.")
409              (p "In the center is a large statue of a woman in a warrior's
410 pose, but something is strange about her weapon and shield.  You wonder what
411 that's all about?")
412              (p "To the south is the lobby.  A door to the east is labeled \"smoking
413 room\", while a door to the west is labeled \"playroom\"."))
414     #:exits
415     (list (make <exit>
416             #:name "south"
417             #:to 'lobby)
418           (make <exit>
419             #:name "west"
420             #:to 'playroom)
421           (make <exit>
422             #:name "east"
423             #:to 'smoking-parlor)))
424    ('grand-hallway:hackthena-statue
425     <hackthena> 'grand-hallway
426     #:name "a statue"
427     #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
428 spirit\".  You've heard of Hackthena... not a goddess, but spiritual protector of
429 all good hacks, and legendary hacker herself.")
430              (p "Hackthena holds the form of a human woman.  She wears flowing
431 robes, has a pear of curly bovine-esque horns protruding from the sides of her
432 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
433 But instead of a weapon, she seems to hold some sort of keyboard.  And her
434 shield... well it's round like a shield, but something seems off about it.
435 You'd better take a closer look to be sure."))
436     #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena"))
437    ('grand-hallway:keyboard
438     <gameobj> 'grand-hallway
439     #:name "a Knight Keyboard"
440     #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
441 Any space cadet can see that with that kind of layout a hack-and-slayer could
442 thrash out some serious key-chords like there's no tomorrow.  You guess
443 Hackthena must be an emacs user."
444     #:invisible? #t
445     #:goes-by '("knight keyboard" "keyboard"))
446    ('grand-hallway:disc-platter
447     <gameobj> 'grand-hallway
448     #:name "a hard disc platter"
449     #:desc "This isn't a shield after all, it seems to be a hard disc
450 platter!  It looks kind of loose..."
451     #:invisible? #t
452     #:goes-by '("hard disc platter" "disc platter" "disc" "shield" "platter"))))
453
454 \f
455 ;;; Playroom
456 ;;; --------
457
458 (define playroom
459   (lol
460    ('playroom
461     <room> #f
462     #:name "The Playroom"
463     #:desc "  There are toys scattered everywhere here.  It's really unclear
464 if this room is intended for children or child-like adults."
465     #:exits
466     (list (make <exit>
467             #:name "east"
468             #:to 'grand-hallway)))
469    ('playroom:cubey
470     <gameobj> 'playroom
471     #:name "cubey"
472     #:take-me? #t
473     #:desc "  It's a little foam cube with googly eyes on it.  So cute!")
474    ('playroom:cuddles-plushie
475     <gameobj> 'playroom
476     #:name "a cuddles plushie"
477     #:goes-by '("plushie" "cuddles plushie" "cuddles")
478     #:take-me? #t
479     #:desc "  A warm and fuzzy cuddles plushie!  It's a cuddlefish!")
480
481    ('playroom:toy-chest
482     <gameobj> 'playroom
483     #:name "a toy chest"
484     #:goes-by '("toy chest" "chest")
485     #:desc (lambda (toy-chest whos-looking)
486              (let ((contents (gameobj-occupants toy-chest)))
487                `((p "A brightly painted wooden chest.  The word \"TOYS\" is "
488                     "engraved on it.")
489                  (p "Inside you see:"
490                     ,(if (eq? contents '())
491                          " nothing!  It's empty!"
492                          `(ul ,(map (lambda (occupant)
493                                       `(li ,(mbody-val
494                                              (<-wait occupant 'get-name))))
495                                     (gameobj-occupants toy-chest))))))))
496     #:take-from-me? #t
497     #:put-in-me? #t)
498
499    ;; Things inside the toy chest
500    ('playroom:toy-chest:rubber-duck
501     <gameobj> 'playroom:toy-chest
502     #:name "a rubber duck"
503     #:goes-by '("rubber duck" "duck")
504     #:take-me? #t
505     #:desc "It's a yellow rubber duck with a bright orange beak.")))
506
507
508 \f
509 ;;; Writing room
510 ;;; ------------
511
512 \f
513 ;;; Armory???
514 ;;; ---------
515
516 ;; ... full of NURPH weapons?
517
518 \f
519 ;;; Smoking parlor
520 ;;; --------------
521
522 (define-class <furniture> (<gameobj>)
523   (sit-phrase #:init-keyword #:sit-phrase)
524   (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
525   (sit-name #:init-keyword #:sit-name)
526
527   (commands
528    #:allocation #:each-subclass
529    #:init-thunk (build-commands
530                  ("sit" ((direct-command cmd-sit-furniture)))))
531   (actions #:allocation #:each-subclass
532            #:init-thunk (build-actions
533                          (cmd-sit-furniture furniture-cmd-sit))))
534
535 (define* (furniture-cmd-sit actor message #:key direct-obj)
536   (define player-name
537     (mbody-val (<-wait (message-from message) 'get-name)))
538   (<- (message-from message) 'tell
539       #:text (format #f "You ~a ~a.\n"
540                      (slot-ref actor 'sit-phrase)
541                      (slot-ref actor 'sit-name)))
542   (<- (slot-ref actor 'loc) 'tell-room
543       #:text (format #f "~a ~a on ~a.\n"
544                      player-name
545                      (slot-ref actor 'sit-phrase-third-person)
546                      (slot-ref actor 'sit-name))
547       #:exclude (message-from message)))
548
549
550 (define smoking-parlor
551   (lol
552    ('smoking-parlor
553     <room> #f
554     #:name "Smoking Parlor"
555     #:desc
556     '((p "This room looks quite posh.  There are huge comfy seats you can sit in
557 if you like. Strangely, you see a large sign saying \"No Smoking\".  The owners must
558 have installed this place and then changed their mind later.")
559       (p "There's a door to the west leading back to the grand hallway, and
560 a nondescript steel door to the south, leading apparently outside."))
561     #:exits
562     (list (make <exit>
563             #:name "west"
564             #:to 'grand-hallway)
565           (make <exit>
566             #:name "south"
567             #:to 'break-room)))
568    ('smoking-parlor:chair
569     <furniture> 'smoking-parlor
570     #:name "a comfy leather chair"
571     #:desc "  That leather chair looks really comfy!"
572     #:goes-by '("leather chair" "comfy leather chair" "chair")
573     #:sit-phrase "sink into"
574     #:sit-phrase-third-person "sinks into"
575     #:sit-name "the comfy leather chair")
576    ('smoking-parlor:sofa
577     <furniture> 'smoking-parlor
578     #:name "a plush leather sofa"
579     #:desc "  That leather chair looks really comfy!"
580     #:goes-by '("leather sofa" "plush leather sofa" "sofa"
581                 "leather couch" "plush leather couch" "couch")
582     #:sit-phrase "sprawl out on"
583     #:sit-phrase-third-person "sprawls out on into"
584     #:sit-name "the plush leather couch")
585    ('smoking-parlor:bar-stool
586     <furniture> 'smoking-parlor
587     #:name "a bar stool"
588     #:desc "  Conveniently located near the bar!  Not the most comfortable
589 seat in the room, though."
590     #:goes-by '("stool" "bar stool" "seat")
591     #:sit-phrase "hop on"
592     #:sit-phrase-third-person "hops onto"
593     #:sit-name "the bar stool")
594    ('ford-prefect
595     <chatty-npc> 'smoking-parlor
596     #:name "Ford Prefect"
597     #:desc "Just some guy, you know?"
598     #:goes-by '("Ford Prefect" "ford prefect"
599                 "frood" "prefect" "ford")
600     #:catchphrases prefect-quotes)
601
602    ('smoking-parlor:no-smoking-sign
603     <gameobj> 'smoking-parlor
604     #:invisible? #t
605     #:name "No Smoking Sign"
606     #:desc "This sign says \"No Smoking\" in big, red letters.
607 It has some bits of bubble gum stuck to it... yuck."
608     #:goes-by '("no smoking sign" "sign"))
609
610    ;; TODO: Cigar dispenser
611    ))
612
613 \f
614
615 ;;; Breakroom
616 ;;; ---------
617
618 (define-class <desk-clerk> (<gameobj>)
619   ;; The desk clerk has three states:
620   ;;  - on-duty: Arrived, and waiting for instructions (and losing patience
621   ;;    gradually)
622   ;;  - slacking: In the break room, probably smoking a cigarette
623   ;;    or checking text messages
624   (state #:init-value 'slacking)
625   (commands #:allocation #:each-subclass
626             #:init-thunk
627             (build-commands
628              (("talk" "chat") ((direct-command cmd-chat)))
629              ("ask" ((direct-command cmd-ask-incomplete)
630                      (prep-direct-command cmd-ask-about)))
631              ("dismiss" ((direct-command cmd-dismiss)))))
632   (patience #:init-value 0)
633   (actions #:allocation #:each-subclass
634            #:init-thunk (build-actions
635                          (init clerk-act-init)
636                          (cmd-chat clerk-cmd-chat)
637                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
638                          (cmd-ask-about clerk-cmd-ask)
639                          (cmd-dismiss clerk-cmd-dismiss)
640                          (update-loop clerk-act-update-loop)
641                          (be-summoned clerk-act-be-summoned))))
642
643 (define (clerk-act-init clerk message . _)
644   ;; call the gameobj main init method
645   (gameobj-act-init clerk message)
646   ;; start our main loop
647   (<- (actor-id clerk) 'update-loop))
648
649 (define clerk-help-topics
650   '(("changing name" .
651      "Changing your name is easy!  We have a clipboard here at the desk
652 where you can make yourself known to other participants in the hotel
653 if you sign it.  Try 'sign form as <your-name>', replacing
654 <your-name>, obviously!")
655     ("common commands" .
656      "Here are some useful commands you might like to try: chat,
657 go, take, drop, say...")
658     ("hotel" .
659      "We hope you enjoy your stay at Hotel Bricabrac.  As you may see,
660 our hotel emphasizes interesting experiences over rest and lodging.
661 The origins of the hotel are... unclear... and it has recently come
662 under new... 'management'.  But at Hotel Bricabrac we believe these
663 aspects make the hotel into a fun and unique experience!  Please,
664 feel free to walk around and explore.")))
665
666
667 (define clerk-knows-about
668   "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
669
670 (define clerk-general-helpful-line
671   (string-append
672    "The clerk says, \"If you need help with anything, feel free to ask me about it.
673 For example, 'ask clerk about changing name'. You can ask me about the following:
674 " clerk-knows-about ".\"\n"))
675
676 (define clerk-slacking-complaints
677   '("The pay here is absolutely lousy."
678     "The owner here has no idea what they're doing."
679     "Some times you just gotta step away, you know?"
680     "You as exhausted as I am?"
681     "Yeah well, this is just temporary.  I'm studying to be a high
682 energy particle physicist.  But ya gotta pay the bills, especially
683 with tuition at where it is..."))
684
685 (define* (clerk-cmd-chat clerk message #:key direct-obj)
686   (match (slot-ref clerk 'state)
687     ('on-duty
688      (<- (message-from message) 'tell
689          #:text clerk-general-helpful-line))
690     ('slacking
691      (<- (message-from message) 'tell
692          #:text
693          (string-append
694           "The clerk says, \""
695           (random-choice clerk-slacking-complaints)
696           "\"\n")))))
697
698 (define (clerk-cmd-ask-incomplete clerk message . _)
699   (<- (message-from message) 'tell
700       #:text "The clerk says, \"Ask about what?\"\n"))
701
702 (define clerk-doesnt-know-text
703   "The clerk apologizes and says she doesn't know about that topic.\n")
704
705 (define* (clerk-cmd-ask clerk message #:key indir-obj
706                         #:allow-other-keys)
707   (match (slot-ref clerk 'state)
708     ('on-duty
709      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
710        ((_ . info)
711            (<- (message-from message) 'tell
712                #:text
713                (string-append "The clerk clears her throat and says:\n  \""
714                               info
715                               "\"\n")))
716        (#f
717         (<- (message-from message) 'tell
718             #:text clerk-doesnt-know-text))))
719     ('slacking
720      (<- (message-from message) 'tell
721          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
722
723 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
724   (match (slot-ref clerk 'state)
725     ('on-duty
726      (<- who-summoned 'tell
727          #:text
728          "The clerk tells you as politely as she can that she's already here,
729 so there's no need to ring the bell.\n"))
730     ('slacking
731      (<- (gameobj-loc clerk) 'tell-room
732          #:text
733          "The clerk's ears perk up, she stamps out a cigarette, and she
734 runs out of the room!\n")
735      (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
736      (slot-set! clerk 'patience 8)
737      (slot-set! clerk 'state 'on-duty)
738      (<- (gameobj-loc clerk) 'tell-room
739          #:text
740          (string-append
741           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
742 badge that says \"Desk Clerk\".
743   \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
744 We look forward to your stay.  If you'd like help getting acclimated,
745 feel free to ask me.  For example, 'ask clerk about changing name'.
746 You can ask me about the following:
747 " clerk-knows-about ".\"\n")))))
748
749 (define* (clerk-cmd-dismiss clerk message . _)
750   (define player-name
751     (mbody-val (<-wait (message-from message) 'get-name)))
752   (match (slot-ref clerk 'state)
753     ('on-duty
754      (<- (gameobj-loc clerk) 'tell-room
755          #:text
756          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
757 The clerk leaves the room in a hurry.\n"
758                  player-name)
759          #:exclude (actor-id clerk))
760      (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
761      (slot-set! clerk 'state 'slacking)
762      (<- (gameobj-loc clerk) 'tell-room
763          #:text clerk-return-to-slacking-text
764          #:exclude (actor-id clerk)))
765     ('slacking
766      (<- (message-from message) 'tell
767          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
768
769 (define clerk-slacking-texts
770   '("The clerk takes a long drag on her cigarette.\n"
771     "The clerk scrolls through text messages on her phone.\n"
772     "The clerk coughs a few times.\n"
773     "The clerk checks her watch and justifies a few more minutes outside.\n"
774     "The clerk fumbles around for a lighter.\n"
775     "The clerk sighs deeply and exhaustedly.\n"
776     "The clerk fumbles around for a cigarette.\n"))
777
778 (define clerk-working-impatience-texts
779   '("The clerk hums something, but you're not sure what it is."
780     "The clerk attempts to change the overhead music, but the dial seems broken."
781     "The clerk clicks around on the desk computer."
782     "The clerk scribbles an equation on a memo pad, then crosses it out."
783     "The clerk mutters something about the proprietor having no idea how to run a hotel."
784     "The clerk thumbs through a printout of some physics paper."))
785
786 (define clerk-slack-excuse-text
787   "The desk clerk excuses herself, but says you are welcome to ring the bell
788 if you need further help.")
789
790 (define clerk-return-to-slacking-text
791   "The desk clerk enters and slams the door behind her.\n")
792
793
794 (define (clerk-act-update-loop clerk message)
795   (define (tell-room text)
796     (<- (gameobj-loc clerk) 'tell-room
797         #:text text
798         #:exclude (actor-id clerk)))
799   (define (loop-if-not-destructed)
800     (if (not (slot-ref clerk 'destructed))
801         ;; This iterates by "recursing" on itself by calling itself
802         ;; (as the message handler) again.  It used to be that we had to do
803         ;; this, because there was a bug where a loop which yielded like this
804         ;; would keep growing the stack due to some parameter goofiness.
805         ;; That's no longer true, but there's an added advantage to this
806         ;; route: it's much more live hackable.  If we change the definition
807         ;; of this method, the character will act differently on the next
808         ;; "tick" of the loop.
809         (<- (actor-id clerk) 'update-loop)))
810   (match (slot-ref clerk 'state)
811     ('slacking
812      (tell-room (random-choice clerk-slacking-texts))
813      (8sleep (+ (random 20) 15))
814      (loop-if-not-destructed))
815     ('on-duty
816      (if (> (slot-ref clerk 'patience) 0)
817          ;; Keep working but lose patience gradually
818          (begin
819            (tell-room (random-choice clerk-working-impatience-texts))
820            (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
821                                          (+ (random 2) 1)))
822            (8sleep (+ (random 60) 40))
823            (loop-if-not-destructed))
824          ;; Back to slacking
825          (begin
826            (tell-room clerk-slack-excuse-text)
827            ;; back bto the break room
828            (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'break-room)))
829            (tell-room clerk-return-to-slacking-text)
830            ;; annnnnd back to slacking
831            (slot-set! clerk 'state 'slacking)
832            (8sleep (+ (random 30) 15))
833            (loop-if-not-destructed))))))
834
835
836 (define break-room
837   (lol
838    ('break-room
839     <room> #f
840     #:name "Employee Break Room"
841     #:desc "  This is less a room and more of an outdoor wire cage.  You get
842 a bit of a view of the brick exterior of the building, and a crisp wind blows,
843 whistling, through the openings of the fenced area.  Partly smoked cigarettes
844 and various other debris cover the floor.
845   Through the wires you can see... well... hm.  It looks oddly like
846 the scenery tapers off nothingness.  But that can't be right, can it?"
847     #:exits
848     (list (make <exit>
849             #:name "north"
850             #:to 'smoking-parlor)))
851    ('break-room:desk-clerk
852     <desk-clerk> 'break-room
853     #:name "the hotel desk clerk"
854     #:desc "  The hotel clerk is wearing a neatly pressed uniform bearing the
855 hotel insignia.  She appears to be rather exhausted."
856     #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
857    ('break-room:void
858     <gameobj> 'break-room
859     #:invisible? #t
860     #:name "The Void"
861     #:desc "As you stare into the void, the void stares back into you."
862     #:goes-by '("void" "abyss" "nothingness" "scenery"))
863    ('break-room:fence
864     <gameobj> 'break-room
865     #:invisible? #t
866     #:name "break room cage"
867     #:desc "It's a mostly-cubical wire mesh surrounding the break area.
868 You can see through the gaps, but they're too small to put more than a
869 couple of fingers through.  There appears to be some wear and tear to
870 the paint, but the wires themselves seem to be unusually sturdy."
871     #:goes-by '("fence" "cage" "wire cage"))))
872
873
874 \f
875 ;;; Ennpie's Sea Lounge
876 ;;; -------------------
877
878 \f
879 ;;; Computer room
880 ;;; -------------
881
882 \f
883 ;;; Game
884 ;;; ----
885
886 (define (game-spec)
887   (append lobby grand-hallway smoking-parlor
888           playroom break-room))
889
890 ;; TODO: Provide command line args
891 (define (run-game . args)
892   (run-demo (game-spec) 'lobby #:repl-server #t))
893