state_gameround=klass() function state_gameround:init(watcher,ruleset) self.board=board:new(watcher,ruleset) self.outcome=nil self.restart_frames=0 end function state_gameround:enter() self:add_menu() end function state_gameround:exit() self:remove_menu() end function state_gameround:reenter() self:add_menu() end function state_gameround:suspend() self:remove_menu() end function state_gameround:add_menu() menuitem(4,"restart",function() self.outcome="restart" self.done=true end) menuitem(5,"go to menu",function() self.outcome="menu" self.done=true end) end function state_gameround:remove_menu() menuitem(4) menuitem(5) end function state_gameround:update() self.board:update() if btn(5) then self.restart_frames+=1 else self.restart_frames=0 end local restart_progress=self.restart_frames/60 self.board:set_restart_progress(restart_progress) if restart_progress>=1.0 then self.outcome="restart" self.done=true return end if self.board:can_take_input() then if (btnp(0)) self.board.cursor:move_x(-1) if (btnp(1)) self.board.cursor:move_x(1) 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) 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 if (self.board:is_won()) self.outcome="win" self.done=true main.state_manager:push(state_wonround:new(self.board)) end function state_gameround:draw() cls(13) self.board:draw() end