home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BakersGame.dxr / 00059_tableaucards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  8.7 KB  |  202 lines

  1. property spriteNum
  2.  
  3. on beginSprite me
  4.   global scount, tcount, stock, tableau
  5.   sprite(me.spriteNum).visible = 1
  6.   if scount = 1 then
  7.     if tcount = 1 then
  8.       sprite(me.spriteNum).loc = point(65, 140)
  9.       tableau[symbol(string(sprite(me.spriteNum).startFrame))] = new(script("tableauobj"), [:])
  10.     else
  11.       sprite(me.spriteNum).loc = sprite(me.spriteNum - 13).loc + point(sprite(me.spriteNum).width + 12, 0)
  12.       tableau[symbol(string(sprite(me.spriteNum).startFrame))] = new(script("tableauobj"), [:])
  13.     end if
  14.   else
  15.     sprite(me.spriteNum).loc = sprite(me.spriteNum - 1).loc + point(0, sprite(me.spriteNum).height / 3)
  16.   end if
  17.   if (tcount = 1) or (tcount = 2) or (tcount = 3) or (tcount = 4) then
  18.     if scount > 7 then
  19.       sprite(me.spriteNum).visible = 0
  20.     end if
  21.   else
  22.     if scount > 6 then
  23.       sprite(me.spriteNum).visible = 0
  24.     end if
  25.   end if
  26.   if scount = 13 then
  27.     scount = 0
  28.     tcount = tcount + 1
  29.   end if
  30.   if sprite(me.spriteNum).visible = 1 then
  31.     sprite(me.spriteNum).member = stock.cards[1].rank & "_" & stock.cards[1].suit
  32.     stock.cards.deleteAt(1)
  33.     tableau[symbol(string(sprite(me.spriteNum).startFrame))].addcards(me.spriteNum, new(script("card"), me.spriteNum))
  34.   end if
  35.   scount = scount + 1
  36. end
  37.  
  38. on mouseDown me
  39.   global tableau
  40.   if sprite(me.spriteNum).visible = 1 then
  41.     puppetSound(3, "pickcard")
  42.     if me.spriteNum = tableau[symbol(string(sprite(me.spriteNum).startFrame))].cards[tableau[symbol(string(sprite(me.spriteNum).startFrame))].cards.count].spnum then
  43.       sprite(me.spriteNum).moveableSprite = 1
  44.       sprite(me.spriteNum).loc = the mouseLoc
  45.       sprite(me.spriteNum).locZ = me.spriteNum + 1000
  46.     else
  47.       checkpilepos(me.spriteNum)
  48.     end if
  49.   end if
  50. end
  51.  
  52. on mouseUp me
  53.   global equalvalue, hotcard, cell, tableau, foundation, sha
  54.   if me.spriteNum = the clickOn then
  55.     if (sprite(me.spriteNum).visible = 1) and (sprite(me.spriteNum).moveableSprite = 1) then
  56.       if sha.count = 0 then
  57.         if (equalvalue = 1) and (hotcard <> 0) then
  58.           puppetSound(3, "pickcard")
  59.           godlist = gethotcard(hotcard)
  60.           w = hiya(hotcard)
  61.           sprite(me.spriteNum).moveableSprite = 0
  62.           sprite(me.spriteNum).visible = 0
  63.           sprite(me.spriteNum).locZ = me.spriteNum
  64.           sprite(me.spriteNum).loc = tableau[symbol(string(sprite(me.spriteNum).startFrame))].cards[symbol(string(me.spriteNum))].location
  65.           sprite(hotcard).member = sprite(the clickOn).member
  66.           sprite(hotcard).visible = 1
  67.           tableau[symbol(string(sprite(me.spriteNum).startFrame))].subcards(symbol(string(me.spriteNum)))
  68.           godlist.addcards(hotcard, new(script("card"), hotcard))
  69.           addpoints(hotcard)
  70.         else
  71.           puppetSound(3, "dropcard")
  72.           sprite(me.spriteNum).locZ = me.spriteNum
  73.           sprite(me.spriteNum).loc = tableau[symbol(string(sprite(me.spriteNum).startFrame))].cards[symbol(string(me.spriteNum))].location
  74.         end if
  75.       else
  76.         if (the clickOn <> 0) and (sprite(the clickOn).visible = 1) and (sprite(the clickOn).moveableSprite = 1) then
  77.           if (equalvalue = 1) and (hotcard <> 0) then
  78.             puppetSound(3, "pickcard")
  79.             the actorList = []
  80.             sprite(the clickOn).loc = tableau[symbol(string(sprite(the clickOn).startFrame))].cards[string(the clickOn).symbol].location
  81.             sprite(the clickOn).locZ = tableau[symbol(string(sprite(the clickOn).startFrame))].cards[string(the clickOn).symbol].spnum
  82.             sprite(the clickOn).visible = 0
  83.             sprite(hotcard).member = sprite(the clickOn).member
  84.             sprite(hotcard).visible = 1
  85.             sprite(hotcard).locZ = hotcard
  86.             tableau[symbol(string(sprite(hotcard).startFrame))].addcards(symbol(string(hotcard)), new(script("card"), hotcard))
  87.             tableau[symbol(string(sprite(the clickOn).startFrame))].subcards(symbol(string(the clickOn)))
  88.             repeat with i = 1 to sha.count
  89.               sprite(the clickOn + i).locZ = the clickOn + i
  90.               sprite(the clickOn + i).loc = tableau[string(sprite(the clickOn + i).startFrame).symbol].cards[string(the clickOn + i).symbol].location
  91.               sprite(the clickOn + i).visible = 0
  92.               sprite(hotcard + i).member = sprite(the clickOn + i).member
  93.               sprite(hotcard + i).visible = 1
  94.               sprite(hotcard + i).locZ = hotcard + i
  95.               tableau[symbol(string(sprite(hotcard + i).startFrame))].addcards(symbol(string(hotcard + i)), new(script("card"), hotcard + i))
  96.               tableau[symbol(string(sprite(the clickOn + i).startFrame))].subcards(symbol(string(the clickOn + i)))
  97.             end repeat
  98.             repeat with i in [130, 143, 156, 169, 182, 195, 208, 221]
  99.               if tableau[string(sprite(i).startFrame).symbol].cards.count = 0 then
  100.                 next repeat
  101.               end if
  102.               sprite(i).loc = tableau[string(sprite(i).startFrame).symbol].cards[tableau[string(sprite(i).startFrame).symbol].cards.count].location
  103.             end repeat
  104.           else
  105.             puppetSound(3, "dropcard")
  106.             sprite(the clickOn).moveableSprite = 0
  107.             sprite(the clickOn).locZ = the clickOn
  108.             sprite(the clickOn).loc = tableau[string(sprite(the clickOn).startFrame).symbol].cards[string(the clickOn).symbol].location
  109.             repeat with i = 1 to sha.count
  110.               sprite(the clickOn + i).locZ = the clickOn + i
  111.               sprite(the clickOn + i).loc = tableau[string(sprite(the clickOn + i).startFrame).symbol].cards[string(the clickOn + i).symbol].location
  112.               sprite(the clickOn + i).moveableSprite = 0
  113.             end repeat
  114.           end if
  115.         end if
  116.       end if
  117.     end if
  118.   end if
  119.   sha.deleteAll()
  120.   the actorList = []
  121.   checklose()
  122. end
  123.  
  124. on backCardEQ me
  125.   global tableau
  126.   if spriteNum <> tableau[symbol(string(sprite(me.spriteNum).startFrame))].cards[1].spnum then
  127.     if (sprite(spriteNum - 1).member.name <> "backofcard") and (sprite(spriteNum - 1).member.name <> "empty") then
  128.       if (getValue(sprite(spriteNum).member.name) = (getValue(sprite(spriteNum - 1).member.name) - 1)) and (getSuit(sprite(spriteNum).member.name) = getSuit(sprite(spriteNum - 1).member.name)) then
  129.         repeat with shit = spriteNum - 1 to spriteNum - 1
  130.           repeat with cakes = 1 to tableau.count
  131.             if tableau[cakes].cards.count = 0 then
  132.               next repeat
  133.             end if
  134.             if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].cards[tableau[cakes].cards.count].spnum).member.name) - 1)) and (getSuit(sprite(shit).member.name) = getSuit(sprite(tableau[cakes].cards[tableau[cakes].cards.count].spnum).member.name)) then
  135.               return 1
  136.               exit
  137.               next repeat
  138.             end if
  139.             if (getValue(sprite(shit).member.name) = 13) and (getValue(sprite(tableau[cakes].cards[tableau[cakes].cards.count].spnum).member.name) = 1) and (getSuit(sprite(shit).member.name) = getSuit(sprite(tableau[cakes].cards[tableau[cakes].cards.count].spnum).member.name)) then
  140.               return 1
  141.               exit
  142.             end if
  143.           end repeat
  144.         end repeat
  145.       else
  146.         sendSprite(spriteNum - 1, #backCardEQ)
  147.       end if
  148.     end if
  149.   end if
  150.   return 0
  151. end
  152.  
  153. on checkpilepos posi
  154.   global tableau, cell
  155.   proxymoxy = []
  156.   t = tableau[string(sprite(posi).startFrame).symbol].cards.findPos(string(posi).symbol)
  157.   j = tableau[string(sprite(posi).startFrame).symbol]
  158.   if t <> tableau[string(sprite(posi).startFrame).symbol].cards.count then
  159.     i = 0
  160.     repeat while i < (tableau[string(sprite(posi).startFrame).symbol].cards.count - t)
  161.       i = i + 1
  162.       if tableau[string(sprite(posi).startFrame).symbol].cards[t + i].suit <> tableau[string(sprite(posi).startFrame).symbol].cards[t + i - 1].suit then
  163.         exit repeat
  164.       end if
  165.       if tableau[string(sprite(posi).startFrame).symbol].cards[t + i].rankvalue <> (tableau[string(sprite(posi).startFrame).symbol].cards[t].rankvalue - i) then
  166.         exit repeat
  167.       end if
  168.       proxymoxy.add(tableau[string(sprite(posi).startFrame).symbol].cards[t + i])
  169.       if i <> (tableau[string(sprite(posi).startFrame).symbol].cards.count - t) then
  170.         next repeat
  171.       end if
  172.     end repeat
  173.     hate = 4
  174.     repeat with i = 1 to 4
  175.       if cell[i].cards.count = 0 then
  176.         next repeat
  177.       end if
  178.       put hate
  179.       hate = hate - 1
  180.     end repeat
  181.     put hate
  182.     if (proxymoxy.count <> 0) and (proxymoxy.count < (hate + 1)) then
  183.       sprite(posi).locZ = posi + 1000
  184.       setemuphigh(proxymoxy, posi)
  185.     else
  186.       proxymoxy.deleteAll()
  187.     end if
  188.   else
  189.     nothing()
  190.   end if
  191. end
  192.  
  193. on setemuphigh yoyo, bvc
  194.   global sha, cell
  195.   sha = yoyo
  196.   sprite(bvc).moveableSprite = 1
  197.   repeat with s = 1 to yoyo.count
  198.     add(the actorList, yoyo[s])
  199.     sprite(yoyo[s].spnum).locZ = yoyo[s].spnum + 1000
  200.   end repeat
  201. end
  202.