From cc3f850c514967ae2f9effef7e68e1d4965c6865 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 1 Apr 2023 09:48:08 -0700 Subject: Refactor to make cooperative hacking nicer --- src/queries.lisp | 50 +++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) (limited to 'src/queries.lisp') diff --git a/src/queries.lisp b/src/queries.lisp index 13c1d26..5184575 100644 --- a/src/queries.lisp +++ b/src/queries.lisp @@ -2,43 +2,15 @@ (in-package :dnd) -(defun all-heroes () - (db:store-objects-with-class 'hero)) - -(defun all-players () - (db:store-objects-with-class 'player)) - -(defun all-other-players (player) - (remove-if (lambda (p) (eq player p)) (all-players))) - -(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-adventures (player) - "Return a list of adventures one of the players' heroes is involved in." - (mapcar #'adventure (player-quests player) )) - -(defun adventure-heros (adventure &key (activep t)) - "All the heros actively involved in this ADVENTURE. 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-adventure adventure)) - (quests-in-adventure adventure))))) - -(defun fetch-comrades (player &key (activep t)) - "Returns all the heroes in any one of the player's adventures. If -ACTIVEP, then only heroes involved in active quests are returned." - (remove-duplicates - (loop :for adventure :in (player-adventures player) - :nconc (adventure-heros adventure :activep activep)))) - -(defun all-adventures () - (db:store-objects-with-class 'adventure)) - -(defun adventures-visible-by (player) - (declare (ignore player)) - (all-adventures)) + + + + + + + + + + + -- cgit v1.2.3