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

  1. property _cards
  2.  
  3. on new me
  4.   me._cards = []
  5.   return me
  6. end
  7.  
  8. on throwCard me, cardToThrow, pointToThrow
  9.   theLoc = [float(cardToThrow.locH), float(cardToThrow.locV)]
  10.   xDis = float(pointToThrow.locH) - float(theLoc[1])
  11.   yDis = float(pointToThrow.locV) - float(theLoc[2])
  12.   theAng = atan(float(yDis) / float(xDis))
  13.   xPos = cos(theAng) * 10
  14.   yPos = sin(theAng) * 10
  15.   theLoc = theLoc + [xPos, yPos]
  16.   cardToThrow.loc = point(float(theLoc[1]), float(theLoc[2]))
  17.   updateStage()
  18. end
  19.  
  20. on throwComplete me, cardToThrow, pointToThrow
  21.   theLoc = [float(cardToThrow.locH), float(cardToThrow.locV)]
  22.   xDis = float(pointToThrow.locH) - float(theLoc[1])
  23.   yDis = float(pointToThrow.locV) - float(theLoc[2])
  24.   theDistBet = sqrt(power(xDis, 2) + power(yDis, 2))
  25.   if theDistBet < 5.0 then
  26.     return 1
  27.   else
  28.     return 0
  29.   end if
  30. end
  31.  
  32. on addCard me, cardToAdd
  33.   me._cards.add(cardToAdd)
  34. end
  35.  
  36. on returnCardCount me
  37.   return me._cards.count
  38. end
  39.  
  40. on sortCards me, globalList
  41.   temp1 = me._cards.duplicate()
  42.   temp2 = []
  43.   repeat with i = 1 to temp1.count
  44.     temp2.add(temp1[i].pValue)
  45.   end repeat
  46.   temp2.sort()
  47.   Temp3 = [VOID, VOID, VOID, VOID, VOID]
  48.   repeat with i = 1 to temp1.count
  49.     Temp3[temp2.findPos(temp1[i].pValue)] = temp1[i]
  50.     temp2[Temp3.findPos(temp1[i])] = VOID
  51.   end repeat
  52.   me._cards = Temp3
  53.   repeat with i = 1 to globalList.count
  54.     globalList[i].member = me._cards[i].mGetImage()
  55.     s = the ticks + 5
  56.     repeat while the ticks < s
  57.       updateStage()
  58.     end repeat
  59.   end repeat
  60. end
  61.  
  62. on checkHand me, isDealer
  63.   if (me._cards[1].pValue = 1) and (me._cards[2].pValue = 10) and (me._cards[3].pValue = 11) and (me._cards[4].pValue = 12) and (me._cards[5].pValue = 13) and ((me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit)) then
  64.     return #royalflush
  65.   else
  66.     if (me._cards[1].pValue = (me._cards[2].pValue - 1)) and (me._cards[2].pValue = (me._cards[3].pValue - 1)) and (me._cards[3].pValue = (me._cards[4].pValue - 1)) and (me._cards[4].pValue = (me._cards[5].pValue - 1)) and ((me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit)) then
  67.       return [#straightflush]
  68.     else
  69.       if ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue)) or ((me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) then
  70.         return #fourofakind
  71.       else
  72.         if ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) or ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) then
  73.           return #fullhouse
  74.         else
  75.           if (me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit) then
  76.             return #flush
  77.           else
  78.             if (me._cards[1].pValue = (me._cards[2].pValue - 1)) and (me._cards[2].pValue = (me._cards[3].pValue - 1)) and (me._cards[3].pValue = (me._cards[4].pValue - 1)) and (me._cards[4].pValue = (me._cards[5].pValue - 1)) then
  79.               return #straight
  80.             else
  81.               if ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue)) or ((me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue)) or ((me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) then
  82.                 return #threeofakind
  83.               else
  84.                 if ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[3].pValue = me._cards[4].pValue)) or ((me._cards[2].pValue = me._cards[3].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) or ((me._cards[1].pValue = me._cards[2].pValue) and (me._cards[4].pValue = me._cards[5].pValue)) then
  85.                   return #twopairs
  86.                 else
  87.                   if (me._cards[1].pValue = me._cards[2].pValue) or (me._cards[2].pValue = me._cards[3].pValue) or (me._cards[3].pValue = me._cards[4].pValue) or (me._cards[4].pValue = me._cards[5].pValue) then
  88.                     return #pair
  89.                   else
  90.                     if not voidp(isDealer) then
  91.                       if (me._cards[1].pValue = 1) and (me._cards[5].pValue = 13) then
  92.                         return #high
  93.                       else
  94.                         return VOID
  95.                       end if
  96.                     else
  97.                       return #high
  98.                     end if
  99.                   end if
  100.                 end if
  101.               end if
  102.             end if
  103.           end if
  104.         end if
  105.       end if
  106.     end if
  107.   end if
  108. end
  109.  
  110. on checkHandValue me
  111.   if (me._cards[1].pValue = 1) and (me._cards[2].pValue = 10) and (me._cards[3].pValue = 11) and (me._cards[4].pValue = 12) and (me._cards[5].pValue = 13) and ((me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit)) then
  112.     return 2000
  113.   else
  114.     if (me._cards[1].pValue = (me._cards[2].pValue - 1)) and (me._cards[2].pValue = (me._cards[3].pValue - 1)) and (me._cards[3].pValue = (me._cards[4].pValue - 1)) and (me._cards[4].pValue = (me._cards[5].pValue - 1)) and ((me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit)) then
  115.       return me._cards[1].pValue + me._cards[2].pValue + me._cards[3].pValue + me._cards[4].pValue + me._cards[5].pValue
  116.     else
  117.       if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue) then
  118.         return me._cards[1].pValue * 4
  119.       else
  120.         if (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  121.           return me._cards[2].pValue * 4
  122.         else
  123.           if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  124.             return (me._cards[1].pValue * 2) + (me._cards[3].pValue * 3)
  125.           else
  126.             if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  127.               return (me._cards[5].pValue * 2) + (me._cards[1].pValue * 3)
  128.             else
  129.               if (me._cards[1].pSuit = me._cards[2].pSuit) and (me._cards[2].pSuit = me._cards[3].pSuit) and (me._cards[3].pSuit = me._cards[4].pSuit) and (me._cards[4].pSuit = me._cards[5].pSuit) then
  130.                 return me._cards[1].pValue + me._cards[2].pValue + me._cards[3].pValue + me._cards[4].pValue + me._cards[5].pValue
  131.               else
  132.                 if (me._cards[1].pValue = (me._cards[2].pValue - 1)) and (me._cards[2].pValue = (me._cards[3].pValue - 1)) and (me._cards[3].pValue = (me._cards[4].pValue - 1)) and (me._cards[4].pValue = (me._cards[5].pValue - 1)) then
  133.                   return me._cards[1].pValue + me._cards[2].pValue + me._cards[3].pValue + me._cards[4].pValue + me._cards[5].pValue
  134.                 else
  135.                   if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[2].pValue = me._cards[3].pValue) then
  136.                     return me._cards[1].pValue * 3
  137.                   else
  138.                     if (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[3].pValue = me._cards[4].pValue) then
  139.                       return me._cards[1].pValue * 3
  140.                     else
  141.                       if (me._cards[3].pValue = me._cards[4].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  142.                         return me._cards[3].pValue * 3
  143.                       else
  144.                         if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[3].pValue = me._cards[4].pValue) then
  145.                           return (me._cards[1].pValue * 2) + (me._cards[3].pValue * 2)
  146.                         else
  147.                           if (me._cards[2].pValue = me._cards[3].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  148.                             return (me._cards[2].pValue * 2) + (me._cards[4].pValue * 2)
  149.                           else
  150.                             if (me._cards[1].pValue = me._cards[2].pValue) and (me._cards[4].pValue = me._cards[5].pValue) then
  151.                               return (me._cards[2].pValue * 2) + (me._cards[4].pValue * 2)
  152.                             else
  153.                               if me._cards[1].pValue = me._cards[2].pValue then
  154.                                 return me._cards[1].pValue * 2
  155.                               else
  156.                                 if me._cards[2].pValue = me._cards[3].pValue then
  157.                                   return me._cards[2].pValue * 2
  158.                                 else
  159.                                   if me._cards[3].pValue = me._cards[4].pValue then
  160.                                     return me._cards[3].pValue * 2
  161.                                   else
  162.                                     if me._cards[4].pValue = me._cards[5].pValue then
  163.                                       return me._cards[4].pValue * 2
  164.                                     else
  165.                                       return #high
  166.                                     end if
  167.                                   end if
  168.                                 end if
  169.                               end if
  170.                             end if
  171.                           end if
  172.                         end if
  173.                       end if
  174.                     end if
  175.                   end if
  176.                 end if
  177.               end if
  178.             end if
  179.           end if
  180.         end if
  181.       end if
  182.     end if
  183.   end if
  184. end
  185.