From f7abccc38ceda7024ca375d34ed88f4fb561ef02 Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 5 Mar 2023 16:36:44 -0800 Subject: Reorganized codebase --- src/queries.lisp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/queries.lisp (limited to 'src/queries.lisp') diff --git a/src/queries.lisp b/src/queries.lisp new file mode 100644 index 0000000..c657979 --- /dev/null +++ b/src/queries.lisp @@ -0,0 +1,34 @@ +;;;; queries.lisp -- query the database + +(in-package :dnd) + +(defun all-heroes () + (db:store-objects-with-class 'hero)) + +(defun player-quests (player) + "Return all quests in which one of player's heroes is engaged." + (remove nil (mapcar #'quest (player-heroes player)))) + +(defun player-campaigns (player) + "Return a list of campaigns one of the players' heroes is involved in." + (mapcar #'campaign (player-quests player) )) + +(defun campaign-heroes (campaign) + "" + ) + +(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)))) -- cgit v1.2.3