home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BlondesBrunettes.dxr / Internal_5.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  8.2 KB  |  271 lines

  1. global stock, waste, reserve, tableau, foundation, pootimer, win, basecard
  2.  
  3. on createdeck
  4.   facelist = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
  5.   unsorted_cards = []
  6.   repeat with h in ["hearts", "diamonds", "clubs", "spades"]
  7.     repeat with i = 1 to 13
  8.       repeat with g = 1 to 2
  9.         unsorted_cards.add([#rank: facelist[i], #suit: h])
  10.       end repeat
  11.     end repeat
  12.   end repeat
  13.   shuffledCards = []
  14.   repeat while unsorted_cards.count > 0
  15.     temp = unsorted_cards[random(unsorted_cards.count)]
  16.     shuffledCards.add(temp)
  17.     unsorted_cards.deleteOne(temp)
  18.   end repeat
  19.   return shuffledCards
  20. end
  21.  
  22. on makesymbol arg
  23.   return symbol(string(arg))
  24. end
  25.  
  26. on getlist forthis
  27.   if (forthis >= 28) and (forthis <= 35) then
  28.     return foundation[makesymbol(forthis)].getlastcard()
  29.   end if
  30.   if (forthis >= 56) and (forthis <= 143) then
  31.     return tableau[makesymbol(sprite(forthis).myrow)].getlastcard()
  32.   end if
  33.   if (forthis >= 38) and (forthis <= 47) then
  34.     return reserve.getlastcard()
  35.   end if
  36.   if forthis = 37 then
  37.     return waste[waste.count]
  38.   end if
  39. end
  40.  
  41. on checkwin
  42.   repeat with i = 1 to foundation.count
  43.     if foundation[i].cards.count = 0 then
  44.       exit repeat
  45.     end if
  46.     if foundation[i].cards.count <> 13 then
  47.       exit repeat
  48.     end if
  49.     if i <> foundation.count then
  50.       next repeat
  51.     end if
  52.     win = "yes"
  53.     pootimer = timeout("poo").new(150, #gotoit)
  54.   end repeat
  55.   checklose()
  56. end
  57.  
  58. on checklose
  59.   if stock.cards.count = 0 then
  60.     repeat with shit = 37 to 37
  61.       if sprite(shit).member.name = "block" then
  62.         next repeat
  63.       end if
  64.       repeat with cakes = 28 to 35
  65.         if sprite(cakes).member.name = "block" then
  66.           if getValue(sprite(shit).member.name) = getOff(basecard) then
  67.             abort()
  68.           end if
  69.           next repeat
  70.         end if
  71.         if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  72.           abort()
  73.           next repeat
  74.         end if
  75.         if (getValue(sprite(shit).member.name) = 1) and (getValue(sprite(cakes).member.name) = 13) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  76.           abort()
  77.         end if
  78.       end repeat
  79.       repeat with craps = 1 to tableau.count
  80.         if tableau[craps].cards.count = 0 then
  81.           next repeat
  82.         end if
  83.         cakes = tableau[craps].cards[tableau[craps].cards.count].spnum
  84.         if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) - 1)) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  85.           abort()
  86.           next repeat
  87.         end if
  88.         if (getValue(sprite(shit).member.name) = 13) and (getValue(sprite(cakes).member.name) = 1) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  89.           abort()
  90.         end if
  91.       end repeat
  92.     end repeat
  93.     if reserve.count > 0 then
  94.       repeat with shit = reserve.cards[reserve.cards.count].spnum to reserve.cards[reserve.cards.count].spnum
  95.         repeat with cakes = 28 to 35
  96.           if sprite(cakes).member.name = "block" then
  97.             if getValue(sprite(shit).member.name) = getOff(basecard) then
  98.               abort()
  99.             end if
  100.             next repeat
  101.           end if
  102.           if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  103.             abort()
  104.             next repeat
  105.           end if
  106.           if (getValue(sprite(shit).member.name) = 1) and (getValue(sprite(cakes).member.name) = 13) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  107.             abort()
  108.           end if
  109.         end repeat
  110.       end repeat
  111.     end if
  112.     repeat with hit = 1 to tableau.count
  113.       if tableau[hit].cards.count = 0 then
  114.         next repeat
  115.       end if
  116.       shit = tableau[hit].cards[tableau[hit].cards.count].spnum
  117.       repeat with cakes = 28 to 35
  118.         if sprite(cakes).member.name = "block" then
  119.           if getValue(sprite(shit).member.name) = getOff(basecard) then
  120.             abort()
  121.           end if
  122.           next repeat
  123.         end if
  124.         if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  125.           abort()
  126.           next repeat
  127.         end if
  128.         if (getValue(sprite(shit).member.name) = 1) and (getValue(sprite(cakes).member.name) = 13) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) then
  129.           abort()
  130.         end if
  131.       end repeat
  132.       repeat with craps = 1 to tableau.count
  133.         if tableau[craps].cards.count = 0 then
  134.           next repeat
  135.         end if
  136.         cakes = tableau[craps].cards[tableau[craps].cards.count].spnum
  137.         if shit = cakes then
  138.           next repeat
  139.         end if
  140.         if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) - 1)) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) and not getduplicate(shit - 1, cakes) then
  141.           abort()
  142.           next repeat
  143.         end if
  144.         if (getValue(sprite(shit).member.name) = 13) and (getValue(sprite(cakes).member.name) = 1) and (suitCo(sprite(shit).member.name) <> suitCo(sprite(cakes).member.name)) and not getduplicate(shit - 1, cakes) then
  145.           abort()
  146.         end if
  147.       end repeat
  148.     end repeat
  149.     win = "no"
  150.     pootimer = timeout("ll").new(130, #gotoit)
  151.   end if
  152. end
  153.  
  154. on getduplicate arch, argu
  155.   if (sprite(arch).member.name <> "empty") and (sprite(arch).member.name <> "backofcard") then
  156.     if (getValue(sprite(arch).member.name) = getValue(sprite(argu).member.name)) and (suitCo(sprite(arch).member.name) = suitCo(sprite(argu).member.name)) then
  157.       return 1
  158.     end if
  159.   end if
  160.   return 0
  161. end
  162.  
  163. on gotoit
  164.   pootimer.forget()
  165.   go("gameover")
  166. end
  167.  
  168. on getValue arg
  169.   if (arg contains "hearts") or (arg contains "spades") then
  170.     return getOff(chars(arg, 1, arg.length - 7))
  171.   else
  172.     if arg contains "diamonds" then
  173.       return getOff(chars(arg, 1, arg.length - 9))
  174.     else
  175.       if arg contains "clubs" then
  176.         return getOff(chars(arg, 1, arg.length - 6))
  177.       end if
  178.     end if
  179.   end if
  180. end
  181.  
  182. on getOff numba
  183.   if numba = "ace" then
  184.     return 1
  185.   else
  186.     if numba = "two" then
  187.       return 2
  188.     else
  189.       if numba = "three" then
  190.         return 3
  191.       else
  192.         if numba = "four" then
  193.           return 4
  194.         else
  195.           if numba = "five" then
  196.             return 5
  197.           else
  198.             if numba = "six" then
  199.               return 6
  200.             else
  201.               if numba = "seven" then
  202.                 return 7
  203.               else
  204.                 if numba = "eight" then
  205.                   return 8
  206.                 else
  207.                   if numba = "nine" then
  208.                     return 9
  209.                   else
  210.                     if numba = "ten" then
  211.                       return 10
  212.                     else
  213.                       if numba = "jack" then
  214.                         return 11
  215.                       else
  216.                         if numba = "queen" then
  217.                           return 12
  218.                         else
  219.                           if numba = "king" then
  220.                             return 13
  221.                           end if
  222.                         end if
  223.                       end if
  224.                     end if
  225.                   end if
  226.                 end if
  227.               end if
  228.             end if
  229.           end if
  230.         end if
  231.       end if
  232.     end if
  233.   end if
  234. end
  235.  
  236. on getSuit arg
  237.   if arg contains "hearts" then
  238.     return #hearts
  239.   else
  240.     if arg contains "diamonds" then
  241.       return #diamonds
  242.     else
  243.       if arg contains "clubs" then
  244.         return #clubs
  245.       else
  246.         if arg contains "spades" then
  247.           return #spades
  248.         end if
  249.       end if
  250.     end if
  251.   end if
  252. end
  253.  
  254. on suitCo arg
  255.   if arg contains "hearts" then
  256.     return #red
  257.   else
  258.     if arg contains "diamonds" then
  259.       return #red
  260.     else
  261.       if arg contains "clubs" then
  262.         return #black
  263.       else
  264.         if arg contains "spades" then
  265.           return #black
  266.         end if
  267.       end if
  268.     end if
  269.   end if
  270. end
  271.