home *** CD-ROM | disk | FTP | other *** search
- global stock, foundation, reserve, waste, points
-
- on prepareFrame me
- stock = new(script("card pile"))
- stock.cards = shuffle()
- foundation = [:]
- reserve = [:]
- points = 0
- waste = new(script("card pile"))
- end
-
- on shuffle
- ranks = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
- suits = ["hearts", "diamonds", "clubs", "spades"]
- unshuffledCards = []
- shuffledCards = []
- repeat with rank in ranks
- repeat with suit in suits
- unshuffledCards.add([#rank: rank, #suit: suit])
- end repeat
- end repeat
- repeat while unshuffledCards.count > 0
- shuffledCards.add(unshuffledCards[random(unshuffledCards.count)])
- unshuffledCards.deleteOne(shuffledCards[shuffledCards.count])
- end repeat
- return shuffledCards
- end
-