bricabrac.scm 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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. ;;; Hotel Bricabrac
  19. (use-modules (mudsync)
  20. (mudsync parser)
  21. (8sync systems actors)
  22. (8sync agenda)
  23. (oop goops)
  24. (ice-9 control)
  25. (ice-9 format)
  26. (ice-9 match)
  27. (rx irregex))
  28. ;;; Utilities, useful or otherwise
  29. ;;; ==============================
  30. (set! *random-state* (random-state-from-platform))
  31. (define (random-choice lst)
  32. (list-ref lst (random (length lst))))
  33. ;; list of lists, lol.
  34. (define-syntax-rule (lol (list-contents ...) ...)
  35. (list (list list-contents ...) ...))
  36. ;;; Some simple object types.
  37. ;;; =========================
  38. (define readable-commands
  39. (list
  40. (direct-command "read" 'cmd-read)))
  41. (define readable-commands*
  42. (append readable-commands
  43. thing-commands))
  44. (define readable-actions
  45. (build-actions
  46. (cmd-read (wrap-apply readable-cmd-read))))
  47. (define readable-actions*
  48. (append readable-actions
  49. thing-actions*))
  50. (define-class <readable> (<thing>)
  51. (read-text #:init-value "All it says is: \"Blah blah blah.\""
  52. #:init-keyword #:read-text)
  53. (commands
  54. #:init-value readable-commands*)
  55. (message-handler
  56. #:init-value
  57. (simple-dispatcher readable-actions*)))
  58. (define (readable-cmd-read actor message)
  59. (<- actor (message-from message) 'tell
  60. #:text (string-append (slot-ref actor 'read-text) "\n")))
  61. ;;; Lobby
  62. ;;; -----
  63. (define-mhandler (npc-chat-randomly actor message)
  64. (define text-to-send
  65. (format #f "~a says: \"~a\"\n"
  66. (slot-ref actor 'name)
  67. (random-choice (slot-ref actor 'catchphrases))))
  68. (<- actor (message-from message) 'tell
  69. #:text text-to-send))
  70. (define chat-commands
  71. (list
  72. (direct-command "chat" 'cmd-chat)
  73. (direct-command "talk" 'cmd-chat)))
  74. (define chat-actions
  75. (build-actions
  76. (cmd-chat (wrap-apply npc-chat-randomly))))
  77. (define hotel-owner-grumps
  78. '("Eight sinks! Eight sinks! And I couldn't unwind them..."
  79. "Don't mind the mess. I built this place on a dare, you
  80. know?"
  81. "(*tearfully*) Here, take this parenthesis. May it serve
  82. you well."
  83. "I gotta get back to the goblin farm soon..."
  84. "Oh, but I was going to make a mansion... a great,
  85. beautiful mansion! Full of ghosts! Now all I have is this cruddy
  86. mo... hotel. Oh... If only I had more time!"
  87. "I told them to paint more of the walls purple.
  88. Why didn't they listen?"
  89. "Listen to that overhead muzak. Whoever made that doesn't
  90. know how to compose very well! Have you heard of the bands 'fmt'
  91. or 'skribe'? Now *that's* composition!"))
  92. (define-class <chatty-npc> (<gameobj>)
  93. (catchphrases #:init-value '("Blarga blarga blarga!")
  94. #:init-keyword #:catchphrases)
  95. (commands
  96. #:init-value chat-commands)
  97. (message-handler
  98. #:init-value
  99. (simple-dispatcher (append gameobj-actions chat-actions))))
  100. (define random-bricabrac
  101. '("a creepy porcelain doll"
  102. "assorted 1950s robots"
  103. "an exquisite tea set"
  104. "an antique mustard pot"
  105. "the pickled head of Elvis"
  106. "the pickled circuitboard of EVLIS"
  107. "a scroll of teletype paper holding the software Four Freedoms"
  108. "a telephone shaped like an orange cartoon cat"))
  109. (define-class <sign-in-form> (<gameobj>)
  110. (commands
  111. #:init-value
  112. (list
  113. (prep-direct-command "sign" 'cmd-sign-form
  114. '("as"))))
  115. (message-handler
  116. #:init-value
  117. (simple-dispatcher
  118. (append
  119. (build-actions
  120. (cmd-sign-form (wrap-apply sign-cmd-sign-in)))
  121. gameobj-actions))))
  122. (define name-sre
  123. (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
  124. (define forbidden-words
  125. (append article preposition
  126. '("and" "or" "but" "admin")))
  127. (define (valid-name? name)
  128. (and (irregex-match name-sre name)
  129. (not (member name forbidden-words))))
  130. (define-mhandler (sign-cmd-sign-in actor message direct-obj indir-obj)
  131. (define old-name
  132. (message-ref
  133. (<-wait actor (message-from message) 'get-name)
  134. 'val))
  135. (define name indir-obj)
  136. (if (valid-name? indir-obj)
  137. (begin
  138. (<-wait actor (message-from message) 'set-name!
  139. #:val name)
  140. (<- actor (slot-ref actor 'loc) 'tell-room
  141. #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
  142. old-name old-name name)))
  143. (<- actor (message-from message) 'tell
  144. #:text "Sorry, that's not a valid name.
  145. Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
  146. character.\n")))
  147. (define summoning-bell-commands
  148. (list
  149. (direct-command "ring" 'cmd-ring)))
  150. (define summoning-bell-commands*
  151. (append summoning-bell-commands
  152. thing-commands*))
  153. (define summoning-bell-actions
  154. (build-actions
  155. (cmd-ring (wrap-apply summoning-bell-cmd-ring))))
  156. (define summoning-bell-actions*
  157. (append summoning-bell-actions
  158. thing-actions*))
  159. (define-class <summoning-bell> (<thing>)
  160. (summons #:init-keyword #:summons)
  161. (commands
  162. #:init-value summoning-bell-commands*)
  163. (message-handler
  164. #:init-value
  165. (simple-dispatcher summoning-bell-actions*)))
  166. (define-mhandler (summoning-bell-cmd-ring bell message)
  167. (define who-rang
  168. (message-ref
  169. (<-wait bell (message-from message) 'get-name)
  170. 'val))
  171. (<- bell (message-from message) 'tell
  172. #:text "*ring ring!* You ring the bell!\n")
  173. (<- bell (gameobj-loc bell) 'tell-room
  174. #:text
  175. (format #f "*ring ring!* ~a rings the bell!\n"
  176. who-rang)
  177. #:exclude (message-from message))
  178. (<- bell (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
  179. #:who-summoned (message-from message)))
  180. (define prefect-quotes
  181. '("I'm a frood who really knows where my towel is!"
  182. "On no account allow a Vogon to read poetry at you."
  183. "Time is an illusion, lunchtime doubly so!"
  184. "How can you have money if none of you produces anything?"
  185. "On no account allow Arthur to request tea on this ship."))
  186. (define lobby
  187. (lol
  188. ('room:lobby
  189. <room> #f
  190. #:name "Hotel Lobby"
  191. #:desc
  192. " You're in some sort of hotel lobby. You see a large sign hanging
  193. over the desk that says \"Hotel Bricabrac\". On the desk is a bell
  194. that says \"ring for service\". Terrible music plays from a speaker
  195. somewhere overhead.
  196. The room is lined with various curio cabinets, filled with all sorts
  197. of kitschy junk. It looks like whoever decorated this place had great
  198. ambitions, but actually assembled it all in a hurry and used whatever
  199. kind of objects they found lying around.
  200. There's a door to the north leading to some kind of hallway."
  201. #:exits
  202. (list (make <exit>
  203. #:name "north"
  204. #:to 'room:grand-hallway)))
  205. ;; NPC: hotel owner
  206. ('npc:lobby:hotel-owner
  207. <chatty-npc> 'room:lobby
  208. #:name "a frumpy fellow"
  209. #:desc " Whoever this is, they looks totally exhausted. They're
  210. collapsed into the only comfortable looking chair in the room and you
  211. don't get the sense that they're likely to move any time soon.
  212. You notice they're wearing a sticker badly adhesed to their clothing
  213. which says \"Hotel Proprietor\", but they look so disorganized that you
  214. think that can't possibly be true... can it?
  215. Despite their exhaustion, you sense they'd be happy to chat with you,
  216. though the conversation may be a bit one sided."
  217. #:goes-by '("frumpy fellow" "fellow"
  218. "Chris Webber" ; heh, did you rtfc? or was it so obvious?
  219. "hotel proprietor" "proprietor")
  220. #:catchphrases hotel-owner-grumps)
  221. ;; Object: Sign
  222. ('thing:lobby:sign
  223. <readable> 'room:lobby
  224. #:name "the Hotel Bricabrac sign"
  225. #:desc " It strikes you that there's something funny going on with this sign.
  226. Sure enough, if you look at it hard enough, you can tell that someone
  227. hastily painted over an existing sign and changed the \"M\" to an \"H\".
  228. Classy!"
  229. #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
  230. #:goes-by '("sign"
  231. "bricabrac sign"
  232. "hotel sign"
  233. "hotel bricabrac sign"
  234. "lobby sign"))
  235. ('thing:lobby:bell
  236. <summoning-bell> 'room:lobby
  237. #:name "a shiny brass bell"
  238. #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
  239. #:desc " A shiny brass bell. Inscribed on its wooden base is the text
  240. \"ring me for service\". You probably could \"ring the bell\" if you
  241. wanted to."
  242. #:summons 'npc:break-room:desk-clerk)
  243. ;; Object: curio cabinets
  244. ('thing:lobby:cabinet
  245. <gameobj> 'room:lobby
  246. #:name "a curio cabinet"
  247. #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet")
  248. #:desc (lambda _
  249. (format #f " The curio cabinet is full of all sorts of oddities!
  250. Something catches your eye!
  251. Ooh, ~a!" (random-choice random-bricabrac))))
  252. ('thing:lobby:sign-in-form
  253. <sign-in-form> 'room:lobby
  254. #:name "sign-in form"
  255. #:goes-by '("sign-in form" "form" "signin form")
  256. #:desc "It looks like you could sign this form and set your name.")
  257. ;; Object: desk
  258. ;; - Object: bell
  259. ;; - Object: sign in form
  260. ;; - Object: pamphlet
  261. ;; Object: <invisible bell>: reprimands that you want to ring the
  262. ;; bell on the desk
  263. )
  264. )
  265. ;;; Grand hallway
  266. ;;; -------------
  267. (define grand-hallway
  268. (lol
  269. ('room:grand-hallway
  270. <room> #f
  271. #:name "Grand Hallway"
  272. #:desc " A majestic red carpet runs down the center of the room.
  273. Busts of serious looking people line the walls, but there's no
  274. clear indication that they have any logical relation to this place.
  275. In the center is a large statue of a bearded man. You wonder what
  276. that's all about?
  277. To the south is the lobby. A door to the east is labeled \"smoking
  278. room\", while a door to the west is labeled \"playroom\"."
  279. #:exits
  280. (list (make <exit>
  281. #:name "south"
  282. #:to 'room:lobby)
  283. (make <exit>
  284. #:name "west"
  285. #:to 'room:playroom)
  286. (make <exit>
  287. #:name "east"
  288. #:to 'room:smoking-parlor)))
  289. ('thing:ignucius-statue
  290. <gameobj> 'room:grand-hallway
  291. #:name "a statue"
  292. #:desc " The statue is of a serious-looking bearded man with long, flowing hair.
  293. The inscription says \"St. Ignucius\".
  294. It has a large physical halo. Removing it is tempting, but it looks pretty
  295. well fastened."
  296. #:goes-by '("statue" "st ignucius" "st. ignucius"))))
  297. ;;; Playroom
  298. ;;; --------
  299. (define playroom
  300. (lol
  301. ('room:playroom
  302. <room> #f
  303. #:name "The Playroom"
  304. #:desc " There are toys scattered everywhere here. It's really unclear
  305. if this room is intended for children or child-like adults."
  306. #:exits
  307. (list (make <exit>
  308. #:name "east"
  309. #:to 'room:grand-hallway)))
  310. ('thing:playroom:cubey
  311. <thing> 'room:playroom
  312. #:name "cubey"
  313. #:takeable #t
  314. #:desc " It's a little foam cube with googly eyes on it. So cute!")
  315. ('thing:cuddles-plushie
  316. <thing> 'room:playroom
  317. #:name "a cuddles plushie"
  318. #:goes-by '("plushie" "cuddles plushie")
  319. #:takeable #t
  320. #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")))
  321. ;;; Writing room
  322. ;;; ------------
  323. ;;; Armory???
  324. ;;; ---------
  325. ;; ... full of NURPH weapons?
  326. ;;; Smoking parlor
  327. ;;; --------------
  328. (define-class <furniture> (<gameobj>)
  329. (sit-phrase #:init-keyword #:sit-phrase)
  330. (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
  331. (sit-name #:init-keyword #:sit-name)
  332. (commands
  333. #:init-value
  334. (list
  335. (direct-command "sit" 'cmd-sit-furniture)))
  336. (message-handler
  337. #:init-value
  338. (simple-dispatcher
  339. (append
  340. (build-actions
  341. (cmd-sit-furniture (wrap-apply furniture-cmd-sit)))
  342. gameobj-actions))))
  343. (define-mhandler (furniture-cmd-sit actor message direct-obj)
  344. (define player-name
  345. (message-ref
  346. (<-wait actor (message-from message) 'get-name)
  347. 'val))
  348. (<- actor (message-from message) 'tell
  349. #:text (format #f "You ~a ~a.\n"
  350. (slot-ref actor 'sit-phrase)
  351. (slot-ref actor 'sit-name)))
  352. (<- actor (slot-ref actor 'loc) 'tell-room
  353. #:text (format #f "~a ~a on ~a.\n"
  354. player-name
  355. (slot-ref actor 'sit-phrase-third-person)
  356. (slot-ref actor 'sit-name))
  357. #:exclude (message-from message)))
  358. (define smoking-parlor
  359. (lol
  360. ('room:smoking-parlor
  361. <room> #f
  362. #:name "Smoking Parlor"
  363. #:desc " This room looks quite posh. There are huge comfy seats you can sit in
  364. if you like.
  365. Strangely, you see a large sign saying \"No Smoking\". The owners must
  366. have installed this place and then changed their mind later.
  367. There's a door to the west leading back to the grand hallway, and
  368. a nondescript steel door to the south, leading apparently outside."
  369. #:exits
  370. (list (make <exit>
  371. #:name "west"
  372. #:to 'room:grand-hallway)
  373. (make <exit>
  374. #:name "south"
  375. #:to 'room:break-room)))
  376. ('thing:smoking-room:chair
  377. <furniture> 'room:smoking-parlor
  378. #:name "a comfy leather chair"
  379. #:desc " That leather chair looks really comfy!"
  380. #:goes-by '("leather chair" "comfy leather chair" "chair")
  381. #:sit-phrase "sink into"
  382. #:sit-phrase-third-person "sinks into"
  383. #:sit-name "the comfy leather chair")
  384. ('thing:smoking-room:sofa
  385. <furniture> 'room:smoking-parlor
  386. #:name "a plush leather sofa"
  387. #:desc " That leather chair looks really comfy!"
  388. #:goes-by '("leather sofa" "plush leather sofa" "sofa"
  389. "leather couch" "plush leather couch" "couch")
  390. #:sit-phrase "sprawl out on"
  391. #:sit-phrase-third-person "sprawls out on into"
  392. #:sit-name "the plush leather couch")
  393. ('thing:smoking-room:bar-stool
  394. <furniture> 'room:smoking-parlor
  395. #:name "a bar stool"
  396. #:desc " Conveniently located near the bar! Not the most comfortable
  397. seat in the room, though."
  398. #:goes-by '("stool" "bar stool" "seat")
  399. #:sit-phrase "hop on"
  400. #:sit-phrase-third-person "hops onto"
  401. #:sit-name "the bar stool")
  402. ('npc:ford-prefect
  403. <chatty-npc> 'room:smoking-parlor
  404. #:name "Ford Prefect"
  405. #:desc "Just some guy, you know?"
  406. #:goes-by '("Ford Prefect" "ford prefect"
  407. "frood" "prefect" "ford")
  408. #:catchphrases prefect-quotes)
  409. ;; TODO: Cigar dispenser
  410. ))
  411. ;;; Breakroom
  412. ;;; ---------
  413. (define clerk-commands
  414. (list
  415. (direct-command "talk" 'cmd-chat)
  416. (direct-command "chat" 'cmd-chat)
  417. (direct-command "ask" 'cmd-ask-incomplete)
  418. (prep-direct-command "ask" 'cmd-ask-about)
  419. (direct-command "dismiss" 'cmd-dismiss)))
  420. (define clerk-commands*
  421. (append clerk-commands thing-commands*))
  422. (define clerk-actions
  423. (build-actions
  424. (init (wrap-apply clerk-act-init))
  425. (cmd-chat (wrap-apply clerk-cmd-chat))
  426. (cmd-ask-incomplete (wrap-apply clerk-cmd-ask-incomplete))
  427. (cmd-ask-about (wrap-apply clerk-cmd-ask))
  428. (cmd-dismiss (wrap-apply clerk-cmd-dismiss))
  429. (update-loop (wrap-apply clerk-act-update-loop))
  430. (be-summoned (wrap-apply clerk-act-be-summoned))))
  431. (define clerk-actions* (append clerk-actions
  432. thing-actions*))
  433. (define-class <desk-clerk> (<thing>)
  434. ;; The desk clerk has three states:
  435. ;; - on-duty: Arrived, and waiting for instructions (and losing patience
  436. ;; gradually)
  437. ;; - slacking: In the break room, probably smoking a cigarette
  438. ;; or checking text messages
  439. (state #:init-value 'slacking)
  440. (commands #:init-value clerk-commands*)
  441. (patience #:init-value 0)
  442. (message-handler
  443. #:init-value
  444. (simple-dispatcher clerk-actions*)))
  445. (define-mhandler (clerk-act-init clerk message)
  446. ;; call the gameobj main init method
  447. (gameobj-act-init clerk message)
  448. ;; start our main loop
  449. (<- clerk (actor-id clerk) 'update-loop))
  450. (define clerk-help-topics
  451. '(("changing name" .
  452. "Changing your name is easy! We have a clipboard here at the desk
  453. where you can make yourself known to other participants in the hotel
  454. if you sign it. Try 'sign form as <your-name>', replacing
  455. <your-name>, obviously!")
  456. ("common commands" .
  457. "Here are some useful commands you might like to try: chat,
  458. go, take, drop, say...")
  459. ("hotel" .
  460. "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
  461. our hotel emphasizes interesting experiences over rest and lodging.
  462. The origins of the hotel are... unclear... and it has recently come
  463. under new... 'management'. But at Hotel Bricabrac we believe these
  464. aspects make the hotel into a fun and unique experience! Please,
  465. feel free to walk around and explore.")))
  466. (define clerk-knows-about
  467. "'changing name', 'common commands', and 'about the hotel'")
  468. (define clerk-general-helpful-line
  469. (string-append
  470. "The clerk says, \"If you need help with anything, feel free to ask me about it.
  471. For example, 'ask clerk about changing name'. You can ask me about the following:
  472. " clerk-knows-about ".\"\n"))
  473. (define clerk-slacking-complaints
  474. '("The pay here is absolutely lousy."
  475. "The owner here has no idea what they're doing."
  476. "Some times you just gotta step away, you know?"
  477. "You as exhausted as I am?"
  478. "Yeah well, this is just temporary. I'm studying to be a high
  479. energy particle physicist. But ya gotta pay the bills, especially
  480. with tuition at where it is..."))
  481. (define-mhandler (clerk-cmd-chat clerk message)
  482. (match (slot-ref clerk 'state)
  483. ('on-duty
  484. (<- clerk (message-from message) 'tell
  485. #:text clerk-general-helpful-line))
  486. ('slacking
  487. (<- clerk (message-from message) 'tell
  488. #:text
  489. (string-append
  490. "The clerk says, \""
  491. (random-choice clerk-slacking-complaints)
  492. "\"\n")))))
  493. (define-mhandler (clerk-cmd-ask-incomplete clerk message)
  494. (<- clerk (message-from message) 'tell
  495. #:text "The clerk says, \"Ask about what?\"\n"))
  496. (define clerk-doesnt-know-text
  497. "The clerk apologizes and says she doesn't know about that topic.\n")
  498. (define-mhandler (clerk-cmd-ask clerk message indir-obj)
  499. (match (slot-ref clerk 'state)
  500. ('on-duty
  501. (match (assoc (pk 'indir indir-obj) clerk-help-topics)
  502. ((_ . info)
  503. (<- clerk (message-from message) 'tell
  504. #:text
  505. (string-append "The clerk clears her throat and says:\n \""
  506. info
  507. "\"\n")))
  508. (#f
  509. (<- clerk (message-from message) 'tell
  510. #:text clerk-doesnt-know-text))))
  511. ('slacking
  512. (<- clerk (message-from message) 'tell
  513. #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
  514. (define-mhandler (clerk-act-be-summoned clerk message who-summoned)
  515. (match (slot-ref clerk 'state)
  516. ('on-duty
  517. (<- clerk who-summoned 'tell
  518. #:text
  519. "The clerk tells you as politely as she can that she's already here,
  520. so there's no need to ring the bell.\n"))
  521. ('slacking
  522. (<- clerk (gameobj-loc clerk) 'tell-room
  523. #:text
  524. "The clerk's ears perk up, she stamps out a cigarette, and she
  525. runs out of the room!\n")
  526. (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
  527. (slot-set! clerk 'patience 8)
  528. (slot-set! clerk 'state 'on-duty)
  529. (<- clerk (gameobj-loc clerk) 'tell-room
  530. #:text
  531. (string-append
  532. " Suddenly, a uniformed woman rushes into the room! She's wearing a
  533. badge that says \"Desk Clerk\".
  534. \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
  535. We look forward to your stay. If you'd like help getting acclimated,
  536. feel free to ask me. For example, 'ask clerk about changing name'.
  537. You can ask me about the following:
  538. " clerk-knows-about ".\"\n")))))
  539. (define-mhandler (clerk-cmd-dismiss clerk message)
  540. (define player-name
  541. (message-ref
  542. (<-wait clerk (message-from message) 'get-name)
  543. 'val))
  544. (match (slot-ref clerk 'state)
  545. ('on-duty
  546. (<- clerk (gameobj-loc clerk) 'tell-room
  547. #:text
  548. (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
  549. The clerk leaves the room in a hurry.\n"
  550. player-name))
  551. (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
  552. (slot-set! clerk 'state 'slacking)
  553. (<- clerk (gameobj-loc clerk) 'tell-room
  554. #:text clerk-return-to-slacking-text))
  555. ('slacking
  556. (<- clerk (message-from message) 'tell
  557. #:text "The clerk sternly asks you to not be so dismissive.\n"))))
  558. (define clerk-slacking-texts
  559. '("The clerk takes a long drag on her cigarette.\n"
  560. "The clerk scrolls through text messages on her phone.\n"
  561. "The clerk coughs a few times.\n"
  562. "The clerk checks her watch and justifies a few more minutes outside.\n"
  563. "The clerk fumbles around for a lighter.\n"
  564. "The clerk sighs deeply and exhaustedly.\n"
  565. "The clerk fumbles around for a cigarette.\n"))
  566. (define clerk-working-impatience-texts
  567. '("The clerk struggles to retain an interested and polite smile.\n"
  568. "The clerk checks the time on her phone.\n"
  569. "The clerk taps her foot.\n"
  570. "The clerk takes a deep breath.\n"
  571. "The clerk yawns.\n"
  572. "The clerk drums her nails on the counter.\n"
  573. "The clerk clicks around on the desk computer.\n"))
  574. (define clerk-slack-excuse-text
  575. "The desk clerk excuses herself, claiming she has important things to
  576. attend to.\n")
  577. (define clerk-return-to-slacking-text
  578. "The desk clerk enters and slams the door behind her.\n")
  579. (define-mhandler (clerk-act-update-loop clerk message)
  580. (define (tell-room text)
  581. (<- clerk (gameobj-loc clerk) 'tell-room
  582. #:text text))
  583. (define (loop return)
  584. (define (stop-if-destructed)
  585. (if (slot-ref clerk 'destructed)
  586. (return #f)))
  587. (match (slot-ref clerk 'state)
  588. ('slacking
  589. (tell-room (random-choice clerk-slacking-texts))
  590. (8sleep (+ (random 10) 10))
  591. (stop-if-destructed)
  592. (loop return))
  593. ('on-duty
  594. (if (> (slot-ref clerk 'patience) 0)
  595. ;; Keep working but lose patience gradually
  596. (begin
  597. (tell-room (random-choice clerk-working-impatience-texts))
  598. (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
  599. (+ (random 2) 1)))
  600. (8sleep (+ (random 25) 20))
  601. (stop-if-destructed)
  602. (loop return))
  603. ;; Back to slacking
  604. (begin
  605. (tell-room clerk-slack-excuse-text)
  606. ;; back bto the break room
  607. (gameobj-set-loc! clerk (pk 'break-room (dyn-ref clerk 'room:break-room)))
  608. (tell-room clerk-return-to-slacking-text)
  609. ;; annnnnd back to slacking
  610. (slot-set! clerk 'state 'slacking)
  611. (8sleep (+ (random 30) 15))
  612. (stop-if-destructed)
  613. (loop return))))))
  614. (call/ec loop))
  615. (define break-room
  616. (lol
  617. ('room:break-room
  618. <room> #f
  619. #:name "Employee Break Room"
  620. #:desc " This is less a room and more of an outdoor wire cage. You get
  621. a bit of a view of the brick exterior of the building, and a crisp wind blows,
  622. whistling, through the openings of the fenced area. Partly smoked cigarettes
  623. and various other debris cover the floor.
  624. Through the wires you can see... well... hm. It looks oddly like
  625. the scenery tapers off nothingness. But that can't be right, can it?"
  626. #:exits
  627. (list (make <exit>
  628. #:name "north"
  629. #:to 'room:smoking-parlor))
  630. )
  631. ('npc:break-room:desk-clerk
  632. <desk-clerk> 'room:break-room
  633. #:name "the hotel desk clerk"
  634. #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
  635. hotel insignia. She looks like she'd much rather be somewhere else."
  636. #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))))
  637. ;;; Ennpie's Sea Lounge
  638. ;;; -------------------
  639. ;;; Computer room
  640. ;;; -------------
  641. ;;; Game
  642. ;;; ----
  643. (define game-spec
  644. (append lobby grand-hallway smoking-parlor
  645. playroom break-room))
  646. ;; TODO: Provide command line args
  647. (define (run-game . args)
  648. (run-demo game-spec 'room:lobby #:repl-server #t))