Compare commits

..

2 Commits

1 changed files with 27 additions and 9 deletions

View File

@ -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
@ -250,10 +254,10 @@ function update()
then then
for i=3,6 do for i=3,6 do
if move_sel(hand, {i,#stacks[i]}) then if move_sel(hand, {i,#stacks[i]}) then
hand=nil
break break
end end
end end
hand=nil
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
@ -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]]