feat: double click to move to final stacks

main
LeRoyce Pearson 2024-02-12 12:10:34 -07:00
parent 9ab6221462
commit 1d67ecdf43
1 changed files with 23 additions and 12 deletions

View File

@ -245,9 +245,15 @@ function update()
if #stacks[1]==0 then if #stacks[1]==0 then
exhausted=true exhausted=true
end end
--[[elseif hand and hover and elseif hand and hover and
hand[1]==hover[1] and left hand[1]==hover[1] and hand[2]==hover[2] and left
then--]] -- TODO: double click to send to finished then
for i=3,6 do
if move_sel(hand, {i,#stacks[i]}) then
hand=nil
break
end
end
elseif hand and hover and left then elseif hand and hover and left then
move_sel(hand,hover) move_sel(hand,hover)
hand=nil hand=nil
@ -290,8 +296,8 @@ function update()
last_left=left last_left=left
end end
function move_sel(hand,hover) function move_is_valid(hand,hover)
if hand[1]==hover[1] then return end if hand[1]==hover[1] then return false end
local moved_card=stacks[hand[1]][hand[2]] local moved_card=stacks[hand[1]][hand[2]]
local is_valid_move=false local is_valid_move=false
if hover[1]==1 then if hover[1]==1 then
@ -327,14 +333,19 @@ function move_sel(hand,hover)
is_valid_move=true is_valid_move=true
end end
end end
if is_valid_move then return is_valid_move
for i=hand[2],#stacks[hand[1]] do end
stacks[hand[1]][hand[2]].state=0
table.insert( function move_sel(hand,hover)
stacks[hover[1]], if not move_is_valid(hand, hover) then return false end
table.remove(stacks[hand[1]], hand[2]))
end for i=hand[2],#stacks[hand[1]] do
stacks[hand[1]][hand[2]].state=0
table.insert(
stacks[hover[1]],
table.remove(stacks[hand[1]], hand[2]))
end end
return true
end end
function sel_can_move(sel) function sel_can_move(sel)