summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-01-22 10:09:42 -0800
committercolin <colin@cicadas.surf>2023-01-22 10:09:42 -0800
commit7bbe9edc81e11aaee184135224712198b2435d87 (patch)
treea22f97e7e33123e87a1faa9ba1d6121772f2e549
parent3fca80d72de160503605ba0303ce58174706914c (diff)
Add: classes for game objects;
-rw-r--r--init.lisp4
-rw-r--r--model.lisp133
2 files changed, 97 insertions, 40 deletions
diff --git a/init.lisp b/init.lisp
index 6585ea9..68b2a16 100644
--- a/init.lisp
+++ b/init.lisp
@@ -4,8 +4,8 @@
(defun init-db (&optional config)
(unless (boundp 'db:*store*)
- (if config
- nil
+ (unless config
+ nil ; TODO: handle the case where we have a config
(make-instance
'db:mp-store
:directory (merge-pathnames "dnd-store/" (user-homedir-pathname))
diff --git a/model.lisp b/model.lisp
index 273b10c..f148455 100644
--- a/model.lisp
+++ b/model.lisp
@@ -9,31 +9,51 @@
`(member :hero))
(defun hero-class (h)
- "barGaryan")
+ "barGaryan") ; TODO: real implementation
(defun hero-title (h)
- "Scouse Chef")
+ "Scouse Chef") ; TODO: real implementation
(defun renown (hero)
- (experience hero))
+ (experience hero)) ; TODO: real implementaiton
+;;; persistent mixins
(defclass has-uid ()
- ((nuid :reader uid :initform (nuid)))
+ ((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 (make-hash-table))
+ :initform nil
+ :type cons
+ :documentation "A PLIST mapping 'equipment slots' to instances of LOOT. Equipment slots are things like :head, :torso, :left-ring, etc")
(equipment-slot-names
- :initform (list :holding)
+ :initform +standard-humanoid-equipment+
:initarg :slot-names
- :type (list keyword)))
+ :type (list keyword)
+ :documentation "The list of slots available to this entity."))
(:metaclass db:persistent-class))
-;; TODO: define an equip protocol
+(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))
;; a user
-(defclass hero (db:store-object can-equip has-uid)
+(defclass hero (game-object can-equip)
((name
:accessor hero-name
:initarg :name
@@ -45,9 +65,6 @@
:accessor experience
:initform 0
:type integer)
- (chronicle
- :accessor hero-chronicle
- :initform (list))
(pwhash
:accessor pwhash
:type string
@@ -63,35 +80,75 @@
;; TODO expiration?
(defclass session (db:store-object)
((hero :reader session-hero
- :initarg :hero)
+ :initarg :hero)
(id :reader session-id
:initform (nuid)
:index-type idx:string-unique-index
:index-reader session-with-id))
(:metaclass db:persistent-class))
-;; aka an issue
-;; (defclass monster (can-equip has-uid)
-;; ((name)
-;; (description)
-;; (difficulty)
-;; (tags)
-;; (status)
-;; (priority)
-;; )
-;; (:metaclass db:persistent-class))
-
-;; (defun experience-value (monster)
-;; ;; Int
-;; ;; (tag + campaign) - lookup table , priortiy,
-;; )
-
-;; ;; aka .... uhh.... dumbass github flair
-;; (defclass loot (db:store-object)
-;; ()
-;; (:metaclass db:persistent-class))
-
-;; ;; aka a project
-;; (defclass campagin (db:store-object)
-;; ()
-;; (: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 and Monsters 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-list-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
+ :index-type idx:hash-list-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 overcomep
+ :initform nil
+ :documentation "indicates whether or not this hazard has been overcome."))
+ (: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."))
+