Many steps towards handling input (but not there yet...)
[mudsync.git] / mudsync / gameobj.scm
1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
3 ;;;
4 ;;; This file is part of Mudsync.
5 ;;;
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ;;; General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync.  If not, see <http://www.gnu.org/licenses/>.
18
19 ;;; Game actor
20 ;;; ==========
21
22 (define-module (mudsync gameobj)
23   #:use-module (8sync systems actors)
24   #:use-module (8sync agenda)
25   #:use-module (oop goops)
26   #:export (<gameobj>
27             gameobj-simple-name-f
28
29             gameobj-loc
30             gameobj-gm
31             gameobj-name
32             gameobj-name-f))
33
34
35 ;;; *all* game components that talk to players should somehow
36 ;;; derive from this class.
37 ;;; And all of them need a GM!
38
39 (define-class <gameobj> (<actor>)
40   ;; location id
41   (loc #:init-value #f
42        #:accessor gameobj-loc)
43   ;; game master id
44   (gm #:init-keyword #:gm
45       #:getter gameobj-gm)
46   ;; a name to be known by
47   (name #:init-keyword #:name
48         #:accessor gameobj-name)
49
50   ;; how to print our name
51   (name-f #:init-keyword #:name-f
52           #:getter gameobj-name-f
53           #:init-value (wrap gameobj-simple-name-f))
54
55   ;; Name aliases
56   (aliases #:init-keyword #:aliases
57            #:init-value '())
58
59   ;; Commands we can handle
60   (commands #:init-value '())
61
62   ;; Commands we can handle by being something's container
63   (contain-commands #:init-value '()))
64
65
66 (define (gameobj-simple-name-f gameobj)
67   "Simplest version: return ourselves for our name."
68   (gameobj-name gameobj))
69
70