Fix code for going someplace that doesn't exist
[mudsync.git] / worlds / bricabrac.scm
index a42be395a7a53cd3bedfc81e86d32f63f24e60a7..3584e87c15dd0376bf91e3b5d16edfbd1936c6fc 100644 (file)
 ;;; Hotel Bricabrac
 
 (use-modules (mudsync)
 ;;; Hotel Bricabrac
 
 (use-modules (mudsync)
+             (mudsync parser)
              (8sync systems actors)
              (8sync agenda)
              (oop goops)
              (8sync systems actors)
              (8sync agenda)
              (oop goops)
-             (ice-9 format))
+             (ice-9 format)
+             (rx irregex))
 
 
 \f
 
 
 \f
@@ -67,9 +69,6 @@
 ;;; Lobby
 ;;; -----
 
 ;;; Lobby
 ;;; -----
 
-(define-class <locked-cabinet> (<gameobj>)
-  )
-
 (define-mhandler (npc-chat-randomly actor message)
   (define text-to-send
     (format #f "~a says: \"~a\"\n"
 (define-mhandler (npc-chat-randomly actor message)
   (define text-to-send
     (format #f "~a says: \"~a\"\n"
 (define hotel-owner-grumps
   '("Eight sinks!  Eight sinks!  And I couldn't unwind them..."
     "Don't mind the mess.  I built this place on a dare, you
 (define hotel-owner-grumps
   '("Eight sinks!  Eight sinks!  And I couldn't unwind them..."
     "Don't mind the mess.  I built this place on a dare, you
-  know?"
+know?"
     "(*tearfully*) Here, take this parenthesis.  May it serve
     "(*tearfully*) Here, take this parenthesis.  May it serve
-  you well."
+you well."
     "I gotta get back to the goblin farm soon..."
     "Oh, but I was going to make a mansion... a great,
     "I gotta get back to the goblin farm soon..."
     "Oh, but I was going to make a mansion... a great,
-  beautiful mansion!  Full of ghosts!  Now all I have is this cruddy
-  mo... hotel.  Oh... If only I had more time!"
+beautiful mansion!  Full of ghosts!  Now all I have is this cruddy
+mo... hotel.  Oh... If only I had more time!"
     "I told them to paint more of the walls purple.
     "I told them to paint more of the walls purple.
-  Why didn't they listen?"
+Why didn't they listen?"
     "Listen to that overhead muzak.  Whoever made that doesn't
     "Listen to that overhead muzak.  Whoever made that doesn't
-  know how to compose very well!  Have you heard of the bands 'fmt'
-  or 'skribe'?  Now *that's* composition!"))
+know how to compose very well!  Have you heard of the bands 'fmt'
+or 'skribe'?  Now *that's* composition!"))
 
 (define-class <chatty-npc> (<gameobj>)
   (catchphrases #:init-value '("Blarga blarga blarga!")
 
 (define-class <chatty-npc> (<gameobj>)
   (catchphrases #:init-value '("Blarga blarga blarga!")
    #:init-value
    (simple-dispatcher (append gameobj-actions chat-actions))))
 
    #:init-value
    (simple-dispatcher (append gameobj-actions chat-actions))))
 
+(define random-bricabrac
+  '("a creepy porcelain doll"
+    "assorted 1950s robots"
+    "an exquisite tea set"
+    "an antique mustard pot"
+    "the pickled head of Elvis"
+    "the pickled circuitboard of EVLIS"
+    "a scroll of teletype paper holding the software Four Freedoms"
+    "a telephone shaped like an orange cartoon cat"))
+
+(define-class <sign-in-form> (<gameobj>)
+  (commands
+   #:init-value
+   (list
+    (indir-as-direct-command "sign" 'cmd-sign-form
+                             '("as"))))
+  (message-handler
+   #:init-value
+   (simple-dispatcher
+    (append
+     (build-actions
+      (cmd-sign-form (wrap-apply sign-cmd-sign-in)))
+     gameobj-actions))))
+
+
+(define name-sre
+  (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
+
+(define forbidden-words
+  (append article preposition
+          '("and" "or" "but" "admin")))
+
+(define (valid-name? name)
+  (and (irregex-match name-sre name)
+       (not (member name forbidden-words))))
+
+(define-mhandler (sign-cmd-sign-in actor message direct-obj indir-obj)
+  (define old-name
+    (message-ref
+     (<-wait actor (message-from message) 'get-name)
+     'val))
+  (define name indir-obj)
+  (if (valid-name? indir-obj)
+      (begin
+        (<-wait actor (message-from message) 'set-name!
+                #:val name)
+        (<- actor (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
+          "Sorry, that's not a valid name.
+Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
+character.")))
+
+
 (define lobby
   (lol
    ('room:lobby
 (define lobby
   (lol
    ('room:lobby
@@ -123,7 +177,12 @@ 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
   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.")
+kind of objects they found lying around.
+  There's a door to the north leading to some kind of hallway."
+    #:exits
+    (list (make <exit>
+            #:name "north"
+            #:to-symbol 'room:grand-hallway)))
    ;; NPC: hotel owner
    ('npc:hotel-owner
     <chatty-npc> 'room:lobby
    ;; NPC: hotel owner
    ('npc:hotel-owner
     <chatty-npc> 'room:lobby
@@ -159,17 +218,50 @@ Classy!"
                 "hotel bricabrac sign"
                 "lobby sign"))
 
                 "hotel bricabrac sign"
                 "lobby sign"))
 
+   ;; Object: curio cabinets
+   ('thing:cabinet
+    <gameobj> 'room:lobby
+    #:name "a curio cabinet"
+    #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
+    #:desc (lambda _
+             (format #f "  The curio cabinet is full of all sorts of oddities!
+Something catches your eye!
+Ooh, ~a!" (random-choice random-bricabrac))))
+   ('thing:sign-in-form
+    <sign-in-form> 'room:lobby
+    #:name "sign-in form"
+    #:goes-by '("sign-in form" "form" "signin form")
+    #:desc "It looks like you could sign this form and set your name.")
    ;; Object: desk
    ;;  - Object: bell
    ;;  - Object: sign in form
    ;;  - Object: pamphlet
    ;; Object: desk
    ;;  - Object: bell
    ;;  - Object: sign in form
    ;;  - Object: pamphlet
-   ;; Object: curio cabinets
    ;; Object: <invisible bell>: reprimands that you want to ring the
    ;;   bell on the desk
    )
   )
 
 
    ;; Object: <invisible bell>: reprimands that you want to ring the
    ;;   bell on the desk
    )
   )
 
 
+\f
+;;; Grand hallway
+;;; -------------
+
+(define grand-hallway
+  (lol
+   ('room:grand-hallway
+    <room> #f
+    #:name "Grand Hallway"
+    #:desc "  A majestic red carpet runs down the center of the room.
+Busts of serious looking people line the walls, but there's no
+clear indication that they have any logical relation to this place.
+  To the south is the lobby.  All around are various doors, but
+they're all boarded up.  Guess this is still a work in progress, huh?"
+    #:exits
+    (list (make <exit>
+            #:name "south"
+            #:to-symbol 'room:lobby))
+    )))
+
 \f
 ;;; Playroom
 ;;; --------
 \f
 ;;; Playroom
 ;;; --------
@@ -202,7 +294,7 @@ Classy!"
 ;;; ----
 
 (define game-spec
 ;;; ----
 
 (define game-spec
-  (append lobby))
+  (append lobby grand-hallway))
 
 (define (run-game . args)
   (run-demo "/tmp/bricabrac-game.db" game-spec 'room:lobby))
 
 (define (run-game . args)
   (run-demo "/tmp/bricabrac-game.db" game-spec 'room:lobby))