summaryrefslogtreecommitdiff
path: root/src/game/adventure.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/adventure.lisp')
-rw-r--r--src/game/adventure.lisp100
1 files changed, 54 insertions, 46 deletions
diff --git a/src/game/adventure.lisp b/src/game/adventure.lisp
index 6bbd2d3..9c3fafd 100644
--- a/src/game/adventure.lisp
+++ b/src/game/adventure.lisp
@@ -53,6 +53,12 @@
;;; HELPERS
+(defun adventure-rumors-path (adventure)
+ (format nil "/rumors-about/~a" (uid adventure)))
+
+(defmethod unique-name ((adventure adventure))
+ (title adventure))
+
;;; QUERIES
(defun player-adventures (player)
@@ -109,6 +115,41 @@ only the active quest(s) are considered, otherwise all quests are considered."
(defrender :list-item ((adventure adventure))
(render :inline adventure))
+(defrender :list-item ((rumor rumor))
+ (with-slots (reporter reported) rumor
+ (with-html
+ (:p (subseq reported 0 (min 20 (length reported))) " ..." " -- " (render :inline reporter)))))
+
+(defun rumors-section (page)
+ (let ((adventure (adventure page)))
+ (with-html
+ (:div
+ (when (rumors adventure)
+ (:h3 "Rumors")
+ (render :list (rumors adventure)))
+ (:h4 "Report a rumor")
+ (:form :method "POST" :action (adventure-rumors-path adventure)
+ (:label :for "REPORTED" "What did ye have to report?")
+ (:br)
+ (:textarea :name "REPORTED" :rows "5" :cols "40")
+ (:br)
+ (:button :type "submit" "Report!"))))))
+
+(defun seers-section (page)
+ (let ((adventure (adventure page)))
+ (with-html
+ (:div
+ (when (seers adventure)
+ (:h4 "Seers: ")
+ (render :list (seers adventure)))
+ (when (possible-seers page)
+ (:form :method "POST" :action (urlpath adventure)
+ (:label :for "SEER" "Add a seer to this adventure:") (:br)
+ (:select :name "SEER"
+ (loop :for p :in (all-other-players (player page))
+ :collect (:option :value (nickname p) (nickname p))))
+ (:button :type "submit" "Add Seer")))))))
+
;;; PAGES & PAGE CLASSES
@@ -118,7 +159,6 @@ only the active quest(s) are considered, otherwise all quests are considered."
:initarg :possible-seers
:initform nil)))
-
(defrender t ((page adventure-awaits))
(with-page (:title "What sparkles in yer eye?")
(:h2 "Enscribe your new adventure in the book of the bards.")
@@ -147,45 +187,21 @@ only the active quest(s) are considered, otherwise all quests are considered."
(:button :type "submit" "Embark!")))))
-(defclass adventure-page ()
- ((adventure :reader adventure :initarg :adventure)
- (player :reader player :initarg :player)))
+(defclass/std adventure-page ()
+ ((adventure player possible-seers)))
+
+(defmethod possible-seers ((page adventure-page))
+ (when (eq (player page) (creator (adventure page)))
+ (remove (player page) (all-players))))
(defrender t ((page adventure-page))
(let ((adventure (adventure page)))
(with-page (:title (title adventure))
(:h1 (title adventure))
(:p (description adventure))
- (:h2 "Rumors: ")
- ; (render :list (rumors adventure))
- (:h2 "Architect of this Adventure: " (nickname (creator adventure)))
- (:h2 "Seers: ")
- (render :list (seers adventure))
- (:form :method "POST" :action (urlpath adventure)
- (:label :for "SEER" "Add a seer to this adventure:") (:br)
- (:select :name "SEER"
- (loop :for p :in (all-other-players (player page))
- :collect (:option :value (nickname p) (nickname p))))
- (:button :type "submit" "Add Seer")))))
-
-(defclass spymaster ()
- ((player :reader player :initarg :player)
- (adventures :reader adventures :initarg :adventures)))
-
-
-(defrender t ((page spymaster))
- (with-page (:title "spymaster - report a rumor")
- (:h1 "Of what hazards have ye heard rumor?")
- (:form :method "POST" :action "/spymaster"
- (:label :for "ADVENTURE" "What adventure did ye hear a rumor about?")
- (:br)
- (render :select (adventures page) :name "ADVENTURE")
- (:br)
- (:label :for "REPORTED" "And what did ye have to report?")
- (:br)
- (:textarea :name "REPORTED" :rows "5" :cols "60")
- (:br)
- (:button :type "submit" "Report!"))))
+ (:p "Created by: " (render :link-to (player page)))
+ (rumors-section page)
+ (seers-section page))))
(defclass/std tavern-adventures ()
((your-adventures)))
@@ -229,20 +245,12 @@ only the active quest(s) are considered, otherwise all quests are considered."
:seers possible-seers)))))))
-(defendpoint* :get "/spymaster" () ()
- (with-session (player)
- (render (page-render-mode)
- (make-instance 'spymaster
- :player player
- :adventures (adventures-visible-by player)))))
-
-(defendpoint* :post "/spymaster" () ()
+(defendpoint* :post "/rumors-about/:adventure an-adventure-with-id:" () ()
(with-session (player)
- (with-plist ((adventure :adventure) (reported :reported)) (lzb:request-body)
- (let ((adventure (an-adventure-with-id adventure)))
- (report-a-rumor player adventure reported))
- (redirect-to "/tavern"))))
+ (with-plist ((reported :reported)) (lzb:request-body)
+ (report-a-rumor player adventure reported)
+ (redirect-to (urlpath adventure)))))
;; NB for current hackers (Tue Mar 7 06:44:02 PM PST 2023)
;; Even though these next three all look the same I'm not going to