summaryrefslogtreecommitdiff
path: root/queries.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-02-20 17:49:42 -0800
committercolin <colin@cicadas.surf>2023-02-20 17:49:42 -0800
commit2be10a3b137d7bcc75b02884ddbe72608f85f9b0 (patch)
tree8230da3fa4395df6adc90001db395c0de21cfd6f /queries.lisp
parent3249a20b60e9652ec772f057e540f60bbcf1f024 (diff)
Refactor: to use render protocol
Diffstat (limited to 'queries.lisp')
-rw-r--r--queries.lisp19
1 files changed, 19 insertions, 0 deletions
diff --git a/queries.lisp b/queries.lisp
index 329ecb2..4538c75 100644
--- a/queries.lisp
+++ b/queries.lisp
@@ -5,3 +5,22 @@
(defun all-heroes ()
(db:store-objects-with-class 'hero))
+(defun player-campaigns (player)
+ "Return a list of campaigns that that player is involved in."
+ (remove nil (mapcar #'hero-campaign (player-heroes player))))
+
+(defun campaign-heros (campaign &key (activep t))
+ "All the heros actively involved in this CAMPAIGN. If ACTIVEP, then
+only the active quest(s) are considered, otherwise all quests are considered."
+ (remove-duplicates
+ (mapcan #'heroes-on-quest
+ (if activep
+ (remove-if-not #'quest-startedp (quests-in-campaign campaign))
+ (quests-in-campaign campaign)))))
+
+(defun fetch-comrades (player &key (activep t))
+ "Returns all the heroes in any one of the player's campaigns. If
+ACTIVEP, then only heroes involved in active quests are returned."
+ (remove-duplicates
+ (loop :for campaign :in (player-campaigns player)
+ :nconc (campaign-heros campaign :activep activep))))