bugfix: safety against breaking the AI if you press undo while it's thinking
[kaya.git] / lib / animator_helper.rb
blobc5f32d792ba25d19e45b47a6c616adda699b958e
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 require 'animations'
10 module AnimatorHelper
11   include Animations
12   
13   def move!(src, dst, path, opts = {})
14     piece = board.move_item(src, dst)
15     src = nil if opts[:adjust]
16     movement(piece, src, dst, path)
17   end
18   
19   def disappear_on!(p, opts = {})
20     name = "disappear on #{p}"
21     item = board.remove_item(p, :keep)
22     disappear(item, name, opts)
23   end
24     
25   def appear_on!(p, piece, opts = {})
26     name = "appear #{piece} on #{p}"
27     item = board.add_piece p, piece, :hidden => true
28     appear(item, name, opts)
29   end
30   
31   def morph_on!(p, piece, opts = {})
32     name = "morph to #{piece} on #{p}"
33     old_item = board.remove_item(p, :keep)
34     new_item = board.add_piece p, piece, :hidden => true
35     group appear(new_item, name + " (appear)", opts),
36           disappear(old_item, name + " (disappear)", opts)
37   end
38 end