feat: select entire movable stack when hand is empty
parent
a7cab90b7e
commit
f2716a9816
|
@ -161,16 +161,20 @@ function update()
|
||||||
c_hover[1]=8
|
c_hover[1]=8
|
||||||
end
|
end
|
||||||
if si>8 and c_left then
|
if si>8 and c_left then
|
||||||
c_hover={
|
c_hover[1]=si-1
|
||||||
si-1,
|
if hand then
|
||||||
#stacks[si-1]
|
c_hover[2]=#stacks[c_hover[1]]
|
||||||
}
|
else
|
||||||
|
c_hover[2]=find_top_of_stack(stacks[c_hover[1]], #stacks[c_hover[1]])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if si>=8 and si<14 and c_right then
|
if si>=8 and si<14 and c_right then
|
||||||
c_hover={
|
c_hover[1]=si+1
|
||||||
si+1,
|
if hand then
|
||||||
#stacks[si+1]
|
c_hover[2]=#stacks[c_hover[1]]
|
||||||
}
|
else
|
||||||
|
c_hover[2]=find_top_of_stack(stacks[c_hover[1]], #stacks[c_hover[1]])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if si>=8 and c_up then
|
if si>=8 and c_up then
|
||||||
c_hover[2]=c_hover[2]-1
|
c_hover[2]=c_hover[2]-1
|
||||||
|
@ -296,6 +300,20 @@ function update()
|
||||||
last_left=left
|
last_left=left
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- This finds the largest stack that can be moved
|
||||||
|
function find_top_of_stack(stack, position)
|
||||||
|
local i=position
|
||||||
|
while i>1 do
|
||||||
|
if stack[i-1].rank~=stack[i].rank+1 or
|
||||||
|
suit_color[stack[i].suit]==suit_color[stack[i-1].suit]
|
||||||
|
then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
i=i-1
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
function move_is_valid(hand,hover)
|
function move_is_valid(hand,hover)
|
||||||
if hand[1]==hover[1] then return false 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]]
|
||||||
|
|
Loading…
Reference in New Issue