diff options
author | Colin Okay <colin@cicadas.surf> | 2022-12-26 14:13:22 -0800 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-12-26 14:13:22 -0800 |
commit | 8e7fc055823fde522fb83f9a7d86dcba39dcf551 (patch) | |
tree | 85d2b529712c0e40df8a19ee1bbaf31e79387eb9 |
initial commit; Add hero model definition
-rw-r--r-- | dungeons-and-deadlines.lisp | 3 | ||||
-rw-r--r-- | model.lisp | 81 | ||||
-rw-r--r-- | package.lisp | 12 | ||||
-rw-r--r-- | utilities.lisp | 25 |
4 files changed, 121 insertions, 0 deletions
diff --git a/dungeons-and-deadlines.lisp b/dungeons-and-deadlines.lisp new file mode 100644 index 0000000..881eb20 --- /dev/null +++ b/dungeons-and-deadlines.lisp @@ -0,0 +1,3 @@ +;;;; dungeons-and-deadlines.lisp + +(in-package #:dungeons-and-deadlines) diff --git a/model.lisp b/model.lisp new file mode 100644 index 0000000..318aa26 --- /dev/null +++ b/model.lisp @@ -0,0 +1,81 @@ +;;;; model.lisp -- bknr.datastore class definitions for dnd + +ty + +(in-package :dungeons-and-deadlines) + +(deftype title () + `(member :noob)) + +(deftype character-class () + `(member :hero)) + +(defclass has-uid (db:store-object) + ((nuid :reader uid :initform (nuid))) + (:metaclass db:persistent-class)) + +(defclass can-equip (db:store-object) + ((equipment-slots + :initform (make-hash-table)) + (equipment-slot-names + :initform (list :holding) + :initarg :slot-names + :type (list keyword))) + (:metaclass db:persistent-class)) + +;; TODO: define an equip protocol + +;; a user +(defclass hero (can-equip has-uid) + ((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) + (experience + :accessor experience + :initform 0 + :type integer) + (chronicle + :accessor hero-chronicle + :initform (list) + :type (cons string)) + (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)) + +;; 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)) diff --git a/package.lisp b/package.lisp new file mode 100644 index 0000000..c18b3eb --- /dev/null +++ b/package.lisp @@ -0,0 +1,12 @@ +;;;; package.lisp + +(defpackage #:dungeons-and-deadlines + (:use #:cl) + (:local-nicknames (#:db #:bknr.datastore) + (#:idx #:bknr.indices) + (#:lzb #:lazybones) + (#:re #:cl-ppcre)) + (:import-from #:lazybones + #:defendpoint*)) + + diff --git a/utilities.lisp b/utilities.lisp new file mode 100644 index 0000000..dd4455c --- /dev/null +++ b/utilities.lisp @@ -0,0 +1,25 @@ +;;;; utilities -- nuff said + +(in-package :dungeons-and-deadlines) + + +(let ((host (uiop:hostname)) + (count 0)) + (defun nuid () + "Generates a Nearly Universal ID" + (format nil "~36r" + (sxhash + (list + (incf count) + host + (get-universal-time)))))) + +(defun hash-string (plaintext salt) + "Hash plaintext using SALT" + (flexi-streams:octets-to-string + (ironclad:digest-sequence + :sha3 + (flexi-streams:string-to-octets (concatenate 'string salt plaintext) + :external-format :utf-8)) + :external-format :latin1)) + |