Add no smoking sign to smoking parlor
[mudsync.git] / worlds / bricabrac.scm
index e5392aaa428222699a8012e7046e48c76545d20a..e4014656086d840d59de217966c9d51f130788f4 100644 (file)
@@ -20,7 +20,7 @@
 
 (use-modules (mudsync)
              (mudsync parser)
-             (8sync systems actors)
+             (8sync actors)
              (8sync agenda)
              (oop goops)
              (ice-9 control)
   (commands
    #:init-value readable-commands*)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-read readable-cmd-read))))
 
 (define (readable-cmd-read actor message)
-  (<- actor (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text (string-append (slot-ref actor 'read-text) "\n")))
 
 
@@ -77,7 +77,7 @@
     (format #f "~a says: \"~a\"\n"
             (slot-ref actor 'name)
             (random-choice (slot-ref actor 'catchphrases))))
-  (<- actor (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text text-to-send))
 
 (define chat-commands
@@ -108,7 +108,7 @@ or 'skribe'?  Now *that's* composition!"))
    #:init-value chat-commands)
   (actions #:allocation #:each-subclass
            #:init-value
-           (mhandlers
+           (build-actions
             (cmd-chat npc-chat-randomly))))
 
 (define random-bricabrac
@@ -128,7 +128,7 @@ or 'skribe'?  Now *that's* composition!"))
     (prep-direct-command "sign" 'cmd-sign-form
                          '("as"))))
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-sign-form sign-cmd-sign-in))))
 
 
@@ -146,15 +146,15 @@ or 'skribe'?  Now *that's* composition!"))
 (define* (sign-cmd-sign-in actor message
                            #:key direct-obj indir-obj preposition)
   (define old-name
-    (msg-val (<-wait actor (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
   (define name indir-obj)
   (if (valid-name? indir-obj)
       (begin
-        (<-wait actor (message-from message) 'set-name! name)
-        (<- actor (slot-ref actor 'loc) 'tell-room
+        (<-wait (message-from message) 'set-name! name)
+        (<- (slot-ref actor 'loc) 'tell-room
             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
                            old-name old-name name)))
-      (<- actor (message-from message) 'tell
+      (<- (message-from message) 'tell
           #:text "Sorry, that's not a valid name.
 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
 character.\n")))
@@ -173,7 +173,7 @@ character.\n")))
   (commands
    #:init-value summoning-bell-commands*)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-ring summoning-bell-cmd-ring))))
 
 (define* (summoning-bell-cmd-ring bell message . _)
@@ -182,13 +182,13 @@ character.\n")))
   ;; handler... meanwhile, this procedure suspends until we get
   ;; their response.
   (define who-rang
-    (msg-val (<-wait bell (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
 
   ;; Now we'll invoke the "tell" message handler on the player
   ;; who rang us, displaying this text on their screen.
   ;; This one just uses <- instead of <-wait, since we don't
   ;; care when it's delivered; we're not following up on it.
-  (<- bell (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text "*ring ring!*  You ring the bell!\n")
   ;; We also want everyone else in the room to "hear" the bell,
   ;; but they get a different message since they aren't the ones
@@ -196,7 +196,7 @@ character.\n")))
   ;; name as extracted and assigned to the who-rang variable.
   ;; Notice how we send this message to our "location", which
   ;; forwards it to the rest of the occupants in the room.
-  (<- bell (gameobj-loc bell) 'tell-room
+  (<- (gameobj-loc bell) 'tell-room
       #:text
       (format #f "*ring ring!*  ~a rings the bell!\n"
               who-rang)
@@ -204,7 +204,7 @@ character.\n")))
   ;; Now we perform the primary task of the bell, which is to summon
   ;; the "clerk" character to the room.  (This is configurable,
   ;; so we dynamically look up their address.)
-  (<- bell (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
+  (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
       #:who-summoned (message-from message)))
 
 
@@ -221,15 +221,15 @@ character.\n")))
     <room> #f
     #:name "Hotel Lobby"
     #:desc
-    "  You're in some sort of hotel lobby.  You see a large sign hanging
-over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
-that says \"ring for service\".  Terrible music plays from a speaker
-somewhere overhead.
-  The room is lined with various curio cabinets, filled with all sorts
-of kitschy junk.  It looks like whoever decorated this place had great
-ambitions, but actually assembled it all in a hurry and used whatever
-kind of objects they found lying around.
-  There's a door to the north leading to some kind of hallway."
+    '((p "You're in some sort of hotel lobby.  You see a large sign hanging "
+         "over the desk that says \"Hotel Bricabrac\".  On the desk is a bell "
+         "that says \"'ring bell' for service\".  Terrible music plays from a speaker "
+         "somewhere overhead.  "
+         "The room is lined with various curio cabinets, filled with all sorts "
+         "of kitschy junk.  It looks like whoever decorated this place had great "
+         "ambitions, but actually assembled it all in a hurry and used whatever "
+         "kind of objects they found lying around.")
+      (p "There's a door to the north leading to some kind of hallway."))
     #:exits
     (list (make <exit>
             #:name "north"
@@ -238,14 +238,15 @@ kind of objects they found lying around.
    ('npc:lobby:hotel-owner
     <chatty-npc> 'room:lobby
     #:name "a frumpy fellow"
-    #:desc "  Whoever this is, they looks totally exhausted.  They're
+    #:desc
+    '((p "  Whoever this is, they looks totally exhausted.  They're
 collapsed into the only comfortable looking chair in the room and you
 don't get the sense that they're likely to move any time soon.
   You notice they're wearing a sticker badly adhesed to their clothing
 which says \"Hotel Proprietor\", but they look so disorganized that you
 think that can't possibly be true... can it?
   Despite their exhaustion, you sense they'd be happy to chat with you,
-though the conversation may be a bit one sided."
+though the conversation may be a bit one sided."))
     #:goes-by '("frumpy fellow" "fellow"
                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
                 "hotel proprietor" "proprietor")
@@ -385,17 +386,17 @@ if this room is intended for children or child-like adults."
    (list
     (direct-command "sit" 'cmd-sit-furniture)))
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-sit-furniture furniture-cmd-sit))))
 
 (define* (furniture-cmd-sit actor message #:key direct-obj)
   (define player-name
-    (msg-val (<-wait actor (message-from message) 'get-name)))
-  (<- actor (message-from message) 'tell
+    (mbody-val (<-wait (message-from message) 'get-name)))
+  (<- (message-from message) 'tell
       #:text (format #f "You ~a ~a.\n"
                      (slot-ref actor 'sit-phrase)
                      (slot-ref actor 'sit-name)))
-  (<- actor (slot-ref actor 'loc) 'tell-room
+  (<- (slot-ref actor 'loc) 'tell-room
       #:text (format #f "~a ~a on ~a.\n"
                      player-name
                      (slot-ref actor 'sit-phrase-third-person)
@@ -408,12 +409,12 @@ if this room is intended for children or child-like adults."
    ('room:smoking-parlor
     <room> #f
     #:name "Smoking Parlor"
-    #:desc "  This room looks quite posh.  There are huge comfy seats you can sit in
-if you like.
-  Strangely, you see a large sign saying \"No Smoking\".  The owners must
-have installed this place and then changed their mind later.
-  There's a door to the west leading back to the grand hallway, and
-a nondescript steel door to the south, leading apparently outside."
+    #:desc
+    '((p "This room looks quite posh.  There are huge comfy seats you can sit in
+if you like. Strangely, you see a large sign saying \"No Smoking\".  The owners must
+have installed this place and then changed their mind later.")
+      (p "There's a door to the west leading back to the grand hallway, and
+a nondescript steel door to the south, leading apparently outside."))
     #:exits
     (list (make <exit>
             #:name "west"
@@ -421,7 +422,7 @@ a nondescript steel door to the south, leading apparently outside."
           (make <exit>
             #:name "south"
             #:to 'room:break-room)))
-   ('thing:smoking-room:chair
+   ('thing:smoking-parlor:chair
     <furniture> 'room:smoking-parlor
     #:name "a comfy leather chair"
     #:desc "  That leather chair looks really comfy!"
@@ -429,7 +430,7 @@ a nondescript steel door to the south, leading apparently outside."
     #:sit-phrase "sink into"
     #:sit-phrase-third-person "sinks into"
     #:sit-name "the comfy leather chair")
-   ('thing:smoking-room:sofa
+   ('thing:smoking-parlor:sofa
     <furniture> 'room:smoking-parlor
     #:name "a plush leather sofa"
     #:desc "  That leather chair looks really comfy!"
@@ -438,7 +439,7 @@ a nondescript steel door to the south, leading apparently outside."
     #:sit-phrase "sprawl out on"
     #:sit-phrase-third-person "sprawls out on into"
     #:sit-name "the plush leather couch")
-   ('thing:smoking-room:bar-stool
+   ('thing:smoking-parlor:bar-stool
     <furniture> 'room:smoking-parlor
     #:name "a bar stool"
     #:desc "  Conveniently located near the bar!  Not the most comfortable
@@ -455,8 +456,15 @@ seat in the room, though."
                 "frood" "prefect" "ford")
     #:catchphrases prefect-quotes)
 
-   ;; TODO: Cigar dispenser
+   ('thing:smoking-parlor:no-smoking-sign
+    <thing> 'room:smoking-parlor
+    #:generally-visible #f
+    #:name "No Smoking Sign"
+    #:desc "This sign says \"No Smoking\" in big, red letters.
+It has some bits of bubble gum stuck to it... yuck."
+    #:goes-by '("no smoking sign" "sign"))
 
+   ;; TODO: Cigar dispenser
    ))
 
 \f
@@ -484,7 +492,7 @@ seat in the room, though."
   (commands #:init-value clerk-commands*)
   (patience #:init-value 0)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (init clerk-act-init)
                          (cmd-chat clerk-cmd-chat)
                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
@@ -497,7 +505,7 @@ seat in the room, though."
   ;; call the gameobj main init method
   (gameobj-act-init clerk message)
   ;; start our main loop
-  (<- clerk (actor-id clerk) 'update-loop))
+  (<- (actor-id clerk) 'update-loop))
 
 (define clerk-help-topics
   '(("changing name" .
@@ -518,7 +526,7 @@ feel free to walk around and explore.")))
 
 
 (define clerk-knows-about
-  "'changing name', 'common commands', and 'about the hotel'")
+  "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
 
 (define clerk-general-helpful-line
   (string-append
@@ -538,56 +546,57 @@ with tuition at where it is..."))
 (define* (clerk-cmd-chat clerk message #:key direct-obj)
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text clerk-general-helpful-line))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text
          (string-append
           "The clerk says, \""
           (random-choice clerk-slacking-complaints)
           "\"\n")))))
 
-(define (clerk-cmd-ask-incomplete clerk message)
-  (<- clerk (message-from message) 'tell
+(define (clerk-cmd-ask-incomplete clerk message . _)
+  (<- (message-from message) 'tell
       #:text "The clerk says, \"Ask about what?\"\n"))
 
 (define clerk-doesnt-know-text
   "The clerk apologizes and says she doesn't know about that topic.\n")
 
-(define (clerk-cmd-ask clerk message indir-obj)
+(define* (clerk-cmd-ask clerk message #:key indir-obj
+                        #:allow-other-keys)
   (match (slot-ref clerk 'state)
     ('on-duty
      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
        ((_ . info)
-           (<- clerk (message-from message) 'tell
+           (<- (message-from message) 'tell
                #:text
                (string-append "The clerk clears her throat and says:\n  \""
                               info
                               "\"\n")))
        (#f
-        (<- clerk (message-from message) 'tell
+        (<- (message-from message) 'tell
             #:text clerk-doesnt-know-text))))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
 
 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk who-summoned 'tell
+     (<- who-summoned 'tell
          #:text
          "The clerk tells you as politely as she can that she's already here,
 so there's no need to ring the bell.\n"))
     ('slacking
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          "The clerk's ears perk up, she stamps out a cigarette, and she
 runs out of the room!\n")
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
      (slot-set! clerk 'patience 8)
      (slot-set! clerk 'state 'on-duty)
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          (string-append
           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
@@ -600,10 +609,10 @@ You can ask me about the following:
 
 (define* (clerk-cmd-dismiss clerk message . _)
   (define player-name
-    (msg-val (<-wait clerk (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
 The clerk leaves the room in a hurry.\n"
@@ -611,11 +620,11 @@ The clerk leaves the room in a hurry.\n"
          #:exclude (actor-id clerk))
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
      (slot-set! clerk 'state 'slacking)
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text clerk-return-to-slacking-text
          #:exclude (actor-id clerk)))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
 
 (define clerk-slacking-texts
@@ -634,7 +643,9 @@ The clerk leaves the room in a hurry.\n"
     "The clerk takes a deep breath.\n"
     "The clerk yawns.\n"
     "The clerk drums her nails on the counter.\n"
-    "The clerk clicks around on the desk computer.\n"))
+    "The clerk clicks around on the desk computer.\n"
+    "The clerk thumbs through a printout of some physics paper.\n"
+    "The clerk mutters that her dissertation isn't going to write itself.\n"))
 
 (define clerk-slack-excuse-text
   "The desk clerk excuses herself, claiming she has important things to
@@ -646,7 +657,7 @@ attend to.\n")
 
 (define (clerk-act-update-loop clerk message)
   (define (tell-room text)
-    (<- clerk (gameobj-loc clerk) 'tell-room
+    (<- (gameobj-loc clerk) 'tell-room
         #:text text
         #:exclude (actor-id clerk)))
   (define (loop-if-not-destructed)
@@ -659,7 +670,7 @@ attend to.\n")
         ;; route: it's much more live hackable.  If we change the definition
         ;; of this method, the character will act differently on the next
         ;; "tick" of the loop.
-        (<- clerk (actor-id clerk) 'update-loop)))
+        (<- (actor-id clerk) 'update-loop)))
   (match (slot-ref clerk 'state)
     ('slacking
      (tell-room (random-choice clerk-slacking-texts))
@@ -722,11 +733,11 @@ hotel insignia.  She looks like she'd much rather be somewhere else."
 ;;; Game
 ;;; ----
 
-(define game-spec
+(define (game-spec)
   (append lobby grand-hallway smoking-parlor
           playroom break-room))
 
 ;; TODO: Provide command line args
 (define (run-game . args)
-  (run-demo game-spec 'room:lobby #:repl-server #t))
+  (run-demo (game-spec) 'room:lobby #:repl-server #t))