Add Hotel Bricabrac
[mudsync.git] / worlds / bricabrac.scm
1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
3 ;;;
4 ;;; This file is part of Mudsync.
5 ;;;
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.
10 ;;;
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.
15 ;;;
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/>.
18
19 ;;; Hotel Bricabrac
20
21 (use-modules (mudsync)
22              (8sync systems actors)
23              (8sync agenda)
24              (oop goops)
25              (ice-9 format))
26
27
28 \f
29 ;;; Utilities, useful or otherwise
30 ;;; ==============================
31
32 (set! *random-state* (random-state-from-platform))
33
34 (define (random-choice lst)
35   (list-ref lst (random (length lst))))
36
37 ;; list of lists, lol.
38 (define-syntax-rule (lol (list-contents ...) ...)
39   (list (list list-contents ...) ...))
40
41 \f
42 ;;; Some simple object types.
43 ;;; =========================
44
45 (define readable-commands
46   (list
47    (direct-command "read" 'cmd-read)))
48 (define readable-actions
49   (build-actions
50    (cmd-read (wrap-apply readable-cmd-read))))
51
52 (define-class <readable> (<gameobj>)
53   (read-text #:init-value "All it says is: \"Blah blah blah.\""
54              #:init-keyword #:read-text)
55   (commands
56    #:init-value readable-commands)
57   (message-handler
58    #:init-value
59    (simple-dispatcher (append gameobj-actions readable-actions))))
60
61 (define (readable-cmd-read actor message)
62   (<- actor (message-from message) 'tell
63       #:text (string-append (slot-ref actor 'read-text) "\n")))
64
65
66 \f
67 ;;; Lobby
68 ;;; -----
69
70 (define-class <locked-cabinet> (<gameobj>)
71   )
72
73 (define-mhandler (npc-chat-randomly actor message)
74   (define text-to-send
75     (format #f "~a says: \"~a\"\n"
76             (slot-ref actor 'name)
77             (random-choice (slot-ref actor 'catchphrases))))
78   (<- actor (message-from message) 'tell
79       #:text text-to-send))
80
81 (define chat-commands
82   (list
83    (direct-command "chat" 'cmd-chat)))
84 (define chat-actions
85   (build-actions
86    (cmd-chat (wrap-apply npc-chat-randomly))))
87
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
91   know?"
92     "(*tearfully*) Here, take this parenthesis.  May it serve
93   you well."
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!"))
103
104 (define-class <chatty-npc> (<gameobj>)
105   (catchphrases #:init-value '("Blarga blarga blarga!")
106                 #:init-keyword #:catchphrases)
107   (commands
108    #:init-value chat-commands)
109   (message-handler
110    #:init-value
111    (simple-dispatcher (append gameobj-actions chat-actions))))
112
113 (define lobby
114   (lol
115    ('room:lobby
116     <room> #f
117     #:name "Hotel Lobby"
118     #:desc
119     "  You're in some sort of hotel lobby.  You see a large sign hanging
120 over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
121 that says \"ring for service\".  Terrible music plays from a speaker
122 somewhere overhead.
123   The room is lined with various curio cabinets, filled with all sorts
124 of kitschy junk.  It looks like whoever decorated this place had great
125 ambitions, but actually assembled it all in a hurry and used whatever
126 kind of objects they found lying around.")
127    ;; NPC: hotel owner
128    ('npc:hotel-owner
129     <chatty-npc> 'room:lobby
130     #:name "a frumpy fellow"
131     #:desc "  Whoever this is, they looks totally exhausted.  They're
132 collapsed into the only comfortable looking chair in the room and you
133 don't get the sense that they're likely to move any time soon.
134   You notice they're wearing a sticker badly adhesed to their clothing
135 which says \"Hotel Proprietor\", but they look so disorganized that you
136 think that can't possibly be true... can it?
137   Despite their exhaustion, you sense they'd be happy to chat with you,
138 though the conversation may be a bit one sided."
139     #:goes-by '("frumpy fellow" "fellow"
140                 "Chris Webber"  ; heh, did you rtfc?  or was it so obvious?
141                 "hotel proprietor" "proprietor")
142     #:catchphrases hotel-owner-grumps)
143    ;; NPC: desk clerk (comes when you ring the s)
144    ;;   impatient teenager, only stays around for a few minutes
145    ;;   complaining, then leaves.
146    
147    ;; Object: Sign
148    ('thing:lobby-sign
149     <readable> 'room:lobby
150     #:name "the Hotel Bricabrac sign"
151     #:desc "  It strikes you that there's something funny going on with this sign.
152 Sure enough, if you look at it hard enough, you can tell that someone
153 hastily painted over an existing sign and changed the \"M\" to an \"H\".
154 Classy!"
155     #:read-text "  All it says is \"Hotel Bricabrac\" in smudged, hasty text."
156     #:goes-by '("sign"
157                 "bricabrac sign"
158                 "hotel sign"
159                 "hotel bricabrac sign"
160                 "lobby sign"))
161
162    ;; Object: desk
163    ;;  - Object: bell
164    ;;  - Object: sign in form
165    ;;  - Object: pamphlet
166    ;; Object: curio cabinets
167    ;; Object: <invisible bell>: reprimands that you want to ring the
168    ;;   bell on the desk
169    )
170   )
171
172
173 \f
174 ;;; Playroom
175 ;;; --------
176
177 \f
178 ;;; Writing room
179 ;;; ------------
180
181 \f
182 ;;; Armory???
183 ;;; ---------
184
185 ;; ... full of NURPH weapons?
186
187 \f
188 ;;; Smoking parlor
189 ;;; --------------
190
191
192 \f
193 ;;; Ennpie's Sea Lounge
194 ;;; -------------------
195
196 \f
197 ;;; Computer room
198 ;;; -------------
199
200 \f
201 ;;; Game
202 ;;; ----
203
204 (define game-spec
205   (append lobby))
206
207 (define (run-game . args)
208   (run-demo "/tmp/bricabrac-game.db" game-spec 'room:lobby))
209