[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs a896a83366 312/472: Merge pull request #164 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs a896a83366 312/472: Merge pull request #164 from codingteam/blink-almost-timed-out-159 |
Date: |
Thu, 6 Jan 2022 21:59:35 -0500 (EST) |
branch: elpa/pacmacs
commit a896a833664450b792742c479c5dd98d1c42fa2c
Merge: 3758d601d3 d608708f15
Author: Alexey Kutepov <reximkut@gmail.com>
Commit: Alexey Kutepov <reximkut@gmail.com>
Merge pull request #164 from codingteam/blink-almost-timed-out-159
Blink almost timed out terrified ghosts
---
pacmacs.el | 25 +++++++++++++++++++++++--
test/pacmacs-test.el | 16 ++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index e0887ab881..c969715207 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -49,6 +49,8 @@
(defconst pacmacs-buffer-name "*Pacmacs*")
(defconst pacmacs-tick-duration-ms 100)
+(defconst pacmacs--ghost-blinking-threshold-ms 2500)
+(defconst pacmacs--ghost-terrified-time-ms 5000)
(defvar pacmacs-debug-output nil)
@@ -151,6 +153,22 @@
(cl-decf terrified-timer
pacmacs-tick-duration-ms)))))
+(defun pacmacs--handle-ghost-blinking-threshold ()
+ (dolist (terrified-ghost pacmacs--terrified-ghosts)
+ (plist-bind ((terrified-timer :terrified-timer))
+ terrified-ghost
+ (when
+ ;; FIXME: In Emacs 24.3 `<=` accepts only 2
+ ;; arguments. Please rewrite this when Emacs 24.3 is finally
+ ;; dropped.
+ (and (<= terrified-timer
+ pacmacs--ghost-blinking-threshold-ms)
+ (<= pacmacs--ghost-blinking-threshold-ms
+ (+ terrified-timer pacmacs-tick-duration-ms)))
+ (plist-put terrified-ghost
+ :current-animation
+ (pacmacs-load-anim "Blinking-Terrified-Ghost"))))))
+
(defun pacmacs--switch-direction-animation-callback (animation-prefix)
(let ((direction-animations (-mapcat
(-lambda (direction)
@@ -182,7 +200,7 @@
:speed 1
:speed-counter 0
:type 'terrified-ghost
- :terrified-timer 5000))
+ :terrified-timer pacmacs--ghost-terrified-time-ms))
(defun pacmacs--make-ghost (row column)
(list :row row
@@ -475,7 +493,11 @@
(pacmacs--anim-object-list-next-frame pacmacs--terrified-ghosts
pacmacs-tick-duration-ms)
(pacmacs--recalc-track-board)
+
(pacmacs--unterrify-timed-out-ghosts)
+ (pacmacs--decrease-terrified-timers)
+ (pacmacs--handle-ghost-blinking-threshold)
+
(if pacmacs--pills
(progn
(pacmacs--step-object pacmacs--player-state)
@@ -487,7 +509,6 @@
(pacmacs--step-ghosts)
(pacmacs--step-terrified-ghosts)
(pacmacs--detect-terrified-ghost-collision)
- (pacmacs--decrease-terrified-timers)
(when (pacmacs--ghost-collision-p)
(dolist (ghost pacmacs--ghosts)
(pacmacs--step-back-object ghost))
diff --git a/test/pacmacs-test.el b/test/pacmacs-test.el
index 2575314fe9..f2be579b06 100644
--- a/test/pacmacs-test.el
+++ b/test/pacmacs-test.el
@@ -90,3 +90,19 @@
(should (equal '((:row 30 :column 40)
(:row 10 :column 20))
destroyed-objects))))
+
+(ert-deftest pacmacs--handle-ghost-blinking-threshold-test ()
+ (let ((pacmacs--terrified-ghosts '((:terrified-timer 900 :current-animation
1)
+ (:terrified-timer 999 :current-animation
2)
+ (:terrified-timer 1001 :current-animation
3)
+ (:terrified-timer 899 :current-animation
4)))
+ (pacmacs-tick-duration-ms 100)
+ (pacmacs--ghost-blinking-threshold-ms 1000))
+ (with-mock
+ (mock (pacmacs-load-anim "Blinking-Terrified-Ghost") => 42 :times 2)
+ (pacmacs--handle-ghost-blinking-threshold)
+ (should (equal '((:terrified-timer 900 :current-animation 42)
+ (:terrified-timer 999 :current-animation 42)
+ (:terrified-timer 1001 :current-animation 3)
+ (:terrified-timer 899 :current-animation 4))
+ pacmacs--terrified-ghosts)))))
- [nongnu] elpa/pacmacs b73dd8215c 220/472: Merge branch 'integration-test-replayer-122'. Close #122, (continued)
- [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, 2022/01/06
- [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 <=
- [nongnu] elpa/pacmacs d3c94de6da 320/472: Remove UT for pacmacs--track-point (#159), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8b40dc51cf 330/472: Add 1st big pill level (#162), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 49292e34d3 342/472: UT for terrified-ghost-timed-out-p function (#171), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 40a3d00209 367/472: Implement glowing walls (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5c45e17c40 399/472: Add docs for destroy function (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f79355209d 060/472: Refactor out functions for creating images (#51), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 080aae5f08 070/472: Use plist-bind for pacman-anim-next-frame function (#54), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1e1cebe39a 073/472: Introduce plist-map utility function (#54), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ba7ad0349d 082/472: Rename pacman to pacmacs. Close #66, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs c447091a19 085/472: Fix description in the game headers, ELPA Syncer, 2022/01/06