React to opponent moves on ICS.
[kaya/ydirson.git] / lib / animator_helper.rb
blob1f16f2a1411710bdeffff74c60d3fd0f50c58f97
1 require 'animations'
3 module AnimatorHelper
4   include Animations
5   
6   def move!(src, dst, path, opts = {})
7     piece = board.move_item(src, dst)
8     src = nil if opts[:adjust]
9     movement(piece, src, dst, path)
10   end
11   
12   def disappear_on!(p, opts = {})
13     name = "disappear on #{p}"
14     if opts[:instant]
15       instant_disappear p, name
16     else
17       item = board.remove_item(p, :keep)
18       disappear(item, name)
19     end
20   end
21     
22   def appear_on!(p, piece, opts = {})
23     name = "appear #{piece} on #{p}"
24     if opts[:instant]
25       instant_appear p, piece, name
26     else
27       item = board.add_piece p, piece, :hidden => true
28       appear(item, name)
29     end
30   end
31   
32   def morph_on!(p, piece, opts = {})
33     name = "morph to #{piece} on #{p}"
34     if opts[:instant]
35       instant_appear p, piece, name
36     else
37       old_item = board.remove_item(p, :keep)
38       new_item = board.add_piece p, piece, :hidden => true
39       group appear(new_item, name + " (appear)"),
40             disappear(old_item, name + " (disappear)")
41     end
42   end
43 end