diff options
Diffstat (limited to 'src/wasp-user-stats.el')
| -rw-r--r-- | src/wasp-user-stats.el | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/wasp-user-stats.el b/src/wasp-user-stats.el new file mode 100644 index 00000000..19d297a4 --- /dev/null +++ b/src/wasp-user-stats.el @@ -0,0 +1,62 @@ +;;; wasp-user-stats --- User data: statistics -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(defvar w/user-faction-exemptions + (list + "LCOLONQ" + "MODCLONK" + "fn_lumi")) + +(defun w/user-initial-faction (user) + "Determine the initial faction for USER." + (unless (-contains? w/user-faction-exemptions user) + (let* ((factions '(nate lever tony))) + (nth (random (length factions)) factions)))) +(defun w/user-ensure-faction () + "Ensure that the current user has a faction assigned." + (let ((cur (alist-get :faction w/user-current))) + (unless cur + (setf (alist-get :faction w/user-current) + (w/user-initial-faction w/user-current-name))))) + +(defconst w/user-elements + '(("fire" "🔥" "red") + ("water" "🌊" "blue") + ("wind" "🍃️" "green") + ("earth" "🪨" "brown") + ("lightning" "⚡" "yellow") + ("heart" "🩷" "pink"))) +(defun w/user-initial-element () + "Determine the initial faction for USER." + (let* ((factions w/user-elements)) + (car (nth (random (length factions)) factions)))) +(defun w/user-ensure-element () + "Ensure that the current user has a faction assigned." + (let ((cur (alist-get :element w/user-current))) + (unless cur + (setf (alist-get :element w/user-current) + (w/user-initial-element))))) + +(defun w/user-faction-total (faction) + "Compute the boost totals for FACTION." + (-sum + (-non-nil + (--map + (alist-get :boost it) + (--filter + (and (listp it) (eq faction (alist-get :faction it))) + (ht-values w/user-cache)))))) +(defun w/user-faction-totals () + "Compute the boost totals for each FACTION." + (list + (w/user-faction-total 'nate) + (w/user-faction-total 'tony) + (w/user-faction-total 'lever))) + +(defun w/user-stats-update () + (w/user-ensure-faction) + (w/user-ensure-element)) + +(provide 'wasp-user-stats) +;;; wasp-user-stats.el ends here |
