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

  1. property _cards
  2.  
  3. on new me
  4.   me._create()
  5.   return me
  6. end
  7.  
  8. on _create me
  9.   unshuffledCards = []
  10.   repeat with theRank in [#ace, #two, #three, #four, #five, #six, #seven, #eight, #nine, #ten, #jack, #queen, #king]
  11.     repeat with theSuit in [#hearts, #diamonds, #clubs, #spades]
  12.       unshuffledCards.add(new(script("playing cards"), theRank, theSuit))
  13.     end repeat
  14.   end repeat
  15.   _cards = me._shuffle(unshuffledCards)
  16. end
  17.  
  18. on _shuffle me, unshuffledCards
  19.   shuffledCards = []
  20.   repeat while unshuffledCards.count > 0
  21.     randomCard = unshuffledCards[random(unshuffledCards.count)]
  22.     shuffledCards.add(randomCard)
  23.     unshuffledCards.deleteOne(randomCard)
  24.   end repeat
  25.   return shuffledCards
  26. end
  27.  
  28. on mDeal me, totalCycles
  29.   if totalCycles > 1 then
  30.     theHand = []
  31.     repeat with cycleNum = 1 to totalCycles
  32.       theHand.add(me._DrawCard())
  33.     end repeat
  34.     return theHand
  35.   else
  36.     return me._DrawCard()
  37.   end if
  38. end
  39.  
  40. on _DrawCard me
  41.   cardDrawn = me._cards[1]
  42.   me._deleteCard(cardDrawn)
  43.   if not me._getCardCount(0) then
  44.     me._create()
  45.   end if
  46.   return cardDrawn
  47. end
  48.  
  49. on _deleteCard me, cardToDelete
  50.   _cards.deleteOne(cardToDelete)
  51. end
  52.  
  53. on _getCardCount me, minAmount
  54.   if _cards.count > minAmount then
  55.     return 1
  56.   else
  57.     return 0
  58.   end if
  59. end
  60.