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)
23 (8sync systems actors)
31 ;;; Utilities, useful or otherwise
32 ;;; ==============================
34 (set! *random-state* (random-state-from-platform))
36 (define (random-choice lst)
37 (list-ref lst (random (length lst))))
39 ;; list of lists, lol.
40 (define-syntax-rule (lol (list-contents ...) ...)
41 (list (list list-contents ...) ...))
44 ;;; Some simple object types.
45 ;;; =========================
47 (define readable-commands
49 (direct-command "read" 'cmd-read)))
50 (define readable-actions
52 (cmd-read (wrap-apply readable-cmd-read))))
54 (define-class <readable> (<gameobj>)
55 (read-text #:init-value "All it says is: \"Blah blah blah.\""
56 #:init-keyword #:read-text)
58 #:init-value readable-commands)
61 (simple-dispatcher (append gameobj-actions readable-actions))))
63 (define (readable-cmd-read actor message)
64 (<- actor (message-from message) 'tell
65 #:text (string-append (slot-ref actor 'read-text) "\n")))
72 (define-mhandler (npc-chat-randomly actor message)
74 (format #f "~a says: \"~a\"\n"
75 (slot-ref actor 'name)
76 (random-choice (slot-ref actor 'catchphrases))))
77 (<- actor (message-from message) 'tell
82 (direct-command "chat" 'cmd-chat)
83 (direct-command "talk" 'cmd-chat)))
86 (cmd-chat (wrap-apply npc-chat-randomly))))
88 (define hotel-owner-grumps
89 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
90 "Don't mind the mess. I built this place on a dare, you
92 "(*tearfully*) Here, take this parenthesis. May it serve
94 "I gotta get back to the goblin farm soon..."
95 "Oh, but I was going to make a mansion... a great,
96 beautiful mansion! Full of ghosts! Now all I have is this cruddy
97 mo... hotel. Oh... If only I had more time!"
98 "I told them to paint more of the walls purple.
99 Why didn't they listen?"
100 "Listen to that overhead muzak. Whoever made that doesn't
101 know how to compose very well! Have you heard of the bands 'fmt'
102 or 'skribe'? Now *that's* composition!"))
104 (define-class <chatty-npc> (<gameobj>)
105 (catchphrases #:init-value '("Blarga blarga blarga!")
106 #:init-keyword #:catchphrases)
108 #:init-value chat-commands)
111 (simple-dispatcher (append gameobj-actions chat-actions))))
113 (define random-bricabrac
114 '("a creepy porcelain doll"
115 "assorted 1950s robots"
116 "an exquisite tea set"
117 "an antique mustard pot"
118 "the pickled head of Elvis"
119 "the pickled circuitboard of EVLIS"
120 "a scroll of teletype paper holding the software Four Freedoms"
121 "a telephone shaped like an orange cartoon cat"))
123 (define-class <sign-in-form> (<gameobj>)
127 (indir-as-direct-command "sign" 'cmd-sign-form
134 (cmd-sign-form (wrap-apply sign-cmd-sign-in)))
139 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
141 (define forbidden-words
142 (append article preposition
143 '("and" "or" "but" "admin")))
145 (define (valid-name? name)
146 (and (irregex-match name-sre name)
147 (not (member name forbidden-words))))
149 (define-mhandler (sign-cmd-sign-in actor message direct-obj indir-obj)
152 (<-wait actor (message-from message) 'get-name)
154 (define name indir-obj)
155 (if (valid-name? indir-obj)
157 (<-wait actor (message-from message) 'set-name!
159 (<- actor (slot-ref actor 'loc) 'tell-room
160 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
161 old-name old-name name)))
162 (<- actor (message-from message) 'tell
163 "Sorry, that's not a valid name.
164 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
174 " You're in some sort of hotel lobby. You see a large sign hanging
175 over the desk that says \"Hotel Bricabrac\". On the desk is a bell
176 that says \"ring for service\". Terrible music plays from a speaker
178 The room is lined with various curio cabinets, filled with all sorts
179 of kitschy junk. It looks like whoever decorated this place had great
180 ambitions, but actually assembled it all in a hurry and used whatever
181 kind of objects they found lying around.
182 There's a door to the north leading to some kind of hallway."
186 #:to 'room:grand-hallway)))
189 <chatty-npc> 'room:lobby
190 #:name "a frumpy fellow"
191 #:desc " Whoever this is, they looks totally exhausted. They're
192 collapsed into the only comfortable looking chair in the room and you
193 don't get the sense that they're likely to move any time soon.
194 You notice they're wearing a sticker badly adhesed to their clothing
195 which says \"Hotel Proprietor\", but they look so disorganized that you
196 think that can't possibly be true... can it?
197 Despite their exhaustion, you sense they'd be happy to chat with you,
198 though the conversation may be a bit one sided."
199 #:goes-by '("frumpy fellow" "fellow"
200 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
201 "hotel proprietor" "proprietor")
202 #:catchphrases hotel-owner-grumps)
203 ;; NPC: desk clerk (comes when you ring the s)
204 ;; impatient teenager, only stays around for a few minutes
205 ;; complaining, then leaves.
209 <readable> 'room:lobby
210 #:name "the Hotel Bricabrac sign"
211 #:desc " It strikes you that there's something funny going on with this sign.
212 Sure enough, if you look at it hard enough, you can tell that someone
213 hastily painted over an existing sign and changed the \"M\" to an \"H\".
215 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
219 "hotel bricabrac sign"
222 ;; Object: curio cabinets
224 <gameobj> 'room:lobby
225 #:name "a curio cabinet"
226 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
228 (format #f " The curio cabinet is full of all sorts of oddities!
229 Something catches your eye!
230 Ooh, ~a!" (random-choice random-bricabrac))))
232 <sign-in-form> 'room:lobby
233 #:name "sign-in form"
234 #:goes-by '("sign-in form" "form" "signin form")
235 #:desc "It looks like you could sign this form and set your name.")
238 ;; - Object: sign in form
239 ;; - Object: pamphlet
240 ;; Object: <invisible bell>: reprimands that you want to ring the
250 (define grand-hallway
254 #:name "Grand Hallway"
255 #:desc " A majestic red carpet runs down the center of the room.
256 Busts of serious looking people line the walls, but there's no
257 clear indication that they have any logical relation to this place.
258 To the south is the lobby. All around are various doors, but
259 they're all boarded up. Guess this is still a work in progress, huh?"
278 ;; ... full of NURPH weapons?
286 ;;; Ennpie's Sea Lounge
287 ;;; -------------------
298 (append lobby grand-hallway))
300 ;; TODO: Provide command line args
301 (define (run-game . args)
302 (run-demo game-spec 'room:lobby #:repl-server #t))