Change undo behavior
- Undo while holding a card drops it - Undo can be redone
This commit is contained in:
parent
119155a903
commit
0912e90510
@ -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()
|
||||
|
10
cursor.lua
10
cursor.lua
@ -81,13 +81,17 @@ function cursor:toggle_grab()
|
||||
self:restore_hover()
|
||||
sounds:menu()
|
||||
elseif acc==acceptance_state.no_move or acc==acceptance_state.would_not_accept then
|
||||
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()
|
||||
else
|
||||
assert(false,"invalid acceptance state")
|
||||
end
|
||||
end
|
||||
|
||||
function cursor:update()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user