diff --git a/board.lua b/board.lua index d2cde39..2d3c4d2 100644 --- a/board.lua +++ b/board.lua @@ -96,8 +96,9 @@ function board:undo() if (not self.checkpoint) return if (not self.watcher:intercept("undo")) sounds:dire() return sounds:menu() + local current_checkpoint=checkpoint:new(self,self.checkpoint.card) self.checkpoint:apply(self) - self.checkpoint=nil + self.checkpoint=current_checkpoint end function board:on_idle() diff --git a/cursor.lua b/cursor.lua index 1ec5a30..a806c12 100644 --- a/cursor.lua +++ b/cursor.lua @@ -81,15 +81,19 @@ function cursor:toggle_grab() self:restore_hover() sounds:menu() elseif acc==acceptance_state.no_move or acc==acceptance_state.would_not_accept then - if (not self.board.watcher:intercept("cancel")) sounds:dire() return - self.grabbed=nil - self:restore_hover() - sounds:menu() + self:drop_grab() else assert(false,"invalid acceptance state") end end +function cursor:drop_grab() + if (not self.board.watcher:intercept("cancel")) sounds:dire() return + self.grabbed=nil + self:restore_hover() + sounds:menu() +end + function cursor:update() if (self.wants_to_restore_hover) self:actually_restore_hover() end diff --git a/state_gameround.lua b/state_gameround.lua index b8b7fa0..3516cc6 100644 --- a/state_gameround.lua +++ b/state_gameround.lua @@ -41,7 +41,13 @@ function state_gameround:update() if (btnp(2)) self.board.cursor:move_y(-1) if (btnp(3)) self.board.cursor:move_y(1) if (btnp(4)) self.board.cursor:toggle_grab() - if (btnp(5)) self.board:undo() + if btnp(5) then + if self.board.cursor:grabbed_card() then + self.board.cursor:drop_grab() + else + self.board:undo() + end + end end if (self.board:is_won()) self.outcome="win" self.done=true main.state_manager:push(state_wonround:new(self.board)) end