[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 1eadfb94fd 225/472: Refactor out pacmacs--wall-cel
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 1eadfb94fd 225/472: Refactor out pacmacs--wall-cells list (#81) |
Date: |
Thu, 6 Jan 2022 21:59:27 -0500 (EST) |
branch: elpa/pacmacs
commit 1eadfb94fd244a2036c3e7276ea3125edbc8891a
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Refactor out pacmacs--wall-cells list (#81)
---
pacmacs.el | 61 ++++++++++++++++++++++++-------------------------------------
1 file changed, 24 insertions(+), 37 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index d6e85227c4..08a64bcc3a 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -58,10 +58,10 @@
(defvar pacmacs--player-state nil)
(defvar pacmacs--ghosts nil)
-(defvar pacmacs--wall-cells nil)
(defvar pacmacs--pills nil)
(defvar pacmacs--big-pills nil)
+(defvar pacmacs--object-list nil)
(defvar pacmacs--object-board nil)
(defvar pacmacs--track-board nil)
@@ -423,21 +423,9 @@
(setq pacmacs-waiting-counter 1000))
(defun pacmacs--fill-object-board ()
- (pacmacs--fill-board pacmacs--object-board nil)
-
- (dolist (pill pacmacs--pills)
- (pacmacs--put-object pill))
-
- (dolist (ghost pacmacs--ghosts)
- (pacmacs--put-object ghost))
-
- (pacmacs--put-object pacmacs--player-state)
-
- (dolist (wall pacmacs--wall-cells)
- (pacmacs--put-object wall))
-
- (dolist (big-pill pacmacs--big-pills)
- (pacmacs--put-object big-pill)))
+ (-each pacmacs--object-list
+ (-lambda ((_ . objects))
+ (-each objects #'pacmacs--put-object))))
(defun pacmacs--render-state ()
(with-current-buffer pacmacs-buffer-name
@@ -505,6 +493,17 @@
(-sort #'string-lessp)
(apply #'vector)))
+(defun pacmacs--lines-to-objects (lines)
+ (apply #'append
+ (cl-loop
+ for line being the element of lines using (index row)
+ collect (cl-loop for x being the element of line using (index column)
+ collect (cond ((char-equal x ?#)
(pacmacs--make-wall-cell row column))
+ ((char-equal x ?.)
(pacmacs--make-regular-pill row column))
+ ((char-equal x ?+)
(pacmacs--make-big-pill row column))
+ ((char-equal x ?o)
(pacmacs--make-player row column))
+ ((char-equal x ?g)
(pacmacs--make-ghost row column)))))))
+
(defun pacmacs--load-map (map-name)
(let* ((lines (split-string (->> map-name
(format "./maps/%s.txt")
@@ -518,29 +517,17 @@
(setq pacmacs--track-board (pacmacs--make-board board-width
board-height))
- (setq pacmacs--wall-cells nil)
- (setq pacmacs--pills nil)
- (setq pacmacs--ghosts nil)
- (setq pacmacs--player-state nil)
- (setq pacmacs--big-pills nil)
-
- (cl-loop
- for line being the element of lines using (index row)
- do (cl-loop for x being the element of line using (index column)
- do (cond ((char-equal x ?#)
- (add-to-list 'pacmacs--wall-cells
(pacmacs--make-wall-cell row column)))
-
- ((char-equal x ?.)
- (add-to-list 'pacmacs--pills
(pacmacs--make-regular-pill row column)))
-
- ((char-equal x ?+)
- (add-to-list 'pacmacs--big-pills
(pacmacs--make-big-pill row column)))
+ (setq pacmacs--object-list
+ (->> lines
+ (pacmacs--lines-to-objects)
+ (-remove #'null)
+ (-group-by (-partial (-flip #'plist-get) :type))))
- ((char-equal x ?o)
- (setq pacmacs--player-state (pacmacs--make-player
row column)))
+ (setq pacmacs--pills (cdr (assoc 'pill pacmacs--object-list)))
+ (setq pacmacs--ghosts (cdr (assoc 'ghost pacmacs--object-list)))
+ (setq pacmacs--player-state (cadr (assoc 'player pacmacs--object-list)))
+ (setq pacmacs--big-pills (cdr (assoc 'big-pill pacmacs--object-list)))
- ((char-equal x ?g)
- (add-to-list 'pacmacs--ghosts (pacmacs--make-ghost
row column))))))
(pacmacs--fill-object-board)))
(provide 'pacmacs)
- [nongnu] elpa/pacmacs 2a9ec76c28 263/472: Automate Big Pills sprites generating (#26), (continued)
- [nongnu] elpa/pacmacs 2a9ec76c28 263/472: Automate Big Pills sprites generating (#26), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a1bf99c5f7 176/472: Add an animation, close #118., ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 29b87c4538 181/472: Refactor out unpaused play state predicate, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 93f964e11e 186/472: Merge branch 'compile-on-ci-123'. Close #123, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 3f7bf5c282 192/472: Fix board UTs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 805d91d22b 194/472: Rename all the buffer stuff to board back (#105), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1ab8264214 198/472: Remove dead vars for board size (#126), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 144a973d83 203/472: Merge branch 'slow-object-look-up-126'. Close #126, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6a4bf8c87f 214/472: Merge branch 'integration-test-recorder-115'. Close #115, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b73dd8215c 220/472: Merge branch 'integration-test-replayer-122'. Close #122, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1eadfb94fd 225/472: Refactor out pacmacs--wall-cells list (#81),
ELPA Syncer <=
- [nongnu] elpa/pacmacs 843d428744 226/472: Refactor out pacmacs--big-pills list (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7eafd1bf11 017/472: Merge branch 'split-merged-modules-19'. Close #19, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f88ea61b10 035/472: Merge branch 'ut-coverage-27'. Close #27, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9acb9eefa4 286/472: Introduce a constructor for terrified ghosts (#153), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 25193bcdbf 289/472: Better running away algorithm (#153), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8fd7660240 290/472: Terrify ghosts by eating big pill (#153), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e4e4053c26 306/472: Ghost terrified time as constant (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1978363e9d 310/472: Fix handle-ghost-blinking-threshold (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a896a83366 312/472: Merge pull request #164 from codingteam/blink-almost-timed-out-159, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d3c94de6da 320/472: Remove UT for pacmacs--track-point (#159), ELPA Syncer, 2022/01/06