Isoraqathedh

The functions

Mar 19th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.83 KB | None | 0 0
  1. (defun component-combine (func dests) "Basic combine moves with a free slot to indicate the combining function. Helper function."
  2.   (loop for dest in dests append (mapcar func dest)))
  3. (defun combine (&rest dests)
  4.   (component-combine #'identity dests)) ; For consistency, this function uses the rather silly identity function.
  5. (defun capture (&rest dests)
  6.   (component-combine #'(lambda (p) (append p (list :capture t))) dests))
  7. (defun move (&rest dests)
  8.   (component-combine #'(lambda (p) (append p (list :move t))) dests))
  9. (defun igui (&rest dests)
  10.   (component-combine #'(lambda (p) (append p (list :igui t))) dests))
  11. (defun lame (&rest dests) ; use (then '(:complete t)) (NYI) for finer control over lame moves.
  12.   (component-combine #'(lambda (p) (append p (list :lame t))) dests))
  13. (defun jump (optlist &rest dests) ; Jumping makes sense only on range moves, or when exactly one of the options are false.
  14.                     ; Single destinations are jumps by default.
  15.   (destructuring-bind (&key (jump-friendly-p t) (jump-enemy-p t)) optlist
  16.                     ; The destructuring-bind above catches settings that are not included with the attribute
  17.     (component-combine #'(lambda (p) (append p (list :jump (list :jump-friendly-p jump-friendly-p
  18.                                  :jump-enemy-p    jump-enemy-p)))) dests)))
  19. (defun cannon (optlist &rest dests)
  20.   (destructuring-bind (&key (steps-before :any)
  21.                 (jump-enemy-p T)
  22.                 (jump-friendly-p T)
  23.                 (capture-screen-p nil)
  24.                 (screen-count 1)
  25.                 (steps-after :any)) optlist
  26.       (component-combine #'(lambda (p) (append p (list :cannon (list :steps-before     steps-before
  27.                                      :jump-enemy-p     jump-enemy-p
  28.                                      :jump-friendly-p  jump-friendly-p
  29.                                      :capture-screen-p capture-screen-p
  30.                                      :screen-count     screen-count
  31.                                      :steps-after      steps-after)))) dests)))
Advertisement
Add Comment
Please, Sign In to add comment