(in-package :dnd) (defclass quest (game-object) ((adventure :reader adventure :initarg :adventure :initform (error "No quest can fall outside the scope of a adventure.") :type adventure :index-type idx:hash-index :index-reader quests-in-adventure :documentation "The adventure to which this quest belongs") (name :accessor name :initarg :name :type string :initform (format nil "~a" (gensym "QUEST"))) (horizon-of-hope :accessor horizon-of-hope :initarg :deadline :type integer :initform nil :documentation "When all hope becomes lost.") (inception :accessor quest-inception :initform nil :type (or nil integer) :documentation "Time at which the quest began.")) (:metaclass db:persistent-class) (:documentation "A collection of hazards with a deadline and start date which heroes will attack.")) (defun player-quests (player) "Return all quests in which one of player's heroes is engaged." (remove nil (mapcar #'quest (player-heroes player)))) (define-id-plucker quest) (defrender :link-to ((quest quest)) (with-html (:a :href (urlpath quest) (name quest)))) (defclass quest-page () ((quest :reader quest :initarg :quest) (player :reader player :initarg :player))) (defrender t ((page quest)) (with-page (:title (unique-name (quest page ))) (:h1 (unique-name (quest page)))))