Compare commits
2 Commits
1d67ecdf43
...
f2716a9816
Author | SHA1 | Date |
---|---|---|
LeRoyce Pearson | f2716a9816 | |
LeRoyce Pearson | a7cab90b7e |
|
@ -161,16 +161,20 @@ function update()
|
|||
c_hover[1]=8
|
||||
end
|
||||
if si>8 and c_left then
|
||||
c_hover={
|
||||
si-1,
|
||||
#stacks[si-1]
|
||||
}
|
||||
c_hover[1]=si-1
|
||||
if hand then
|
||||
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
|
||||
if si>=8 and si<14 and c_right then
|
||||
c_hover={
|
||||
si+1,
|
||||
#stacks[si+1]
|
||||
}
|
||||
c_hover[1]=si+1
|
||||
if hand then
|
||||
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
|
||||
if si>=8 and c_up then
|
||||
c_hover[2]=c_hover[2]-1
|
||||
|
@ -250,10 +254,10 @@ function update()
|
|||
then
|
||||
for i=3,6 do
|
||||
if move_sel(hand, {i,#stacks[i]}) then
|
||||
hand=nil
|
||||
break
|
||||
end
|
||||
end
|
||||
hand=nil
|
||||
elseif hand and hover and left then
|
||||
move_sel(hand,hover)
|
||||
hand=nil
|
||||
|
@ -296,6 +300,20 @@ function update()
|
|||
last_left=left
|
||||
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)
|
||||
if hand[1]==hover[1] then return false end
|
||||
local moved_card=stacks[hand[1]][hand[2]]
|
||||
|
|
Loading…
Reference in New Issue