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)))
51 (define readable-commands*
52 (append readable-commands
55 (define readable-actions
57 (cmd-read (wrap-apply readable-cmd-read))))
59 (define readable-actions*
60 (append readable-actions
63 (define-class <readable> (<thing>)
64 (read-text #:init-value "All it says is: \"Blah blah blah.\""
65 #:init-keyword #:read-text)
67 #:init-value readable-commands*)
70 (simple-dispatcher readable-actions*)))
72 (define (readable-cmd-read actor message)
73 (<- actor (message-from message) 'tell
74 #:text (string-append (slot-ref actor 'read-text) "\n")))
81 (define-mhandler (npc-chat-randomly actor message)
83 (format #f "~a says: \"~a\"\n"
84 (slot-ref actor 'name)
85 (random-choice (slot-ref actor 'catchphrases))))
86 (<- actor (message-from message) 'tell
91 (direct-command "chat" 'cmd-chat)
92 (direct-command "talk" 'cmd-chat)))
95 (cmd-chat (wrap-apply npc-chat-randomly))))
97 (define hotel-owner-grumps
98 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
99 "Don't mind the mess. I built this place on a dare, you
101 "(*tearfully*) Here, take this parenthesis. May it serve
103 "I gotta get back to the goblin farm soon..."
104 "Oh, but I was going to make a mansion... a great,
105 beautiful mansion! Full of ghosts! Now all I have is this cruddy
106 mo... hotel. Oh... If only I had more time!"
107 "I told them to paint more of the walls purple.
108 Why didn't they listen?"
109 "Listen to that overhead muzak. Whoever made that doesn't
110 know how to compose very well! Have you heard of the bands 'fmt'
111 or 'skribe'? Now *that's* composition!"))
113 (define-class <chatty-npc> (<gameobj>)
114 (catchphrases #:init-value '("Blarga blarga blarga!")
115 #:init-keyword #:catchphrases)
117 #:init-value chat-commands)
120 (simple-dispatcher (append gameobj-actions chat-actions))))
122 (define random-bricabrac
123 '("a creepy porcelain doll"
124 "assorted 1950s robots"
125 "an exquisite tea set"
126 "an antique mustard pot"
127 "the pickled head of Elvis"
128 "the pickled circuitboard of EVLIS"
129 "a scroll of teletype paper holding the software Four Freedoms"
130 "a telephone shaped like an orange cartoon cat"))
132 (define-class <sign-in-form> (<gameobj>)
136 (indir-as-direct-command "sign" 'cmd-sign-form
143 (cmd-sign-form (wrap-apply sign-cmd-sign-in)))
148 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
150 (define forbidden-words
151 (append article preposition
152 '("and" "or" "but" "admin")))
154 (define (valid-name? name)
155 (and (irregex-match name-sre name)
156 (not (member name forbidden-words))))
158 (define-mhandler (sign-cmd-sign-in actor message direct-obj indir-obj)
161 (<-wait actor (message-from message) 'get-name)
163 (define name indir-obj)
164 (if (valid-name? indir-obj)
166 (<-wait actor (message-from message) 'set-name!
168 (<- actor (slot-ref actor 'loc) 'tell-room
169 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
170 old-name old-name name)))
171 (<- actor (message-from message) 'tell
172 #:text "Sorry, that's not a valid name.
173 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
183 " You're in some sort of hotel lobby. You see a large sign hanging
184 over the desk that says \"Hotel Bricabrac\". On the desk is a bell
185 that says \"ring for service\". Terrible music plays from a speaker
187 The room is lined with various curio cabinets, filled with all sorts
188 of kitschy junk. It looks like whoever decorated this place had great
189 ambitions, but actually assembled it all in a hurry and used whatever
190 kind of objects they found lying around.
191 There's a door to the north leading to some kind of hallway."
195 #:to 'room:grand-hallway)))
197 ('npc:lobby:hotel-owner
198 <chatty-npc> 'room:lobby
199 #:name "a frumpy fellow"
200 #:desc " Whoever this is, they looks totally exhausted. They're
201 collapsed into the only comfortable looking chair in the room and you
202 don't get the sense that they're likely to move any time soon.
203 You notice they're wearing a sticker badly adhesed to their clothing
204 which says \"Hotel Proprietor\", but they look so disorganized that you
205 think that can't possibly be true... can it?
206 Despite their exhaustion, you sense they'd be happy to chat with you,
207 though the conversation may be a bit one sided."
208 #:goes-by '("frumpy fellow" "fellow"
209 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
210 "hotel proprietor" "proprietor")
211 #:catchphrases hotel-owner-grumps)
212 ;; NPC: desk clerk (comes when you ring the s)
213 ;; impatient teenager, only stays around for a few minutes
214 ;; complaining, then leaves.
218 <readable> 'room:lobby
219 #:name "the Hotel Bricabrac sign"
220 #:desc " It strikes you that there's something funny going on with this sign.
221 Sure enough, if you look at it hard enough, you can tell that someone
222 hastily painted over an existing sign and changed the \"M\" to an \"H\".
224 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
228 "hotel bricabrac sign"
231 ;; Object: curio cabinets
232 ('thing:lobby:cabinet
233 <gameobj> 'room:lobby
234 #:name "a curio cabinet"
235 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
237 (format #f " The curio cabinet is full of all sorts of oddities!
238 Something catches your eye!
239 Ooh, ~a!" (random-choice random-bricabrac))))
240 ('thing:lobby:sign-in-form
241 <sign-in-form> 'room:lobby
242 #:name "sign-in form"
243 #:goes-by '("sign-in form" "form" "signin form")
244 #:desc "It looks like you could sign this form and set your name.")
247 ;; - Object: sign in form
248 ;; - Object: pamphlet
249 ;; Object: <invisible bell>: reprimands that you want to ring the
259 (define grand-hallway
263 #:name "Grand Hallway"
264 #:desc " A majestic red carpet runs down the center of the room.
265 Busts of serious looking people line the walls, but there's no
266 clear indication that they have any logical relation to this place.
267 In the center is a large statue of a bearded man. You wonder what
269 To the south is the lobby. A door to the east is labeled \"smoking
270 room\", while a door to the west is labeled \"playroom\"."
280 #:to 'room:smoking-parlor)))
281 ('thing:ignucius-statue
282 <gameobj> 'room:grand-hallway
284 #:desc " The statue is of a serious-looking bearded man with long, flowing hair.
285 The inscription says \"St. Ignucius\".
286 It has a large physical halo. It doesn't look like it would be hard to remove."
287 #:goes-by '("statue" "st ignucius" "st. ignucius"))))
297 #:name "The Playroom"
298 #:desc " There are toys scattered everywhere here. It's really unclear
299 if this room is intended for children or child-like adults."
303 #:to 'room:grand-hallway)))
304 ('thing:playroom:cubey
305 <thing> 'room:playroom
308 #:desc " It's a little foam cube with googly eyes on it. So cute!")))
319 ;; ... full of NURPH weapons?
325 (define-class <furniture> (<gameobj>)
326 (sit-phrase #:init-keyword #:sit-phrase)
327 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
328 (sit-name #:init-keyword #:sit-name)
333 (direct-command "sit" 'cmd-sit-furniture)))
339 (cmd-sit-furniture (wrap-apply furniture-cmd-sit)))
342 (define-mhandler (furniture-cmd-sit actor message direct-obj)
345 (<-wait actor (message-from message) 'get-name)
347 (<- actor (message-from message) 'tell
348 #:text (format #f "You ~a ~a.\n"
349 (slot-ref actor 'sit-phrase)
350 (slot-ref actor 'sit-name)))
351 (<- actor (slot-ref actor 'loc) 'tell-room
352 #:text (format #f "~a ~a on ~a.\n"
354 (slot-ref actor 'sit-phrase-third-person)
355 (slot-ref actor 'sit-name))
356 #:exclude (message-from message)))
359 (define smoking-parlor
361 ('room:smoking-parlor
363 #:name "Smoking Parlor"
364 #:desc " This room looks quite posh. There are huge comfy seats you can sit in
366 Strangely, you see a large sign saying \"No Smoking\". The owners must
367 have installed this place and then changed their mind later.
368 Nonetheless there are some candy cigarettes and cigars you can pick up
369 at the bar. (editor's note: or will be soon :])"
373 #:to 'room:grand-hallway)))
374 ('thing:smoking-room:chair
375 <furniture> 'room:smoking-parlor
376 #:name "a comfy leather chair"
377 #:desc " That leather chair looks really comfy!"
378 #:goes-by '("leather chair" "comfy leather chair" "chair")
379 #:sit-phrase "sink into"
380 #:sit-phrase-third-person "sinks into"
381 #:sit-name "the comfy leather chair")
382 ('thing:smoking-room:sofa
383 <furniture> 'room:smoking-parlor
384 #:name "a plush leather sofa"
385 #:desc " That leather chair looks really comfy!"
386 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
387 "leather couch" "plush leather couch" "couch")
388 #:sit-phrase "sprawl out on"
389 #:sit-phrase-third-person "sprawls out on into"
390 #:sit-name "the plush leather couch")
391 ('thing:smoking-room:bar-stool
392 <furniture> 'room:smoking-parlor
394 #:desc " Conveniently located near the bar! Not the most comfortable
395 seat in the room, though."
396 #:goes-by '("stool" "bar stool")
397 #:sit-phrase "hop on"
398 #:sit-phrase-third-person "hops onto"
399 #:sit-name "the bar stool")
401 ;; TODO: Cigar dispenser
406 ;;; Ennpie's Sea Lounge
407 ;;; -------------------
418 (append lobby grand-hallway smoking-parlor
421 ;; TODO: Provide command line args
422 (define (run-game . args)
423 (run-demo game-spec 'room:lobby #:repl-server #t))