global points, pootimer, win, tableau, crappo, stock, redeals
on checkwin arg
if points = (52 * 10) then
win = "yes"
pootimer = timeout("poo").new(150, #gotoit)
else
if (stock.cards.count = 0) and (redeals = 1) then
checklose()
end if
end if
end
on gotoit
pootimer.forget()
go("gameover")
end
on checklose
repeat with shit = 119 to 134
if sprite(shit).member.name = "empty" then
next repeat
end if
repeat with cakes = 111 to 114
if sprite(cakes).member.name = "empty" then
if getValue(sprite(shit).member.name) = 1 then
abort()
end if
next repeat
end if
if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (getSuit(sprite(shit).member.name) = getSuit(sprite(cakes).member.name)) then
abort()
end if
end repeat
repeat with cakes = 1 to tableau.count
if tableau[cakes].getcardcount() = 0 then
next repeat
end if
if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and (getSuitCo(sprite(shit).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) then
abort()
end if
end repeat
end repeat
repeat with shit = 1 to tableau.count
if tableau[shit].getcardcount() = 0 then
abort()
end if
repeat with cakes = 111 to 114
if sprite(cakes).member.name = "empty" then
if getValue(sprite(tableau[shit].getlastcard().spnum).member.name) = 1 then
abort()
end if
next repeat
end if
if (getValue(sprite(tableau[shit].getlastcard().spnum).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (getSuit(sprite(tableau[shit].getlastcard().spnum).member.name) = getSuit(sprite(cakes).member.name)) then
abort()
end if
end repeat
repeat with cakes = 1 to tableau.count
if tableau[cakes].getcardcount() = 0 then
next repeat
end if
if shit = cakes then
next repeat
end if
if (getValue(sprite(tableau[shit].getlastcard().spnum).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and (getSuitCo(sprite(tableau[shit].getlastcard().spnum).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) and not getduplicate() then
abort()
end if
end repeat
if sprite(tableau[shit].getlastcard().spnum).backCardEQ() then
if (arg contains "hearts") or (arg contains "spades") then
return getOff(chars(arg, 1, arg.length - 7))
else
if arg contains "diamonds" then
return getOff(chars(arg, 1, arg.length - 9))
else
if arg contains "clubs" then
return getOff(chars(arg, 1, arg.length - 6))
end if
end if
end if
end
on getOff numba
if numba = "ace" then
return 1
else
if numba = "two" then
return 2
else
if numba = "three" then
return 3
else
if numba = "four" then
return 4
else
if numba = "five" then
return 5
else
if numba = "six" then
return 6
else
if numba = "seven" then
return 7
else
if numba = "eight" then
return 8
else
if numba = "nine" then
return 9
else
if numba = "ten" then
return 10
else
if numba = "jack" then
return 11
else
if numba = "queen" then
return 12
else
if numba = "king" then
return 13
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end
on getSuit arg
if arg contains "hearts" then
return #hearts
else
if arg contains "diamonds" then
return #diamonds
else
if arg contains "clubs" then
return #clubs
else
if arg contains "spades" then
return #spades
end if
end if
end if
end if
end
on getSuitCo arg
if arg contains "hearts" then
return #red
else
if arg contains "diamonds" then
return #red
else
if arg contains "clubs" then
return #black
else
if arg contains "spades" then
return #black
end if
end if
end if
end if
end
on getduplicate
ass = 0
repeat with hell = 1 to tableau.count
if tableau[hell].getcardcount() = 0 then
next repeat
end if
repeat with bell = 1 to tableau.count
if tableau[bell].getcardcount() = 0 then
next repeat
end if
if tableau[bell].getcardcount() >= 2 then
if (tableau[hell].getlastcard().rank = tableau[bell].cards[tableau[bell].getcardcount() - 1].rank) and (tableau[hell].getlastcard().suitcolor <> tableau[bell].cards[tableau[bell].getcardcount() - 1].suitcolor) then