blob: bb0d680e4f3af22538260101cfa721236b8e90a9 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
(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."))
;;; HELPERS
(defun quest-startedp (quest)
(quest-inception quest))
;;; QUERIES
(defun player-quests (player)
"Return all quests in which one of player's heroes is engaged."
(remove nil (mapcar #'quest (player-heroes player))))
;;; TRANSACTIONS
(defun create-quest-from-rumors (adventure name rumors)
;; TBD
)
;;; MODEL VIEWS
(defrender :link-to ((quest quest))
(with-html
(:a :href (urlpath quest)
(name quest))))
;;; PAGES & PAGE CLASSES
(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)))))
;;; ENDPOINT HELPERS
(define-id-plucker quest)
;;; ENDPOINT DEFINITIONS
(defendpoint* :get "/quest/:quest a-quest-with-id:/:name:" () ()
(with-session (player)
(render (page-render-mode)
(make-instance 'quest-page
:player player
:hero quest))))
|