48 lines
931 B
Plaintext
48 lines
931 B
Plaintext
suits = ["Spades", "Clubs", "Hearts", "Diamonds"]
|
|
pips = ["Ace","Two","Three","Four","Five","Six","Seven",
|
|
"Eight","Nine","Ten","Jack","Queen","King"]
|
|
|
|
Card = {}
|
|
Card.str = function()
|
|
return self.pip + " of " + self.suit + " (value: " + self.value + ")"
|
|
end function
|
|
|
|
//Build Deck
|
|
deck = []
|
|
for s in suits.indexes
|
|
for p in pips.indexes
|
|
card = new Card
|
|
card.suit = suits[s]
|
|
card.pip = pips[p]
|
|
card.value = s * 100 + p
|
|
deck.push card
|
|
end for
|
|
end for
|
|
|
|
draw = function(count=7)
|
|
hand = []
|
|
for i in range(1, count)
|
|
hand.push deck.pop
|
|
end for
|
|
return hand
|
|
end function
|
|
|
|
display = function(stack)
|
|
for card in stack
|
|
print card.str
|
|
end for
|
|
end function
|
|
|
|
print "Deck created. Cards in Deck: " + deck.len
|
|
|
|
deck.shuffle
|
|
print "Deck Shuffled"
|
|
|
|
hand = draw
|
|
print "First hand: "
|
|
display hand
|
|
|
|
print
|
|
print deck.len + " cards left in deck:"
|
|
display deck
|