summaryrefslogtreecommitdiff
path: root/src/game/quest.lisp
blob: ed9a5b4aee12b1380c2adef64903d19e1f45ebd9 (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
(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)))))