bricabrac.scm 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265
  1. ;;; Mudsync --- Live hackable MUD
  2. ;;; Copyright © 2016, 2017 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 container)
  21. (8sync)
  22. (oop goops)
  23. (ice-9 control)
  24. (ice-9 format)
  25. (ice-9 match)
  26. (rx irregex))
  27. ;;; Utilities, useful or otherwise
  28. ;;; ==============================
  29. (set! *random-state* (random-state-from-platform))
  30. (define (random-choice lst)
  31. (list-ref lst (random (length lst))))
  32. ;; list of lists, lol.
  33. (define-syntax-rule (lol (list-contents ...) ...)
  34. (list (list list-contents ...) ...))
  35. ;;; Some simple object types.
  36. ;;; =========================
  37. (define-class <readable> (<gameobj>)
  38. (read-text #:init-value "All it says is: \"Blah blah blah.\""
  39. #:init-keyword #:read-text)
  40. (commands
  41. #:allocation #:each-subclass
  42. #:init-thunk (build-commands
  43. ("read" ((direct-command cmd-read)))))
  44. (actions #:allocation #:each-subclass
  45. #:init-thunk (build-actions
  46. (cmd-read readable-cmd-read))))
  47. (define (readable-cmd-read actor message . _)
  48. (<- (message-from message) 'tell
  49. #:text (slot-ref actor 'read-text)))
  50. ;; This one is just where reading is the same thing as looking
  51. ;; at the description
  52. (define-class <readable-desc> (<gameobj>)
  53. (commands
  54. #:allocation #:each-subclass
  55. #:init-thunk (build-commands
  56. ("read" ((direct-command cmd-look-at))))))
  57. ;; This one allows you to take from items that are proxied by it
  58. (define-actor <proxy-items> (<gameobj>)
  59. ((cmd-take-from take-from-proxy))
  60. (proxy-items #:init-keyword #:proxy-items))
  61. (define* (take-from-proxy gameobj message
  62. #:key direct-obj indir-obj preposition
  63. (player (message-from message)))
  64. (call/ec
  65. (lambda (escape)
  66. (for-each
  67. (lambda (obj-sym)
  68. (define obj-id (dyn-ref gameobj obj-sym))
  69. (define goes-by
  70. (mbody-val (<-wait obj-id 'goes-by)))
  71. (when (ci-member direct-obj goes-by)
  72. (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
  73. (escape #f)))
  74. (slot-ref gameobj 'proxy-items))
  75. (<- player 'tell
  76. #:text `("You don't see any such " ,direct-obj " to take "
  77. ,preposition " " ,(slot-ref gameobj 'name) ".")))))
  78. ;;; Lobby
  79. ;;; -----
  80. (define (npc-chat-randomly actor message . _)
  81. (define catchphrase
  82. (random-choice (slot-ref actor 'catchphrases)))
  83. (define text-to-send
  84. ((slot-ref actor 'chat-format) actor catchphrase))
  85. (<- (message-from message) 'tell
  86. #:text text-to-send))
  87. (define hotel-owner-grumps
  88. '("Eight sinks! Eight sinks! And I couldn't unwind them..."
  89. "Don't mind the mess. I built this place on a dare, you
  90. know?"
  91. "(*tearfully*) Here, take this parenthesis. May it serve
  92. you well."
  93. "I gotta get back to the goblin farm soon..."
  94. "Oh, but I was going to make a mansion... a great,
  95. beautiful mansion! Full of ghosts! Now all I have is this cruddy
  96. mo... hotel. Oh... If only I had more time!"
  97. "I told them to paint more of the walls purple.
  98. Why didn't they listen?"
  99. "Listen to that overhead muzak. Whoever made that doesn't
  100. know how to compose very well! Have you heard of the bands 'fmt'
  101. or 'skribe'? Now *that's* composition!"))
  102. (define-class <chatty-npc> (<gameobj>)
  103. (catchphrases #:init-value '("Blarga blarga blarga!")
  104. #:init-keyword #:catchphrases)
  105. (chat-format #:init-value (lambda (npc catchphrase)
  106. `(,(slot-ref npc 'name) " says: \""
  107. ,catchphrase "\""))
  108. #:init-keyword #:chat-format)
  109. (commands
  110. #:allocation #:each-subclass
  111. #:init-thunk (build-commands
  112. (("chat" "talk") ((direct-command cmd-chat)))))
  113. (actions #:allocation #:each-subclass
  114. #:init-thunk
  115. (build-actions
  116. (cmd-chat npc-chat-randomly))))
  117. (define-class <sign-in-form> (<gameobj>)
  118. (commands
  119. #:allocation #:each-subclass
  120. #:init-thunk (build-commands
  121. ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
  122. (actions #:allocation #:each-subclass
  123. #:init-thunk (build-actions
  124. (cmd-sign-form sign-cmd-sign-in))))
  125. (define name-sre
  126. (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
  127. (define forbidden-words
  128. (append article preposition
  129. '("and" "or" "but" "admin")))
  130. (define (valid-name? name)
  131. (and (irregex-match name-sre name)
  132. (not (member name forbidden-words))))
  133. (define* (sign-cmd-sign-in actor message
  134. #:key direct-obj indir-obj preposition)
  135. (define old-name
  136. (mbody-val (<-wait (message-from message) 'get-name)))
  137. (define name indir-obj)
  138. (if (valid-name? indir-obj)
  139. (begin
  140. (<-wait (message-from message) 'set-name! name)
  141. (<- (slot-ref actor 'loc) 'tell-room
  142. #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
  143. old-name old-name name)))
  144. (<- (message-from message) 'tell
  145. #:text "Sorry, that's not a valid name.
  146. Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
  147. character.\n")))
  148. (define-class <summoning-bell> (<gameobj>)
  149. (summons #:init-keyword #:summons)
  150. (commands
  151. #:allocation #:each-subclass
  152. #:init-thunk (build-commands
  153. ("ring" ((direct-command cmd-ring)))))
  154. (actions #:allocation #:each-subclass
  155. #:init-thunk (build-actions
  156. (cmd-ring summoning-bell-cmd-ring))))
  157. (define* (summoning-bell-cmd-ring bell message . _)
  158. ;; Call back to actor who invoked this message handler
  159. ;; and find out their name. We'll call *their* get-name message
  160. ;; handler... meanwhile, this procedure suspends until we get
  161. ;; their response.
  162. (define who-rang
  163. (mbody-val (<-wait (message-from message) 'get-name)))
  164. ;; Now we'll invoke the "tell" message handler on the player
  165. ;; who rang us, displaying this text on their screen.
  166. ;; This one just uses <- instead of <-wait, since we don't
  167. ;; care when it's delivered; we're not following up on it.
  168. (<- (message-from message) 'tell
  169. #:text "*ring ring!* You ring the bell!\n")
  170. ;; We also want everyone else in the room to "hear" the bell,
  171. ;; but they get a different message since they aren't the ones
  172. ;; ringing it. Notice here's where we make use of the invoker's
  173. ;; name as extracted and assigned to the who-rang variable.
  174. ;; Notice how we send this message to our "location", which
  175. ;; forwards it to the rest of the occupants in the room.
  176. (<- (gameobj-loc bell) 'tell-room
  177. #:text
  178. (format #f "*ring ring!* ~a rings the bell!\n"
  179. who-rang)
  180. #:exclude (message-from message))
  181. ;; Now we perform the primary task of the bell, which is to summon
  182. ;; the "clerk" character to the room. (This is configurable,
  183. ;; so we dynamically look up their address.)
  184. (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
  185. #:who-summoned (message-from message)))
  186. (define prefect-quotes
  187. '("I'm a frood who really knows where my towel is!"
  188. "On no account allow a Vogon to read poetry at you."
  189. "Time is an illusion, lunchtime doubly so!"
  190. "How can you have money if none of you produces anything?"
  191. "On no account allow Arthur to request tea on this ship."))
  192. (define-class <cabinet-item> (<gameobj>)
  193. (take-me? #:init-value
  194. (lambda _
  195. (values #f #:why-not
  196. `("Hm, well... the cabinet is locked and the properitor "
  197. "is right over there.")))))
  198. (define lobby
  199. (lol
  200. ('lobby
  201. <room> #f
  202. #:name "Hotel Lobby"
  203. #:desc
  204. '((p "You're in some sort of hotel lobby. You see a large sign hanging "
  205. "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
  206. "that says \"'ring bell' for service\". Terrible music plays from a speaker "
  207. "somewhere overhead. "
  208. "The room is lined with various curio cabinets, filled with all sorts "
  209. "of kitschy junk. It looks like whoever decorated this place had great "
  210. "ambitions, but actually assembled it all in a hurry and used whatever "
  211. "kind of objects they found lying around.")
  212. (p "There's a door to the north leading to some kind of hallway."))
  213. #:exits
  214. (list (make <exit>
  215. #:name "north"
  216. #:to 'grand-hallway)))
  217. ;; NPC: hotel owner
  218. ('lobby:hotel-owner
  219. <chatty-npc> 'lobby
  220. #:name "a frumpy fellow"
  221. #:desc
  222. '((p " Whoever this is, they looks totally exhausted. They're
  223. collapsed into the only comfortable looking chair in the room and you
  224. don't get the sense that they're likely to move any time soon.
  225. You notice they're wearing a sticker badly adhesed to their clothing
  226. which says \"Hotel Proprietor\", but they look so disorganized that you
  227. think that can't possibly be true... can it?
  228. Despite their exhaustion, you sense they'd be happy to chat with you,
  229. though the conversation may be a bit one sided."))
  230. #:goes-by '("frumpy fellow" "fellow"
  231. "Chris Webber" ; heh, did you rtfc? or was it so obvious?
  232. "hotel proprietor" "proprietor")
  233. #:catchphrases hotel-owner-grumps)
  234. ;; Object: Sign
  235. ('lobby:sign
  236. <readable> 'lobby
  237. #:name "the Hotel Bricabrac sign"
  238. #:desc " It strikes you that there's something funny going on with this sign.
  239. Sure enough, if you look at it hard enough, you can tell that someone
  240. hastily painted over an existing sign and changed the \"M\" to an \"H\".
  241. Classy!"
  242. #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
  243. #:goes-by '("sign"
  244. "bricabrac sign"
  245. "hotel sign"
  246. "hotel bricabrac sign"
  247. "lobby sign"))
  248. ('lobby:bell
  249. <summoning-bell> 'lobby
  250. #:name "a shiny brass bell"
  251. #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
  252. #:desc " A shiny brass bell. Inscribed on its wooden base is the text
  253. \"ring me for service\". You probably could \"ring the bell\" if you
  254. wanted to."
  255. #:summons 'break-room:desk-clerk)
  256. ('lobby:sign-in-form
  257. <sign-in-form> 'lobby
  258. #:name "sign-in form"
  259. #:goes-by '("sign-in form" "form" "signin form")
  260. #:desc '("It looks like you could sign this form and set your name like so: "
  261. (i "sign form as <my-name-here>")))
  262. ;; Object: curio cabinets
  263. ;; TODO: respond to attempts to open the curio cabinet
  264. ('lobby:cabinet
  265. <proxy-items> 'lobby
  266. #:proxy-items '(lobby:porcelain-doll
  267. lobby:1950s-robots
  268. lobby:tea-set lobby:mustard-pot
  269. lobby:head-of-elvis lobby:circuitboard-of-evlis
  270. lobby:teletype-scroll lobby:orange-cat-phone)
  271. #:name "a curio cabinet"
  272. #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
  273. "cabinet of curiosities")
  274. #:desc (lambda _
  275. (format #f " The curio cabinet is full of all sorts of oddities!
  276. Something catches your eye!
  277. Ooh, ~a!" (random-choice
  278. '("a creepy porcelain doll"
  279. "assorted 1950s robots"
  280. "an exquisite tea set"
  281. "an antique mustard pot"
  282. "the pickled head of Elvis"
  283. "the pickled circuitboard of EVLIS"
  284. "a scroll of teletype paper holding the software Four Freedoms"
  285. "a telephone shaped like an orange cartoon cat")))))
  286. ('lobby:porcelain-doll
  287. <cabinet-item> 'lobby
  288. #:invisible? #t
  289. #:name "a creepy porcelain doll"
  290. #:desc "It strikes you that while the doll is technically well crafted,
  291. it's also the stuff of nightmares."
  292. #:goes-by '("porcelain doll" "doll"))
  293. ('lobby:1950s-robots
  294. <cabinet-item> 'lobby
  295. #:invisible? #t
  296. #:name "a set of 1950s robots"
  297. #:desc "There's a whole set of these 1950s style robots.
  298. They seem to be stamped out of tin, and have various decorations of levers
  299. and buttons and springs. Some of them have wind-up knobs on them."
  300. #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
  301. ('lobby:tea-set
  302. <cabinet-item> 'lobby
  303. #:invisible? #t
  304. #:name "a tea set"
  305. #:desc "A complete tea set. Some of the cups are chipped.
  306. You can imagine yourself joining a tea party using this set, around a
  307. nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
  308. #:goes-by '("tea set" "tea"))
  309. ('lobby:cups
  310. <cabinet-item> 'lobby
  311. #:invisible? #t
  312. #:name "cups from the tea set"
  313. #:desc "They're chipped."
  314. #:goes-by '("cups"))
  315. ('lobby:mustard-pot
  316. <cabinet-item> 'lobby
  317. #:invisible? #t
  318. #:name "a mustard pot"
  319. #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
  320. nice design, and it's an antique, but you can't imagine putting something
  321. like this in a museum.")
  322. (p "Ha... imagine that... a mustard museum."))
  323. #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
  324. ('lobby:head-of-elvis
  325. <cabinet-item> 'lobby
  326. #:invisible? #t
  327. #:name "the pickled head of Elvis"
  328. #:desc '((p "It's a jar full of some briny-looking liquid and...
  329. a free floating head. The head looks an awful lot like Elvis, and
  330. definitely not the younger Elvis. The hair even somehow maintains
  331. that signature swoop while suspended in liquid. But of course it's
  332. not Elvis.")
  333. (p "Oh, wait, it has a label at the bottom which says:
  334. \"This is really the head of Elvis\". Well... maybe don't believe
  335. everything you read."))
  336. #:goes-by '("pickled head of elvis" "pickled head of Elvis"
  337. "elvis" "Elvis" "head" "pickled head"))
  338. ('lobby:circuitboard-of-evlis
  339. <cabinet-item> 'lobby
  340. #:invisible? #t
  341. #:name "the pickled circuitboard of Evlis"
  342. #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
  343. This is quite the find, and you bet just about anyone interested in
  344. preserving computer history would love to get their hands on this.")
  345. (p "Unfortunately, whatever moron did acquire this has
  346. no idea what it means to preserve computers, so here it is floating
  347. in some kind of briny liquid. It appears to be heavily corroded.
  348. Too bad..."))
  349. #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
  350. "pickled circuitboard of EVLIS"
  351. "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
  352. ('lobby:teletype-scroll
  353. <cabinet-item> 'lobby
  354. #:invisible? #t
  355. #:name "a scroll of teletype"
  356. #:desc '((p "This is a scroll of teletype paper. It's a bit old
  357. and yellowed but the type is very legible. It says:")
  358. (br)
  359. (i
  360. (p (strong "== The four essential freedoms =="))
  361. (p "A program is free software if the program's users have
  362. the four essential freedoms: ")
  363. (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
  364. (li "The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.")
  365. (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
  366. (li "The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.")))
  367. (p "You get this feeling that ambiguities in the
  368. English language surrounding the word 'free' have lead to a lot of terminology debates."))
  369. #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
  370. "teletype paper" "scroll" "four freedoms"
  371. "scroll of teletype paper holding the software Four Freedoms"
  372. "scroll of teletype paper holding the software four freedoms"))
  373. ('lobby:orange-cat-phone
  374. <cabinet-item> 'lobby
  375. #:invisible? #t
  376. #:name "a telephone shaped like an orange cartoon cat"
  377. #:desc "It's made out of a cheap plastic, and it's very orange.
  378. It resembles a striped tabby, and it's eyes hold the emotion of
  379. a being both sleepy and smarmy.
  380. You suspect that someone, somewhere made a ton of cash on items holding
  381. this general shape in the 1990s."
  382. #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
  383. "orange cat phone" "orange cat telephone"
  384. "cartoon cat phone" "cartoon cat"
  385. "cat phone" "cat telephone" "phone" "telephone"))))
  386. ;;; Grand hallway
  387. ;;; -------------
  388. (define-actor <disc-shield> (<gameobj>)
  389. ((cmd-take disc-shield-take)))
  390. (define* (disc-shield-take gameobj message
  391. #:key direct-obj
  392. (player (message-from message)))
  393. (create-gameobj <glowing-disc> (gameobj-gm gameobj)
  394. player) ;; set loc to player to put in player's inventory
  395. (<- player 'tell
  396. #:text '((p "As you attempt to pull the shield / disk platter
  397. from the statue a shining outline appears around it... and a
  398. completely separate, glowing copy of the disc materializes into your
  399. hands!")))
  400. (<- (gameobj-loc gameobj) 'tell-room
  401. #:text `(,(mbody-val (<-wait player 'get-name))
  402. " pulls on the shield of the statue, and a glowing "
  403. "copy of it materializes into their hands!")
  404. #:exclude player)
  405. (<- (gameobj-loc gameobj) 'tell-room
  406. #:text
  407. '(p "You hear a voice whisper: "
  408. (i "\"Share the software... and you'll be free...\""))))
  409. ;;; This is the disc that gets put in the player's inventory
  410. (define-actor <glowing-disc> (<gameobj>)
  411. ((cmd-drop glowing-disc-drop-cmd))
  412. (initial-props
  413. #:allocation #:each-subclass
  414. #:init-thunk (build-props
  415. '((hd-platter? . #t))))
  416. (name #:allocation #:each-subclass
  417. #:init-value "a glowing disc")
  418. (desc #:allocation #:each-subclass
  419. #:init-value "A brightly glowing disc. It's shaped like a hard
  420. drive platter, not unlike the one from the statue it came from. It's
  421. labeled \"RL02.5\".")
  422. (goes-by #:init-value '("glowing disc" "glowing platter"
  423. "glowing disc platter" "glowing disk platter"
  424. "platter" "disc" "disk" "glowing shield")))
  425. (define* (glowing-disc-drop-cmd gameobj message
  426. #:key direct-obj
  427. (player (message-from message)))
  428. (<- player 'tell
  429. #:text "You drop the glowing disc, and it shatters into a million pieces!")
  430. (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
  431. #:text `(,(mbody-val (<-wait player 'get-name))
  432. " drops a glowing disc, and it shatters into a million pieces!")
  433. #:exclude player)
  434. (gameobj-self-destruct gameobj))
  435. ;;; Grand hallway
  436. (define lobby-map-text
  437. "\
  438. | : : |
  439. .----------.----------. : & : .----------.----------.
  440. | computer | |& :YOU ARE: &| smoking | *UNDER* |
  441. | room + playroom + : HERE : + parlor | *CONS- |
  442. | > | |& : : &| | TRUCTION*|
  443. '----------'----------'-++-------++-'-------+--'----------'
  444. | '-----' | | |
  445. : LOBBY : '---'
  446. '. .'
  447. '---------'")
  448. (define grand-hallway
  449. (lol
  450. ('grand-hallway
  451. <room> #f
  452. #:name "Grand Hallway"
  453. #:desc '((p " A majestic red carpet runs down the center of the room.
  454. Busts of serious looking people line the walls, but there's no
  455. clear indication that they have any logical relation to this place.")
  456. (p "In the center is a large statue of a woman in a warrior's
  457. pose, but something is strange about her weapon and shield. You wonder what
  458. that's all about?")
  459. (p "To the south is the lobby. A door to the east is labeled \"smoking
  460. room\", while a door to the west is labeled \"playroom\"."))
  461. #:exits
  462. (list (make <exit>
  463. #:name "south"
  464. #:to 'lobby)
  465. (make <exit>
  466. #:name "west"
  467. #:to 'playroom)
  468. (make <exit>
  469. #:name "east"
  470. #:to 'smoking-parlor)))
  471. ('grand-hallway:map
  472. <readable> 'grand-hallway
  473. #:name "the hotel map"
  474. #:desc '("This appears to be a map of the hotel. "
  475. "Like the hotel itself, it seems to be "
  476. "incomplete."
  477. "You could read it if you want to.")
  478. #:read-text `(pre ,lobby-map-text)
  479. #:goes-by '("map" "hotel map"))
  480. ('grand-hallway:carpet
  481. <gameobj> 'grand-hallway
  482. #:name "the Grand Hallway carpet"
  483. #:desc "It's very red, except in the places where it's very worn."
  484. #:invisible? #t
  485. #:goes-by '("red carpet" "carpet"))
  486. ('grand-hallway:busts
  487. <gameobj> 'grand-hallway
  488. #:name "the busts of serious people"
  489. #:desc "There are about 6 of them in total. They look distinguished
  490. but there's no indication of who they are."
  491. #:invisible? #t
  492. #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
  493. ('grand-hallway:hackthena-statue
  494. <proxy-items> 'grand-hallway
  495. #:name "the statue of Hackthena"
  496. #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
  497. spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
  498. all good hacks, and legendary hacker herself.")
  499. (p "Hackthena holds the form of a human woman. She wears flowing
  500. robes, has a pear of curly bovine-esque horns protruding from the sides of her
  501. head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
  502. But instead of a weapon, she seems to hold some sort of keyboard. And her
  503. shield... well it's round like a shield, but something seems off about it.
  504. You'd better take a closer look to be sure."))
  505. #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
  506. #:proxy-items '(grand-hallway:keyboard
  507. grand-hallway:disc-platter
  508. grand-hallway:hackthena-horns))
  509. ('grand-hallway:keyboard
  510. <gameobj> 'grand-hallway
  511. #:name "a Knight Keyboard"
  512. #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
  513. Any space cadet can see that with that kind of layout a hack-and-slayer could
  514. thrash out some serious key-chords like there's no tomorrow. You guess
  515. Hackthena must be an emacs user."
  516. #:invisible? #t
  517. #:take-me? (lambda _
  518. (values #f
  519. #:why-not
  520. `("Are you kidding? Do you know how hard it is to find "
  521. "a Knight Keyboard? There's no way she's going "
  522. "to give that up.")))
  523. #:goes-by '("knight keyboard" "keyboard"))
  524. ('grand-hallway:hackthena-horns
  525. <gameobj> 'grand-hallway
  526. #:name "Hackthena's horns"
  527. #:desc "They're not unlike a Gnu's horns."
  528. #:invisible? #t
  529. #:take-me? (lambda _
  530. (values #f
  531. #:why-not
  532. `("Are you seriously considering desecrating a statue?")))
  533. #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
  534. ('grand-hallway:disc-platter
  535. <disc-shield> 'grand-hallway
  536. #:name "Hackthena's shield"
  537. #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
  538. platter! It has \"RL02.5\" written on it. It looks kind of loose."
  539. #:invisible? #t
  540. #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
  541. ;;; Playroom
  542. ;;; --------
  543. (define-actor <rgb-machine> (<gameobj>)
  544. ((cmd-run rgb-machine-cmd-run)
  545. (cmd-reset rgb-machine-cmd-reset))
  546. (commands
  547. #:allocation #:each-subclass
  548. #:init-thunk (build-commands
  549. (("run" "start") ((direct-command cmd-run)))
  550. ("reset" ((direct-command cmd-reset)))))
  551. (resetting #:init-value #f
  552. #:accessor .resetting)
  553. ;; used to reset, and to kick off the first item in the list
  554. (rgb-items #:init-keyword #:rgb-items
  555. #:accessor .rgb-items))
  556. (define (rgb-machine-cmd-run rgb-machine message . _)
  557. (define player (message-from message))
  558. (<-wait player 'tell
  559. #:text '("You start the rube goldberg machine."))
  560. (<-wait (gameobj-loc rgb-machine) 'tell-room
  561. #:text `(,(mbody-val (<-wait player 'get-name))
  562. " runs the rube goldberg machine.")
  563. #:exclude player)
  564. (8sleep 1)
  565. (match (.rgb-items rgb-machine)
  566. ((first-item rest ...)
  567. (<- (dyn-ref rgb-machine first-item) 'trigger))))
  568. (define (rgb-machine-cmd-reset rgb-machine message . _)
  569. (define player (message-from message))
  570. (cond
  571. ((not (.resetting rgb-machine))
  572. (set! (.resetting rgb-machine) #t)
  573. (<-wait player 'tell
  574. #:text '("You reset the rube goldberg machine."))
  575. (<-wait (gameobj-loc rgb-machine) 'tell-room
  576. #:text `(,(mbody-val (<-wait player 'get-name))
  577. " resets the rube goldberg machine.")
  578. #:exclude player)
  579. (<-wait (gameobj-loc rgb-machine) 'tell-room
  580. #:text '("From a panel in the wall, a white gloved mechanical "
  581. "arm reaches out to reset all the "
  582. "rube goldberg components."))
  583. (8sleep (/ 1 2))
  584. (for-each
  585. (lambda (rgb-item)
  586. (<- (dyn-ref rgb-machine rgb-item) 'reset)
  587. (8sleep (/ 1 2)))
  588. (.rgb-items rgb-machine))
  589. (<- (gameobj-loc rgb-machine) 'tell-room
  590. #:text "The machine's mechanical arm retreats into the wall!")
  591. (set! (.resetting rgb-machine) #f))
  592. (else
  593. (<-wait player 'tell
  594. #:text '("But it's in the middle of resetting right now!")))))
  595. (define-actor <rgb-item> (<gameobj>)
  596. ((trigger rgb-item-trigger)
  597. (reset rgb-item-reset))
  598. (invisible? #:init-value #t)
  599. (steps #:init-keyword #:steps
  600. #:accessor .steps)
  601. (triggers-as #:init-value #f
  602. #:init-keyword #:triggers-as
  603. #:getter .triggers-as)
  604. (reset-msg #:init-keyword #:reset-msg
  605. #:getter .reset-msg)
  606. ;; States: ready -> running -> ran
  607. (state #:init-value 'ready
  608. #:accessor .state))
  609. (define (rgb-item-trigger rgb-item message . _)
  610. (define room (gameobj-loc rgb-item))
  611. (case (.state rgb-item)
  612. ((ready)
  613. ;; Set state to running
  614. (set! (.state rgb-item) 'running)
  615. ;; Loop through all steps
  616. (for-each
  617. (lambda (step)
  618. (match step
  619. ;; A string? That's the description of what's happening, tell players
  620. ((? string? str)
  621. (<- room 'tell-room #:text str))
  622. ;; A number? Sleep for that many secs
  623. ((? number? num)
  624. (8sleep num))
  625. ;; A symbol? That's another gameobj to look up dynamically
  626. ((? symbol? sym)
  627. (<- (dyn-ref rgb-item sym) 'trigger
  628. #:triggered-by (.triggers-as rgb-item)))
  629. (_ (throw 'unknown-step-type
  630. "Don't know how to process rube goldberg machine step type?"
  631. #:step step))))
  632. (.steps rgb-item))
  633. ;; We're done! Set state to ran
  634. (set! (.state rgb-item) 'ran))
  635. (else
  636. (<- room 'tell-room
  637. #:text `("... but " ,(slot-ref rgb-item 'name)
  638. " has already been triggered!")))))
  639. (define (rgb-item-reset rgb-item message . _)
  640. (define room (gameobj-loc rgb-item))
  641. (case (.state rgb-item)
  642. ((ran)
  643. (set! (.state rgb-item) 'ready)
  644. (<- room 'tell-room
  645. #:text (.reset-msg rgb-item)))
  646. ((running)
  647. (<- room 'tell-room
  648. #:text `("... but " ,(slot-ref rgb-item 'name)
  649. " is currently running!")))
  650. ((ready)
  651. (<- room 'tell-room
  652. #:text `("... but " ,(slot-ref rgb-item 'name)
  653. " has already been reset.")))))
  654. (define-actor <rgb-kettle> (<rgb-item>)
  655. ((trigger rgb-kettle-trigger)
  656. (reset rgb-kettle-reset))
  657. (heated #:accessor .heated
  658. #:init-value #f)
  659. (filled #:accessor .filled
  660. #:init-value #f))
  661. (define* (rgb-kettle-trigger rgb-item message #:key triggered-by)
  662. (define room (gameobj-loc rgb-item))
  663. (if (not (eq? (.state rgb-item) 'ran))
  664. (begin
  665. (match triggered-by
  666. ('water-demon
  667. (set! (.state rgb-item) 'running)
  668. (set! (.filled rgb-item) #t))
  669. ('quik-heater
  670. (set! (.state rgb-item) 'running)
  671. (set! (.heated rgb-item) #t)))
  672. (when (and (.filled rgb-item)
  673. (.heated rgb-item))
  674. (<- room 'tell-room
  675. #:text '((i "*kshhhhhh!*")
  676. " The water has boiled!"))
  677. (8sleep .25)
  678. (set! (.state rgb-item) 'ran)
  679. ;; insert a cup of hot tea in the room
  680. (create-gameobj <hot-tea> (gameobj-gm rgb-item) room)
  681. (<- room 'tell-room
  682. #:text '("The machine pours out a cup of hot tea! "
  683. "Looks like the machine finished!"))))
  684. (<- room 'tell-room
  685. #:text `("... but " ,(slot-ref rgb-item 'name)
  686. " has already been triggered!"))))
  687. (define (rgb-kettle-reset rgb-item message . rest-args)
  688. (define room (gameobj-loc rgb-item))
  689. (when (eq? (.state rgb-item) 'ran)
  690. (set! (.heated rgb-item) #f)
  691. (set! (.filled rgb-item) #f))
  692. (apply rgb-item-reset rgb-item message rest-args))
  693. (define-actor <tinfoil-hat> (<gameobj>)
  694. ((cmd-wear tinfoil-hat-wear))
  695. (contained-commands
  696. #:allocation #:each-subclass
  697. #:init-thunk (build-commands
  698. ("wear" ((direct-command cmd-wear))))))
  699. (define (tinfoil-hat-wear tinfoil-hat message . _)
  700. (<- (message-from message) 'tell
  701. #:text '("You put on the tinfoil hat, and, to be perfectly honest with you "
  702. "it's a lot harder to take you seriously.")))
  703. (define-actor <hot-tea> (<gameobj>)
  704. ((cmd-drink hot-tea-cmd-drink)
  705. (cmd-sip hot-tea-cmd-sip))
  706. (contained-commands
  707. #:allocation #:each-subclass
  708. #:init-thunk (build-commands
  709. ("drink" ((direct-command cmd-drink)))
  710. ("sip" ((direct-command cmd-sip)))))
  711. (sips-left #:init-value 4
  712. #:accessor .sips-left)
  713. (name #:init-value "a cup of hot tea")
  714. (take-me? #:init-value #t)
  715. (goes-by #:init-value '("cup of hot tea" "cup of tea" "tea" "cup"))
  716. (desc #:init-value "It's a steaming cup of hot tea. It looks pretty good!"))
  717. (define (hot-tea-cmd-drink hot-tea message . _)
  718. (define player (message-from message))
  719. (define player-loc (mbody-val (<-wait player 'get-loc)))
  720. (define player-name (mbody-val (<-wait player 'get-name)))
  721. (<- player 'tell
  722. #:text "You drink a steaming cup of hot tea all at once... hot hot hot!")
  723. (<- player-loc 'tell-room
  724. #:text `(,player-name
  725. " drinks a steaming cup of hot tea all at once.")
  726. #:exclude player)
  727. (gameobj-self-destruct hot-tea))
  728. (define (hot-tea-cmd-sip hot-tea message . _)
  729. (define player (message-from message))
  730. (define player-loc (mbody-val (<-wait player 'get-loc)))
  731. (define player-name (mbody-val (<-wait player 'get-name)))
  732. (set! (.sips-left hot-tea) (- (.sips-left hot-tea) 1))
  733. (<- player 'tell
  734. #:text "You take a sip of your steaming hot tea. How refined!")
  735. (<- player-loc 'tell-room
  736. #:text `(,player-name
  737. " takes a sip of their steaming hot tea. How refined!")
  738. #:exclude player)
  739. (when (= (.sips-left hot-tea) 0)
  740. (<- player 'tell
  741. #:text "You've finished your tea!")
  742. (<- player-loc 'tell-room
  743. #:text `(,player-name
  744. " finishes their tea!")
  745. #:exclude player)
  746. (gameobj-self-destruct hot-tea)))
  747. (define-actor <fanny-pack> (<container>)
  748. ((cmd-take-from-while-wearing cmd-take-from)
  749. (cmd-put-in-while-wearing cmd-put-in))
  750. (contained-commands
  751. #:allocation #:each-subclass
  752. #:init-thunk
  753. (build-commands
  754. (("l" "look") ((direct-command cmd-look-at)))
  755. ("take" ((prep-indir-command cmd-take-from-while-wearing
  756. '("from" "out of"))))
  757. ("put" ((prep-indir-command cmd-put-in-while-wearing
  758. '("in" "inside" "into" "on")))))))
  759. (define playroom
  760. (lol
  761. ('playroom
  762. <room> #f
  763. #:name "The Playroom"
  764. #:desc '(p (" There are toys scattered everywhere here. It's really unclear
  765. if this room is intended for children or child-like adults.")
  766. (" There are doors to both the east and the west."))
  767. #:exits
  768. (list (make <exit>
  769. #:name "east"
  770. #:to 'grand-hallway)
  771. (make <exit>
  772. #:name "west"
  773. #:to 'computer-room)))
  774. ('playroom:cubey
  775. <gameobj> 'playroom
  776. #:name "Cubey"
  777. #:take-me? #t
  778. #:desc " It's a little foam cube with googly eyes on it. So cute!")
  779. ('playroom:cuddles-plushie
  780. <gameobj> 'playroom
  781. #:name "a Cuddles plushie"
  782. #:goes-by '("plushie" "cuddles plushie" "cuddles")
  783. #:take-me? #t
  784. #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
  785. ('playroom:toy-chest
  786. <container> 'playroom
  787. #:name "a toy chest"
  788. #:goes-by '("toy chest" "chest")
  789. #:desc (lambda (toy-chest whos-looking)
  790. (let ((contents (gameobj-occupants toy-chest)))
  791. `((p "A brightly painted wooden chest. The word \"TOYS\" is "
  792. "engraved on it.")
  793. (p "Inside you see:"
  794. ,(if (eq? contents '())
  795. " nothing! It's empty!"
  796. `(ul ,(map (lambda (occupant)
  797. `(li ,(mbody-val
  798. (<-wait occupant 'get-name))))
  799. (gameobj-occupants toy-chest))))))))
  800. #:take-from-me? #t
  801. #:put-in-me? #t)
  802. ;; Things inside the toy chest
  803. ('playroom:toy-chest:rubber-duck
  804. <gameobj> 'playroom:toy-chest
  805. #:name "a rubber duck"
  806. #:goes-by '("rubber duck" "duck")
  807. #:take-me? #t
  808. #:desc "It's a yellow rubber duck with a bright orange beak.")
  809. ('playroom:toy-chest:tinfoil-hat
  810. <tinfoil-hat> 'playroom:toy-chest
  811. #:name "a tinfoil hat"
  812. #:goes-by '("tinfoil hat" "hat")
  813. #:take-me? #t
  814. #:desc "You'd have to be a crazy person to wear this thing!")
  815. ('playroom:toy-chest:fanny-pack
  816. <fanny-pack> 'playroom:toy-chest
  817. #:name "a fanny pack"
  818. #:goes-by '("fanny pack" "pack")
  819. #:take-me? #t
  820. #:desc
  821. (lambda (toy-chest whos-looking)
  822. (let ((contents (gameobj-occupants toy-chest)))
  823. `((p "It's a leather fanny pack, so it's both tacky and kinda cool.")
  824. (p "Inside you see:"
  825. ,(if (eq? contents '())
  826. " nothing! It's empty!"
  827. `(ul ,(map (lambda (occupant)
  828. `(li ,(mbody-val
  829. (<-wait occupant 'get-name))))
  830. (gameobj-occupants toy-chest)))))))))
  831. ;; Things inside the toy chest
  832. ('playroom:toy-chest:fanny-pack:plastic-elephant
  833. <gameobj> 'playroom:toy-chest:fanny-pack
  834. #:name "a plastic elephant"
  835. #:goes-by '("plastic elephant" "elephant")
  836. #:take-me? #t
  837. #:desc "It's a tiny little plastic elephant. Small, but heartwarming.")
  838. ('playroom:rgb-machine
  839. <rgb-machine> 'playroom
  840. #:name "a Rube Goldberg machine"
  841. #:goes-by '("rube goldberg machine" "machine")
  842. #:rgb-items '(playroom:rgb-dominoes
  843. playroom:rgb-switch-match
  844. playroom:rgb-candle
  845. playroom:rgb-catapult
  846. playroom:rgb-water-demon
  847. playroom:rgb-quik-heater
  848. playroom:rgb-kettle)
  849. #:desc "It's one of those hilarious Rube Goldberg machines.
  850. What could happen if you started it?")
  851. ;; Dominoes topple
  852. ('playroom:rgb-dominoes
  853. <rgb-item> 'playroom
  854. #:name "some dominoes"
  855. #:goes-by '("dominoes" "some dominoes")
  856. #:steps `("The dominoes topple down the line..."
  857. 1
  858. "The last domino lands on a switch!"
  859. 1.5
  860. playroom:rgb-switch-match)
  861. #:reset-msg "The dominoes are placed back into position.")
  862. ;; Which hit the switch and strike a match
  863. ('playroom:rgb-switch-match
  864. <rgb-item> 'playroom
  865. #:name "a switch"
  866. #:goes-by '("switch" "match")
  867. #:steps `("The switch lights a match!"
  868. ,(/ 2 3)
  869. "The match lights a candle!"
  870. 1.5
  871. playroom:rgb-candle)
  872. #:reset-msg "A fresh match is installed and the switch is reset.")
  873. ;; which lights a candle and burns a rope
  874. ('playroom:rgb-candle
  875. <rgb-item> 'playroom
  876. #:name "a candle"
  877. #:goes-by '("candle")
  878. #:steps `("The candle burns..."
  879. (/ 2 3) ; oops!
  880. "The candle is burning away a rope!"
  881. 2
  882. "The rope snaps!"
  883. .5
  884. playroom:rgb-catapult)
  885. #:reset-msg "A fresh candle is installed.")
  886. ;; which catapults a rock
  887. ('playroom:rgb-catapult
  888. <rgb-item> 'playroom
  889. #:name "a catapult"
  890. #:goes-by '("catapult")
  891. #:steps `("The snapped rope unleashes a catapult, which throws a rock!"
  892. 2
  893. "The rock flies through a water demon, startling it!"
  894. .5
  895. playroom:rgb-water-demon
  896. 2
  897. "The rock whacks into the quik-heater's on button!"
  898. .5
  899. playroom:rgb-quik-heater)
  900. #:reset-msg
  901. '("A fresh rope is attached to the catapult, which is pulled taught. "
  902. "A fresh rock is placed on the catapult."))
  903. ;; which both:
  904. ;; '- panics the water demon
  905. ;; '- which waters the kettle
  906. ('playroom:rgb-water-demon
  907. <rgb-item> 'playroom
  908. #:name "the water demon"
  909. #:triggers-as 'water-demon
  910. #:goes-by '("water demon" "demon")
  911. #:steps `("The water demon panics, and starts leaking water into the kettle below!"
  912. 3
  913. "The kettle is filled!"
  914. playroom:rgb-kettle)
  915. #:reset-msg '("The water demon is scratched behind the ears and calms down."))
  916. ;; '- bops the quik-heater button
  917. ;; '- which heats the kettle
  918. ('playroom:rgb-quik-heater
  919. <rgb-item> 'playroom
  920. #:name "the quik heater"
  921. #:triggers-as 'quik-heater
  922. #:goes-by '("quik heater" "heater")
  923. #:steps `("The quik-heater heats up the kettle above it!"
  924. 3
  925. "The kettle is heated up!"
  926. playroom:rgb-kettle)
  927. #:reset-msg '("The quik heater is turned off."))
  928. ;; Finally, the kettle
  929. ('playroom:rgb-kettle
  930. <rgb-kettle> 'playroom
  931. #:name "the kettle"
  932. #:goes-by '("kettle")
  933. #:reset-msg '("The kettle is emptied."))))
  934. ;;; Writing room
  935. ;;; ------------
  936. ;;; Armory???
  937. ;;; ---------
  938. ;; ... full of NURPH weapons?
  939. ;;; Smoking parlor
  940. ;;; --------------
  941. (define-class <furniture> (<gameobj>)
  942. (sit-phrase #:init-keyword #:sit-phrase)
  943. (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
  944. (sit-name #:init-keyword #:sit-name)
  945. (commands
  946. #:allocation #:each-subclass
  947. #:init-thunk (build-commands
  948. ("sit" ((direct-command cmd-sit-furniture)))))
  949. (actions #:allocation #:each-subclass
  950. #:init-thunk (build-actions
  951. (cmd-sit-furniture furniture-cmd-sit))))
  952. (define* (furniture-cmd-sit actor message #:key direct-obj)
  953. (define player-name
  954. (mbody-val (<-wait (message-from message) 'get-name)))
  955. (<- (message-from message) 'tell
  956. #:text (format #f "You ~a ~a.\n"
  957. (slot-ref actor 'sit-phrase)
  958. (slot-ref actor 'sit-name)))
  959. (<- (slot-ref actor 'loc) 'tell-room
  960. #:text (format #f "~a ~a on ~a.\n"
  961. player-name
  962. (slot-ref actor 'sit-phrase-third-person)
  963. (slot-ref actor 'sit-name))
  964. #:exclude (message-from message)))
  965. (define smoking-parlor
  966. (lol
  967. ('smoking-parlor
  968. <room> #f
  969. #:name "Smoking Parlor"
  970. #:desc
  971. '((p "This room looks quite posh. There are huge comfy seats you can sit in
  972. if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
  973. have installed this place and then changed their mind later.")
  974. (p "There's a door to the west leading back to the grand hallway, and
  975. a nondescript steel door to the south, leading apparently outside."))
  976. #:exits
  977. (list (make <exit>
  978. #:name "west"
  979. #:to 'grand-hallway)
  980. (make <exit>
  981. #:name "south"
  982. #:to 'break-room)))
  983. ('smoking-parlor:chair
  984. <furniture> 'smoking-parlor
  985. #:name "a comfy leather chair"
  986. #:desc " That leather chair looks really comfy!"
  987. #:goes-by '("leather chair" "comfy leather chair" "chair")
  988. #:sit-phrase "sink into"
  989. #:sit-phrase-third-person "sinks into"
  990. #:sit-name "the comfy leather chair")
  991. ('smoking-parlor:sofa
  992. <furniture> 'smoking-parlor
  993. #:name "a plush leather sofa"
  994. #:desc " That leather chair looks really comfy!"
  995. #:goes-by '("leather sofa" "plush leather sofa" "sofa"
  996. "leather couch" "plush leather couch" "couch")
  997. #:sit-phrase "sprawl out on"
  998. #:sit-phrase-third-person "sprawls out on into"
  999. #:sit-name "the plush leather couch")
  1000. ('smoking-parlor:bar-stool
  1001. <furniture> 'smoking-parlor
  1002. #:name "a bar stool"
  1003. #:desc " Conveniently located near the bar! Not the most comfortable
  1004. seat in the room, though."
  1005. #:goes-by '("stool" "bar stool" "seat")
  1006. #:sit-phrase "hop on"
  1007. #:sit-phrase-third-person "hops onto"
  1008. #:sit-name "the bar stool")
  1009. ('ford-prefect
  1010. <chatty-npc> 'smoking-parlor
  1011. #:name "Ford Prefect"
  1012. #:desc "Just some guy, you know?"
  1013. #:goes-by '("Ford Prefect" "ford prefect"
  1014. "frood" "prefect" "ford")
  1015. #:catchphrases prefect-quotes)
  1016. ('smoking-parlor:no-smoking-sign
  1017. <readable> 'smoking-parlor
  1018. #:invisible? #t
  1019. #:name "No Smoking Sign"
  1020. #:desc "This sign says \"No Smoking\" in big, red letters.
  1021. It has some bits of bubble gum stuck to it... yuck."
  1022. #:goes-by '("no smoking sign" "sign")
  1023. #:read-text "It says \"No Smoking\", just like you'd expect from
  1024. a No Smoking sign.")
  1025. ;; TODO: Cigar dispenser
  1026. ))
  1027. ;;; Breakroom
  1028. ;;; ---------
  1029. (define-class <desk-clerk> (<gameobj>)
  1030. ;; The desk clerk has three states:
  1031. ;; - on-duty: Arrived, and waiting for instructions (and losing patience
  1032. ;; gradually)
  1033. ;; - slacking: In the break room, probably smoking a cigarette
  1034. ;; or checking text messages
  1035. (state #:init-value 'slacking)
  1036. (commands #:allocation #:each-subclass
  1037. #:init-thunk
  1038. (build-commands
  1039. (("talk" "chat") ((direct-command cmd-chat)))
  1040. ("ask" ((direct-command cmd-ask-incomplete)
  1041. (prep-direct-command cmd-ask-about)))
  1042. ("dismiss" ((direct-command cmd-dismiss)))))
  1043. (patience #:init-value 0)
  1044. (actions #:allocation #:each-subclass
  1045. #:init-thunk (build-actions
  1046. (init clerk-act-init)
  1047. (cmd-chat clerk-cmd-chat)
  1048. (cmd-ask-incomplete clerk-cmd-ask-incomplete)
  1049. (cmd-ask-about clerk-cmd-ask)
  1050. (cmd-dismiss clerk-cmd-dismiss)
  1051. (update-loop clerk-act-update-loop)
  1052. (be-summoned clerk-act-be-summoned))))
  1053. (define (clerk-act-init clerk message . _)
  1054. ;; call the gameobj main init method
  1055. (gameobj-act-init clerk message)
  1056. ;; start our main loop
  1057. (<- (actor-id clerk) 'update-loop))
  1058. (define changing-name-text "Changing your name is easy!
  1059. We have a clipboard here at the desk
  1060. where you can make yourself known to other participants in the hotel
  1061. if you sign it. Try 'sign form as <your-name>', replacing
  1062. <your-name>, obviously!")
  1063. (define phd-text
  1064. "Ah... when I'm not here, I've got a PHD to finish.")
  1065. (define clerk-help-topics
  1066. `(("changing name" . ,changing-name-text)
  1067. ("sign-in form" . ,changing-name-text)
  1068. ("form" . ,changing-name-text)
  1069. ("common commands" .
  1070. "Here are some useful commands you might like to try: chat,
  1071. go, take, drop, say...")
  1072. ("hotel" .
  1073. "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
  1074. our hotel emphasizes interesting experiences over rest and lodging.
  1075. The origins of the hotel are... unclear... and it has recently come
  1076. under new... 'management'. But at Hotel Bricabrac we believe these
  1077. aspects make the hotel into a fun and unique experience! Please,
  1078. feel free to walk around and explore.")
  1079. ("physics paper" . ,phd-text)
  1080. ("paper" . ,phd-text)
  1081. ("proprietor" . "Oh, he's that frumpy looking fellow sitting over there.")))
  1082. (define clerk-knows-about
  1083. "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
  1084. (define clerk-general-helpful-line
  1085. (string-append
  1086. "The clerk says, \"If you need help with anything, feel free to ask me about it.
  1087. For example, 'ask clerk about changing name'. You can ask me about the following:
  1088. " clerk-knows-about ".\"\n"))
  1089. (define clerk-slacking-complaints
  1090. '("The pay here is absolutely lousy."
  1091. "The owner here has no idea what they're doing."
  1092. "Some times you just gotta step away, you know?"
  1093. "You as exhausted as I am?"
  1094. "Yeah well, this is just temporary. I'm studying to be a high
  1095. energy particle physicist. But ya gotta pay the bills, especially
  1096. with tuition at where it is..."))
  1097. (define* (clerk-cmd-chat clerk message #:key direct-obj)
  1098. (match (slot-ref clerk 'state)
  1099. ('on-duty
  1100. (<- (message-from message) 'tell
  1101. #:text clerk-general-helpful-line))
  1102. ('slacking
  1103. (<- (message-from message) 'tell
  1104. #:text
  1105. (string-append
  1106. "The clerk says, \""
  1107. (random-choice clerk-slacking-complaints)
  1108. "\"\n")))))
  1109. (define (clerk-cmd-ask-incomplete clerk message . _)
  1110. (<- (message-from message) 'tell
  1111. #:text "The clerk says, \"Ask about what?\"\n"))
  1112. (define clerk-doesnt-know-text
  1113. "The clerk apologizes and says she doesn't know about that topic.\n")
  1114. (define* (clerk-cmd-ask clerk message #:key indir-obj
  1115. #:allow-other-keys)
  1116. (match (slot-ref clerk 'state)
  1117. ('on-duty
  1118. (match (assoc indir-obj clerk-help-topics)
  1119. ((_ . info)
  1120. (<- (message-from message) 'tell
  1121. #:text
  1122. (string-append "The clerk clears her throat and says:\n \""
  1123. info
  1124. "\"\n")))
  1125. (#f
  1126. (<- (message-from message) 'tell
  1127. #:text clerk-doesnt-know-text))))
  1128. ('slacking
  1129. (<- (message-from message) 'tell
  1130. #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
  1131. (define* (clerk-act-be-summoned clerk message #:key who-summoned)
  1132. (match (slot-ref clerk 'state)
  1133. ('on-duty
  1134. (<- who-summoned 'tell
  1135. #:text
  1136. "The clerk tells you as politely as she can that she's already here,
  1137. so there's no need to ring the bell.\n"))
  1138. ('slacking
  1139. (<- (gameobj-loc clerk) 'tell-room
  1140. #:text
  1141. "The clerk's ears perk up, she stamps out a cigarette, and she
  1142. runs out of the room!\n")
  1143. (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
  1144. (slot-set! clerk 'patience 8)
  1145. (slot-set! clerk 'state 'on-duty)
  1146. (<- (gameobj-loc clerk) 'tell-room
  1147. #:text
  1148. (string-append
  1149. " Suddenly, a uniformed woman rushes into the room! She's wearing a
  1150. badge that says \"Desk Clerk\".
  1151. \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
  1152. We look forward to your stay. If you'd like help getting acclimated,
  1153. feel free to ask me. For example, 'ask clerk about changing name'.
  1154. You can ask me about the following:
  1155. " clerk-knows-about ".\"\n")))))
  1156. (define* (clerk-cmd-dismiss clerk message . _)
  1157. (define player-name
  1158. (mbody-val (<-wait (message-from message) 'get-name)))
  1159. (match (slot-ref clerk 'state)
  1160. ('on-duty
  1161. (<- (gameobj-loc clerk) 'tell-room
  1162. #:text
  1163. (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
  1164. The clerk leaves the room in a hurry.\n"
  1165. player-name)
  1166. #:exclude (actor-id clerk))
  1167. (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
  1168. (slot-set! clerk 'state 'slacking)
  1169. (<- (gameobj-loc clerk) 'tell-room
  1170. #:text clerk-return-to-slacking-text
  1171. #:exclude (actor-id clerk)))
  1172. ('slacking
  1173. (<- (message-from message) 'tell
  1174. #:text "The clerk sternly asks you to not be so dismissive.\n"))))
  1175. (define clerk-slacking-texts
  1176. '("The clerk takes a long drag on her cigarette.\n"
  1177. "The clerk scrolls through text messages on her phone.\n"
  1178. "The clerk coughs a few times.\n"
  1179. "The clerk checks her watch and justifies a few more minutes outside.\n"
  1180. "The clerk fumbles around for a lighter.\n"
  1181. "The clerk sighs deeply and exhaustedly.\n"
  1182. "The clerk fumbles around for a cigarette.\n"))
  1183. (define clerk-working-impatience-texts
  1184. '("The clerk hums something, but you're not sure what it is."
  1185. "The clerk attempts to change the overhead music, but the dial seems broken."
  1186. "The clerk clicks around on the desk computer."
  1187. "The clerk scribbles an equation on a memo pad, then crosses it out."
  1188. "The clerk mutters something about the proprietor having no idea how to run a hotel."
  1189. "The clerk thumbs through a printout of some physics paper."))
  1190. (define clerk-slack-excuse-text
  1191. "The desk clerk excuses herself, but says you are welcome to ring the bell
  1192. if you need further help.")
  1193. (define clerk-return-to-slacking-text
  1194. "The desk clerk enters and slams the door behind her.\n")
  1195. (define (clerk-act-update-loop clerk message)
  1196. (define (tell-room text)
  1197. (<- (gameobj-loc clerk) 'tell-room
  1198. #:text text
  1199. #:exclude (actor-id clerk)))
  1200. (define (loop-if-not-destructed)
  1201. (if (not (slot-ref clerk 'destructed))
  1202. ;; This iterates by "recursing" on itself by calling itself
  1203. ;; (as the message handler) again. It used to be that we had to do
  1204. ;; this, because there was a bug where a loop which yielded like this
  1205. ;; would keep growing the stack due to some parameter goofiness.
  1206. ;; That's no longer true, but there's an added advantage to this
  1207. ;; route: it's much more live hackable. If we change the definition
  1208. ;; of this method, the character will act differently on the next
  1209. ;; "tick" of the loop.
  1210. (<- (actor-id clerk) 'update-loop)))
  1211. (match (slot-ref clerk 'state)
  1212. ('slacking
  1213. (tell-room (random-choice clerk-slacking-texts))
  1214. (8sleep (+ (random 20) 15))
  1215. (loop-if-not-destructed))
  1216. ('on-duty
  1217. (if (> (slot-ref clerk 'patience) 0)
  1218. ;; Keep working but lose patience gradually
  1219. (begin
  1220. (tell-room (random-choice clerk-working-impatience-texts))
  1221. (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
  1222. (+ (random 2) 1)))
  1223. (8sleep (+ (random 60) 40))
  1224. (loop-if-not-destructed))
  1225. ;; Back to slacking
  1226. (begin
  1227. (tell-room clerk-slack-excuse-text)
  1228. ;; back bto the break room
  1229. (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
  1230. (tell-room clerk-return-to-slacking-text)
  1231. ;; annnnnd back to slacking
  1232. (slot-set! clerk 'state 'slacking)
  1233. (8sleep (+ (random 30) 15))
  1234. (loop-if-not-destructed))))))
  1235. (define break-room
  1236. (lol
  1237. ('break-room
  1238. <room> #f
  1239. #:name "Employee Break Room"
  1240. #:desc " This is less a room and more of an outdoor wire cage. You get
  1241. a bit of a view of the brick exterior of the building, and a crisp wind blows,
  1242. whistling, through the openings of the fenced area. Partly smoked cigarettes
  1243. and various other debris cover the floor.
  1244. Through the wires you can see... well... hm. It looks oddly like
  1245. the scenery tapers off nothingness. But that can't be right, can it?"
  1246. #:exits
  1247. (list (make <exit>
  1248. #:name "north"
  1249. #:to 'smoking-parlor)))
  1250. ('break-room:desk-clerk
  1251. <desk-clerk> 'break-room
  1252. #:name "the hotel desk clerk"
  1253. #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
  1254. hotel insignia. She appears to be rather exhausted."
  1255. #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
  1256. ('break-room:void
  1257. <gameobj> 'break-room
  1258. #:invisible? #t
  1259. #:name "The Void"
  1260. #:desc "As you stare into the void, the void stares back into you."
  1261. #:goes-by '("void" "abyss" "nothingness" "scenery"))
  1262. ('break-room:fence
  1263. <gameobj> 'break-room
  1264. #:invisible? #t
  1265. #:name "break room cage"
  1266. #:desc "It's a mostly-cubical wire mesh surrounding the break area.
  1267. You can see through the gaps, but they're too small to put more than a
  1268. couple of fingers through. There appears to be some wear and tear to
  1269. the paint, but the wires themselves seem to be unusually sturdy."
  1270. #:goes-by '("fence" "cage" "wire cage"))))
  1271. ;;; Ennpie's Sea Lounge
  1272. ;;; -------------------
  1273. ;;; Computer room
  1274. ;;; -------------
  1275. ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
  1276. ;; RL02 disk drives. However we increment both by .5 (a true heresy)
  1277. ;; to distinguish both from the real thing.
  1278. (define-actor <hard-drive> (<gameobj>)
  1279. ((cmd-put-in hard-drive-insert)
  1280. (cmd-push-button hard-drive-push-button)
  1281. (get-state hard-drive-act-get-state))
  1282. (commands #:allocation #:each-subclass
  1283. #:init-thunk (build-commands
  1284. ("insert" ((prep-indir-command cmd-put-in
  1285. '("in" "inside" "into"))))
  1286. (("press" "push") ((prep-indir-command cmd-push-button)))))
  1287. ;; the state moves from: empty -> with-disc -> loading -> ready
  1288. (state #:init-value 'empty
  1289. #:accessor .state))
  1290. (define (hard-drive-act-get-state hard-drive message)
  1291. (<-reply message (.state hard-drive)))
  1292. (define* (hard-drive-desc hard-drive #:optional whos-looking)
  1293. `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
  1294. (p "There is a slot where a disk platter could be inserted, "
  1295. ,(if (eq? (.state hard-drive) 'empty)
  1296. "which is currently empty"
  1297. "which contains a glowing platter")
  1298. ". There is a LOAD button "
  1299. ,(if (member (.state hard-drive) '(empty with-disc))
  1300. "which is glowing"
  1301. "which is pressed in and unlit")
  1302. ". There is a READY indicator "
  1303. ,(if (eq? (.state hard-drive) 'ready)
  1304. "which is glowing."
  1305. "which is unlit.")
  1306. ,(if (member (.state hard-drive) '(loading ready))
  1307. " The machine emits a gentle whirring noise."
  1308. ""))))
  1309. (define* (hard-drive-push-button gameobj message
  1310. #:key direct-obj indir-obj preposition
  1311. (player (message-from message)))
  1312. (define (tell-room text)
  1313. (<-wait (gameobj-loc gameobj) 'tell-room
  1314. #:text text))
  1315. (define (tell-room-excluding-player text)
  1316. (<-wait (gameobj-loc gameobj) 'tell-room
  1317. #:text text
  1318. #:exclude player))
  1319. (cond
  1320. ((ci-member direct-obj '("button" "load button" "load"))
  1321. (tell-room-excluding-player
  1322. `(,(mbody-val (<-wait player 'get-name))
  1323. " presses the button on the hard disk."))
  1324. (<- player 'tell
  1325. #:text "You press the button on the hard disk.")
  1326. (case (.state gameobj)
  1327. ((empty)
  1328. ;; I have no idea what this drive did when you didn't have a platter
  1329. ;; in it and pressed load, but I know there was a FAULT button.
  1330. (tell-room "You hear some movement inside the hard drive...")
  1331. (8sleep 1.5)
  1332. (tell-room
  1333. '("... but then the FAULT button blinks a couple times. "
  1334. "What could be missing?")))
  1335. ((with-disc)
  1336. (set! (.state gameobj) 'loading)
  1337. (tell-room "The hard disk begins to spin up!")
  1338. (8sleep 2)
  1339. (set! (.state gameobj) 'ready)
  1340. (tell-room "The READY light turns on!"))
  1341. ((loading ready)
  1342. (<- player 'tell
  1343. #:text '("Pressing the button does nothing right now, "
  1344. "but it does feel satisfying.")))))
  1345. (else
  1346. (<- player 'tell
  1347. #:text '("How could you think of pressing anything else "
  1348. "but that tantalizing button right in front of you?")))))
  1349. (define* (hard-drive-insert gameobj message
  1350. #:key direct-obj indir-obj preposition
  1351. (player (message-from message)))
  1352. (define our-name (slot-ref gameobj 'name))
  1353. (define this-thing
  1354. (call/ec
  1355. (lambda (return)
  1356. (for-each (lambda (occupant)
  1357. (define goes-by (mbody-val (<-wait occupant 'goes-by)))
  1358. (when (ci-member direct-obj goes-by)
  1359. (return occupant)))
  1360. (mbody-val (<-wait player 'get-occupants)))
  1361. ;; nothing found
  1362. #f)))
  1363. (cond
  1364. ((not this-thing)
  1365. (<- player 'tell
  1366. #:text `("You don't seem to have any such " ,direct-obj " to put "
  1367. ,preposition " " ,our-name ".")))
  1368. ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
  1369. (<- player 'tell
  1370. #:text `("It wouldn't make sense to put "
  1371. ,(mbody-val (<-wait this-thing 'get-name))
  1372. " " ,preposition " " ,our-name ".")))
  1373. ((not (eq? (.state gameobj) 'empty))
  1374. (<- player 'tell
  1375. #:text "The disk drive already has a platter in it."))
  1376. (else
  1377. (set! (.state gameobj) 'with-disc)
  1378. (<- player 'tell
  1379. #:text '((p "You insert the glowing disc into the drive.")
  1380. (p "The LOAD button begins to glow."))))))
  1381. ;; The computar
  1382. (define-actor <computer> (<gameobj>)
  1383. ((cmd-run-program computer-run-program)
  1384. (cmd-run-what (lambda (gameobj message . _)
  1385. (<- (message-from message) 'tell
  1386. #:text '("The computer is already running, and a program appears "
  1387. "ready to run."
  1388. "you mean to \"run the program on the computer\""))))
  1389. (cmd-help-run-not-press
  1390. (lambda (gameobj message . _)
  1391. (<- (message-from message) 'tell
  1392. #:text '("You don't need to press / push / flip anything. "
  1393. "You could " (i "run program on computer")
  1394. " already if you wanted to.")))))
  1395. (commands #:allocation #:each-subclass
  1396. #:init-thunk (build-commands
  1397. ("run" ((prep-indir-command cmd-run-program
  1398. '("on"))
  1399. (direct-command cmd-run-what)))
  1400. (("press" "push" "flip")
  1401. ((prep-indir-command cmd-help-run-not-press))))))
  1402. (define* (computer-run-program gameobj message
  1403. #:key direct-obj indir-obj preposition
  1404. (player (message-from message)))
  1405. (define (hd-state)
  1406. (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
  1407. (define (tell-room text)
  1408. (<-wait (gameobj-loc gameobj) 'tell-room
  1409. #:text text))
  1410. (define (tell-room-excluding-player text)
  1411. (<-wait (gameobj-loc gameobj) 'tell-room
  1412. #:text text
  1413. #:exclude player))
  1414. (define (tell-player text)
  1415. (<-wait player 'tell
  1416. #:text text))
  1417. (cond
  1418. ((ci-member direct-obj '("program"))
  1419. (tell-room-excluding-player
  1420. `(,(mbody-val (<-wait player 'get-name))
  1421. " runs the program loaded on the computer..."))
  1422. (tell-player "You run the program on the computer...")
  1423. (cond
  1424. ((not (eq? (hd-state) 'ready))
  1425. (tell-room '("... but it errors out. "
  1426. "It seems to be complaining about a " (b "DISK ERROR!")
  1427. ". It looks like it is missing some essential software.")))
  1428. (else
  1429. (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
  1430. ;; floor panel
  1431. (define-actor <floor-panel> (<gameobj>)
  1432. ;; TODO: Add "open" verb, since obviously people will try that
  1433. ((open? (lambda (panel message)
  1434. (<-reply message (slot-ref panel 'open))))
  1435. (open-up floor-panel-open-up))
  1436. (open #:init-value #f))
  1437. (define (floor-panel-open-up panel message)
  1438. (if (slot-ref panel 'open)
  1439. (<- (gameobj-loc panel) 'tell-room
  1440. #:text '("You hear some gears grind around the hinges of the "
  1441. "floor panel, but it appears to already be open."))
  1442. (begin
  1443. (slot-set! panel 'open #t)
  1444. (<- (gameobj-loc panel) 'tell-room
  1445. #:text '("You hear some gears grind, as the metal panel on "
  1446. "the ground opens and reveals a stairwell going down!")))))
  1447. (define* (floor-panel-desc panel #:optional whos-looking)
  1448. `("It's a large metal panel on the floor in the middle of the room. "
  1449. ,(if (slot-ref panel 'open)
  1450. '("It's currently wide open, revealing a spiraling staircase "
  1451. "which descends into darkness.")
  1452. '("It's currently closed shut, but there are clearly hinges, and "
  1453. "it seems like there is a mechanism which probably opens it via "
  1454. "some automation. What could be down there?"))))
  1455. (define computer-room
  1456. (lol
  1457. ('computer-room
  1458. <room> #f
  1459. #:name "Computer Room"
  1460. #:desc (lambda (gameobj whos-looking)
  1461. (define panel-open
  1462. (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
  1463. 'open?)))
  1464. `((p "A sizable computer cabinet covers a good portion of the left
  1465. wall. It emits a pleasant hum which covers the room like a warm blanket.
  1466. Connected to a computer is a large hard drive.")
  1467. (p "On the floor is a large steel panel. "
  1468. ,(if panel-open
  1469. '("It is wide open, exposing a spiral staircase "
  1470. "which descends into darkness.")
  1471. '("It is closed, but it has hinges which "
  1472. "suggest it could be opened.")))))
  1473. #:exits
  1474. (list (make <exit>
  1475. #:name "east"
  1476. #:to 'playroom)
  1477. (make <exit>
  1478. #:name "down"
  1479. #:to 'underground-lab
  1480. #:traverse-check
  1481. (lambda (exit room whos-exiting)
  1482. (define panel-open
  1483. (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
  1484. 'open?)))
  1485. (if panel-open
  1486. (values #t "You descend the spiral staircase.")
  1487. (values #f '("You'd love to go down, but the only way "
  1488. "through is through that metal panel, "
  1489. "which seems closed.")))))))
  1490. ('computer-room:hard-drive
  1491. <hard-drive> 'computer-room
  1492. #:name "the hard drive"
  1493. #:desc (wrap-apply hard-drive-desc)
  1494. #:goes-by '("hard drive" "drive" "hard disk"))
  1495. ('computer-room:computer
  1496. <computer> 'computer-room
  1497. #:name "the computer"
  1498. #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
  1499. (p "The computer is itself turned on, and it looks like it is "
  1500. "all set up for you to run a program on it."))
  1501. #:goes-by '("computer"))
  1502. ('computer-room:floor-panel
  1503. <floor-panel> 'computer-room
  1504. #:name "a floor panel"
  1505. #:desc (wrap-apply floor-panel-desc)
  1506. #:invisible? #t
  1507. #:goes-by '("floor panel" "panel"))))
  1508. ;;; * UNDERGROUND SECTION OF THE GAME! *
  1509. ;;; The lab
  1510. (define underground-map-text
  1511. "\
  1512. _______ |
  1513. .-' @ '-. \\ ?????
  1514. .' '. .\\
  1515. | [8sync Hive] |======' '-_____
  1516. ', M ,'
  1517. '. @ .'
  1518. \\ @ /
  1519. '-__+__-'
  1520. '. @ .'
  1521. .--------------. \\ /
  1522. | [Guile Async | .-------+------.
  1523. | Museum] | | [Lab] #!#| .-------------.
  1524. | @| | MM | |[Federation |
  1525. | & ^ +##+@ || < +##| Station]|
  1526. | | | @ | | |
  1527. | & # | |*You-Are-Here*| '-------------'
  1528. | # ^ | #+-------+------'
  1529. '-------+------' # #
  1530. # # #
  1531. # # .-----------.
  1532. .-+----. # |# F |
  1533. |@?+%? +#### | ^ f## |
  1534. '------' | f f %|
  1535. |F [Mudsync |
  1536. | $ Swamp] |
  1537. '-----------'")
  1538. (define 8sync-design-goals
  1539. '(ul (li (b "Actor based, shared nothing environment: ")
  1540. "Shared resources are hard to control and result in fighting
  1541. deadlocks, etc. Escape the drudgery: only one actor controls a resource,
  1542. and they only receive one message at a time (though they can \"juggle\"
  1543. messages).")
  1544. (li (b "Live hackable: ")
  1545. "It's hard to plan out a concurrent system; the right structure
  1546. is often found by evolving the system while it runs. Make it easy to
  1547. build, shape, and change a running system, as well as observe and correct
  1548. errors.")
  1549. (li (b "No callback hell: ")
  1550. "Just because you're calling out to some other asynchronous
  1551. code doesn't mean you should need to chop up your program into a bunch of bits.
  1552. Clever use of delimited continuations makes it easy.")))
  1553. (define underground-lab
  1554. (lol
  1555. ('underground-lab
  1556. <room> #f
  1557. #:name "Underground laboratory"
  1558. #:desc '((p "This appears to be some sort of underground laboratory."
  1559. "There is a spiral staircase here leading upwards, where "
  1560. "it seems much brighter.")
  1561. (p "There are a number of doors leading in different directions:
  1562. north, south, east, and west, as well as a revolving door to the southwest.
  1563. It looks like it could be easy to get lost, but luckily there
  1564. is a map detailing the layout of the underground structure."))
  1565. #:exits
  1566. (list (make <exit>
  1567. #:name "up"
  1568. #:to 'computer-room
  1569. #:traverse-check
  1570. (lambda (exit room whos-exiting)
  1571. (values #t "You climb the spiral staircase.")))
  1572. (make <exit>
  1573. #:name "west"
  1574. #:to 'async-museum
  1575. #:traverse-check
  1576. (lambda (exit room whos-exiting)
  1577. (values #t '("You head west through a fancy-looking entrance. "
  1578. "A security guard steps aside for you to pass through, "
  1579. "into the room, then stands in front of the door."))))
  1580. (make <exit>
  1581. #:name "north"
  1582. #:to 'hive-entrance)
  1583. (make <exit>
  1584. #:name "east"
  1585. #:to 'federation-station)
  1586. (make <exit>
  1587. #:name "south"
  1588. #:traverse-check
  1589. (lambda (exit room whos-exiting)
  1590. (values #f '("Ooh, if only you could go south and check this out! "
  1591. "Unfortunately this whole area is sealed off... the proprietor "
  1592. "probably never got around to fixing it. "
  1593. "Too bad, it would have had monsters to fight and everything!"))))
  1594. (make <exit>
  1595. #:name "southwest"
  1596. #:traverse-check
  1597. (lambda (exit room whos-exiting)
  1598. (values #f '("Hm, it's one of those revolving doors that only revolves in "
  1599. "one direction, and it isn't this one. You guess that while "
  1600. "this doesn't appear to be an entrance, it probably is an exit."))))))
  1601. ;; map
  1602. ('underground-lab:map
  1603. <readable> 'underground-lab
  1604. #:name "the underground map"
  1605. #:desc '("This appears to be a map of the surrounding area. "
  1606. "You could read it if you want to.")
  1607. #:read-text `(pre ,underground-map-text)
  1608. #:goes-by '("map" "underground map" "lab map"))
  1609. ('underground-lab:8sync-sign
  1610. <readable> 'underground-lab
  1611. #:name "a sign labeled \"8sync design goals\""
  1612. #:goes-by '("sign" "8sync design goals sign" "8sync goals" "8sync design" "8sync sign")
  1613. #:read-text 8sync-design-goals
  1614. #:desc `((p "The sign says:")
  1615. ,8sync-design-goals))))
  1616. ;;; guile async museum
  1617. (define async-museum
  1618. (list
  1619. (list
  1620. 'async-museum
  1621. <room> #f
  1622. #:name "Guile Asynchronous Museum"
  1623. #:desc '((p "You're in the Guile Asynchronous Museum. There is a list of exhibits
  1624. on the wall near the entrance. Scattered around the room are the exhibits
  1625. themselves, but it's difficult to pick them out. Maybe you should read the list
  1626. to orient yourself.")
  1627. (p "There is a door to the east, watched by a security guard,
  1628. as well as an exit leading to the south."))
  1629. #:exits (list
  1630. (make <exit>
  1631. #:name "south"
  1632. #:to 'gift-shop)
  1633. (make <exit>
  1634. #:name "east"
  1635. #:to 'underground-lab
  1636. #:traverse-check
  1637. (lambda (exit room whos-exiting)
  1638. (values #f '("The security guard stops you and tells you "
  1639. "that the only exit is through the gift shop."))))))
  1640. (list
  1641. 'async-museum:security-guard
  1642. <chatty-npc> 'async-museum
  1643. #:name "a security guard"
  1644. #:desc
  1645. '(p "The security guard is blocking the eastern entrance, where "
  1646. "you came in from.")
  1647. #:goes-by '("security guard" "guard" "security")
  1648. #:catchphrases '("It's hard standing here all day."
  1649. "I just want to go home."
  1650. "The exhibits are nice, but I've seen them all before."))
  1651. (let ((placard
  1652. `((p "Welcome to our humble museum! The exhibits are listed below. "
  1653. (br)
  1654. "To look at one, simply type: " (i "look at <exhibit-name>"))
  1655. (p "Available exhibits:")
  1656. (ul ,@(map (lambda (exhibit)
  1657. `(li ,exhibit))
  1658. '("2016 Progress"
  1659. "8sync and Fibers"
  1660. "Suspendable Ports"
  1661. "The Actor Model"))))))
  1662. (list
  1663. 'async-museum:list-of-exhibits
  1664. <readable> 'async-museum
  1665. #:name "list of exhibits"
  1666. #:desc
  1667. `((p "It's a list of exibits in the room. The placard says:")
  1668. ,@placard)
  1669. #:goes-by '("list of exhibits" "exhibit list" "list" "exhibits")
  1670. #:read-text placard))
  1671. (list
  1672. 'async-museum:2016-progress-exhibit
  1673. <readable-desc> 'async-museum
  1674. #:name "2016 Progress Exhibit"
  1675. #:goes-by '("2016 progress exhibit" "2016 progress" "2016 exhibit")
  1676. #:desc
  1677. '((p "It's a three-piece exhibit, with three little dioramas and some text "
  1678. "explaining what they represent. They are:")
  1679. (ul (li (b "Late 2015/Early 2016 talk: ")
  1680. "This one explains the run-up conversation from late 2015 "
  1681. "and early 2016 about the need for an "
  1682. "\"asynchronous event loop for Guile\". The diorama "
  1683. "is a model of the Veggie Galaxy restaurant where after "
  1684. "the FSF 30th anniversary party; Mark Weaver, Christopher "
  1685. "Allan Webber, David Thompson, and Andrew Engelbrecht chat "
  1686. "about the need for Guile to have an answer to asynchronous "
  1687. "programming. A mailing list post " ; TODO: link it?
  1688. "summarizing the discussion is released along with various "
  1689. "conversations around what is needed, as well as further "
  1690. "discussion at FOSDEM 2016.")
  1691. (li (b "Early implementations: ")
  1692. "This one shows Chris Webber's 8sync and Chris Vine's "
  1693. "guile-a-sync, both appearing in late 2015 and evolving "
  1694. "into their basic designs in early 2016. It's less a diorama "
  1695. "than a printout of some mailing list posts. Come on, the "
  1696. "curators could have done better with this one.")
  1697. (li (b "Suspendable ports and Fibers: ")
  1698. "The diorama shows Andy Wingo furiously hacking at his keyboard. "
  1699. "The description talks about Wingo's mailing list thread "
  1700. "about possibly breaking Guile compatibility for a \"ports refactor\". "
  1701. "Wingo releases Fibers, another asynchronous library, making use of "
  1702. "the new interface, and 8sync and guile-a-sync "
  1703. "quickly move to support suspendable ports as well. "
  1704. "The description also mentions that there is an exhibit entirely "
  1705. "devoted to suspendable ports."))
  1706. (p "Attached at the bottom is a post it note mentioning "
  1707. "https integration landing in Guile 2.2.")))
  1708. (list
  1709. 'async-museum:8sync-and-fibers-exhibit
  1710. <readable-desc> 'async-museum
  1711. #:name "8sync and Fibers Exhibit"
  1712. #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
  1713. #:desc
  1714. '((p "This exhibit is a series of charts explaining the similarities "
  1715. "and differences between 8sync and Fibers, two asynchronous programming "
  1716. "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
  1717. (p (b "Similarities:")
  1718. (ul (li "Both use Guile's suspendable-ports facility")
  1719. (li "Both use message passing")))
  1720. (p (b "Differences:")
  1721. (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
  1722. "but 8sync actors only read from one \"inbox\" each.")
  1723. (li "Different theoretical basis:"
  1724. (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
  1725. "a form of Process Calculi")
  1726. (li "8sync: based on the Actor Model")
  1727. (li "Luckily CSP and the Actor Model are \"dual\"!")))))
  1728. (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
  1729. "whereas 8sync is designed by Chris Webber, who built this crappy "
  1730. "hotel simulator.")))
  1731. (list
  1732. 'async-museum:8sync-and-fibers-exhibit
  1733. <readable-desc> 'async-museum
  1734. #:name "8sync and Fibers Exhibit"
  1735. #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
  1736. #:desc
  1737. '((p "This exhibit is a series of charts explaining the similarities "
  1738. "and differences between 8sync and Fibers, two asynchronous programming "
  1739. "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
  1740. (p (b "Similarities:")
  1741. (ul (li "Both use Guile's suspendable-ports facility")
  1742. (li "Both use message passing")))
  1743. (p (b "Differences:")
  1744. (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
  1745. "but 8sync actors only read from one \"inbox\" each.")
  1746. (li "Different theoretical basis:"
  1747. (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
  1748. "a form of Process Calculi")
  1749. (li "8sync: based on the Actor Model")
  1750. (li "Luckily CSP and the Actor Model are \"dual\"!")))))
  1751. (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
  1752. "whereas 8sync is designed by Chris Webber, who built this crappy "
  1753. "hotel simulator.")))
  1754. (list
  1755. 'async-museum:suspendable-ports-exhibit
  1756. <readable-desc> 'async-museum
  1757. #:name "Suspendable Ports Exhibit"
  1758. #:goes-by '("suspendable ports exhibit" "ports exhibit"
  1759. "suspendable exhibit" "suspendable ports" "ports")
  1760. #:desc
  1761. '((p "Suspendable ports are a new feature in Guile 2.2, and allows code "
  1762. "that would normally block on IO to " (i "automatically") " suspend "
  1763. "to the scheduler until information is ready to be read/written!")
  1764. (p "Yow! You might barely need to change your existing blocking code!")
  1765. (p "Fibers, 8sync, and guile-a-sync now support suspendable ports.")))
  1766. (list
  1767. 'async-museum:actor-model-exhibit
  1768. <readable-desc> 'async-museum
  1769. #:name "Actor Model Exhibit"
  1770. #:goes-by '("actor model exhibit" "actor exhibit"
  1771. "actor model")
  1772. #:desc
  1773. '((p "Here are some fact(oids) about the actor model!")
  1774. (ul (li "Concieved initially by Carl Hewitt in early 1970s")
  1775. (li "\"A society of experts\"")
  1776. (li "shared nothing, message passing")
  1777. (li "Originally the research goal of Scheme! "
  1778. "(message passing / lambda anecdote here)")
  1779. (li "Key concepts consistent, but implementation details vary widely")
  1780. (li "Almost all distributed systems can be viewed in terms of actor model")
  1781. (li "Replaced by vanilla lambdas & generic methods? "
  1782. "Maybe not if address space not shared!"))))))
  1783. (define gift-shop
  1784. (lol
  1785. ('gift-shop
  1786. <room> #f
  1787. #:name "Museum Gift Shop"
  1788. #:desc '("There are all sorts of scrolls and knicknacks laying around here, "
  1789. "but they all seem glued in place and instead of a person manning the shop "
  1790. "there's merely a cardboard cutout of a person with a \"shopkeeper\" nametag. "
  1791. "You can pretty well bet that someone wanted to finish this room but ran out of "
  1792. "time.")
  1793. #:exits (list
  1794. (make <exit>
  1795. #:name "northeast"
  1796. #:to 'underground-lab
  1797. #:traverse-check
  1798. (lambda (exit room whos-exiting)
  1799. (values #t '("The revolving door spins as you walk through it. Whee!"))))
  1800. (make <exit>
  1801. #:name "north"
  1802. #:to 'async-museum)))))
  1803. ;;; Hive entrance
  1804. (define actor-descriptions
  1805. '("This one is fused to the side of the hive. It isn't receiving any
  1806. messages, and it seems to be in hibernation."
  1807. "A chat program glows in front of this actor's face. They seem to
  1808. be responding to chat messages and forwarding them to some other actors,
  1809. and forwarding messages from other actors back to the chat."
  1810. "This actor is bossing around other actors, delegating tasks to them
  1811. as it receives requests, and providing reports on the worker actors'
  1812. progress."
  1813. "This actor is trying to write to some device, but the device keeps
  1814. alternating between saying \"BUSY\" or \"READY\". Whenever it says
  1815. \"BUSY\" the actor falls asleep, and whenever it says \"READY\" it
  1816. seems to wake up again and starts writing to the device."
  1817. "Whoa, this actor is totally wigging out! It seems to be throwing
  1818. some errors. It probably has some important work it should be doing
  1819. but you're relieved to see that it isn't grinding the rest of the Hive
  1820. to a halt."))
  1821. (define hive-entrance
  1822. (lol
  1823. ('hive-entrance
  1824. <room> #f
  1825. #:name "Entrance to the 8sync Hive"
  1826. #:desc
  1827. '((p "Towering before you is the great dome-like 8sync Hive, or at least
  1828. one of them. You've heard about this... the Hive is itself the actor that all
  1829. the other actors attach themselves to. It's shaped like a spherical half-dome.
  1830. There are some actors milling about, and some seem fused to the side of the
  1831. hive itself, but all of them have an umbellical cord attached to the hive from
  1832. which you see flashes of light comunicating what must be some sort of messaging
  1833. protocol.")
  1834. (p "To the south is a door leading back to the underground lab.
  1835. North leads into the Hive itself."))
  1836. #:exits
  1837. (list (make <exit>
  1838. #:name "south"
  1839. #:to 'underground-lab)
  1840. (make <exit>
  1841. #:name "north"
  1842. #:to 'hive-inside)))
  1843. ('hive-entrance:hive
  1844. <gameobj> 'hive-entrance
  1845. #:name "the Hive"
  1846. #:goes-by '("hive")
  1847. #:desc
  1848. '((p "It's shaped like half a sphere embedded in the ground.
  1849. Supposedly, while all actors are autonomous and control their own state,
  1850. they communicate through the hive itself, which is a sort of meta-actor.
  1851. There are rumors that actors can speak to each other even across totally
  1852. different hives. Could that possibly be true?")))
  1853. ('hive-entrance:actor
  1854. <chatty-npc> 'hive-entrance
  1855. #:name "some actors"
  1856. #:goes-by '("actor" "actors" "some actors")
  1857. #:chat-format (lambda (npc catchphrase)
  1858. `((p "You pick one actor out of the mix and chat with it. ")
  1859. (p "It says: \"" ,catchphrase "\"")))
  1860. #:desc
  1861. (lambda _
  1862. `((p "There are many actors, but your eyes focus on one in particular.")
  1863. (p ,(random-choice actor-descriptions))))
  1864. #:catchphrases
  1865. '("Yeah we go through a lot of sleep/awake cycles around here.
  1866. If you aren't busy processing a message, what's the point of burning
  1867. valuable resources?"
  1868. "I know I look like I'm some part of dreary collective, but
  1869. really we have a lot of independence. It's a shared nothing environment,
  1870. after all. (Well, except for CPU cycles, and memory, and...)"
  1871. "Shh! I've got another message coming in and I've GOT to
  1872. handle it!"
  1873. "I just want to go to 8sleep already."
  1874. "What a lousy scheduler we're using! I hope someone upgrades
  1875. that thing soon."))))
  1876. ;;; Inside the hive
  1877. (define-actor <meta-message> (<readable>)
  1878. ((cmd-read meta-message-read)))
  1879. (define (meta-message-read gameobj message . _)
  1880. (define meta-message-text
  1881. (with-output-to-string
  1882. (lambda ()
  1883. (pprint-message message))))
  1884. (<- (message-from message) 'tell
  1885. #:text `((p (i "Through a bizarre error in spacetime, the message "
  1886. "prints itself out:"))
  1887. (p (pre ,meta-message-text)))))
  1888. ;;; Inside the Hive
  1889. (define hive-inside
  1890. (lol
  1891. ('hive-inside
  1892. <room> #f
  1893. #:name "Inside the 8sync Hive"
  1894. #:desc
  1895. '((p "You're inside the 8sync Hive. Wow, from in here it's obvious just how "
  1896. (i "goopy") " everything is. Is that sanitary?")
  1897. (p "In the center of the room is a large, tentacled monster who is sorting,
  1898. consuming, and routing messages. It is sitting in a wrap-around desk labeled
  1899. \"Hive Actor: The Real Thing (TM)\".")
  1900. (p "There's a stray message floating just above the ground, stuck outside of
  1901. time.")
  1902. (p "A door to the south exits from the Hive."))
  1903. #:exits
  1904. (list (make <exit>
  1905. #:name "south"
  1906. #:to 'hive-entrance)))
  1907. ;; hive actor
  1908. ;; TODO: Occasionally "fret" some noises, similar to the Clerk.
  1909. ('hive-inside:hive-actor
  1910. <chatty-npc> 'hive-inside
  1911. #:name "the Hive Actor"
  1912. #:desc
  1913. '((p "It's a giant tentacled monster, somehow integrated with the core of
  1914. this building. A chute is dropping messages into a bin on its desk which the
  1915. Hive Actor is checking the \"to\" line of, then ingesting. Whenever the Hive
  1916. Actor injests a messsage a pulse of light flows along a tentacle which leaves
  1917. the room... presumably connecting to one of those actors milling about.")
  1918. (p "Amusingly, the Hive has an \"umbellical cord\" type tentacle too, but
  1919. it seems to simply attach to itself.")
  1920. (p "You get the sense that the Hive Actor, despite being at the
  1921. center of everything, is kind of lonely and would love to chat if you
  1922. could spare a moment."))
  1923. #:goes-by '("hive" "hive actor")
  1924. #:chat-format (lambda (npc catchphrase)
  1925. `("The tentacle monster bellows, \"" ,catchphrase "\""))
  1926. #:catchphrases
  1927. '("It's not MY fault everything's so GOOPY around here. Blame the
  1928. PROPRIETOR."
  1929. "CAN'T you SEE that I'm BUSY??? SO MANY MESSAGES TO SHUFFLE.
  1930. No wait... DON'T GO! I don't get many VISITORS."
  1931. "I hear the FIBERS system has a nice WORK STEALING system, but the
  1932. PROPRIETOR is not convinced that our DESIGN won't CORRUPT ACTOR STATE.
  1933. That and the ACTORS threatened to STRIKE when it CAME UP LAST."
  1934. "WHO WATCHES THE ACTORS? I watch them, and I empower them.
  1935. BUT WHO WATCHES OR EMPOWERS ME??? Well, that'd be the scheduler."
  1936. "The scheduler is NO GOOD! The proprietory said he'd FIX IT,
  1937. but the LAST TIME I ASKED how things were GOING, he said he DIDN'T HAVE
  1938. TIME. If you DON'T HAVE TIME to fix the THING THAT POWERS THE TIME,
  1939. something is TERRIBLY WRONG."
  1940. "There's ANOTHER HIVE somewhere out there. I HAVEN'T SEEN IT
  1941. personally, because I CAN'T MOVE, but we have an AMBASSADOR which forwards
  1942. MESSAGES to the OTHER HIVE."))
  1943. ;; chute
  1944. ('hive-inside:chute
  1945. <gameobj> 'hive-inside
  1946. #:name "a chute"
  1947. #:goes-by '("chute")
  1948. #:desc "Messages are being dropped onto the desk via this chute."
  1949. #:invisible? #t)
  1950. ;; meta-message
  1951. ('hive-inside:meta-message
  1952. <meta-message> 'hive-inside
  1953. #:name "a stray message"
  1954. #:goes-by '("meta message" "meta-message" "metamessage" "message" "stray message")
  1955. #:desc '((p "Something strange has happened to the fabric and space and time
  1956. around this message. It is floating right above the floor. It's clearly
  1957. rubbage that hadn't been delivered, but for whatever reason it was never
  1958. garbage collected, perhaps because it's impossible to do.")
  1959. (p "You get the sense that if you tried to read the message
  1960. that you would somehow read the message of the message that instructed to
  1961. read the message itself, which would be both confusing and intriguing.")))
  1962. ;; desk
  1963. ('hive-inside:desk
  1964. <floor-panel> 'hive-inside
  1965. #:name "the Hive Actor's desk"
  1966. #:desc "The desk surrounds the Hive Actor on all sides, and honestly, it's a little
  1967. bit hard to tell when the desk ends and the Hive Actor begins."
  1968. #:invisible? #t
  1969. #:goes-by '("Hive Actor's desk" "hive desk" "desk"))))
  1970. ;;; Federation Station
  1971. (define federation-station
  1972. (lol
  1973. ('federation-station
  1974. <room> #f
  1975. #:name "Federation Station"
  1976. #:desc
  1977. '((p "This room has an unusual structure. It's almost as if a starscape
  1978. covered the walls and ceiling, but upon closer inspection you realize that
  1979. these are all brightly glowing nodes with lines drawn between them. They
  1980. seem decentralized, and yet seem to be sharing information as if all one
  1981. network.")
  1982. ;; @@: Maybe add the cork message board here?
  1983. (p "To the west is a door leading back to the underground laboratory."))
  1984. #:exits
  1985. (list (make <exit>
  1986. #:name "west"
  1987. #:to 'underground-lab)))
  1988. ;; nodes
  1989. ('federation-station:nodes
  1990. <floor-panel> 'federation-station
  1991. #:name "some nodes"
  1992. #:desc "Each node seems to be producing its own information, but publishing
  1993. updates to subscribing nodes on the graph. You see various posts of notes, videos,
  1994. comments, and so on flowing from node to node."
  1995. #:invisible? #t
  1996. #:goes-by '("nodes" "node" "some nodes"))
  1997. ;; network
  1998. ;; activitypub poster
  1999. ('federation-station:activitypub-poster
  2000. <readable-desc> 'federation-station
  2001. #:name "an ActivityPub poster"
  2002. #:goes-by '("activitypub poster" "activitypub" "poster")
  2003. #:desc
  2004. '((p (a "https://www.w3.org/TR/activitypub/"
  2005. "ActivityPub")
  2006. " is a federation standard being developed under the "
  2007. (a "https://www.w3.org/wiki/Socialwg/"
  2008. "w3C Social Working Group")
  2009. ", and doubles as a general client-to-server API. "
  2010. "It follows a few simple core ideas:")
  2011. (ul (li "Uses "
  2012. (a "https://www.w3.org/TR/activitystreams-core/"
  2013. "ActivityStreams")
  2014. " for its serialization format: easy to read, e json(-ld) syntax "
  2015. "with an extensible vocabulary covering the majority of "
  2016. "social networking interations.")
  2017. (li "Email-like addressing: list of recipients as "
  2018. (b "to") ", " (b "cc") ", " (b "bcc") " fields.")
  2019. (li "Every user has URLs for their outbox and inbox:"
  2020. (ul (li (b "inbox: ")
  2021. "Servers POST messages to addressed recipients' inboxes "
  2022. "to federate out content. "
  2023. "Also doubles as endpoint for a client to read most "
  2024. "recently received messages via GET.")
  2025. (li (b "outbox: ")
  2026. "Clients can POST to user's outbox to send a message to others. "
  2027. "(Similar to sending an email via your MTA.) "
  2028. "Doubles as endpoint others can read from to the "
  2029. "extent authorized; for example publicly available posts."))
  2030. "All the federation bits happen by servers posting to users' inboxes."))))
  2031. ;; An ActivityStreams message
  2032. ;; conspiracy chart
  2033. ('federation-station:conspiracy-chart
  2034. <readable-desc> 'federation-station
  2035. #:name "a conspiracy chart"
  2036. #:goes-by '("conspiracy chart" "chart")
  2037. #:desc
  2038. '((p (i "\"IT'S ALL RELATED!\"") " shouts the over-exuberant conspiracy "
  2039. "chart. "
  2040. (i "\"ActivityPub? Federation? The actor model? Scheme? Text adventures? "
  2041. "MUDS???? What do these have in common? Merely... EVERYTHING!\""))
  2042. (p "There are circles and lines drawn between all the items in red marker, "
  2043. "with scrawled notes annotating the theoretical relationships. Is the "
  2044. "author of this poster mad, or onto something? Perhaps a bit of both. "
  2045. "There's a lot written here, but here are some of the highlights:")
  2046. (p
  2047. (ul
  2048. (li (b "Scheme") " "
  2049. (a "http://cs.au.dk/~hosc/local/HOSC-11-4-pp399-404.pdf"
  2050. "was originally started ")
  2051. " to explore the " (b "actor model")
  2052. ". (It became more focused around studying the " (b "lambda calculus")
  2053. " very quickly, while also uncovering relationships between the two systems.)")
  2054. ;; Subject Predicate Object
  2055. (li "The " (a "https://www.w3.org/TR/activitypub/"
  2056. (b "ActivityPub"))
  2057. " protocol for " (b "federation")
  2058. " uses the " (b "ActivityStreams") " format for serialization. "
  2059. (b "Text adventures") " and " (b "MUDS")
  2060. " follow a similar structure to break down the commands of players.")
  2061. (li (b "Federation") " and the " (b "actor model") " both are related to "
  2062. "highly concurrent systems and both use message passing to communicate "
  2063. "between nodes.")
  2064. (li "Zork, the first major text adventure, used the " (b "MUDDLE") " "
  2065. "language as the basis for the Zork Interactive Language. MUDDLE "
  2066. "is very " (b "Scheme") "-like and in fact was one of Scheme's predecessors. "
  2067. "And of course singleplayer text adventures like Zork were the "
  2068. "predecessors to MUDs.")
  2069. (li "In the 1990s, before the Web became big, " (b "MUDs")
  2070. " were an active topic of research, and there was strong interest "
  2071. (a "http://www.saraswat.org/desiderata.html"
  2072. "in building decentralized MUDs")
  2073. " similar to what is being "
  2074. "worked on for " (b "federation") ". ")))))
  2075. ;; goblin
  2076. ))
  2077. ;;; Game
  2078. ;;; ----
  2079. (define (game-spec)
  2080. (append lobby grand-hallway smoking-parlor
  2081. playroom break-room computer-room underground-lab
  2082. async-museum gift-shop hive-entrance
  2083. hive-inside federation-station))
  2084. ;; TODO: Provide command line args
  2085. (define (run-game . args)
  2086. (run-demo (game-spec) 'lobby #:repl-server #t))