diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-22 19:23:45 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-22 19:23:45 +0000 |
| commit | 62c13bcfa1933274be856ac5840a933bbaca5f27 (patch) | |
| tree | 81e2d4ab1a749a4d2561e824708abd60a04d67d0 /chess-tutorial.el | |
| parent | 171cc1aceb0e9acafe329ff6cd0ca1e2852876ce (diff) | |
Bug fixes and reducing the TODO list.
Diffstat (limited to 'chess-tutorial.el')
| -rw-r--r-- | chess-tutorial.el | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/chess-tutorial.el b/chess-tutorial.el new file mode 100644 index 0000000..58f7343 --- /dev/null +++ b/chess-tutorial.el @@ -0,0 +1,39 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; A special kind of display that merely autosaves the game +;; + +(require 'chess-game) + +(chess-message-catalog 'english + '((queen-would-take . "The queen would take your knight!") + (congratulations . "Congratulations!") + (knight-1-done . "Goal: take all the pawns, without letting the queen take your knight"))) + +(defun chess-tutorial-knight-1 (game ignore event &rest args) + (if (eq event 'move) + (let ((position (chess-game-pos game))) + (if (null (chess-pos-search position ?p)) + (chess-message 'congratulations) + (when (chess-search-position + position (car (chess-pos-search position ?N)) ?q) + (chess-game-run-hooks chess-module-game 'undo 1) + (chess-display-update nil) + (chess-error 'queen-would-take)))))) + +(defun chess-tutorial () + (interactive) + (let* (chess-default-modules + (display (chess-create-display))) + (with-current-buffer display + (chess-game-set-start-position + (chess-display-game nil) + (chess-fen-to-pos "8/3p1p/2p3p/4q/2p3p/3p1p/8/N w - -")) + (chess-game-add-hook (chess-display-game nil) 'chess-tutorial-knight-1) + (setq chess-pos-always-white t) + (chess-display-popup nil) + (chess-message 'knight-1-done)))) + +(provide 'chess-tutorial) + +;;; chess-tutorial.el ends here |
