summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/adventure.lisp100
-rw-r--r--src/game/hero.lisp10
-rw-r--r--src/game/quest.lisp22
-rw-r--r--src/game/tavern.lisp26
-rw-r--r--src/game/views.lisp5
-rw-r--r--src/names.lisp5
-rw-r--r--src/player.lisp13
-rw-r--r--src/view-components.lisp3
8 files changed, 101 insertions, 83 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
diff --git a/src/game/hero.lisp b/src/game/hero.lisp
index 68606b2..56c5786 100644
--- a/src/game/hero.lisp
+++ b/src/game/hero.lisp
@@ -51,6 +51,9 @@
;;; HELPERS
+(defmethod unique-name ((hero hero))
+ (name hero))
+
;;; QUERIES
(defun all-heroes ()
(db:store-objects-with-class 'hero))
@@ -71,7 +74,6 @@
(:span "who's quest is to")
(:span (render :link-to quest))))))
-
(defrender :link-to ((hero hero))
(with-html
(:a :href (urlpath hero)
@@ -86,7 +88,11 @@
(defrender t ((page hero-page))
(with-page (:title (unique-name (hero page)))
(:h1 (unique-name (hero page)))
- (:p "uhhh.....")))
+ (:div
+ (if (quest (hero page))
+ (:p "This hero is questing on "
+ (render :link-to (quest (hero page))))
+ (:p "this hero is free to join a quest")))))
(defrender t ((page (eql :goddess-shrine)))
(with-page (:title "A Sacred Shrine")
diff --git a/src/game/quest.lisp b/src/game/quest.lisp
index d36b9f9..ab1b9a7 100644
--- a/src/game/quest.lisp
+++ b/src/game/quest.lisp
@@ -26,22 +26,28 @@
: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."))
+ (:documentation
+ "A collection of hazards with a deadline and start date which heroes will attack."))
+;;; HELPERS
+;;; QUERIES
(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)
+;;; TRANSACTIONS
+;;; 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)))
@@ -50,18 +56,10 @@
(with-page (:title (unique-name (quest page )))
(:h1 (unique-name (quest page)))))
-;;; HELPERS
-
-;;; QUERIES
-
-;;; TRANSACTIONS
-
-;;; MODEL VIEWS
-
-;;; PAGES & PAGE CLASSES
-
;;; ENDPOINT HELPERS
+(define-id-plucker quest)
+
;;; ENDPOINT DEFINITIONS
(defendpoint* :get "/quest/:quest a-quest-with-id:/:name:" () ()
diff --git a/src/game/tavern.lisp b/src/game/tavern.lisp
index 5997218..5ddb8b9 100644
--- a/src/game/tavern.lisp
+++ b/src/game/tavern.lisp
@@ -6,22 +6,18 @@
;;; PAGES & PAGE CLASSES
(defclass/std tavern ()
- ((player)))
+ ((player adventures)))
(defrender t ((tavern tavern))
(with-page (:title "A Bustling Tavern")
- (let ((player (player tavern)))
- (render :details player)
- (when (player-heroes player)
- (:h2 "Your Heroes:")
- (render :list (player-heroes player)))
- (:a :href "tavern/adventures" "Adventures for which you are seer.")
- (:br)
- (:a :href "/goddess-shrine" "Pray a new hero rises.")
- (:br)
- (:a :href "/spymaster" "Report a Roguish Rumour...")
- (:br)
- (:a :href "/adventure-awaits" "Embark on a new Adventure!"))))
+ (let ((player (player tavern)))
+ (render :details player)
+ (when (player-heroes player)
+ (:h4 "Your Heroes:")
+ (render :list (player-heroes player)))
+ (when (adventures tavern)
+ (:h4 "All Adventures:")
+ (render :list (adventures tavern))))))
;;; ENDPONT HELPERS
@@ -31,7 +27,9 @@
(defendpoint* :get "/tavern" () ()
(with-session (me)
(render (page-render-mode)
- (make-instance 'tavern :player me))))
+ (make-instance 'tavern
+ :player me
+ :adventures (all-adventures)))))
diff --git a/src/game/views.lisp b/src/game/views.lisp
index 1b2f05d..e674598 100644
--- a/src/game/views.lisp
+++ b/src/game/views.lisp
@@ -5,5 +5,6 @@
(defun page-nav ()
(with-html
(:nav :class "navbar"
- (:ul
- (:li (:a :href "/tavern" "🍺 Tavern"))))))
+ (:div (:a :href "/tavern" "🍺 Tavern"))
+ (:div (:a :href "/goddess-shrine" "🦸 Roll Up A Hero"))
+ (:div (:a :href "/adventure-awaits" "🔭 Embark on an Adventure")))))
diff --git a/src/names.lisp b/src/names.lisp
index 05397a6..e0a4e99 100644
--- a/src/names.lisp
+++ b/src/names.lisp
@@ -7,11 +7,6 @@
(:documentation "Returns a unique name for an object, or NIL if it does not have one.")
(:method ((ob t)) nil))
-(defmethod unique-name ((adventure adventure))
- (title adventure))
-
-(defmethod unique-name ((hero hero))
- (name hero))
(defgeneric urlpath (object)
diff --git a/src/player.lisp b/src/player.lisp
index 11cd2b9..6533f59 100644
--- a/src/player.lisp
+++ b/src/player.lisp
@@ -42,6 +42,11 @@
;;; HELPERS
+
+(defmethod unique-name ((player player))
+ (nickname player))
+
+
;;; QUERIES
(defun all-players ()
@@ -76,7 +81,6 @@
(with-html
(:option :value (uid player) (nickname player))))
-
(defrender :checkbox ((player player))
(with-html
(:input :type "checkbox" :id (uid player) :name "POSSIBLE-SEER" :value (uid player))
@@ -86,6 +90,13 @@
(with-html
(nickname player)))
+(defrender :link-to ((player player))
+ (render :inline player))
+
+(defrender :inline ((player player))
+ (with-html (:a :href (urlpath player) (nickname player)))
+ )
+
;;; PAGES & PAGE CLASSES
(defclass/std doorkeeper ()
diff --git a/src/view-components.lisp b/src/view-components.lisp
index 0711dda..1c21952 100644
--- a/src/view-components.lisp
+++ b/src/view-components.lisp
@@ -9,7 +9,7 @@
lists. CLASS is the lass string for the containing list. ITEM-CLASS is
the class string for the contained list items."
(with-html
- (:ol :class class
+ (:ul :class class
(dolist (item data)
(:li :class item-class (render :list-item item))))))
@@ -49,3 +49,4 @@ the class string for the contained list items."
(:li (:a :href "/quests" :aria-label "Quests" "📜"))
(:li (:a :href "/tavern" :aria-label "Tavern" "🍺"))))))
+