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 #:text "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)))
188 ('npc:lobby:hotel-owner
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
223 ('thing:lobby:cabinet
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))))
231 ('thing:lobby:sign-in-form
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 In the center is a large statue of a bearded man. You wonder what
260 To the south is the lobby. A door to the east is labeled \"smoking
261 room\", while a door to the west is labeled \"playroom\"."
271 #:to 'room:smoking-parlor)))
272 ('thing:ignucius-statue
273 <gameobj> 'room:grand-hallway
275 #:desc " The statue is of a serious-looking bearded man with long, flowing hair.
276 The inscription says \"St. Ignucius\".
277 It has a large physical halo. It doesn't look like it would be hard to remove."
278 #:goes-by '("statue" "st ignucius" "st. ignucius"))))
288 #:name "The Playroom"
289 #:desc " There are toys scattered everywhere here. It's really unclear
290 if this room is intended for children or child-like adults."
294 #:to 'room:grand-hallway)))
295 ('thing:playroom:cubey
296 <thing> 'room:playroom
299 #:desc " It's a little foam cube with googly eyes on it. So cute!")))
310 ;; ... full of NURPH weapons?
316 (define-class <furniture> (<gameobj>)
317 (sit-phrase #:init-keyword #:sit-phrase)
318 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
319 (sit-name #:init-keyword #:sit-name)
324 (direct-command "sit" 'cmd-sit-furniture)))
330 (cmd-sit-furniture (wrap-apply furniture-cmd-sit)))
333 (define-mhandler (furniture-cmd-sit actor message direct-obj)
336 (<-wait actor (message-from message) 'get-name)
338 (<- actor (message-from message) 'tell
339 #:text (format #f "You ~a ~a.\n"
340 (slot-ref actor 'sit-phrase)
341 (slot-ref actor 'sit-name)))
342 (<- actor (slot-ref actor 'loc) 'tell-room
343 #:text (format #f "~a ~a on ~a.\n"
345 (slot-ref actor 'sit-phrase-third-person)
346 (slot-ref actor 'sit-name))
347 #:exclude (message-from message)))
350 (define smoking-parlor
352 ('room:smoking-parlor
354 #:name "Smoking Parlor"
355 #:desc " This room looks quite posh. There are huge comfy seats you can sit in
357 Strangely, you see a large sign saying \"No Smoking\". The owners must
358 have installed this place and then changed their mind later.
359 Nonetheless there are some candy cigarettes and cigars you can pick up
360 at the bar. (editor's note: or will be soon :])"
364 #:to 'room:grand-hallway)))
365 ('thing:smoking-room:chair
366 <furniture> 'room:smoking-parlor
367 #:name "a comfy leather chair"
368 #:desc " That leather chair looks really comfy!"
369 #:goes-by '("leather chair" "comfy leather chair" "chair")
370 #:sit-phrase "sink into"
371 #:sit-phrase-third-person "sinks into"
372 #:sit-name "the comfy leather chair")
373 ('thing:smoking-room:sofa
374 <furniture> 'room:smoking-parlor
375 #:name "a plush leather sofa"
376 #:desc " That leather chair looks really comfy!"
377 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
378 "leather couch" "plush leather couch" "couch")
379 #:sit-phrase "sprawl out on"
380 #:sit-phrase-third-person "sprawls out on into"
381 #:sit-name "the plush leather couch")
382 ('thing:smoking-room:bar-stool
383 <furniture> 'room:smoking-parlor
385 #:desc " Conveniently located near the bar! Not the most comfortable
386 seat in the room, though."
387 #:goes-by '("stool" "bar stool")
388 #:sit-phrase "hop on"
389 #:sit-phrase-third-person "hops onto"
390 #:sit-name "the bar stool")
392 ;; TODO: Cigar dispenser
397 ;;; Ennpie's Sea Lounge
398 ;;; -------------------
409 (append lobby grand-hallway smoking-parlor
412 ;; TODO: Provide command line args
413 (define (run-game . args)
414 (run-demo game-spec 'room:lobby #:repl-server #t))