Code: Select all
if( GLOBAL_VARS.GAME_STATE == GLOBAL_VARS.CARD_CHANGE ) then
table.sort(GLOBAL_VARS.Player2Store.hand, function(a,b) return a.number>b.number end)
table.sort(GLOBAL_VARS.Player2Store.TopResvCards, function(a,b) return a.number>b.number end)
for i = #GLOBAL_VARS.Player2Store.TopResvCards, 1, -1 do
for j = #GLOBAL_VARS.Player2Store.hand, 1, -1 do
if((GLOBAL_VARS.Player2Store.hand[i].Attribute and GLOBAL_VARS.Player2Store.TopResvCards[j].Attribute == nil) or
(GLOBAL_VARS.Player2Store.hand[i].number > GLOBAL_VARS.Player2Store.TopResvCards[j].number) ) then
local temp = {}
local temp2 = {}
table.insert(temp, GLOBAL_VARS.Player2Store.hand[i])
table.insert(temp2, GLOBAL_VARS.Player2Store.TopResvCards[j])
table.remove(GLOBAL_VARS.Player2Store.hand, i)
table.remove(GLOBAL_VARS.Player2Store.TopResvCards, j)
table.insert(GLOBAL_VARS.Player2Store.hand, i, temp2[1])
table.insert(GLOBAL_VARS.Player2Store.TopResvCards, j, temp[1])
end
end
end
end
Edit: Upon further inspection it appears to be cycling through a lot of other cards, not just swapping 2 around every time; more like juggling a load of cards between the two tables.