function board:animate_move_ace_to_well(card, well) local slot_layout=self.ruleset.layouts:slot( self.ruleset.n_slots\2+1 ) local well_layout=self.ruleset.layouts:well(well) local start_x,start_y=slot_layout:place_card(1) local end_x,end_y=well_layout:place_card(1) -- index shouldn't matter local _self=self self:_animate_move_card( card,function() _self.wells[well]:add(card) end, start_x,start_y,function() return end_x,end_y end ) end function board:animate_move_new_card_to_slot(card, slot) local src_layout=self.ruleset.layouts:slot(self.ruleset.n_slots\2+1) local dst_layout=self.ruleset.layouts:slot(slot) local start_x,start_y=src_layout:place_card(1) local _self=self self:_animate_move_card( card,function() _self.slots[slot]:add(card) end, start_x,start_y,function() return dst_layout:place_card(#_self.slots[slot].contents+1) end ) end function board:animate_and_move_to_well(slot, well) local slot_layout=self.ruleset.layouts:slot(slot) local well_layout=self.ruleset.layouts:well(well) local start_x,start_y=slot_layout:place_card(#self.slots[slot].contents) local end_x,end_y=well_layout:place_card(1) -- index shouldn't matter local card=self.slots[slot]:pop() local _self=self self:_animate_move_card( card,function() _self.wells[well]:add(card) end, start_x,start_y,function() return end_x,end_y end ) end function board:_animate_move_card(card,on_end,start_x,start_y,compute_end) local frame=0 local progress=0.0 local anim_obj={} local end_x,end_y=start_x,start_y local _self=self function anim_obj:update() if (frame==0) end_x,end_y=compute_end() frame+=1 progress=frame/7 if (progress>=1.0) on_end() return false return true end function anim_obj:draw() local x=start_x+(end_x-start_x)*progress local y=start_y+(end_y-start_y)*progress _self.ruleset.deck:draw_card(x,y,card,false) end self.animator:add(anim_obj) end