Compare commits

..

2 Commits

Author SHA1 Message Date
a7697fa1b2 Don't undo during restart animation 2024-02-13 19:15:19 -08:00
0912e90510 Change undo behavior
- Undo while holding a card drops it
- Undo can be redone
2024-02-13 19:09:35 -08:00
3 changed files with 17 additions and 6 deletions

View File

@ -96,8 +96,9 @@ function board:undo()
if (not self.checkpoint) return if (not self.checkpoint) return
if (not self.watcher:intercept("undo")) sounds:dire() return if (not self.watcher:intercept("undo")) sounds:dire() return
sounds:menu() sounds:menu()
local current_checkpoint=checkpoint:new(self,self.checkpoint.card)
self.checkpoint:apply(self) self.checkpoint:apply(self)
self.checkpoint=nil self.checkpoint=current_checkpoint
end end
function board:on_idle() function board:on_idle()

View File

@ -81,13 +81,17 @@ function cursor:toggle_grab()
self:restore_hover() self:restore_hover()
sounds:menu() sounds:menu()
elseif acc==acceptance_state.no_move or acc==acceptance_state.would_not_accept then 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 if (not self.board.watcher:intercept("cancel")) sounds:dire() return
self.grabbed=nil self.grabbed=nil
self:restore_hover() self:restore_hover()
sounds:menu() sounds:menu()
else
assert(false,"invalid acceptance state")
end
end end
function cursor:update() function cursor:update()

View File

@ -41,7 +41,13 @@ function state_gameround:update()
if (btnp(2)) self.board.cursor:move_y(-1) if (btnp(2)) self.board.cursor:move_y(-1)
if (btnp(3)) 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(4)) self.board.cursor:toggle_grab()
if (btnp(5)) self.board:undo() if btnp(5) and self.restart_frames < 4 then
if self.board.cursor:grabbed_card() then
self.board.cursor:drop_grab()
else
self.board:undo()
end
end
end end
if (self.board:is_won()) self.outcome="win" self.done=true main.state_manager:push(state_wonround:new(self.board)) if (self.board:is_won()) self.outcome="win" self.done=true main.state_manager:push(state_wonround:new(self.board))
end end