emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/pacmacs 0103a77462 302/472: Remove replace-filtered-game-o


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs 0103a77462 302/472: Remove replace-filtered-game-objects (#153)
Date: Thu, 6 Jan 2022 21:59:34 -0500 (EST)

branch: elpa/pacmacs
commit 0103a774620eb9d5387d05c1b7f896c1dff4b021
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>

    Remove replace-filtered-game-objects (#153)
    
    pacmacs--unterrify-timed-out-ghosts can be rewritten in terms of
    pacmacs--replace-game-objects
---
 pacmacs.el | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/pacmacs.el b/pacmacs.el
index 0b3373fd32..e0887ab881 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -414,16 +414,6 @@
   (pacmacs--create-game-object row column 'pacmacs--ghosts
                                #'pacmacs--make-ghost))
 
-(defun pacmacs--replace-filtered-game-objects (list-name replacing-constructor 
predicate)
-  (let ((game-objects (symbol-value list-name)))
-    (dolist (game-object (-filter predicate game-objects))
-      (plist-bind ((row :row)
-                 (column :column))
-          game-object
-        (funcall replacing-constructor row column))
-      (pacmacs--remove-object game-object))
-    (set list-name (-remove predicate game-objects))))
-
 (defun pacmacs--replace-game-objects (game-objects new-constructor 
old-destructor)
   (dolist (game-object game-objects)
     (plist-bind ((row :row)
@@ -439,11 +429,15 @@
   (setq pacmacs--ghosts nil))
 
 (defun pacmacs--unterrify-timed-out-ghosts ()
-  (pacmacs--replace-filtered-game-objects
-   'pacmacs--terrified-ghosts
-   #'pacmacs--create-ghost
-   (-lambda (terrified-ghost)
-     (<= (plist-get terrified-ghost :terrified-timer) 0))))
+  (let ((timed-out-predicate
+         (-lambda (terrified-ghost)
+           (<= (plist-get terrified-ghost :terrified-timer) 0))))
+    (pacmacs--replace-game-objects
+     (-filter timed-out-predicate pacmacs--terrified-ghosts)
+     #'pacmacs--create-ghost
+     #'pacmacs--remove-object)
+    (setq pacmacs--terrified-ghosts (-remove timed-out-predicate
+                                             pacmacs--terrified-ghosts))))
 
 (defun pacmacs--detect-pill-collision ()
   (plist-bind ((row :row)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]