1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4 ;;; This file is part of Mudsync.
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;; General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (mudsync room)
20 #:use-module (mudsync gameobj)
21 #:use-module (8sync systems actors)
22 #:use-module (8sync agenda)
23 #:use-module (oop goops)
33 (define-class <exit> ()
35 (to-symbol #:accessor exit-to-symbol
36 #:init-keyword #:to-symbol)
37 ;; The actual address we use
38 (to-address #:accessor exit-to-address
39 #:init-keyword #:address)
40 ;; Name of the room (@@: Should this be names?)
41 (name #:accessor exit-name
42 #:init-keyword #:name)
43 (desc #:accessor exit-desc
44 #:init-keyword #:desc)
46 ;; *Note*: These two methods have an extra layer of indirection, but
47 ;; it's for a good reason.
48 (visible-check #:init-value (const #t)
49 #:init-keyword #:visible-check)
50 ;; By default all exits can be traversed
51 (traverse-check #:init-value (const #t)
52 #:init-keyword #:traverse-check))
54 (define* (exit-can-traverse? exit actor
55 #:optional (target-actor (actor-id actor)))
56 ((slot-ref exit 'traverse-check) exit actor target-actor))
58 (define* (exit-is-visible? exit actor
59 #:optional (target-actor (actor-id actor)))
60 ((slot-ref exit 'traverse-check) exit actor target-actor))
63 ;; Kind of a useful utility, maybe?
64 (define (simple-slot-getter slot)
65 (lambda (actor message)
66 (reply-message actor message
67 #:val (slot-ref actor slot))))
69 (define always (const #t))
72 (define full-command list)
74 ;; TODO: fill these in
75 (define cmatch-just-verb #f)
76 (define cmatch-direct-verb #f)
77 (define cmatch-direct-obj #f)
79 (define %room-contain-commands
81 (full-command "look" cmatch-just-verb always 'look-room)
82 (full-command "look" cmatch-direct-obj always 'look-member)
83 (full-command "go" cmatch-just-verb always 'go-where)
84 (full-command "go" cmatch-direct-obj always 'go-exit)))
87 ;; TODO: Subclass from container?
88 (define-class <room> (<gameobj>)
90 (exits #:init-value '()
94 #:init-value %room-contain-commands)
97 #:allocation #:each-subclass
98 ;; @@: Can remove this indirection once things settle
99 #:init-value (wrap-apply room-action-dispatch)))
104 ;; desc == description
105 (wire-exits! (wrap-apply room-wire-exits!))))
107 (define room-actions*
108 (append room-actions gameobj-actions))
110 (define room-action-dispatch
111 (simple-dispatcher room-actions*))
114 (define (room-wire-exits! room message)
115 "Actually hook up the rooms' exit addresses to the rooms they
120 (<-wait room (gameobj-gm room) 'lookup-room
121 #:symbol (exit-to-symbol exit)))
123 (set! (exit-to-address exit) new-exit))