Compare commits
2 Commits
671d1410d5
...
1d67ecdf43
Author | SHA1 | Date |
---|---|---|
LeRoyce Pearson | 1d67ecdf43 | |
LeRoyce Pearson | 9ab6221462 |
|
@ -41,6 +41,7 @@ stacks={}
|
|||
c_hover=nil
|
||||
hand=nil
|
||||
locations={}
|
||||
debug=false
|
||||
|
||||
function create_deck()
|
||||
local cards={}
|
||||
|
@ -81,10 +82,25 @@ end
|
|||
|
||||
function BOOT()
|
||||
stacks={
|
||||
create_deck(), {}, -- deck, pile
|
||||
{}, {}, -- deck, pile
|
||||
{}, {}, {}, {}, -- finished
|
||||
{}, {}, {}, {}, {}, {}, {}
|
||||
}
|
||||
|
||||
if debug then
|
||||
for i=13,1,-1 do
|
||||
for a=1,4 do
|
||||
table.insert(stacks[7+a], {
|
||||
x=0,y=0,state=0,
|
||||
rank=i,
|
||||
suit=a
|
||||
})
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
stacks[1] = create_deck()
|
||||
shuffle(stacks[1])
|
||||
table.insert(locations,{1,2,2})
|
||||
-- Set up stacks
|
||||
|
@ -229,9 +245,15 @@ function update()
|
|||
if #stacks[1]==0 then
|
||||
exhausted=true
|
||||
end
|
||||
--[[elseif hand and hover and
|
||||
hand[1]==hover[1] and left
|
||||
then--]] -- TODO: double click to send to finished
|
||||
elseif hand and hover and
|
||||
hand[1]==hover[1] and hand[2]==hover[2] and left
|
||||
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
|
||||
move_sel(hand,hover)
|
||||
hand=nil
|
||||
|
@ -274,8 +296,8 @@ function update()
|
|||
last_left=left
|
||||
end
|
||||
|
||||
function move_sel(hand,hover)
|
||||
if hand[1]==hover[1] then return end
|
||||
function move_is_valid(hand,hover)
|
||||
if hand[1]==hover[1] then return false end
|
||||
local moved_card=stacks[hand[1]][hand[2]]
|
||||
local is_valid_move=false
|
||||
if hover[1]==1 then
|
||||
|
@ -311,14 +333,19 @@ function move_sel(hand,hover)
|
|||
is_valid_move=true
|
||||
end
|
||||
end
|
||||
if is_valid_move then
|
||||
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
|
||||
return is_valid_move
|
||||
end
|
||||
|
||||
function move_sel(hand,hover)
|
||||
if not move_is_valid(hand, hover) then return false 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
|
||||
return true
|
||||
end
|
||||
|
||||
function sel_can_move(sel)
|
||||
|
|
Loading…
Reference in New Issue