atoms.lisp: When restoring an unstable position, continue the animation.
[atoms] / atoms.lisp
index 5dc0def..eac69bc 100644 (file)
                 (incf remaining)
                 (setf found player)))))
       (changed game :scores :players players)
-      (when (= remaining 1)
+      (when (and (= remaining 1) (>= (length players) 2))
        (setf (player-state found) :winning)
        (changed game :finished :victor found)))))
 
          (unless (cell-played cell player-index)
            (return-from escape))
          (setf (player-state player) :playing)
-         (perform-explosions game (list cell)))
-       (changed game :processing-move)))))
+         (changed game :processing-move)
+         (perform-explosions game (list cell)))))))
 
 (defmethod restart-game ((game atom-game) &key grid players)
   (game-cancel-timeout game)
          do (restore player snap-player))
     (setf (game-player-index game) (slot-value snapshot 'player-index))
     (game-cancel-timeout game)
-    (changed game :refresh)))
+    (changed game :refresh)
+    (let ((critical-cells (loop for i below (array-total-size grid)
+                               for cell = (row-major-aref grid i)
+                               if (cell-critical-p cell)
+                               collect cell)))
+      (when critical-cells (perform-explosions game critical-cells)))))
 
 ;;;--------------------------------------------------------------------------
 ;;; The interactive board.
                                               :step-increment 1))
    (count-adjustment :type gtk:adjustment
                     :initform (make-instance 'gtk:adjustment
-                                             :lower 2 :upper 20
+                                             :lower 1 :upper 20
                                              :step-increment 1))
    (players :type gtk:list-store
            :initform (make-instance 'gtk:list-store