[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 1a678dfee7 110/472: Refactor out pacmacs--object-a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 1a678dfee7 110/472: Refactor out pacmacs--object-at-p (#74) |
Date: |
Thu, 6 Jan 2022 21:59:17 -0500 (EST) |
branch: elpa/pacmacs
commit 1a678dfee71aa64cb07ca689012d7e88b8f35696
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Refactor out pacmacs--object-at-p (#74)
---
pacmacs-board.el | 14 ++++++++++++++
pacmacs.el | 18 ++++++------------
test/pacmacs-board-test.el | 12 ++++++++++++
test/pacmacs-test.el | 12 +-----------
4 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/pacmacs-board.el b/pacmacs-board.el
index f60a56ce10..894bd5d245 100644
--- a/pacmacs-board.el
+++ b/pacmacs-board.el
@@ -57,6 +57,20 @@
(mod column width)
value)))
+(defun pacmacs--object-at-p (board row column objects)
+ (plist-bind ((width :width)
+ (height :height))
+ board
+ (member (cons (mod row height)
+ (mod column width))
+ (mapcar #'(lambda (object)
+ (plist-bind ((row :row)
+ (column :column))
+ object
+ (cons row column)))
+ objects))))
+
(provide 'pacmacs-board)
;;; pacmacs-board.el ends here
+
diff --git a/pacmacs.el b/pacmacs.el
index be7ca5b149..88c83eb543 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -142,21 +142,15 @@
(kill-buffer-and-window))
(kill-buffer buffer-or-name))))
-(defun pacmacs--object-at-p (row column objects)
- (member (cons (mod row pacmacs-board-height)
- (mod column pacmacs-board-width))
- (mapcar #'(lambda (object)
- (plist-bind ((row :row)
- (column :column))
- object
- (cons row column)))
- objects)))
-
(defun pacmacs--wall-at-p (row column)
- (pacmacs--object-at-p row column pacmacs-wall-cells))
+ (pacmacs--object-at-p pacmacs-board
+ row column
+ pacmacs-wall-cells))
(defun pacmacs--pill-at-p (row column)
- (pacmacs--object-at-p row column pacmacs-pills))
+ (pacmacs--object-at-p pacmacs-board
+ row column
+ pacmacs-pills))
(defun pacmacs-quit ()
(interactive)
diff --git a/test/pacmacs-board-test.el b/test/pacmacs-board-test.el
index ccbec9e757..162887571d 100644
--- a/test/pacmacs-board-test.el
+++ b/test/pacmacs-board-test.el
@@ -29,3 +29,15 @@
(pacmacs--cell-set input-board 1 1 42)
(should (equal expected-board
input-board))))
+
+(ert-deftest pacmacs--object-at-p-test ()
+ (let ((board (list :width 5
+ :height 4))
+ (objects (-map #'(lambda (x)
+ (list :row x
+ :column x))
+ (number-sequence 0 3))))
+ (should (pacmacs--object-at-p board 0 0 objects))
+ (should (not (pacmacs--object-at-p board 0 1 objects)))
+ (should (pacmacs--object-at-p board 0 5 objects))
+ (should (not (pacmacs--object-at-p board 1 5 objects)))))
diff --git a/test/pacmacs-test.el b/test/pacmacs-test.el
index 8859859408..3ef8e9bd37 100644
--- a/test/pacmacs-test.el
+++ b/test/pacmacs-test.el
@@ -8,17 +8,7 @@
(should (equal expected-board
input-board))))
-(ert-deftest pacmacs--object-at-p-test ()
- (let ((pacmacs-board-width 5)
- (pacmacs-board-height 4)
- (objects (-map #'(lambda (x)
- (list :row x
- :column x))
- (number-sequence 0 3))))
- (should (pacmacs--object-at-p 0 0 objects))
- (should (not (pacmacs--object-at-p 0 1 objects)))
- (should (pacmacs--object-at-p 0 5 objects))
- (should (not (pacmacs--object-at-p 1 5 objects)))))
+
(ert-deftest pacmacs--cell-tracked-p-test ()
(let ((pacmacs-board-width 2)
- [nongnu] elpa/pacmacs 2cf174ca7e 434/472: Create signs folder with game over sign (#191), (continued)
- [nongnu] elpa/pacmacs 2cf174ca7e 434/472: Create signs folder with game over sign (#191), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7d4356c92c 445/472: Implement pacmacs-score-awesome (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0f4eb7aebf 452/472: Decouple score page render from sign render (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a12795e835 455/472: Introduce pacmacs-scores-mode (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs cdae42dba5 461/472: Replace too specific function with composition, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 864fe2b02e 465/472: Bump the copyright year for all the files, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs edadbe5e53 469/472: Bump version to 0.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs db16fba9cd 470/472: Add missing license statement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 98ce700143 023/472: Hide cursor in the game's buffer. Close #12, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 3070cf0e6a 063/472: Merge branch 'refactor-image-resource-51'. Close #51, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1a678dfee7 110/472: Refactor out pacmacs--object-at-p (#74),
ELPA Syncer <=
- [nongnu] elpa/pacmacs 5492ed0a87 118/472: Refactor pacmacs-render-state (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b5078d2632 141/472: Move most of the rendering stuff to pacman-render, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a460cd8b06 148/472: Merge pull request #107 from rexim/feature/new-maps, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs c426f6ac91 078/472: Fix some accidental paredit typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 4341b23d87 094/472: Implement wraparound. Close #67, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 12942ddeff 113/472: Refactor out pacmacs--fill-board (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 91408c074d 115/472: Refactor pacmacs--track-object (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ed40addf95 116/472: Refactor pacmacs--put-object (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs eac9d47c62 117/472: Refactor pacmacs-render-track-board (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d763bd0f82 121/472: Fix the UTs, ELPA Syncer, 2022/01/06