summaryrefslogtreecommitdiff
path: root/model.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'model.lisp')
-rw-r--r--model.lisp59
1 files changed, 41 insertions, 18 deletions
diff --git a/model.lisp b/model.lisp
index 9bcaadb..e4c8943 100644
--- a/model.lisp
+++ b/model.lisp
@@ -31,7 +31,7 @@
(defclass can-equip ()
((equipment-table
:initform nil
- :type cons
+ :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+
@@ -40,6 +40,13 @@
: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))
@@ -56,19 +63,14 @@
()
(:metaclass db:persistent-class))
-;; a user
-(defclass hero (game-object can-equip)
- ((name
- :accessor hero-name
- :initarg :name
- :initform (error "Heroes must be named")
+(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 hero-known-as)
- (experience
- :accessor experience
- :initform 0
- :type integer)
+ :index-reader player-with-nick)
(pwhash
:accessor pwhash
:type string
@@ -81,13 +83,34 @@
:documentation "Salt for this hero's password hash."))
(:metaclass db:persistent-class))
-(defun all-heroes ()
- (db:store-objects-with-class 'hero))
+;; 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)
- ((hero :reader session-hero
- :initarg :hero)
+ ((player :reader session-player
+ :initarg :player)
(id :reader session-id
:initform (nuid)
:index-type idx:string-unique-index
@@ -121,7 +144,7 @@
:reader quest-campaign
:initarg :campaign
:initform (error "No quest can fall outside the scope of a campaign.")
- :index-type idx:hash-list-index
+ :index-type idx:hash-index
:index-reader quests-in-campaign
:documentation "The campaign to which this quest belongs")
(name
@@ -148,7 +171,7 @@
(defclass hazard (game-object)
((quest
:accessor quest-of
- :index-type idx:hash-list-index
+ :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