blob: e4c894328ce92e284d31108657f8435864859fbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
;;;; model.lisp -- bknr.datastore class definitions for dnd
(in-package :dnd)
(deftype title ()
`(member :noob))
(deftype character-class ()
`(member :hero))
(deftype priority ()
`(member :low :medium :high))
(defun hero-class (h)
"barGaryan") ; TODO: real implementation
(defun hero-title (h)
"Scouse Chef") ; TODO: real implementation
(defun renown (hero)
(experience hero)) ; TODO: real implementaiton
;;; persistent mixins
(defclass has-uid ()
((nuid :reader uid
:initform (nuid)
:index-type idx:string-unique-index
:index-reader object-with-uid))
(:metaclass db:persistent-class))
(defclass can-equip ()
((equipment-table
:initform nil
:type list
:documentation "A PLIST mapping 'equipment slots' to instances of LOOT. Equipment slots are things like :head, :torso, :left-ring, etc")
(equipment-slot-names
:initform +standard-humanoid-equipment+
:initarg :slot-names
:type (list keyword)
:documentation "The list of slots available to this entity."))
(:metaclass db:persistent-class))
(defclass has-bag ()
((bag
:reader bag
:initform nil
:type list
:documentation "A list of items that this entity is carrying."))
(:metaclass db:persistent-class))
(defclass has-chronicle ()
((chronicle :accessor chronicle :initform nil))
(:metaclass db:persistent-class)
(:documentation "A chronicle is a general purpose log of events. It stores a single slot that"))
(defparameter +standard-humanoid-equipment+
'(:head :neck :torso :waist :legs :feet :arms :left-fingers :right-fingers
:left-holding :right-holding :cloak)
"The equipment slots for standard humanoids")
;; abstract class
(defclass game-object (db:store-object has-uid has-chronicle)
()
(:metaclass db:persistent-class))
(defclass player (db:store-object has-uid)
((nick
:reader user-nick
:initarg :nick
:initform (error "Players must have a nick")
:type string
:index-type idx:string-unique-index
:index-reader player-with-nick)
(pwhash
:accessor pwhash
:type string
:initarg :pwhash
:documentation "A hash of the password, hashed with the value of the pwsalt slot.")
(pwsalt
:reader pwsalt
:initform (nuid)
:type string
:documentation "Salt for this hero's password hash."))
(:metaclass db:persistent-class))
;; a user
(defclass hero (game-object has-bag can-equip)
((name
:accessor hero-name
:initarg :name
:initform (error "Heroes must be named")
:type string
:index-type idx:string-unique-index
:index-reader hero-known-as)
(player
:reader hero-player
:initarg :player
:type player
:index-type idx:hash-index
:index-reader player-heroes
)
(campaign
:accessor hero-campaign
:initarg :campaign
:initform nil
:type campaign
:documentation "A hero may be in at mostk one campaign at a time."))
(:metaclass db:persistent-class))
;; TODO expiration?
(defclass session (db:store-object)
((player :reader session-player
:initarg :player)
(id :reader session-id
:initform (nuid)
:index-type idx:string-unique-index
:index-reader session-with-id))
(:metaclass db:persistent-class))
(defclass campaign (game-object)
((creator
:reader campaign-creator
:initarg :creator
:initform (error "campaigns must have a creator")
:documentation "The hero instance of the user who made this campaign.")
(seers
:accessor campaign-seers
:initarg :seers
:initform nil
:documentation "Seers are the people who peer out into their instruments of divination that heroes may go on quests.")
(title
:accessor campaign-title
:initarg :title
:initform (error "A campaign needs a title"))
(rumors
:accessor campaign-rumors
:initarg nil
:documentation "Beasts, Monsters, and Hazards rumored to be lurking about."))
(:metaclass db:persistent-class)
(:documentation "A campaign is a container of quests. Campaigns are expected to be engaged with on a particular schedule, and are run by particular people."))
(defclass quest (game-object)
((campaign
:reader quest-campaign
:initarg :campaign
:initform (error "No quest can fall outside the scope of a campaign.")
:index-type idx:hash-index
:index-reader quests-in-campaign
:documentation "The campaign to which this quest belongs")
(name
:accessor quest-name
:initarg :name
:initform (format nil "~a" (gensym "QUEST")))
(horizon-of-hope
:accessor horizon-of-hope
:initarg :deadline
:initform nil
:documentation "When all hope becomes lost.")
(heroes
:accessor heroes-in-quest
:initarg :heroes
:initform nil
:documentation "A list of heroes in this quest. Join and flight dates are logged in the chronicle.")
(startedp
:accessor quest-startedp
:initform nil
:documentation "Indication of whether the quest is active or not - i.e. whether heroes are on this quest."))
(:metaclass db:persistent-class)
(:documentation "A collection of hazards"))
(defclass hazard (game-object)
((quest
:accessor quest-of
:index-type idx:hash-index
:index-reader hazards-in-quest
:documentation "The quest to which this hazard belongs. Initially it is unbound. It becomes boudn when the hazard is added to a quest.")
(overcomep
:accessor is-overcome
:initform nil
:documentation "indicates whether or not this hazard has been overcome.")
(imminence
:accessor imminence-of
:type priority
:documentation "")
(menace ;; difficulty
:accessor menace-of
:type integer
:documentation "How dangerous the hazard is." ))
(:metaclass db:persistent-class)
(:documentation "Hazard is a superclass for all hazards encountered in a quest. It's chronicle includes data about which heroes fought and which overcame."))
;; (defclass monster ())
|